forked from colmena/colmena
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-load-settings.js
More file actions
81 lines (69 loc) · 1.5 KB
/
01-load-settings.js
File metadata and controls
81 lines (69 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict';
// to enable these logs set `DEBUG=boot:01-load-settings` or `DEBUG=boot:*`
var log = require('debug')('boot:01-load-settings');
module.exports = function(app) {
var Setting = app.models.Setting;
function loadDefaultSettings() {
console.error('Creating default settings');
var settings = [{
type: 'string',
key: 'appName',
value: 'LoopBack Admin'
}, {
type: 'select',
key: 'appTheme',
value: 'skin-blue',
options: [
'skin-blue',
'skin-black'
]
}, {
type: 'select',
key: 'appLayout',
value: 'fixed',
options: [
'skin-blue',
'not-fixed'
]
}, {
type: 'string',
key: 'formLayout',
value: 'horizontal'
}, {
type: 'int',
key: 'formLabelSize',
value: 3
}, {
type: 'int',
key: 'formInputSize',
value: 9
}, {
type: 'boolean',
key: 'com.module.users.enable_registration',
value: true
}];
settings.forEach(function(setting) {
Setting.create(setting, function(err) {
if (err) {
console.error(err);
}
});
});
}
function loadExistingSettings() {
console.error('Loading existing settings');
Setting.find(function(data) {
log(data);
});
}
Setting.count(function(err, result) {
if (err) {
console.error(err);
}
if (result < 1) {
loadDefaultSettings();
} else {
loadExistingSettings();
}
});
};