-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathUIControlGroups.js
More file actions
61 lines (52 loc) · 1.62 KB
/
Copy pathUIControlGroups.js
File metadata and controls
61 lines (52 loc) · 1.62 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
const fs = require('fs');
const USER_CONTROLS = 'views/template/userControlGroups.html';
const ADMIN_CONTROLS = 'views/template/adminControlGroups.html';
const LOGIN_CONTROLS = 'views/LoginUserGroups.html';
var msg = '';
var userForm = '';
class UIControls {
constructor(obj) {
for ( let key in obj ) {
this [key] = obj [key];
}
}
LoadLoginPage() {
userForm = LOGIN_CONTROLS;
msg = 'Reading from file' + userForm;
console.log(msg);
return new Promise(function(resolve, reject) {
fs.readFile(userForm, (err, data) => {
if (err) {
reject(Error(err));
} else {
console.log(data);
resolve(data);
}
});
});
}
LoadPage(loginInfo) {
var user = loginInfo[0].login;
var role = loginInfo[0].role;
msg = '\n User: ' + user + ' Role: ' + role + '\n';
console.log(msg);
if ( user == 'ADMIN' || role == 'ADMIN') {
userForm = ADMIN_CONTROLS;
} else {
userForm = USER_CONTROLS;
}
msg = 'Reading from file' + userForm;
console.log(msg);
return new Promise(function(resolve, reject) {
fs.readFile(userForm, (err, data) => {
if (err) {
reject(Error(err));
} else {
console.log(data);
resolve(data);
}
});
});
}
}
module.exports = UIControls;