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.operation-mod/public/js/operation-mod.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.operation-mod/public/js/operation-mod.js index 3f1219765..f47bbd997 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.operation-mod/public/js/operation-mod.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.operation-mod/public/js/operation-mod.js @@ -115,8 +115,8 @@ var operationModule = function () { var featureMap = { "DEVICE_LOCK": "lock", "VPN": "vpn", - "PER_APP_VPN": "perappvpn", - "APP_TO_PER_APP_VPN_MAPPING": "apptoperappvpnmapping", + "PER_APP_VPN": "per-app-vpn", + "APP_TO_PER_APP_VPN_MAPPING": "app-to-per-app-vpn-mapping", "RING": "ring", "LOCATION": "location", "NOTIFICATION": "notification", @@ -124,12 +124,12 @@ var operationModule = function () { "RESTRICTION": "restriction", "CELLULAR": "cellular", "WIFI": "wifi", - "INSTALL_STORE_APPLICATION": "storeapplication", - "INSTALL_ENTERPRISE_APPLICATION": "enterpriseapplication", - "REMOVE_APPLICATION": "removeapplication", - "ENTERPRISE_WIPE": "enterprisewipe" + "INSTALL_STORE_APPLICATION": "store-application", + "INSTALL_ENTERPRISE_APPLICATION": "enterprise-application", + "REMOVE_APPLICATION": "remove-application", + "ENTERPRISE_WIPE": "enterprise-wipe" }; - return "/ios/operation/" + featureMap[operationCode]; + return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode]; }; /** 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/public/js/device-detail.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/public/js/device-detail.js index 074095034..87d902e44 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/public/js/device-detail.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/public/js/device-detail.js @@ -50,49 +50,61 @@ var InitiateViewOption = null; ); } + $(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) { - var activeTabPane = $(e.target).attr("href"), - activeCollapsePane = $(activeTabPane).find("[data-toggle=collapse]").data("target"), - activeCollapsePaneSiblings = $(activeTabPane).siblings().find("[data-toggle=collapse]").data("target"), - activeListGroupItem = $(".media .list-group-item.active"); + var activeTabPane = $(e.target).attr("href"); + var activeListGroupItem = $(".media .list-group-item.active"); - $(activeCollapsePaneSiblings).collapse("hide"); - $(activeCollapsePane).collapse("show"); + $(activeTabPane).removeClass("visible-xs-block"); + $(activeTabPane).siblings().not(".arrow-left").addClass("visible-xs-block"); positionArrow(activeListGroupItem); - - $(".panel-heading .caret-updown").removeClass("fw-sort-down"); - $(".panel-heading.collapsed .caret-updown").addClass("fw-sort-up"); }); $(".media.tab-responsive .tab-content").on("shown.bs.collapse", function (e) { - var activeTabPane = $(e.target).parent().attr("id"); - $(".media.tab-responsive [data-toggle=tab][href=#" + activeTabPane + "]").tab("show"); - $(".panel-heading .caret-updown").removeClass("fw-sort-up"); - $(".panel-heading.collapsed .caret-updown").addClass("fw-sort-down"); + var thisParent = $(e.target).parent(); + var activeTabPaneCaret = thisParent.find('.caret-updown'); + var activeTabPaneCaretSiblings = thisParent.siblings().find('.caret-updown'); + + activeTabPaneCaret.removeClass("fw-up").addClass("fw-down"); + activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up"); + }); + + + $('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){ + var clickedPanel = $(this).attr('href'); + + if($(clickedPanel).hasClass('in')){ + $(clickedPanel).collapse('hide'); + }else{ + $(clickedPanel).collapse('show'); + } }); + function positionArrow(selectedTab) { - var selectedTabHeight = $(selectedTab).outerHeight(); + var selectedTabHeight = $(selectedTab).innerHeight(); var arrowPosition = 0; var totalHeight = 0; var arrow = $(".media .panel-group.tab-content .arrow-left"); - var parentHeight = $(arrow).parent().outerHeight(); + var parentHeight = $(arrow).parent().innerHeight(); -// if($(selectedTab).prev().length){ -// $(selectedTab).prevAll().each(function() { -// totalHeight += $(this).outerHeight(); -// }); -// arrowPosition = totalHeight + (selectedTabHeight / 2); -// }else{ -// arrowPosition = selectedTabHeight / 2; -// } + + if($(selectedTab).prev().length){ + $(selectedTab).prevAll().each(function() { + totalHeight += $(this).innerHeight(); + }); + arrowPosition = totalHeight + (selectedTabHeight / 2); + }else{ + arrowPosition = selectedTabHeight / 2; + } if(arrowPosition >= parentHeight){ - parentHeight = arrowPosition + 10; - $(arrow).parent().height(parentHeight); + parentHeight = arrowPosition + 50; + $(arrow).siblings(".panel.active").height(parentHeight); }else{ $(arrow).parent().removeAttr("style"); } + $(arrow).css("top", arrowPosition - 10); } @@ -228,8 +240,8 @@ var InitiateViewOption = null; $("#applications-list-container").html(content); } else { $("#applications-list-container"). - html("

     No applications found. " + - "please try refreshing the list in a while.

    "); + html("

    No applications found.

    " + + "

    Please try refreshing the list in a while.

    "); } } }, @@ -315,4 +327,5 @@ var InitiateViewOption = null; } ); } + }()); 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..4dfc3b86c 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,22 +3,25 @@ {{unit "mdm.unit.device.qr-modal"}} {{#zone "contentTitle"}} -
    -
    - + {{#if isAuthorized}} +
    +
    + +
    -
    + {{/if}} {{/zone}} {{#zone "content"}} + {{#if isAuthorized}}
    @@ -366,8 +369,16 @@ {{/defineZone}}
    + {{else}} +

    + Permission Denied +

    +
    + You are not authorized to view specified device in the system. + {{/if}} {{/zone}} {{#zone "bottomJs"}} + {{#if isAuthorized}} @@ -380,4 +391,5 @@ {{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; } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk index 8f86ac592..62abf46b6 100644 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk differ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 6f4ecfd76..4d96f8acd 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; +import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import javax.ws.rs.*; @@ -35,26 +36,31 @@ public interface DeviceManagementAdminService { @POST @Path("/lock-devices") + @Permission(name = "Lock Device", permission = "/device-mgt/devices/owning/operations/windows/lock") Response lock(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/disenroll-devices") + @Permission(name = "Disenroll Device", permission = "/device-mgt/devices/disenroll/windows") Response disenroll(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/wipe-devices") + @Permission(name = "Wipe Device", permission = "/device-mgt/devices/owning/operations/windows/wipe") Response wipe(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/ring-devices") + @Permission(name = "Ring Device", permission = "/device-mgt/devices/owning/operations/windows/ring") Response ring(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/lockreset-devices") + @Permission(name = "Lock-Reset Device", permission = "/device-mgt/devices/owning/operations/windows/lockreset") Response lockReset(@HeaderParam("Accept") String acceptHeader, List deviceIds) throws WindowsDeviceEnrolmentException; }