From 73222e347bd7e116bcebd8aca0e4410a9147cca3 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 11 May 2016 15:59:35 +0530 Subject: [PATCH] Fixed https://wso2.org/jira/browse/IOTS-104 --- .../jaggeryapps/devicemgt/app/modules/utility.js | 11 +++-------- .../devicemgt/app/pages/cdmf.page.devices/devices.js | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js index 185c2fa029..38cb7032ba 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js @@ -80,18 +80,13 @@ utility = function () { }; publicMethods.getDeviceTypeConfig = function (deviceType) { - var JFile = Packages.java.io.File; - var sep = JFile.separator; - - var systemProcess = require('process'); - var parent = 'file:///' + (systemProcess.getProperty('jaggery.home') || systemProcess.getProperty('carbon.home')).replace(/[\\]/g, '/').replace(/^[\/]/g, ''); - + var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view"); + if (deviceType in deviceTypeConfigMap) { return deviceTypeConfigMap[deviceType]; } var deviceTypeConfig; - var deviceTypeConfigFile = new File(parent + sep + "repository" + sep + "conf" + sep - + "device-types" + sep + deviceType + ".json"); + var deviceTypeConfigFile = new File("/app/units/" + unitName + "/private/config.json"); if (deviceTypeConfigFile.isExists()) { try { deviceTypeConfigFile.open("r"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js index e56c529cc9..085f1f5a69 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js @@ -54,12 +54,16 @@ function onRequest(context) { var deviceTypes = []; if (data) { for (var i = 0; i < data.length; i++) { - var deviceType = utility.getDeviceTypeConfig(data[i].name).deviceType; + var config = utility.getDeviceTypeConfig(data[i].name); + if (!config){ + continue; + } + var deviceType = config.deviceType; deviceTypes.push({ "type": data[i].name, "category": deviceType.category, - "label": deviceType.label, - "thumb": utility.getDeviceThumb(data[i].name) + "label": deviceType.label, + "thumb": utility.getDeviceThumb(data[i].name) }); } }