diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java index fb100be94b9..7e53718442b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java @@ -42,10 +42,6 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { private static final String QUERY_PARAMS = "queryParams"; private static final String FORM_PARAMS = "formParams"; private static final Pattern PATH_PARAM_REGEX = Pattern.compile("\\{(.*?)\\}"); - private List pathParams = new ArrayList<>(); - private List queryParams = new ArrayList<>(); - private List formParams = new ArrayList<>(); - public ConfigurationBasedFeatureManager( List features) { @@ -59,7 +55,10 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { Map apiParams = new HashMap<>(); apiParams.put(METHOD, operation.getMethod().toUpperCase()); apiParams.put(URI, operation.getContext()); - setPathParams(operation.getContext()); + List pathParams = new ArrayList<>(); + List queryParams = new ArrayList<>(); + List formParams = new ArrayList<>(); + setPathParams(operation.getContext(), pathParams); apiParams.put(PATH_PARAMS, pathParams); if (operation.getQueryParameters() != null) { queryParams = operation.getQueryParameters().getParameter(); @@ -116,7 +115,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { return false; } - private void setPathParams(String context) { + private void setPathParams(String context, List pathParams) { Matcher regexMatcher = PATH_PARAM_REGEX.matcher(context); while (regexMatcher.find()) { pathParams.add(regexMatcher.group(1)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index c34cc04302c..f072a27d5bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -45,16 +45,6 @@ var operationModule = function () { var feature; for (var i = 0; i < features.length; i++) { feature = {}; - var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"]; - if (analyticStreams) { - for (var stream in analyticStreams) { - if (analyticStreams[stream].name == features[i].name) { - feature.ui_unit = analyticStreams[stream].ui_unit; - break; - } - } - } - feature["operation"] = features[i].code; feature["name"] = features[i].name; feature["description"] = features[i].description; @@ -80,10 +70,17 @@ var operationModule = function () { publicMethods.getControlOperations = function (deviceType) { var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); + var features = utility.getDeviceTypeConfig(deviceType).deviceType.features; for (var op in operations) { - var iconPath = utility.getOperationIcon(deviceType, operations[op].operation); - if (iconPath) { - operations[op]["icon"] = iconPath; + var iconIdentifier = operations[op].operation; + if (features && features[iconIdentifier]) { + var icon = features[iconIdentifier].icon; + if (icon) { + operations[op]["iconFont"] = icon; + } else if (iconPath) { + var iconPath = utility.getOperationIcon(deviceType, iconIdentifier); + operations[op]["icon"] = iconPath; + } } } return operations; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs index ca52690eb03..fe87cb7896a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs @@ -36,10 +36,14 @@ {{#each control_operations}} - {{#if icon}} - + {{#if iconFont}} + {{else}} - + {{#if icon}} + + {{else}} + + {{/if}} {{/if}} {{name}} @@ -61,7 +65,8 @@
-
+ {{#each params.0.pathParams}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.js index d1a58b9bd32..f5562524396 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.js @@ -21,6 +21,7 @@ function onRequest(context) { var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; var device = context.unit.params.device; var autoCompleteParams = context.unit.params.autoCompleteParams; + var encodedFeaturePayloads=context.unit.params.encodedFeaturePayloads; var controlOperations = operationModule.getControlOperations(device.type); var queryParams = []; var formParams = []; @@ -34,6 +35,9 @@ function onRequest(context) { currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams); } controlOperations[i]["params"] = currentParamList; + if (encodedFeaturePayloads) { + controlOperations[i]["payload"] = getPayload(encodedFeaturePayloads, controlOperations[i]["operation"]); + } } return {"control_operations": controlOperations, "device": device}; } @@ -52,4 +56,9 @@ function processParams(paramsList, autoCompleteParams) { paramsList[i] = {"name": paramName, "value": paramValue, "type": paramType}; } return paramsList; +} + +function getPayload(featuresPayload, featureCode){ + var featuresJSONPayloads = JSON.parse(featuresPayload); + return featuresJSONPayloads[featureCode]; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/public/js/operation-bar.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/public/js/operation-bar.js index 68bb7f5f186..386e837d762 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/public/js/operation-bar.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/public/js/operation-bar.js @@ -50,7 +50,12 @@ function submitForm(formId) { var httpMethod = form.attr("method").toUpperCase(); var contentType = form.attr("enctype"); console.log(payload); - if (contentType == undefined || contentType.isEmpty()) { + var featurePayload = form.attr("data-payload"); + if (featurePayload) { + contentType = "application/json"; + payload = JSON.parse(atob(featurePayload)); + + } else if (contentType == undefined || contentType.isEmpty()) { contentType = "application/x-www-form-urlencoded"; payload = uriencodedFormStr; }