From 2c200707203ba385e629a1a3bfa2bfaeaafab6d0 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 4 Apr 2017 14:36:50 +0530 Subject: [PATCH] fixing icon issue in operation bar --- .../modules/business-controllers/operation.js | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 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 dd200cdfbe..666b1b571d 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 @@ -40,52 +40,66 @@ var operationModule = function () { privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types/" + deviceType + "/features"; var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { - var features = JSON.parse(responsePayload.responseText); - var featureList = []; - var feature; - for (var i = 0; i < features.length; i++) { - feature = {}; - feature["operation"] = features[i].code; - feature["name"] = features[i].name; - feature["description"] = features[i].description; - feature["contentType"] = features[i].contentType; - feature["deviceType"] = deviceType; - feature["params"] = []; - var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"]; - if (featuresEntry) { - var featureEntry = featuresEntry[features[i].code]; - if (featureEntry) { - var permissionEntry = featureEntry["permission"]; - if (permissionEntry) { - feature["permission"] = permissionEntry - } - } - } - var metaData = features[i].metadataEntries; - if (metaData) { - for (var j = 0; j < metaData.length; j++) { - feature["params"].push(metaData[j].value); - } - featureList.push(feature); - } - } - return featureList; - }, function (responsePayload) { - var response = {}; - response["status"] = "error"; - return response; - } + var features = JSON.parse(responsePayload.responseText); + var featureList = []; + var feature; + for (var i = 0; i < features.length; i++) { + feature = {}; + feature["operation"] = features[i].code; + feature["name"] = features[i].name; + feature["description"] = features[i].description; + feature["contentType"] = features[i].contentType; + feature["deviceType"] = deviceType; + feature["params"] = []; + var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"]; + if (featuresEntry) { + var featureEntry = featuresEntry[features[i].code]; + if (featureEntry) { + var permissionEntry = featureEntry["permission"]; + if (permissionEntry) { + feature["permission"] = permissionEntry + } + } + } + var metaData = features[i].metadataEntries; + if (metaData) { + for (var j = 0; j < metaData.length; j++) { + feature["params"].push(metaData[j].value); + } + featureList.push(feature); + } + } + return featureList; + }, function (responsePayload) { + var response = {}; + response["status"] = "error"; + return response; + } ); return featuresList; }; publicMethods.getControlOperations = function (deviceType) { var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); + var features = utility.getDeviceTypeConfig(deviceType).deviceType.features; for (var op in operations) { var iconIdentifier = operations[op].operation; - var icon = utility.getOperationIcon(deviceType, iconIdentifier); - if (icon) { - operations[op]["icon"] = icon; + 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; + } + var formParams = features[iconIdentifier].formParams; + if (formParams) { + operations[op]["uiParams"] = formParams; + } + // var icon = utility.getOperationIcon(deviceType, iconIdentifier); + // if (icon) { + // log.error("icon found : " + icon ); + // operations[op]["icon"] = icon; } } return operations; @@ -99,9 +113,9 @@ var operationModule = function () { var user = session.get(constants.USER_SESSION_KEY); var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + - constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + - getAccessToken(deviceType, user.username, deviceId) + '"}'; + '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + + constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + + getAccessToken(deviceType, user.username, deviceId) + '"}'; return post(endPoint, params, JSON.parse(header), "json"); }; @@ -109,9 +123,9 @@ var operationModule = function () { var user = session.get(constants.USER_SESSION_KEY); var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + - constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + - '"}'; + '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + + constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + + '"}'; var result = get(endPoint, {}, JSON.parse(header), "json"); if (result.data) { var values = result.data.sensorValue.split(',');