From eb909415dd416ae0cf3fa1789a38e22a14cdf519 Mon Sep 17 00:00:00 2001 From: dunithd Date: Thu, 6 Jul 2017 14:44:16 +0530 Subject: [PATCH] Fixing device vitals getting NaN value and rounding memory usage value --- .../device-view.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js index 5c6dcf6ab..1ab8d6b06 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js @@ -92,8 +92,10 @@ function onRequest(context) { viewModel["internalMemory"]["total"] = Math. round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100; if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["internalMemory"]["usage"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]; + viewModel["internalMemory"]["usage"] = Math.round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - + filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) * 100) / 100; + if(isNaN(viewModel["internalMemory"]["usage"])) + viewModel["internalMemory"]["usage"] = "N/A"; } else { viewModel["internalMemory"]["usage"] = 0; } @@ -162,6 +164,8 @@ function onRequest(context) { round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] - filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"]) / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100; + if(isNaN(viewModel["ramUsage"]["value"])) + viewModel["ramUsage"]["value"] = "N/A"; } else { viewModel["ramUsage"]["value"] = 0; } @@ -170,8 +174,10 @@ function onRequest(context) { viewModel["internalMemory"]["total"] = Math. round(filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 100) / 100; if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) { - viewModel["internalMemory"]["usage"] = filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] - - filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]; + viewModel["internalMemory"]["usage"] = Math.round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] - + filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]) * 100) / 100; + if(isNaN(viewModel["internalMemory"]["usage"])) + viewModel["internalMemory"]["usage"] = "N/A"; } else { viewModel["internalMemory"]["usage"] = 0; }