- {{#equal device.type "windows"}}
+ {{#equal deviceView.deviceType "windows"}}
Not available yet
{{/equal}}
- {{#if device.viewModel.deviceInfo}}
- {{#if device.viewModel.BatteryLevel}}
+ {{#if deviceView.deviceInfoAvailable}}
+ {{#if deviceView.BatteryLevel}}
@@ -172,14 +173,14 @@
- {{device.viewModel.BatteryLevel.value}} %
+ {{deviceView.BatteryLevel.value}} %
{{/if}}
-
+
@@ -187,14 +188,14 @@
-
+
- {{#if device.viewModel.ramUsage}}
+ {{#if deviceView.ramUsage}}
@@ -202,14 +203,14 @@
- {{device.viewModel.ramUsage.value}} %
+ {{deviceView.ramUsage.value}} %
{{/if}}
- {{#if device.viewModel.internalMemory}}
+ {{#if deviceView.internalMemory}}
@@ -217,9 +218,9 @@
- {{device.viewModel.internalMemory.usage}} %
+ {{deviceView.internalMemory.usage}} %
- TOTAL OF {{device.viewModel.internalMemory.total}} GB
+ TOTAL OF {{deviceView.internalMemory.total}} GB
@@ -227,7 +228,7 @@
{{/if}}
- {{#if device.viewModel.externalMemory}}
+ {{#if deviceView.externalMemory}}
@@ -235,9 +236,9 @@
- {{device.viewModel.externalMemory.usage}} %
+ {{deviceView.externalMemory.usage}} %
- TOTAL OF {{device.viewModel.externalMemory.total}} GB
+ TOTAL OF {{deviceView.externalMemory.total}} GB
@@ -284,16 +285,11 @@
-
-
Loading Policy Compliance...
+
+ Loading Policy Compliance...
-
-
-
- There is currently no effective policy applied for this device.
-
-
@@ -311,16 +307,22 @@
Device Location
-
-
-
- Device location cannot be retrieved.
-
-
-
-
+ {{#if deviceView.location}}
+
+
+ {{else}}
+
+
+
+ Device location information is not available.
+
+
+
+
+
+ {{/if}}
@@ -438,20 +440,20 @@
{{/zone}}
{{#zone "bottomJs"}}
{{#if isAuthorized}}
-
-
-
-
-
-
- {{js "js/device-detail.js"}}
-
- {{js "js/load-map.js"}}
+
+
+
+
+
+
+ {{js "js/device-detail.js"}}
+
+ {{js "js/load-map.js"}}
{{/if}}
{{/zone}}
\ No newline at end of file
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 3e737a894..5373100c9 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
@@ -18,136 +18,166 @@
function onRequest(context) {
// var log = new Log("view.js");
- var deviceType = context.uriParams.deviceType;
+ var deviceType = context["uriParams"]["deviceType"];
var deviceId = request.getParameter("id");
- var deviceData = {};
+ var deviceViewData = {};
if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId);
if (response["status"] == "success") {
- deviceData["deviceFound"] = true;
- deviceData["isAuthorized"] = true;
+ deviceViewData["deviceFound"] = true;
+ deviceViewData["isAuthorized"] = true;
- var device = response["content"];
- var viewModel = {};
- var deviceInfo = device["properties"]["DEVICE_INFO"];
- if (deviceInfo && String(deviceInfo.toString()).length > 0) {
- deviceInfo = parse(stringify(deviceInfo));
- if (device["type"] == "ios") {
- deviceInfo = parse(deviceInfo);
- viewModel["imei"] = device["properties"]["IMEI"];
- viewModel["phoneNumber"] = deviceInfo["PhoneNumber"];
- viewModel["udid"] = deviceInfo["UDID"];
- viewModel["BatteryLevel"] = Math.round(deviceInfo["BatteryLevel"] * 100);
- viewModel["DeviceCapacity"] = Math.round(deviceInfo["DeviceCapacity"] * 100) / 100;
- viewModel["AvailableDeviceCapacity"] = Math.
- round(deviceInfo["AvailableDeviceCapacity"] * 100) / 100;
- viewModel["DeviceCapacityUsed"] = Math.
- round((viewModel["DeviceCapacity"] - viewModel["AvailableDeviceCapacity"]) * 100) / 100;
- viewModel["DeviceCapacityPercentage"] = Math.
- round(viewModel["AvailableDeviceCapacity"] / viewModel["DeviceCapacity"] * 10000) / 100;
- viewModel["location"] = {
- latitude: device["properties"]["LATITUDE"],
- longitude: device["properties"]["LONGITUDE"]
- };
- viewModel["ownership"] = device["ownership"];
- } else if (device["type"] == "android") {
- viewModel["deviceIdentifier"] = device["deviceIdentifier"];
- viewModel["deviceName"] = device["name"];
- viewModel["owner"] = device["owner"];
- viewModel["ownership"] = device["ownership"];
- 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);
- }
+ var filteredDeviceData = response["content"];
- viewModel["location"] = {
- latitude: device["properties"]["LATITUDE"],
- longitude: device["properties"]["LONGITUDE"]
- };
- var info = {};
- var infoList = parse(deviceInfo);
- if (infoList != null && infoList != undefined) {
- for (var j = 0; j < infoList.length; j++) {
- info[infoList[j].name] = infoList[j].value;
+ // creating deviceView information model from filtered device data
+ var viewModel = {};
+ if (filteredDeviceData["type"]) {
+ viewModel["deviceType"] = filteredDeviceData["type"];
+ }
+ if (filteredDeviceData["deviceIdentifier"]) {
+ viewModel["deviceIdentifier"] = filteredDeviceData["deviceIdentifier"];
+ }
+ if (filteredDeviceData["name"]) {
+ viewModel["name"] = filteredDeviceData["name"];
+ }
+ if (filteredDeviceData["enrolmentInfo"]) {
+ if (filteredDeviceData["enrolmentInfo"]["status"]) {
+ viewModel["status"] = filteredDeviceData["enrolmentInfo"]["status"];
+ }
+ if (filteredDeviceData["enrolmentInfo"]["owner"]) {
+ viewModel["owner"] = filteredDeviceData["enrolmentInfo"]["owner"];
+ }
+ if (filteredDeviceData["enrolmentInfo"]["ownership"]) {
+ viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"];
+ }
+ }
+ if (filteredDeviceData["initialDeviceInfo"]) {
+ viewModel["deviceInfoAvailable"] = true;
+ if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) {
+ viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"];
+ }
+ if (!filteredDeviceData["latestDeviceInfo"]) {
+ if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) {
+ if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") {
+ viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000);
}
}
- deviceInfo = info;
-
- if (device["deviceInfo"]) {
- viewModel["location"] = {
- latitude: device["deviceInfo"]["location"]["latitude"],
- longitude: device["deviceInfo"]["location"]["longitude"]
- };
- viewModel["deviceInfo"] = true;
-
- viewModel["model"] = device["deviceInfo"]["deviceModel"];
- viewModel["vendor"] = device["deviceInfo"]["vendor"];
- viewModel["lastUpdatedTime"] = device["deviceInfo"]["updatedTime"].
- substr(0, device["deviceInfo"]["updatedTime"].indexOf("+"));
-
+ if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) {
+ viewModel["location"] = {};
+ viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"];
+ viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"];
+ }
+ if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) {
+ viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"];
+ viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"];
+ }
+ if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) {
viewModel["BatteryLevel"] = {};
- viewModel["BatteryLevel"]["value"] = device["deviceInfo"]["batteryLevel"];
-
- 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["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"];
viewModel["internalMemory"] = {};
- viewModel["externalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
- round(device["deviceInfo"]["internalTotalMemory"] * 100) / 100;
- if (device["deviceInfo"]["internalTotalMemory"] != 0) {
+ round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100;
+ if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
- round((device["deviceInfo"]["internalTotalMemory"] - device["deviceInfo"]["internalAvailableMemory"])
- / device["deviceInfo"]["internalTotalMemory"] * 10000) / 100;
+ round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] -
+ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"])
+ / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
+ viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math.
- round(device["deviceInfo"]["externalTotalMemory"] * 100) / 100;
- if (device["deviceInfo"]["externalTotalMemory"] != 0) {
+ round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100;
+ if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["externalMemory"]["usage"] = Math.
- round((device["deviceInfo"]["externalTotalMemory"] - device["deviceInfo"]["externalAvailableMemory"])
- / device["deviceInfo"]["externalTotalMemory"] * 10000) / 100;
+ round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] -
+ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"])
+ / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["externalMemory"]["usage"] = 0;
}
- } else {
- viewModel["deviceInfo"] = false;
}
- } else if (device["type"] == "windows") {
- viewModel["imei"] = device["properties"]["IMEI"];
- viewModel["model"] = device["properties"]["DEVICE_MODEL"];
- viewModel["vendor"] = device["properties"]["VENDOR"];
- viewModel["internalMemory"] = {};
- viewModel["externalMemory"] = {};
- viewModel["location"] = {
- latitude: device["properties"]["LATITUDE"],
- longitude: device["properties"]["LONGITUDE"]
- };
- viewModel["ownership"] = device["ownership"];
}
- device["viewModel"] = viewModel;
}
- deviceData["device"] = device;
+ if (filteredDeviceData["latestDeviceInfo"]) {
+ viewModel["deviceInfoAvailable"] = true;
+ if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) {
+ if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"] != "0") {
+ viewModel["osBuildDate"] = new Date(filteredDeviceData["latestDeviceInfo"]["osBuildDate"] * 1000);
+ }
+ }
+ if (filteredDeviceData["latestDeviceInfo"]["location"]["latitude"] &&
+ filteredDeviceData["latestDeviceInfo"]["location"]["longitude"]) {
+ viewModel["location"] = {};
+ viewModel["location"]["latitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["latitude"];
+ viewModel["location"]["longitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["longitude"];
+ }
+ if (filteredDeviceData["latestDeviceInfo"]["vendor"] && filteredDeviceData["latestDeviceInfo"]["deviceModel"]) {
+ viewModel["vendor"] = filteredDeviceData["latestDeviceInfo"]["vendor"];
+ viewModel["model"] = filteredDeviceData["latestDeviceInfo"]["deviceModel"];
+ }
+ if (filteredDeviceData["latestDeviceInfo"]["updatedTime"]) {
+ viewModel["lastUpdatedTime"] = filteredDeviceData["latestDeviceInfo"]["updatedTime"].
+ substr(0, filteredDeviceData["latestDeviceInfo"]["updatedTime"].indexOf("+"));
+ }
+ viewModel["BatteryLevel"] = {};
+ viewModel["BatteryLevel"]["value"] = filteredDeviceData["latestDeviceInfo"]["batteryLevel"];
+
+ viewModel["cpuUsage"] = {};
+ viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"];
+
+ viewModel["ramUsage"] = {};
+ if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
+ viewModel["ramUsage"]["value"] = Math.
+ round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] -
+ filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"])
+ / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100;
+ } else {
+ viewModel["ramUsage"]["value"] = 0;
+ }
+
+ viewModel["internalMemory"] = {};
+ viewModel["internalMemory"]["total"] = Math.
+ round(filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 100) / 100;
+ if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) {
+ viewModel["internalMemory"]["usage"] = Math.
+ round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] -
+ filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"])
+ / filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100;
+ } else {
+ viewModel["internalMemory"]["usage"] = 0;
+ }
+
+ viewModel["externalMemory"] = {};
+ viewModel["externalMemory"]["total"] = Math.
+ round(filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 100) / 100;
+ if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) {
+ viewModel["externalMemory"]["usage"] = Math.
+ round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] -
+ filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"])
+ / filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100;
+ } else {
+ viewModel["externalMemory"]["usage"] = 0;
+ }
+ }
+ if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
+ viewModel["deviceInfoAvailable"] = false;
+ }
+
+ deviceViewData["deviceView"] = viewModel;
} else if (response["status"] == "unauthorized") {
- deviceData["deviceFound"] = true;
- deviceData["isAuthorized"] = false;
+ deviceViewData["deviceFound"] = true;
+ deviceViewData["isAuthorized"] = false;
} else if (response["status"] == "notFound") {
- deviceData["deviceFound"] = false;
+ deviceViewData["deviceFound"] = false;
}
- return deviceData;
+ } else {
+ deviceViewData["deviceFound"] = false;
}
+
+ return deviceViewData;
}
\ No newline at end of file