From 1e3d8021e9a92c9166f402f04e9f92cf4a968819 Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Thu, 3 Nov 2016 14:48:14 +0530 Subject: [PATCH] Adding Android and Windows operation bars --- .../operation-bar.hbs | 32 ++ .../operation-bar.js | 106 +++++ .../operation-bar.json | 4 + .../public/js/operation-bar.js | 248 ++++++++++++ .../templates/hidden-operations-android.hbs | 286 ++++++++++++++ .../templates/hidden-operations-ios.hbs | 366 ++++++++++++++++++ .../public/templates/operations.hbs | 249 ++++++++++++ .../operation-bar.hbs | 32 ++ .../operation-bar.js | 106 +++++ .../operation-bar.json | 4 + .../public/js/operation-bar.js | 248 ++++++++++++ .../templates/hidden-operations-android.hbs | 286 ++++++++++++++ .../templates/hidden-operations-ios.hbs | 366 ++++++++++++++++++ .../public/templates/operations.hbs | 249 ++++++++++++ 14 files changed, 2582 insertions(+) create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.js create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.json create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-android.hbs create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-ios.hbs create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/operations.hbs create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.hbs create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.js create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.json create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/js/operation-bar.js create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-android.hbs create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-ios.hbs create mode 100644 components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/operations.hbs diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs new file mode 100644 index 000000000..893953771 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs @@ -0,0 +1,32 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} + +{{unit "mdm.unit.date-range-picker"}} + +{{#zone "content"}} +
+ {{unit "mdm.unit.device.operation-mod"}} +
+{{/zone}} + +{{#zone "bottomJs"}} + + + {{js "js/operation-bar.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.js new file mode 100644 index 000000000..512edff65 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.js @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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 = {}; + + // adding android operations related permission checks + permissions["android"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) { + permissions["android"].push("DEVICE_RING"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) { + permissions["android"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) { + permissions["android"].push("DEVICE_UNLOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) { + permissions["android"].push("DEVICE_LOCATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) { + permissions["android"].push("CLEAR_PASSWORD"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) { + permissions["android"].push("DEVICE_REBOOT"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) { + permissions["android"].push("UPGRADE_FIRMWARE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) { + permissions["android"].push("DEVICE_MUTE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) { + permissions["android"].push("NOTIFICATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) { + permissions["android"].push("CHANGE_LOCK_CODE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) { + permissions["android"].push("ENTERPRISE_WIPE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) { + permissions["android"].push("WIPE_DATA"); + } + + // adding ios operations related permission checks + permissions["ios"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/lock")) { + permissions["ios"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/location")) { + permissions["ios"].push("LOCATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/enterprise-wipe")) { + permissions["ios"].push("ENTERPRISE_WIPE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/notification")) { + permissions["ios"].push("NOTIFICATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/ring")) { + permissions["ios"].push("RING"); + } + + // adding windows operations related permission checks + permissions["windows"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock")) { + permissions["windows"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) { + permissions["windows"].push("DISENROLL"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/wipe")) { + permissions["windows"].push("WIPE_DATA"); + } + 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/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/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.json b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.json new file mode 100644 index 000000000..56a988c76 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "extends": "cdmf.unit.device.operation-bar" +} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js new file mode 100644 index 000000000..90ce9ce4a --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Setting-up global variables. + */ + +var operations = '.wr-operations', + modalPopup = '.modal', + modalPopupContent = modalPopup + ' .modal-content', + navHeight = $('#nav').height(), + headerHeight = $('header').height(), + offset = (headerHeight + navHeight), + deviceSelection = '.device-select', + platformTypeConstants = { + "ANDROID": "android", + "IOS": "ios", + "WINDOWS": "windows" + }, + ownershipTypeConstants = { + "BYOD": "BYOD", + "COPE": "COPE" + }, + operationBarModeConstants = { + "BULK": "BULK_OPERATION_MODE", + "SINGLE": "SINGLE_OPERATION_MODE" + }; + +/* + * Function to get selected devices ID's + */ +function getSelectedDeviceIds() { + var deviceIdentifierList = []; + $(deviceSelection).each(function (index) { + var device = $(this); + var deviceId = device.data('deviceid'); + var deviceType = device.data('type'); + deviceIdentifierList.push({ + "id": deviceId, + "type": deviceType + }); + }); + if (deviceIdentifierList.length == 0) { + var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.api().rows().every(function () { + if ($(this.node()).hasClass('DTTT_selected')) { + var deviceId = $(thisTable.api().row(this).node()).data('deviceid'); + var deviceType = $(thisTable.api().row(this).node()).data('devicetype'); + deviceIdentifierList.push({ + "id": deviceId, + "type": deviceType + }); + } + }); + } + + return deviceIdentifierList; +} + +/* + * On operation click function. + * @param selection: Selected operation + */ +function operationSelect(selection) { + var deviceIdList = getSelectedDeviceIds(); + if (deviceIdList == 0) { + $(modalPopupContent).html($("#errorOperations").html()); + } else { + $(modalPopupContent).addClass("operation-data"); + $(modalPopupContent).html($(operations + " .operation[data-operation-code=" + selection + "]").html()); + $(modalPopupContent).data("operation-code", selection); + } + showPopup(); +} + +function getDevicesByTypes(deviceList) { + var deviceTypes = {}; + $.each(deviceList, function (index, item) { + if (!deviceTypes[item.type]) { + deviceTypes[item.type] = []; + } + if (item.type == platformTypeConstants.ANDROID || + item.type == platformTypeConstants.IOS || item.type == platformTypeConstants.WINDOWS) { + deviceTypes[item.type].push(item.id); + } + }); + return deviceTypes; +} + +//function unloadOperationBar() { +// $("#showOperationsBtn").addClass("hidden"); +// $(".wr-operations").html(""); +//} + +function loadOperationBar(deviceType, ownership, mode) { + var operationBar = $("#operations-bar"); + var operationBarSrc = operationBar.attr("src"); + + $.template("operations-bar", operationBarSrc, function (template) { + 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) { + if (totalFeatures[j]["code"] == "DEVICE_UNLOCK") { + if (ownership == ownershipTypeConstants.COPE) { + permittedOperations.push(totalFeatures[j]); + } + } else if (totalFeatures[j]["code"] == "WIPE_DATA") { + if (mode == operationBarModeConstants.BULK) { + if (ownership == ownershipTypeConstants.COPE) { + permittedOperations.push(totalFeatures[j]); + } + } else { + permittedOperations.push(totalFeatures[j]); + } + } else { + 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); + 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; + } + + return current; + }); + + viewModel.features = permittedOperations; + var content = template(viewModel); + $(".wr-operations").html(content); + }, + // error callback + function (message) { + $(".wr-operations").html(message); + }); + }); +} + +function runOperation(operationName) { + var deviceIdList = getSelectedDeviceIds(); + var list = getDevicesByTypes(deviceIdList); + + var successCallback = function (data) { + if (operationName == "NOTIFICATION") { + $(modalPopupContent).html($("#messageSuccess").html()); + } else { + $(modalPopupContent).html($("#operationSuccess").html()); + } + showPopup(); + }; + var errorCallback = function (data) { + $(modalPopupContent).html($("#errorOperationUnexpected").html()); + showPopup(); + }; + + var payload, serviceEndPoint; + if (list[platformTypeConstants.IOS]) { + payload = + operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); + serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); + } else if (list[platformTypeConstants.ANDROID]) { + payload = operationModule + .generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]); + serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); + } else if (list[platformTypeConstants.WINDOWS]) { + payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, + list[platformTypeConstants.WINDOWS]); + serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); + } + if (operationName == "NOTIFICATION") { + var errorMsgWrapper = "#notification-error-msg"; + var errorMsg = "#notification-error-msg span"; + var messageTitle = $("#messageTitle").val(); + var messageText = $("#messageText").val(); + if (!(messageTitle && messageText)) { + $(errorMsg).text("Enter a message. It cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } else { + invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); + $(modalPopupContent).removeData(); + hidePopup(); + } + } else { + invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); + $(modalPopupContent).removeData(); + hidePopup(); + } +} + +/* + * DOM ready functions. + */ +$(document).ready(function () { + $(operations).show(); +}); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-android.hbs new file mode 100644 index 000000000..b92461ff7 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-android.hbs @@ -0,0 +1,286 @@ +
+ +
+ + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + Configure +
+
+
+ + + +
+
+ + +
+ +
+ + + +
+ +
+ Configure +
+ +
+ + +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ Uninstall +
+
+
+ + + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+
\ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-ios.hbs new file mode 100644 index 000000000..4cb006ef0 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/hidden-operations-ios.hbs @@ -0,0 +1,366 @@ +
+ +
+ + +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+ Install +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+ Install +
+
+
+ +
+ +
+ +
+ Uninstall +
+
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ Configure +
+ + + +
+ + +
+ +
+ + + +
+
+ +
+
+ Path Prefix +
+
+
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+
+ +
+
+ : +
+
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ Configure +
+ + +
+ +
+ +
+ +
+ +
AirPlay password +
+ +
+ Configure +
+ +
+
\ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/operations.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/operations.hbs new file mode 100644 index 000000000..0b94ae088 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/templates/operations.hbs @@ -0,0 +1,249 @@ +
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+{{#each features}} + + + {{name}} + +
+ + + +
+{{/each}} +
\ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.hbs new file mode 100644 index 000000000..893953771 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.hbs @@ -0,0 +1,32 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} + +{{unit "mdm.unit.date-range-picker"}} + +{{#zone "content"}} +
+ {{unit "mdm.unit.device.operation-mod"}} +
+{{/zone}} + +{{#zone "bottomJs"}} + + + {{js "js/operation-bar.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.js new file mode 100644 index 000000000..512edff65 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.js @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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 = {}; + + // adding android operations related permission checks + permissions["android"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) { + permissions["android"].push("DEVICE_RING"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) { + permissions["android"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) { + permissions["android"].push("DEVICE_UNLOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) { + permissions["android"].push("DEVICE_LOCATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) { + permissions["android"].push("CLEAR_PASSWORD"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) { + permissions["android"].push("DEVICE_REBOOT"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) { + permissions["android"].push("UPGRADE_FIRMWARE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) { + permissions["android"].push("DEVICE_MUTE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) { + permissions["android"].push("NOTIFICATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) { + permissions["android"].push("CHANGE_LOCK_CODE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) { + permissions["android"].push("ENTERPRISE_WIPE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) { + permissions["android"].push("WIPE_DATA"); + } + + // adding ios operations related permission checks + permissions["ios"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/lock")) { + permissions["ios"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/location")) { + permissions["ios"].push("LOCATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/enterprise-wipe")) { + permissions["ios"].push("ENTERPRISE_WIPE"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/notification")) { + permissions["ios"].push("NOTIFICATION"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/ring")) { + permissions["ios"].push("RING"); + } + + // adding windows operations related permission checks + permissions["windows"] = []; + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock")) { + permissions["windows"].push("DEVICE_LOCK"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) { + permissions["windows"].push("DISENROLL"); + } + if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/wipe")) { + permissions["windows"].push("WIPE_DATA"); + } + 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/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/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.json b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.json new file mode 100644 index 000000000..56a988c76 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/operation-bar.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "extends": "cdmf.unit.device.operation-bar" +} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/js/operation-bar.js new file mode 100644 index 000000000..90ce9ce4a --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/js/operation-bar.js @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Setting-up global variables. + */ + +var operations = '.wr-operations', + modalPopup = '.modal', + modalPopupContent = modalPopup + ' .modal-content', + navHeight = $('#nav').height(), + headerHeight = $('header').height(), + offset = (headerHeight + navHeight), + deviceSelection = '.device-select', + platformTypeConstants = { + "ANDROID": "android", + "IOS": "ios", + "WINDOWS": "windows" + }, + ownershipTypeConstants = { + "BYOD": "BYOD", + "COPE": "COPE" + }, + operationBarModeConstants = { + "BULK": "BULK_OPERATION_MODE", + "SINGLE": "SINGLE_OPERATION_MODE" + }; + +/* + * Function to get selected devices ID's + */ +function getSelectedDeviceIds() { + var deviceIdentifierList = []; + $(deviceSelection).each(function (index) { + var device = $(this); + var deviceId = device.data('deviceid'); + var deviceType = device.data('type'); + deviceIdentifierList.push({ + "id": deviceId, + "type": deviceType + }); + }); + if (deviceIdentifierList.length == 0) { + var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.api().rows().every(function () { + if ($(this.node()).hasClass('DTTT_selected')) { + var deviceId = $(thisTable.api().row(this).node()).data('deviceid'); + var deviceType = $(thisTable.api().row(this).node()).data('devicetype'); + deviceIdentifierList.push({ + "id": deviceId, + "type": deviceType + }); + } + }); + } + + return deviceIdentifierList; +} + +/* + * On operation click function. + * @param selection: Selected operation + */ +function operationSelect(selection) { + var deviceIdList = getSelectedDeviceIds(); + if (deviceIdList == 0) { + $(modalPopupContent).html($("#errorOperations").html()); + } else { + $(modalPopupContent).addClass("operation-data"); + $(modalPopupContent).html($(operations + " .operation[data-operation-code=" + selection + "]").html()); + $(modalPopupContent).data("operation-code", selection); + } + showPopup(); +} + +function getDevicesByTypes(deviceList) { + var deviceTypes = {}; + $.each(deviceList, function (index, item) { + if (!deviceTypes[item.type]) { + deviceTypes[item.type] = []; + } + if (item.type == platformTypeConstants.ANDROID || + item.type == platformTypeConstants.IOS || item.type == platformTypeConstants.WINDOWS) { + deviceTypes[item.type].push(item.id); + } + }); + return deviceTypes; +} + +//function unloadOperationBar() { +// $("#showOperationsBtn").addClass("hidden"); +// $(".wr-operations").html(""); +//} + +function loadOperationBar(deviceType, ownership, mode) { + var operationBar = $("#operations-bar"); + var operationBarSrc = operationBar.attr("src"); + + $.template("operations-bar", operationBarSrc, function (template) { + 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) { + if (totalFeatures[j]["code"] == "DEVICE_UNLOCK") { + if (ownership == ownershipTypeConstants.COPE) { + permittedOperations.push(totalFeatures[j]); + } + } else if (totalFeatures[j]["code"] == "WIPE_DATA") { + if (mode == operationBarModeConstants.BULK) { + if (ownership == ownershipTypeConstants.COPE) { + permittedOperations.push(totalFeatures[j]); + } + } else { + permittedOperations.push(totalFeatures[j]); + } + } else { + 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); + 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; + } + + return current; + }); + + viewModel.features = permittedOperations; + var content = template(viewModel); + $(".wr-operations").html(content); + }, + // error callback + function (message) { + $(".wr-operations").html(message); + }); + }); +} + +function runOperation(operationName) { + var deviceIdList = getSelectedDeviceIds(); + var list = getDevicesByTypes(deviceIdList); + + var successCallback = function (data) { + if (operationName == "NOTIFICATION") { + $(modalPopupContent).html($("#messageSuccess").html()); + } else { + $(modalPopupContent).html($("#operationSuccess").html()); + } + showPopup(); + }; + var errorCallback = function (data) { + $(modalPopupContent).html($("#errorOperationUnexpected").html()); + showPopup(); + }; + + var payload, serviceEndPoint; + if (list[platformTypeConstants.IOS]) { + payload = + operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); + serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); + } else if (list[platformTypeConstants.ANDROID]) { + payload = operationModule + .generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]); + serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); + } else if (list[platformTypeConstants.WINDOWS]) { + payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, + list[platformTypeConstants.WINDOWS]); + serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); + } + if (operationName == "NOTIFICATION") { + var errorMsgWrapper = "#notification-error-msg"; + var errorMsg = "#notification-error-msg span"; + var messageTitle = $("#messageTitle").val(); + var messageText = $("#messageText").val(); + if (!(messageTitle && messageText)) { + $(errorMsg).text("Enter a message. It cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } else { + invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); + $(modalPopupContent).removeData(); + hidePopup(); + } + } else { + invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); + $(modalPopupContent).removeData(); + hidePopup(); + } +} + +/* + * DOM ready functions. + */ +$(document).ready(function () { + $(operations).show(); +}); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-android.hbs new file mode 100644 index 000000000..b92461ff7 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-android.hbs @@ -0,0 +1,286 @@ +
+ +
+ + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + Configure +
+
+
+ + + +
+
+ + +
+ +
+ + + +
+ +
+ Configure +
+ +
+ + +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ Install +
+
+
+ +
+ + +
+ +
+ Uninstall +
+
+
+ + + +
+
+ +
+
+ +
+ Configure +
+
+
+ +
+
\ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-ios.hbs new file mode 100644 index 000000000..4cb006ef0 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/hidden-operations-ios.hbs @@ -0,0 +1,366 @@ +
+ +
+ + +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+ Install +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+ Install +
+
+
+ +
+ +
+ +
+ Uninstall +
+
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ Configure +
+ + + +
+ + +
+ +
+ + + +
+
+ +
+
+ Path Prefix +
+
+
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+
+ +
+
+ : +
+
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ Configure +
+ + +
+ +
+ +
+ +
+ +
AirPlay password +
+ +
+ Configure +
+ +
+
\ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/operations.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/operations.hbs new file mode 100644 index 000000000..0b94ae088 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar/public/templates/operations.hbs @@ -0,0 +1,249 @@ +
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+{{#each features}} + + + {{name}} + +
+ + + +
+{{/each}} +
\ No newline at end of file