|
|
@ -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) {
|
|
|
|