diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js index 43ee2fc82c..367db085bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js @@ -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 () { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js index 9ad1b2001b..3d050b38a1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/group.js @@ -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; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js index a26e64de9c..bca48a0362 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js @@ -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; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.analytics/analytics.hbs deleted file mode 100644 index 367a268ac7..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.analytics/analytics.hbs +++ /dev/null @@ -1,42 +0,0 @@ -{{unit "cdmf.unit.ui.title" pageTitle="Analytics"}} -{{unit "cdmf.unit.ui.content.title" pageHeader=title}} - -{{#zone "breadcrumbs"}} -
' + tmph + ' | '; - } - } - else { - for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) { - gridSize[litem]++; - html += '' + ((m < 10) ? '0' : '') + m + ' | '; - } - } - - html += '
< | January, 2011 | > | ||||
---|---|---|---|---|---|---|
< | January, 2011 | > | ||||
---|---|---|---|---|---|---|