mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Update new analytics components.
This commit is contained in:
parent
1e709bc394
commit
bcbde92143
@ -258,32 +258,34 @@ deviceModule = function () {
|
||||
};
|
||||
|
||||
// Refactored methods
|
||||
publicMethods.getOwnDevicesCount = function () {
|
||||
publicMethods.getDevicesCount = function () {
|
||||
var carbonUser = session.get(constants.USER_SESSION_KEY);
|
||||
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username
|
||||
+ "/count";
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return responsePayload;
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
publicMethods.getAllDevicesCount = function () {
|
||||
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count";
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return responsePayload;
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
if (carbonUser) {
|
||||
var userModule = require("/app/modules/user.js").userModule;
|
||||
var uiPermissions = userModule.getUIPermissions();
|
||||
var url;
|
||||
if (uiPermissions.LIST_DEVICES) {
|
||||
url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count";
|
||||
} else if (uiPermissions.LIST_OWN_DEVICES) {
|
||||
url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username
|
||||
+ "/count";
|
||||
} else {
|
||||
log.error("Access denied for user: " + carbonUser.username);
|
||||
return -1;
|
||||
}
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return responsePayload;
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
log.error("User object was not found in the session");
|
||||
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
||||
}
|
||||
};
|
||||
|
||||
publicMethods.getDeviceTypes = function () {
|
||||
|
||||
@ -38,12 +38,14 @@ var groupModule = {};
|
||||
endPoint = groupServiceEndpoint + "/count";
|
||||
} else if (permissions.LIST_GROUPS) {
|
||||
endPoint = groupServiceEndpoint + "/user/" + user.username + "/count";
|
||||
} else {
|
||||
log.error("Access denied for user: " + carbonUser.username);
|
||||
return -1;
|
||||
}
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
endPoint, function (responsePayload) {
|
||||
return responsePayload;
|
||||
}
|
||||
,
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
return -1;
|
||||
@ -56,8 +58,7 @@ var groupModule = {};
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
endPoint, function (responsePayload) {
|
||||
return responsePayload;
|
||||
}
|
||||
,
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
return -1;
|
||||
|
||||
@ -653,6 +653,9 @@ var userModule = function () {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) {
|
||||
permissions["LIST_POLICIES"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/add")) {
|
||||
permissions["ADD_DEVICE"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) {
|
||||
permissions["ADD_GROUP"] = true;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ function onRequest(context) {
|
||||
var groupModule = require("/app/modules/group.js").groupModule;
|
||||
var policyModule = require("/app/modules/policy.js").policyModule;
|
||||
|
||||
page.device_count = deviceModule.getAllDevicesCount();
|
||||
page.device_count = deviceModule.getDevicesCount();
|
||||
page.group_count = groupModule.getGroupCount();
|
||||
page.user_count = userModule.getUsers()["content"].length;
|
||||
page.policy_count = policyModule.getAllPolicies()["content"].length;
|
||||
|
||||
@ -34,8 +34,9 @@ function onRequest(context) {
|
||||
var currentUser = session.get(constants.USER_SESSION_KEY);
|
||||
if (currentUser) {
|
||||
page.permissions = {};
|
||||
page.permissions.list = stringify(userModule.getUIPermissions());
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/add")) {
|
||||
var uiPermissions = userModule.getUIPermissions();
|
||||
page.permissions.list = stringify(uiPermissions);
|
||||
if (uiPermissions.ADD_DEVICE) {
|
||||
page.permissions.enroll = true;
|
||||
}
|
||||
page.currentUser = currentUser;
|
||||
@ -45,7 +46,7 @@ function onRequest(context) {
|
||||
deviceCount = groupModule.getGroupDeviceCount(groupName, groupOwner);
|
||||
page.groupOwner = groupOwner;
|
||||
} else {
|
||||
deviceCount = deviceModule.getOwnDevicesCount();
|
||||
deviceCount = deviceModule.getDevicesCount();
|
||||
}
|
||||
if (deviceCount > 0) {
|
||||
page.deviceCount = deviceCount;
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
{{#each devices}}
|
||||
{{deviceMap this}}
|
||||
<tr data-type="selectable" data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}">
|
||||
<td class="remove-padding icon-only content-fill">
|
||||
<div class="thumbnail icon">
|
||||
<img class="square-element text fw "
|
||||
src="{{../imageLocation}}{{type}}.type-view/images/thumb.png"/>
|
||||
</div>
|
||||
</td>
|
||||
<td class="fade-edge" data-search="{{properties.DEVICE_MODEL}},{{properties.VENDOR}}"
|
||||
data-display="{{properties.DEVICE_MODEL}}">
|
||||
<h4 data-deviceid="{{deviceIdentifier}}">{{name}}</h4>
|
||||
{{#if properties.VENDOR}}
|
||||
<div>({{properties.VENDOR}} - {{properties.DEVICE_MODEL}})</div>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="fade-edge remove-padding-top" data-search="{{enrolmentInfo.owner}}"
|
||||
data-display="{{enrolmentInfo.owner}}"
|
||||
data-grid-label="Owner">{{enrolmentInfo.owner}}</td>
|
||||
<td class="fade-edge remove-padding-top" data-search="{{enrolmentInfo.status}}"
|
||||
data-display="{{enrolmentInfo.status}}" data-grid-label="Status">
|
||||
{{#equal enrolmentInfo.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i> Active</span>{{/equal}}
|
||||
{{#equal enrolmentInfo.status "INACTIVE"}}<span><i
|
||||
class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
|
||||
{{#equal enrolmentInfo.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
|
||||
{{#equal enrolmentInfo.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
|
||||
</td>
|
||||
<td class="fade-edge remove-padding-top" data-search="{{type}}" data-display="{{type}}"
|
||||
data-grid-label="Type">{{type}}</td>
|
||||
|
||||
<td class="fade-edge remove-padding-top" data-search="{{enrolmentInfo.ownership}}"
|
||||
data-display="{{enrolmentInfo.ownership}}"
|
||||
data-grid-label="Ownership">{{enrolmentInfo.ownership}}</td>
|
||||
|
||||
<td class="text-right content-fill text-left-on-grid-view no-wrap">
|
||||
{{#unequal enrolmentInfo.status "REMOVED"}}
|
||||
<a href="device/{{type}}?id={{deviceIdentifier}}"
|
||||
data-click-event="remove-form" class="btn padding-reduce-on-grid-view">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-view fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs hidden-on-grid-view">View</span>
|
||||
</a>
|
||||
<a href="analytics?deviceId={{deviceIdentifier}}&deviceType={{type}}&deviceName={{name}}"
|
||||
data-click-event="remove-form" class="btn padding-reduce-on-grid-view">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-statistics fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs hidden-on-grid-view">Analytics</span>
|
||||
</a>
|
||||
{{#unless ../../isGroupView}}
|
||||
<a href="#" data-click-event="remove-form"
|
||||
class="btn padding-reduce-on-grid-view group-device-link"
|
||||
data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}"
|
||||
data-devicename="{{name}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-grouping fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs hidden-on-grid-view">Group</span>
|
||||
</a>
|
||||
{{/unless}}
|
||||
<a href="#" data-click-event="remove-form"
|
||||
class="btn padding-reduce-on-grid-view edit-device-link"
|
||||
data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}"
|
||||
data-devicename="{{name}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-edit fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs hidden-on-grid-view">Edit</span>
|
||||
</a>
|
||||
<a href="#" data-click-event="remove-form"
|
||||
class="btn padding-reduce-on-grid-view remove-device-link"
|
||||
data-deviceid="{{deviceIdentifier}}" data-devicetype="{{type}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-delete fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs hidden-on-grid-view">Delete</span>
|
||||
</a>
|
||||
{{/unequal}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
Loading…
Reference in New Issue
Block a user