Merge pull request #483 from rasika/release-3.0.x

Adding UI permissions on Android Operations
revert-dabc3590
Ruwan 8 years ago committed by GitHub
commit 771372a890

@ -15,7 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#if control_operations}} {{#if controlOperations}}
<div class="wr-operations" style="height: 87px; display: block;" <div class="wr-operations" style="height: 87px; display: block;"
xmlns="http://www.w3.org/1999/html"> xmlns="http://www.w3.org/1999/html">
<style> <style>
@ -35,7 +35,7 @@
color: #B8B8B8; color: #B8B8B8;
} }
</style> </style>
{{#each control_operations}} {{#each controlOperations}}
<a href="javascript:operationSelect('{{operation}}')"> <a href="javascript:operationSelect('{{operation}}')">
{{#if iconFont}} {{#if iconFont}}
<i class="fw {{iconFont}}"></i> <i class="fw {{iconFont}}"></i>

@ -19,28 +19,37 @@
function onRequest(context) { function onRequest(context) {
var log = new Log("operation.js"); var log = new Log("operation.js");
var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var device = context.unit.params.device; var device = context.unit.params.device;
var autoCompleteParams = context.unit.params.autoCompleteParams; var autoCompleteParams = context.unit.params.autoCompleteParams;
var encodedFeaturePayloads=context.unit.params.encodedFeaturePayloads; var encodedFeaturePayloads = context.unit.params.encodedFeaturePayloads;
var controlOperations = operationModule.getControlOperations(device.type); var allControlOps = operationModule.getControlOperations(device.type);
var filteredControlOps = [];
var queryParams = []; var queryParams = [];
var formParams = []; var formParams = [];
var pathParams = []; var pathParams = [];
for (var i = 0; i < controlOperations.length; i++) { for (var i = 0; i < allControlOps.length; i++) {
var currentParamList = controlOperations[i]["params"]; var controlOperation = {};
var uiParamList = controlOperations[i]["uiParams"]; var uiPermission = allControlOps[i]["uiPermission"];
if (uiPermission && !userModule.isAuthorized("/permission/admin/" + uiPermission)) {
continue;
}
controlOperation = allControlOps[i];
var currentParamList = allControlOps[i]["params"];
for (var j = 0; j < currentParamList.length; j++) { for (var j = 0; j < currentParamList.length; j++) {
var currentParam = currentParamList[j]; var currentParam = currentParamList[j];
currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams); currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams);
currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams); currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams);
currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams); currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams);
} }
controlOperations[i]["uiParams"] = uiParamList; controlOperation["params"] = currentParamList;
if (encodedFeaturePayloads) { if (encodedFeaturePayloads) {
controlOperations[i]["payload"] = getPayload(encodedFeaturePayloads, controlOperations[i]["operation"]); allControlOps[i]["payload"] = getPayload(encodedFeaturePayloads, allControlOps[i]["operation"]);
} }
filteredControlOps.push(controlOperation);
} }
return {"control_operations": controlOperations, "device": device}; return {"controlOperations": filteredControlOps, "device": device};
} }
function processParams(paramsList, autoCompleteParams) { function processParams(paramsList, autoCompleteParams) {
@ -59,7 +68,7 @@ function processParams(paramsList, autoCompleteParams) {
return paramsList; return paramsList;
} }
function getPayload(featuresPayload, featureCode){ function getPayload(featuresPayload, featureCode) {
var featuresJSONPayloads = JSON.parse(featuresPayload); var featuresJSONPayloads = JSON.parse(featuresPayload);
return featuresJSONPayloads[featureCode]; return featuresJSONPayloads[featureCode];
} }

@ -6,7 +6,8 @@
"groupingEnabled": "false", "groupingEnabled": "false",
"features": { "features": {
"DEVICE_RING": { "DEVICE_RING": {
"icon": "fw-dial-up" "icon": "fw-dial-up",
"permission": "/device-mgt/devices/owning-device/operations/android/ring"
}, },
"DEVICE_LOCK": { "DEVICE_LOCK": {
"icon": "fw-lock", "icon": "fw-lock",
@ -22,16 +23,20 @@
"optional": true, "optional": true,
"label": "Hard lock enabled" "label": "Hard lock enabled"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/lock"
}, },
"DEVICE_LOCATION": { "DEVICE_LOCATION": {
"icon": "fw-map-location" "icon": "fw-map-location",
"permission": "/device-mgt/devices/owning-device/operations/android/location"
}, },
"CLEAR_PASSWORD": { "CLEAR_PASSWORD": {
"icon": "fw-clear" "icon": "fw-clear",
"permission": "/device-mgt/devices/owning-device/operations/android/clear-password"
}, },
"DEVICE_REBOOT": { "DEVICE_REBOOT": {
"icon": "fw-refresh" "icon": "fw-refresh",
"permission": "/device-mgt/devices/owning-device/operations/android/reboot"
}, },
"UPGRADE_FIRMWARE": { "UPGRADE_FIRMWARE": {
"icon": "fw-hardware", "icon": "fw-hardware",
@ -55,10 +60,12 @@
"optional": true, "optional": true,
"label": "Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)" "label": "Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/upgrade"
}, },
"DEVICE_MUTE": { "DEVICE_MUTE": {
"icon": "fw-mute" "icon": "fw-mute",
"permission": "/device-mgt/devices/owning-device/operations/android/mute"
}, },
"NOTIFICATION": { "NOTIFICATION": {
"icon": "fw-message", "icon": "fw-message",
@ -75,7 +82,8 @@
"optional": false, "optional": false,
"label": "Message Here..." "label": "Message Here..."
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/send-notification"
}, },
"CHANGE_LOCK_CODE": { "CHANGE_LOCK_CODE": {
"icon": "fw-security", "icon": "fw-security",
@ -86,10 +94,12 @@
"optional": false, "optional": false,
"label": "Lock Code" "label": "Lock Code"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/change-lock-code"
}, },
"ENTERPRISE_WIPE": { "ENTERPRISE_WIPE": {
"icon": "fw-block" "icon": "fw-block",
"permission": "/device-mgt/devices/owning-device/operations/android/enterprise-wipe"
}, },
"WIPE_DATA": { "WIPE_DATA": {
"icon": "fw-delete", "icon": "fw-delete",
@ -100,7 +110,8 @@
"optional": false, "optional": false,
"label": "Enter PIN code* of the device." "label": "Enter PIN code* of the device."
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/wipe"
} }
} }
} }

Loading…
Cancel
Save