From 4947664b4b0c3a0e8de6a3464fa0f14937c0435d Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 23 Sep 2016 11:15:45 +0530 Subject: [PATCH] Fix for jira: https://wso2.org/jira/browse/EMM-1617 --- .../app/units/mdm.unit.device.view/view.js | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js index 494a9379d..d4a932630 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js @@ -52,16 +52,11 @@ function onRequest(context) { longitude: device["properties"]["LONGITUDE"] }; } else if (device["type"] == "android") { - viewModel["deviceName"] = device["name"]; viewModel["deviceIdentifier"] = device["deviceIdentifier"]; - viewModel["imei"] = device["properties"]["IMEI"]; - viewModel["model"] = device["deviceInfo"]["deviceModel"]; - viewModel["vendor"] = device["deviceInfo"]["vendor"]; + viewModel["deviceName"] = device["name"]; viewModel["owner"] = device["owner"]; viewModel["ownership"] = device["ownership"]; - viewModel["lastUpdatedTime"] = device["deviceInfo"]["updatedTime"]. - substr(0, device["deviceInfo"]["updatedTime"].indexOf("+")); - + viewModel["imei"] = device["properties"]["IMEI"]; var osBuildDate = device["properties"]["OS_BUILD_DATE"]; if (osBuildDate != null && osBuildDate != "0") { viewModel["os_build_date"] = new Date(osBuildDate * 1000); @@ -79,41 +74,49 @@ function onRequest(context) { } } deviceInfo = info; - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = device["deviceInfo"]["batteryLevel"]; - viewModel["cpuUsage"] = {}; - viewModel["cpuUsage"]["value"] = device["deviceInfo"]["cpuUsage"]; + if (device["deviceInfo"]) { + viewModel["model"] = device["deviceInfo"]["deviceModel"]; + viewModel["vendor"] = device["deviceInfo"]["vendor"]; + viewModel["lastUpdatedTime"] = device["deviceInfo"]["updatedTime"]. + substr(0, device["deviceInfo"]["updatedTime"].indexOf("+")); - viewModel["ramUsage"] = {}; - if (device["deviceInfo"]["totalRAMMemory"] != 0) { - viewModel["ramUsage"]["value"] = Math. - round((device["deviceInfo"]["totalRAMMemory"] - device["deviceInfo"]["availableRAMMemory"]) - / device["deviceInfo"]["totalRAMMemory"] * 10000) / 100; - } else { - viewModel["ramUsage"]["value"] = 0; - } + viewModel["BatteryLevel"] = {}; + viewModel["BatteryLevel"]["value"] = device["deviceInfo"]["batteryLevel"]; - viewModel["internalMemory"] = {}; - viewModel["externalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(device["deviceInfo"]["internalTotalMemory"] * 100) / 100; - if (device["deviceInfo"]["internalTotalMemory"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((device["deviceInfo"]["internalTotalMemory"] - device["deviceInfo"]["internalAvailableMemory"]) - / device["deviceInfo"]["internalTotalMemory"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } + viewModel["cpuUsage"] = {}; + viewModel["cpuUsage"]["value"] = device["deviceInfo"]["cpuUsage"]; + + viewModel["ramUsage"] = {}; + if (device["deviceInfo"]["totalRAMMemory"] != 0) { + viewModel["ramUsage"]["value"] = Math. + round((device["deviceInfo"]["totalRAMMemory"] - device["deviceInfo"]["availableRAMMemory"]) + / device["deviceInfo"]["totalRAMMemory"] * 10000) / 100; + } else { + viewModel["ramUsage"]["value"] = 0; + } - viewModel["externalMemory"]["total"] = Math. - round(device["deviceInfo"]["externalTotalMemory"] * 100) / 100; - if (device["deviceInfo"]["externalTotalMemory"] != 0) { - viewModel["externalMemory"]["usage"] = Math. - round((device["deviceInfo"]["externalTotalMemory"] - device["deviceInfo"]["externalAvailableMemory"]) - / device["deviceInfo"]["externalTotalMemory"] * 10000) / 100; - } else { - viewModel["externalMemory"]["usage"] = 0; + viewModel["internalMemory"] = {}; + viewModel["externalMemory"] = {}; + viewModel["internalMemory"]["total"] = Math. + round(device["deviceInfo"]["internalTotalMemory"] * 100) / 100; + if (device["deviceInfo"]["internalTotalMemory"] != 0) { + viewModel["internalMemory"]["usage"] = Math. + round((device["deviceInfo"]["internalTotalMemory"] - device["deviceInfo"]["internalAvailableMemory"]) + / device["deviceInfo"]["internalTotalMemory"] * 10000) / 100; + } else { + viewModel["internalMemory"]["usage"] = 0; + } + + viewModel["externalMemory"]["total"] = Math. + round(device["deviceInfo"]["externalTotalMemory"] * 100) / 100; + if (device["deviceInfo"]["externalTotalMemory"] != 0) { + viewModel["externalMemory"]["usage"] = Math. + round((device["deviceInfo"]["externalTotalMemory"] - device["deviceInfo"]["externalAvailableMemory"]) + / device["deviceInfo"]["externalTotalMemory"] * 10000) / 100; + } else { + viewModel["externalMemory"]["usage"] = 0; + } } } else if (device["type"] == "windows") { viewModel["imei"] = device["properties"]["IMEI"];