merge-requests/1/head
thusithakalugamage 8 years ago
commit a994779bd8

@ -15,6 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#zone "content"}} {{#zone "content"}}
<div id = "operations-mod" data-permissions="{{permissions}}"> <div id = "operations-mod" data-permissions="{{permissions}}">
{{unit "mdm.unit.device.operation-mod"}} {{unit "mdm.unit.device.operation-mod"}}

@ -17,55 +17,53 @@
*/ */
function onRequest(context) { function onRequest(context) {
var log = new Log("mdm.unit.device.operation-bar"); // var log = new Log("mdm.unit.device.operation-bar");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceType = context.uriParams.deviceType;
var viewModel = {}; var viewModel = {};
var permissions = []; var permissions = {};
// permission checks // adding android operations related permission checks
if (deviceType == "android") { permissions["android"] = [];
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/ring")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/ring")) {
permissions.push("DEVICE_RING"); permissions["android"].push("DEVICE_RING");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/lock-devices")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/lock-devices")) {
permissions.push("DEVICE_LOCK"); permissions["android"].push("DEVICE_LOCK");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/unlock-devices")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/unlock-devices")) {
permissions.push("DEVICE_UNLOCK"); permissions["android"].push("DEVICE_UNLOCK");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/location")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/location")) {
permissions.push("DEVICE_LOCATION"); permissions["android"].push("DEVICE_LOCATION");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/clear-password")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/clear-password")) {
permissions.push("CLEAR_PASSWORD"); permissions["android"].push("CLEAR_PASSWORD");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/reboot")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/reboot")) {
permissions.push("DEVICE_REBOOT"); permissions["android"].push("DEVICE_REBOOT");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/upgrade-firmware")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/upgrade-firmware")) {
permissions.push("UPGRADE_FIRMWARE"); permissions["android"].push("UPGRADE_FIRMWARE");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/mute")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/mute")) {
permissions.push("DEVICE_MUTE"); permissions["android"].push("DEVICE_MUTE");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/send-notification")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/send-notification")) {
permissions.push("NOTIFICATION"); permissions["android"].push("NOTIFICATION");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/change-lock-code")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/change-lock-code")) {
permissions.push("CHANGE_LOCK_CODE"); permissions["android"].push("CHANGE_LOCK_CODE");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/enterprise-wipe")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/enterprise-wipe")) {
permissions.push("ENTERPRISE_WIPE"); permissions["android"].push("ENTERPRISE_WIPE");
} }
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/wipe")) { if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/android/wipe")) {
permissions.push("WIPE_DATA"); permissions["android"].push("WIPE_DATA");
} }
} else if (deviceType == "ios") {
} else if (deviceType == "windows") { // adding ios operations related permission checks
} // adding windows operations related permission checks
viewModel["permissions"] = stringify(permissions); viewModel["permissions"] = stringify(permissions);

@ -108,21 +108,21 @@ function loadOperationBar(deviceType) {
//var serviceURL = "/mdm-admin/features/" + platformType; //var serviceURL = "/mdm-admin/features/" + platformType;
var serviceURL = "/api/device-mgt/v1.0/devices/" + platformType + "/*/features"; var serviceURL = "/api/device-mgt/v1.0/devices/" + platformType + "/*/features";
var successCallback = function (data) { var successCallback = function (data) {
var permittedOpps = []; var permittedOperations = [];
var i; var i;
var permissionList = $("#operations-mod").data("permissions"); var permissionList = JSON.parse($("#operations-mod").data("permissions"));
var totalFeatures = JSON.parse(data); var totalFeatures = JSON.parse(data);
for (i = 0; i < permissionList.length; i++) { for (i = 0; i < permissionList[deviceType].length; i++) {
var j; var j;
for (j = 0; j < totalFeatures.length; j++) { for (j = 0; j < totalFeatures.length; j++) {
if (permissionList[i] == totalFeatures[j]["code"]) { if (permissionList[deviceType][i] == totalFeatures[j]["code"]) {
permittedOpps.push(totalFeatures[j]); permittedOperations.push(totalFeatures[j]);
} }
} }
} }
var viewModel = {}; var viewModel = {};
permittedOpps = permittedOpps.filter(function (current) { permittedOperations = permittedOperations.filter(function (current) {
var iconName; var iconName;
switch (deviceType) { switch (deviceType) {
case platformTypeConstants.ANDROID: case platformTypeConstants.ANDROID:
@ -143,7 +143,7 @@ function loadOperationBar(deviceType) {
} }
}); });
viewModel.features = permittedOpps; viewModel.features = permittedOperations;
var content = template(viewModel); var content = template(viewModel);
$(".wr-operations").html(content); $(".wr-operations").html(content);
}; };

Loading…
Cancel
Save