Fix group count listing in dashboard

revert-70aa11f8
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. * 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") @Path("/groups")
@Api(value = "Device Group Management", description = "This API carries all device group management related operations " + @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.") value = "Maximum size of resource array to return.")
@QueryParam("limit") int limit); @QueryParam("limit") int limit);
@Path("/count")
@GET @GET
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,

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

@ -477,10 +477,10 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
permissions["LIST_OWN_DEVICES"] = true; 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; 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; permissions["LIST_GROUPS"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/list")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/list")) {

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

Loading…
Cancel
Save