Fix group count listing in dashboard

merge-requests/7/head
charitha 8 years ago
parent a2c0526b40
commit e53b0c3860

@ -53,7 +53,7 @@ import java.util.List;
/**
* Device group related REST-API. This can be used to manipulated device group related details.
*/
@API(name = "Group Management", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"})
@API(name = "GroupManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"})
@Path("/groups")
@Api(value = "Device Group Management", description = "This API carries all device group management related operations " +

@ -106,6 +106,7 @@ public interface GroupManagementAdminService {
value = "Maximum size of resource array to return.")
@QueryParam("limit") int limit);
@Path("/count")
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,

@ -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;

@ -477,10 +477,10 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
permissions["LIST_OWN_DEVICES"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/list")) {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) {
permissions["LIST_ALL_GROUPS"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/list")) {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/view")) {
permissions["LIST_GROUPS"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/list")) {

@ -36,9 +36,7 @@ function onRequest() {
viewModel.permissions = permissions;
viewModel.enrollmentURL = devicemgtProps.enrollmentURL;
viewModel.deviceCount = deviceModule.getDevicesCount();
//TODO: Enable Group Management Service API on CDMF
//page.group_count = groupModule.getGroupCount();
viewModel.groupCount = -1;
viewModel.groupCount = groupModule.getGroupCount();
viewModel.userCount = userModule.getUsersCount();
viewModel.policyCount = policyModule.getPoliciesCount();
viewModel.roleCount = userModule.getRolesCount();

Loading…
Cancel
Save