Skip to content

Commit 487e739

Browse files
authored
Automated formatting (#583)
* automated formatting core + routes * res management * automated html formatting * automated formatting app TS * fix merge typo * fix merge typos
1 parent 175b8bb commit 487e739

108 files changed

Lines changed: 6018 additions & 6830 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/config.service.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let conf = null;
66
exports.get_conf = get_conf;
77

88
// todo: maybe add a file in config with all the default value, load it and overide it with custom config
9-
function init () {
9+
function init() {
1010
if (!is_init) {
1111
conf = CONFIG;
1212
if (!conf.duration) {
@@ -27,33 +27,33 @@ function init () {
2727
}
2828
if (!conf.enable_ui) {
2929
conf.enable_ui = {
30-
'messages': true,
31-
'databases': true,
32-
'tps': true,
33-
'websites': true,
34-
'u2f_key': true,
35-
'ip': true,
36-
'newsletters': true,
37-
'log': true
30+
messages: true,
31+
databases: true,
32+
tps: true,
33+
websites: true,
34+
u2f_key: true,
35+
ip: true,
36+
newsletters: true,
37+
log: true
3838
};
3939
}
4040
conf.enable_ui.main_group = CONFIG.general.use_group_in_path;
4141
conf.enable_ui.user_group = !CONFIG.general.disable_user_group;
4242

4343
if (!conf.project) {
4444
conf.project = {
45-
'enable_group': true,
46-
'default_size': 500,
47-
'default_path': '/opt/project',
48-
'default_expire': 360,
49-
'allow_extend': false
45+
enable_group: true,
46+
default_size: 500,
47+
default_path: '/opt/project',
48+
default_expire: 360,
49+
allow_extend: false
5050
};
5151
}
5252

5353
if (!conf.reservation) {
5454
conf.reservation = {
55-
'group_or_project': 'group',
56-
'show_choice_in_ui': false
55+
group_or_project: 'group',
56+
show_choice_in_ui: false
5757
};
5858
}
5959

@@ -62,7 +62,7 @@ function init () {
6262
}
6363

6464
// todo: should replace all {const CONFIG = require('config');} by a call to this function
65-
function get_conf () {
65+
function get_conf() {
6666
init();
6767
return conf;
6868
}

core/db.service.js

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ var mongo_tags = null;
2121
var mongo_pending_projects = null;
2222
var mongo_pending_databases = null;
2323

24-
var mongo_connect = async function() {
24+
var mongo_connect = async function () {
2525
let url = CONFIG.mongo.url;
2626
let client = null;
27-
if(!url) {
28-
client = new MongoClient(`mongodb://${CONFIG.mongo.host}:${CONFIG.mongo.port}`, { useNewUrlParser: true, useUnifiedTopology: true });
27+
if (!url) {
28+
client = new MongoClient(`mongodb://${CONFIG.mongo.host}:${CONFIG.mongo.port}`, {
29+
useNewUrlParser: true,
30+
useUnifiedTopology: true
31+
});
2932
} else {
3033
client = new MongoClient(CONFIG.mongo.url, { useNewUrlParser: true, useUnifiedTopology: true });
3134
}
@@ -46,31 +49,57 @@ var mongo_connect = async function() {
4649
};
4750
// mongo_connect();
4851

49-
exports.init_db = async function() {
52+
exports.init_db = async function () {
5053
logger.info('initialize db connection');
5154
try {
52-
if(mongodb != null) {
55+
if (mongodb != null) {
5356
return null;
5457
}
5558
await mongo_connect();
5659
logger.info('connected');
5760
return null;
58-
} catch(err){
61+
} catch (err) {
5962
logger.debug('Failed to init db', err);
6063
return err;
6164
}
6265
};
6366
exports.mongodb = mongodb;
64-
exports.mongo_users = function() {return mongo_users;};
65-
exports.mongo_groups = function() {return mongo_groups;};
66-
exports.mongo_events = function() {return mongo_events;};
67-
exports.mongo_reservations = function() {return mongo_reservations;};
68-
exports.mongo_databases = function() {return mongo_databases;};
69-
exports.mongo_web = function() {return mongo_web;};
70-
exports.mongo_projects = function() {return mongo_projects;};
71-
exports.mongo_tags = function() {return mongo_tags;};
72-
exports.mongo_pending_projects = function() {return mongo_pending_projects;};
73-
exports.mongo_oldusers = function() {return mongo_oldusers;};
74-
exports.mongo_oldgroups = function() {return mongo_oldgroups;};
75-
exports.mongo_others = function(coll) { return mongodb.collection(coll);};
76-
exports.mongo_pending_databases = function() {return mongo_pending_databases;};
67+
exports.mongo_users = function () {
68+
return mongo_users;
69+
};
70+
exports.mongo_groups = function () {
71+
return mongo_groups;
72+
};
73+
exports.mongo_events = function () {
74+
return mongo_events;
75+
};
76+
exports.mongo_reservations = function () {
77+
return mongo_reservations;
78+
};
79+
exports.mongo_databases = function () {
80+
return mongo_databases;
81+
};
82+
exports.mongo_web = function () {
83+
return mongo_web;
84+
};
85+
exports.mongo_projects = function () {
86+
return mongo_projects;
87+
};
88+
exports.mongo_tags = function () {
89+
return mongo_tags;
90+
};
91+
exports.mongo_pending_projects = function () {
92+
return mongo_pending_projects;
93+
};
94+
exports.mongo_oldusers = function () {
95+
return mongo_oldusers;
96+
};
97+
exports.mongo_oldgroups = function () {
98+
return mongo_oldgroups;
99+
};
100+
exports.mongo_others = function (coll) {
101+
return mongodb.collection(coll);
102+
};
103+
exports.mongo_pending_databases = function () {
104+
return mongo_pending_databases;
105+
};

core/file.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@ const templates_dir_default = 'templates/default';
1212

1313
// Todo: Manage mail template with nunjuck
1414

15-
nunjucks.configure(
16-
[templates_dir, templates_dir_default],
17-
{
18-
autoescape: true,
19-
trimBlocks: true,
20-
lstripBlocks: true
21-
}
22-
);
23-
15+
nunjucks.configure([templates_dir, templates_dir_default], {
16+
autoescape: true,
17+
trimBlocks: true,
18+
lstripBlocks: true
19+
});
2420

2521
const tplconf = require('../' + templates_dir + '/templates.json');
2622

27-
function create_file (name, data) {
28-
return new Promise( function (resolve, reject) {
29-
23+
function create_file(name, data) {
24+
return new Promise(function (resolve, reject) {
3025
if (!tplconf[name]) {
3126
logger.warn('Templates file are missing for ' + name);
3227
reject('Templates file are missing for ' + name);
@@ -71,19 +66,17 @@ function create_file (name, data) {
7166
if (tpl.filename_mode) {
7267
fs.chmodSync(filepath + '/' + filename, tpl.filename_mode);
7368
}
74-
resolve (filepath + '/' + filename);
69+
resolve(filepath + '/' + filename);
7570
return;
7671
});
7772
});
7873
});
7974
});
8075
}
8176

82-
8377
/* Todo: find if we should export create_file or not */
8478
/* Todo: should find a clean way to set name of param from function prototype) */
8579
module.exports = {
86-
8780
/*
8881
set_suffix: function (suffix) {
8982
filename_suffix = suffix;
@@ -122,7 +115,12 @@ module.exports = {
122115
},
123116

124117
ldap_change_user_groups: function (user, group_add_dn, group_remove_dn, fid) { // will use user.group
125-
return create_file('ldap_change_user_groups', { user: user, group_add_dn: group_add_dn, group_remove_dn: group_remove_dn, fid: fid });
118+
return create_file('ldap_change_user_groups', {
119+
user: user,
120+
group_add_dn: group_add_dn,
121+
group_remove_dn: group_remove_dn,
122+
fid: fid
123+
});
126124
},
127125

128126
/* method for users.js */
@@ -144,7 +142,12 @@ module.exports = {
144142
},
145143

146144
user_change_group: function (user, group_add, group_remove, fid) {
147-
return create_file('user_change_group', { user: user, group_add: group_add, group_remove: group_remove, fid: fid });
145+
return create_file('user_change_group', {
146+
user: user,
147+
group_add: group_add,
148+
group_remove: group_remove,
149+
fid: fid
150+
});
148151
},
149152

150153
user_delete_user: function (user, fid) {
@@ -172,7 +175,6 @@ module.exports = {
172175
return create_file('user_add_ssh_key', { user: user, fid: fid });
173176
},
174177

175-
176178
/* method for ssh.js */
177179
ssh_keygen: function (user, fid) {
178180
return create_file('ssh_keygen', { user: user, fid: fid });
@@ -202,7 +204,5 @@ module.exports = {
202204

203205
project_add_group_to_project: function (project, group, fid) {
204206
return create_file('project_add_group_to_project', { project: project, group: group, fid: fid });
205-
},
206-
207-
207+
}
208208
};

0 commit comments

Comments
 (0)