This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.jag
183 lines (158 loc) · 5.56 KB
/
index.jag
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<%
//Module objects
var absolute = require ('modules/absolute.js').mvc;
var goose = require('modules/goose.js').goose;
var deviceModule = require('modules/device.js').device;
var userModule = require('modules/user.js').user;
var notificationModule = require('modules/notification.js').notification;
var storeModule = require('modules/store.js').store;
var webconsoleModule = require('modules/webconsole.js').webconsole;
var dashboardModule = require('modules/dashboard.js').dashboard;
var featureModule = require('modules/feature.js').feature;
var helpers = require('modules/helpers.js');
var common = require('modules/common.js');
// Routers
var userRouter = require('api/userRouter.js').user;
var featureRouter = require('api/featureRouter.js').feature;
var permissionRouter = require('api/permissionRouter.js').permission;
var policyRouter = require('api/policyRouter.js').policy;
var deviceRouter = require('api/deviceRouter.js').device;
var notificationRouter = require('api/notificationRouter.js').notification;
var groupRouter = require('api/groupRouter.js').group;
var reportRouter = require('api/reportRouter.js').reports;
var GOOSE_CONFIGS = {
CONTEXT : "/mdm/api/",
AUTH_SUPPORT : true
};
var ABSOLUTE_CONFIGS = {
SERVER_URL:"/mdm/",
IGNORE:[],
API:"api",
AUTH_SUPPORT: true
};
var MDM_USER_SESSION = "mdmConsoleUser";
var log = new Log();
var configs = require('config/mdm.js').config();
var db = common.getDatabase();
var current_user = session.get(MDM_USER_SESSION);
var current_user_roles = undefined;
if(current_user != undefined){
current_user_roles = current_user.roles;
}
GOOSE_CONFIGS.AUTH_USER_ROLES = current_user_roles;
ABSOLUTE_CONFIGS.AUTH_USER_ROLES = current_user_roles;
var router = new goose(GOOSE_CONFIGS);
ABSOLUTE_CONFIGS.ROUTER = router;
var mvc = new absolute(ABSOLUTE_CONFIGS);
//Setting up the authorization roles
router.setupRules(require('/config/route.json').apiRoutes);
mvc.setupRules(require('/config/route.json').pageRoutes);
var device = new deviceModule();
var user = new userModule();
var notification = new notificationModule();
var webconsole = new webconsoleModule(db);
var dashboard = new dashboardModule(db);
var feature = new featureModule(db);
var store = new storeModule(db);
var userRouterInstance = new userRouter(db,router);
var featureRouterInstance = new featureRouter(db,router);
var permissionRouterInstance = new permissionRouter(db,router);
var policyRouterInstance = new policyRouter(db,router);
var deviceRouterInstance = new deviceRouter(db, router);
var notificationRouterInstance = new notificationRouter(db, router);
var groupRouterInstance = new groupRouter(db,router);
var reportRouterInstance = new reportRouter (db,router);
router.post('store/users/devices', function(ctx){
common.handleError(this, ctx, function(){
var result = store.getAllDevicesFromEmail(ctx);
print(result);
});
});
router.post('store/users/apps', function(ctx){
common.handleError(this, ctx, function(){
var result = store.getAllAppFromDevice(ctx);
});
});
router.get('dashboard/devices/all/percentage/byos', function(ctx){
var result = dashboard.getDeviceCountByOS(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('dashboard/devices/all/percentage/byownership', function(ctx){
var result = dashboard.getDeviceCountByOwnership(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('dashboard/all/info', function(ctx){
var result = dashboard.getDashboardInfo(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('dashboard/devices/android/info', function(ctx){
var result = dashboard.getAllAndroidDevices(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('dashboard/devices/ios/info', function(ctx){
var result = dashboard.getAlliOSDevices(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('dashboard/policies/compliance', function(ctx){
var result = notification.getPolicyComplianceDevicesCount(ctx); //should be move to dashborad.js
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('webconsole/devices', function(ctx){
var result = webconsole.getDevicesCountAndUserCountForAllGroups(ctx);
response.content = result;
});
router.get('webconsole/listDevices', function(ctx){
var result = webconsole.getDevices(ctx);
print(result);
});
router.get('webconsole/allUsers', function(ctx){
var result = webconsole.getAllUsers(ctx);
print(result);
});
router.get('features', function(ctx){
var result = feature.getAllFeatures(ctx);
if(result!= null && result != undefined){
response.content = result;
response.status = 200;
}else{
response.status = 404;
}
});
router.get('find', function(ctx){
var driver = require('/modules/driver.js').driver;
var query = driver.execute("SELECT * FROM PLATFORMS WHERE id=?", "1");
// log.info(query);
});
helpers.registerHelpers(mvc);
mvc.route(request);
%>