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 fa4688cda2..5cee2c06a4 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 @@ -99,7 +99,7 @@ - + @@ -109,7 +109,10 @@

Enabling Device Operations

-

To enable device operations, select the desired platform from above filter.

+
+ To enable device operations, select the desired platform and + ownership from above filter. +
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-bar/operation-bar.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.operation-bar/operation-bar.hbs index a5c46e15aa..8939537719 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-bar/operation-bar.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.operation-bar/operation-bar.hbs @@ -19,7 +19,7 @@ {{unit "mdm.unit.date-range-picker"}} {{#zone "content"}} -
+
{{unit "mdm.unit.device.operation-mod"}}
{{/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-bar/operation-bar.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-bar/operation-bar.js index b6ac6b5f8c..512edff658 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-bar/operation-bar.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-bar/operation-bar.js @@ -16,8 +16,8 @@ * under the License. */ -function onRequest() { - // var log = new Log("mdm.unit.device.operation-bar"); +function onRequest(context) { + var log = new Log("mdm.unit.device.operation-bar"); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var viewModel = {}; var permissions = {}; @@ -93,10 +93,14 @@ function onRequest() { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/ring")) { permissions["windows"].push("DEVICE_RING"); } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lockreset")) { + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock-reset")) { permissions["windows"].push("LOCK_RESET"); } viewModel["permissions"] = stringify(permissions); + + viewModel["deviceType"] = context.unit.params.deviceType; + viewModel["ownership"] = context.unit.params.ownership; + return viewModel; } \ 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.operation-bar/public/js/operation-bar.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-bar/public/js/operation-bar.js index a3186092ac..93be0add70 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-bar/public/js/operation-bar.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-bar/public/js/operation-bar.js @@ -31,6 +31,10 @@ var operations = '.wr-operations', "ANDROID": "android", "IOS": "ios", "WINDOWS": "windows" + }, + ownershipTypeConstants = { + "BYOD": "BYOD", + "COPE": "COPE" }; /* @@ -94,62 +98,79 @@ function getDevicesByTypes(deviceList) { return deviceTypes; } -function unloadOperationBar() { - $("#showOperationsBtn").addClass("hidden"); - $(".wr-operations").html(""); -} +//function unloadOperationBar() { +// $("#showOperationsBtn").addClass("hidden"); +// $(".wr-operations").html(""); +//} -function loadOperationBar(deviceType) { +function loadOperationBar(deviceType, ownership) { var operationBar = $("#operations-bar"); var operationBarSrc = operationBar.attr("src"); - var platformType = deviceType; - //var selectedDeviceID = deviceId; + $.template("operations-bar", operationBarSrc, function (template) { - //var serviceURL = "/mdm-admin/features/" + platformType; - var serviceURL = "/api/device-mgt/v1.0/devices/" + platformType + "/*/features"; - var successCallback = function (data) { - var permittedOperations = []; - var i; - var permissionList = $("#operations-mod").data("permissions"); - var totalFeatures = JSON.parse(data); - for (i = 0; i < permissionList[deviceType].length; i++) { - var j; - for (j = 0; j < totalFeatures.length; j++) { - if (permissionList[deviceType][i] == totalFeatures[j]["code"]) { - permittedOperations.push(totalFeatures[j]); + var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/*/features"; + invokerUtil.get( + serviceURL, + // success callback + function (data) { + var permittedOperations = []; + var i; + var permissionList = $("#operations-mod").data("permissions"); + var totalFeatures = JSON.parse(data); + for (i = 0; i < permissionList[deviceType].length; i++) { + var j; + for (j = 0; j < totalFeatures.length; j++) { + if (permissionList[deviceType][i] == totalFeatures[j]["code"]) { + if (deviceType == platformTypeConstants.ANDROID && + totalFeatures[j]["code"] == "DEVICE_UNLOCK") { + if (ownership == ownershipTypeConstants.COPE) { + permittedOperations.push(totalFeatures[j]); + } + } else { + permittedOperations.push(totalFeatures[j]); + } + } } } - } - var viewModel = {}; - permittedOperations = permittedOperations.filter(function (current) { - var iconName; - switch (deviceType) { - case platformTypeConstants.ANDROID: - iconName = operationModule.getAndroidIconForFeature(current.code); - current.type = deviceType; - break; - case platformTypeConstants.WINDOWS: - iconName = operationModule.getWindowsIconForFeature(current.code); - break; - case platformTypeConstants.IOS: - iconName = operationModule.getIOSIconForFeature(current.code); - break; - } + var viewModel = {}; + permittedOperations = permittedOperations.filter(function (current) { + var iconName; + switch (deviceType) { + case platformTypeConstants.ANDROID: + iconName = operationModule.getAndroidIconForFeature(current.code); + break; + case platformTypeConstants.WINDOWS: + iconName = operationModule.getWindowsIconForFeature(current.code); + break; + case platformTypeConstants.IOS: + iconName = operationModule.getIOSIconForFeature(current.code); + break; + } + + /* adding ownership in addition to device-type + as it's vital in cases where UI for the same feature should change + according to ownership + */ + if (ownership) { + current.ownership = ownership; + } + + if (iconName) { + current.icon = iconName; + } - if (iconName) { - current.icon = iconName; return current; - } - }); + }); - viewModel.features = permittedOperations; - var content = template(viewModel); - $(".wr-operations").html(content); - }; - invokerUtil.get(serviceURL, successCallback, function (message) { - $(".wr-operations").html(message); - }); + viewModel.features = permittedOperations; + var content = template(viewModel); + $(".wr-operations").html(content); + }, + // error callback + function (message) { + $(".wr-operations").html(message); + }); }); } 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-bar/public/templates/operations.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.operation-bar/public/templates/operations.hbs index cd32216746..0b94ae0881 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-bar/public/templates/operations.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.operation-bar/public/templates/operations.hbs @@ -107,14 +107,16 @@
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 8ba22bcd0c..2fee10e12b 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 @@ -51,6 +51,7 @@ function onRequest(context) { latitude: device["properties"]["LATITUDE"], longitude: device["properties"]["LONGITUDE"] }; + viewModel["ownership"] = device["ownership"]; } else if (device["type"] == "android") { viewModel["deviceIdentifier"] = device["deviceIdentifier"]; viewModel["deviceName"] = device["name"]; @@ -132,6 +133,7 @@ function onRequest(context) { latitude: device["properties"]["LATITUDE"], longitude: device["properties"]["LONGITUDE"] }; + viewModel["ownership"] = device["ownership"]; } device["viewModel"] = viewModel; }