From 3e118d8800d0dbcaff7d47e75f80ba90d55dd5de Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 5 Jul 2017 23:20:41 +0530 Subject: [PATCH] Fixing https://github.com/wso2/product-iots/issues/1063: Adding filter out features --- .../app/modules/business-controllers/operation.js | 13 +++++++------ .../cdmf.unit.device.operation-bar/operation-bar.js | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) 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 3451c66cb3..1d18e05fe9 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 @@ -79,18 +79,19 @@ var operationModule = function () { return featuresList; }; - publicMethods.getControlOperations = function (deviceType) { + publicMethods.getControlOperations = function (device) { + var deviceType = device.type; var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); var features = utility.getDeviceTypeConfig(deviceType).deviceType.features; for (var op in operations) { var iconIdentifier = operations[op].operation; if (features && features[iconIdentifier]) { var icon = features[iconIdentifier].icon; - var isCloud = devicemgtProps["isCloud"]; - //TODO: remove isCloud check once able to verify features from the device agent - var isDisabled = features[iconIdentifier].isDisabled; - if (isDisabled && isCloud) { - operations[op]["isDisabled"] = isDisabled; + //TODO: need improve this check to get feature availability from agent side + var filter = features[iconIdentifier].filter; + if (device && filter && filter.property && device[filter.property] !== filter.value) { + operations[op]["isDisabled"] = true; + operations[op]["disabledText"] = filter.text; } else { operations[op]["isDisabled"] = false; } 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 f556252439..835316c07d 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 @@ -22,7 +22,7 @@ function onRequest(context) { 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 controlOperations = operationModule.getControlOperations(device); var queryParams = []; var formParams = []; var pathParams = [];