From dbeedf246ba7bcdec77de26366838f4d4c6755fb Mon Sep 17 00:00:00 2001 From: dilanua Date: Sun, 20 Nov 2016 10:55:56 +0530 Subject: [PATCH] Adding deviceStatisticsEnabled property to check visibility of device-statistics menu item --- .../jaggeryapps/devicemgt/app/conf/config.json | 4 ++-- .../units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs | 11 +++++++---- .../units/mdm.unit.ui.navbar.nav-menu/nav-menu.js | 12 ++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 06417b7e8b..4fb7741b97 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -7,7 +7,6 @@ "httpsWebURL" : "%https.ip%", "wssURL" : "%https.ip%", "wsURL" : "%http.ip%", - "dashboardServerURL" : "%https.ip%", "enrollmentDir": "/emm-web-agent/enrollment", "iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSAPIRoot" : "%https.ip%/ios/", @@ -121,5 +120,6 @@ "isOAuthEnabled" : true, "backendRestEndpoints" : { "deviceMgt" : "/api/device-mgt/v1.0" - } + }, + "deviceStatisticsEnabled" : false } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs index ac2b44eaf4..cd674764c4 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs @@ -28,10 +28,12 @@ System Resources - {{#if permissions.VIEW_DASHBOARD}} -
  • - Device Statistics -
  • + {{#if dashboardAvailable}} + {{#if permissions.VIEW_DASHBOARD}} +
  • + Device Statistics +
  • + {{/if}} {{/if}} {{#if permissions.LIST_DEVICES}}
  • @@ -104,6 +106,7 @@
    + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js index b7aba2e890..4269d39298 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js @@ -17,6 +17,10 @@ */ function onRequest(context) { + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + var constants = require("/app/modules/constants.js"); + context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { if (arguments.length < 3) { throw new Error("Handlebars Helper equal needs 2 parameters"); @@ -27,9 +31,7 @@ function onRequest(context) { return options.fn(this); } }); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var constants = require("/app/modules/constants.js"); + var links = { "user-mgt": [], "role-mgt": [], @@ -40,7 +42,7 @@ function onRequest(context) { // following viewModel.link value comes here based on the value passed at the point // where units are attached to a page zone. - // eg: {{unit "appbar" pageLink="users" title="User Management"}} + // eg: {{unit "app-bar" pageLink="users" title="User Management"}} viewModel["currentActions"] = links[viewModel["pageLink"]]; viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; viewModel["currentUser"] = session.get(constants["USER_SESSION_KEY"]); @@ -57,6 +59,8 @@ function onRequest(context) { permissions["LIST_NOTIFICATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/notifications/view"); permissions["VIEW_DASHBOARD"] = userModule.isAuthorized("/permission/admin/device-mgt/dashboard/view"); + viewModel["dashboardAvailable"] = mdmProps["deviceStatisticsEnabled"]; + viewModel["permissions"] = permissions; viewModel["appContext"] = mdmProps["appContext"]; viewModel["serverURL"] = mdmProps["httpsWebURL"];