|
|
|
@ -26,8 +26,7 @@ var groupModule = {};
|
|
|
|
|
var utility = require("/app/modules/utility.js").utility;
|
|
|
|
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
|
|
|
|
|
|
|
|
|
var groupServiceEndpoint = devicemgtProps["httpsURL"] +
|
|
|
|
|
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/groups";
|
|
|
|
|
var deviceServiceEndpoint = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0";
|
|
|
|
|
|
|
|
|
|
var user = session.get(constants.USER_SESSION_KEY);
|
|
|
|
|
|
|
|
|
@ -36,26 +35,26 @@ var groupModule = {};
|
|
|
|
|
groupModule.getGroupCount = function () {
|
|
|
|
|
var permissions = userModule.getUIPermissions();
|
|
|
|
|
if (permissions.LIST_ALL_GROUPS) {
|
|
|
|
|
endPoint = groupServiceEndpoint + "/count";
|
|
|
|
|
endPoint = deviceServiceEndpoint + "/admin/groups/count";
|
|
|
|
|
} else if (permissions.LIST_GROUPS) {
|
|
|
|
|
endPoint = groupServiceEndpoint + "/user/" + user.username + "/count";
|
|
|
|
|
endPoint = deviceServiceEndpoint + "/groups/count";
|
|
|
|
|
} else {
|
|
|
|
|
log.error("Access denied for user: " + carbonUser.username);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return serviceInvokers.XMLHttp.get(
|
|
|
|
|
endPoint, function (responsePayload) {
|
|
|
|
|
return responsePayload;
|
|
|
|
|
return responsePayload["responseText"];
|
|
|
|
|
},
|
|
|
|
|
function (responsePayload) {
|
|
|
|
|
log.error(responsePayload);
|
|
|
|
|
log.error(responsePayload["responseText"]);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
groupModule.getGroupDeviceCount = function (groupName, owner) {
|
|
|
|
|
endPoint = groupServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices/count";
|
|
|
|
|
endPoint = deviceServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices/count";
|
|
|
|
|
return serviceInvokers.XMLHttp.get(
|
|
|
|
|
endPoint, function (responsePayload) {
|
|
|
|
|
return responsePayload;
|
|
|
|
@ -68,7 +67,7 @@ var groupModule = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
groupModule.getGroupDevices = function (groupName, owner) {
|
|
|
|
|
endPoint = groupServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices";
|
|
|
|
|
endPoint = deviceServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices";
|
|
|
|
|
return serviceInvokers.XMLHttp.get(
|
|
|
|
|
endPoint, function (responsePayload) {
|
|
|
|
|
return responsePayload;
|
|
|
|
|