diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs index ab7bf0fce..1f166ffbf 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs @@ -26,6 +26,7 @@
  • + Devices @@ -38,7 +39,15 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.lib.data-table"}} - {{unit "cdmf.unit.device.operation-mod"}} - {{unit "cdmf.unit.device.view"}} + {{#if isAuthorized}} + {{unit "cdmf.unit.lib.data-table"}} + {{unit "cdmf.unit.device.operation-mod"}} + {{unit "cdmf.unit.device.view"}} + {{else}} +

    + Permission Denied +

    +
    + You are not authorized to view any enrolled device in the system. + {{/if}} {{/zone}} \ 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/pages/mdm.page.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js index 21ce99302..1f7e9c088 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js @@ -17,17 +17,24 @@ */ function onRequest(context){ - var utility = require("/app/modules/utility.js").utility; - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) - throw new Error("Handlebars Helper equal needs 2 parameters"); - if( lvalue!=rvalue ) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var viewModel = {}; - var deviceType = context.uriParams.deviceType; - return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")}; + // permission checks + // [1] checking viewing devices permission + viewModel["isAuthorized"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view"); + + if (viewModel["isAuthorized"]) { + context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { + if (arguments.length < 3) + throw new Error("Handlebars Helper equal needs 2 parameters"); + if( lvalue!=rvalue ) { + return options.inverse(this); + } else { + return options.fn(this); + } + }); + } + + return viewModel; } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs index 0c5652957..b56d066f1 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs @@ -156,6 +156,12 @@

    + {{else}} +

    + Permission Denied +

    +
    + You are not authorized to view any enrolled device in the system. {{/if}} {{/zone}} 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.device.view/public/img/device_icons/android.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/android.png old mode 100755 new mode 100644 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.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs index b21c3982d..3fbd58e75 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs @@ -3,23 +3,26 @@ {{unit "mdm.unit.device.qr-modal"}} {{#zone "contentTitle"}} -
    -
    -
    + {{/if}} {{/zone}} {{#zone "content"}} -
    + {{#if isAuthorized}} +
    @@ -79,305 +82,314 @@
    -
    - -
    - {{#defineZone "device-detail-properties"}} -
    -
    - +
    + +
    + {{#defineZone "device-detail-properties"}} +
    +
    + -
    - - -
    -

           Loading Device Details . . .
    +
    + + +
    +

           Loading Device Details . . .
    +
    +
    + -
    +
    +
    +
    + {{/defineZone}} +
    +
    + {{else}} +

    + Permission Denied +

    +
    + You are not authorized to view specified device in the system. + {{/if}} {{/zone}} {{#zone "bottomJs"}} - - - - {{js "js/device-detail.js"}} - - {{js "js/load-map.js"}} + {{#if isAuthorized}} + + + + {{js "js/device-detail.js"}} + + {{js "js/load-map.js"}} + {{/if}} {{/zone}} \ 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.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js index fe0d3a643..05309e1fa 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var log = new Log("view.js"); + // var log = new Log("view.js"); var deviceType = context.uriParams.deviceType; var deviceId = request.getParameter("id"); var deviceData = {}; @@ -26,6 +26,8 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var response = deviceModule.viewDevice(deviceType, deviceId); if (response["status"] == "success") { + deviceData["isAuthorized"] = true; + var device = response["content"]; var viewModel = {}; var deviceInfo = device["properties"]["DEVICE_INFO"]; @@ -54,8 +56,7 @@ function onRequest(context) { viewModel["vendor"] = device["properties"]["VENDOR"]; var osBuildDate = device["properties"]["OS_BUILD_DATE"]; if (osBuildDate != null && osBuildDate != "0") { - var formattedDate = new Date(osBuildDate * 1000); - viewModel["os_build_date"] = formattedDate; + viewModel["os_build_date"] = new Date(osBuildDate * 1000); } viewModel["internal_memory"] = {}; viewModel["external_memory"] = {}; @@ -96,6 +97,8 @@ function onRequest(context) { device["viewModel"] = viewModel; } deviceData["device"] = device; + } else if (response["status"] == "unauthorized") { + deviceData["isAuthorized"] = false; } return deviceData; }