Improve code

revert-dabc3590
Amanda 5 years ago
parent 9535aa5ced
commit 269b11ed41

@ -149,136 +149,16 @@
{{#if device.deviceInfoAvailable}} {{#if device.deviceInfoAvailable}}
<table class="table table-striped table-hover table-bordered display data-table" <table class="table table-striped table-hover table-bordered display data-table"
id="device-info-table"> id="device-info-table">
{{#each device.extensiveDeviceInfo}}
<tr> <tr>
<td> <td>
IMEI {{@key}}
</td> </td>
<td> <td>
{{#if device.imei}}<span>{{device.imei}}</span> <span>{{this}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
IMSI
</td>
<td>
{{#if device.imsi}}<span>{{device.imsi}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Serial Number
</td>
<td>
{{#if device.serial}}<span>{{device.serial}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
MAC Address
</td>
<td>
{{#if device.macAddress}}<span>{{device.macAddress}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
OS Version
</td>
<td>
{{#if device.OSVersion}}<span>{{device.OSVersion}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
OS Build Date
</td>
<td>
{{#if device.osBuildDate}}<span>{{device.osBuildDate}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Vendor
</td>
<td>
{{#if device.vendor}}<span>{{device.vendor}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Model
</td>
<td>
{{#if device.model}}<span>{{device.model}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
CPU Usage
</td>
<td>
{{#if device.cpuUsage}}<span>{{device.cpuUsage.value}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
SSID
</td>
<td>
{{#if device.ssid}}<span>{{device.ssid}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Connection Type
</td>
<td>
{{#if device.connectionType}}<span>{{device.connectionType}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Operator
</td>
<td>
{{#if device.operator}}<span>{{device.operator}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td>
</tr>
<tr>
<td>
Phone Number
</td>
<td>
{{#if device.phoneNumber}}<span>{{device.phoneNumber}}</span>
{{else}}<p>This information is not available yet.</p>
{{/if}}
</td> </td>
</tr> </tr>
{{/each}}
</table> </table>
{{else}}<p>Extensive information is not available yet.</p> {{else}}<p>Extensive information is not available yet.</p>
{{/if}} {{/if}}

@ -76,34 +76,33 @@ function onRequest(context) {
viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"]; viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"];
} }
} }
var extensiveDeviceInfo = {};
if (filteredDeviceData["initialDeviceInfo"]) { if (filteredDeviceData["initialDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = true; viewModel["deviceInfoAvailable"] = true;
if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) { if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) {
viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"]; viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"];
extensiveDeviceInfo["IMEI"] = filteredDeviceData["initialDeviceInfo"]["IMEI"];
} }
if (filteredDeviceData["initialDeviceInfo"]["IMSI"]) { if (filteredDeviceData["initialDeviceInfo"]["IMSI"]) {
viewModel["imsi"] = filteredDeviceData["initialDeviceInfo"]["IMSI"]; extensiveDeviceInfo["IMSI"] = filteredDeviceData["initialDeviceInfo"]["IMSI"];
} }
if (filteredDeviceData["initialDeviceInfo"]["OS_VERSION"]) { if (filteredDeviceData["initialDeviceInfo"]["OS_VERSION"]) {
viewModel["OSVersion"] = filteredDeviceData["initialDeviceInfo"]["OS_VERSION"]; extensiveDeviceInfo["OS Version"] = filteredDeviceData["initialDeviceInfo"]["OS_VERSION"];
}
if (filteredDeviceData["initialDeviceInfo"]["OS_VERSION"]) {
viewModel["OSVersion"] = filteredDeviceData["initialDeviceInfo"]["OS_VERSION"];
} }
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) {
viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]; extensiveDeviceInfo["Model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"];
} }
if (filteredDeviceData["initialDeviceInfo"]["VENDOR"]) { if (filteredDeviceData["initialDeviceInfo"]["VENDOR"]) {
viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"]; extensiveDeviceInfo["Vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"];
} }
if (filteredDeviceData["initialDeviceInfo"]["SERIAL"]) { if (filteredDeviceData["initialDeviceInfo"]["SERIAL"]) {
viewModel["serial"] = filteredDeviceData["initialDeviceInfo"]["SERIAL"]; extensiveDeviceInfo["Serial Number"] = filteredDeviceData["initialDeviceInfo"]["SERIAL"];
} }
if (filteredDeviceData["initialDeviceInfo"]["MAC_ADDRESS"]) { if (filteredDeviceData["initialDeviceInfo"]["MAC_ADDRESS"]) {
viewModel["macAddress"] = filteredDeviceData["initialDeviceInfo"]["MAC_ADDRESS"]; extensiveDeviceInfo["MAC Address"] = filteredDeviceData["initialDeviceInfo"]["MAC_ADDRESS"];
} }
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) { if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) {
viewModel["osBuildDate"] = filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]; extensiveDeviceInfo["OS Build Date"] = filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"];
} }
if (!filteredDeviceData["latestDeviceInfo"]) { if (!filteredDeviceData["latestDeviceInfo"]) {
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) { if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) {
@ -134,10 +133,10 @@ function onRequest(context) {
viewModel["internalMemory"]["usage"] = 0; viewModel["internalMemory"]["usage"] = 0;
} }
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["OPERATOR"]) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["OPERATOR"]) {
viewModel["operator"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["OPERATOR"]; extensiveDeviceInfo["Operator"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["OPERATOR"];
} }
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["PHONE_NUMBER"]) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["PHONE_NUMBER"]) {
viewModel["phoneNumber"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["PHONE_NUMBER"]; extensiveDeviceInfo["Phone Number"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["PHONE_NUMBER"];
} }
viewModel["externalMemory"] = {}; viewModel["externalMemory"] = {};
@ -173,13 +172,13 @@ function onRequest(context) {
viewModel["model"] = filteredDeviceData["latestDeviceInfo"]["deviceModel"]; viewModel["model"] = filteredDeviceData["latestDeviceInfo"]["deviceModel"];
} }
if (filteredDeviceData["latestDeviceInfo"]["osVersion"]) { if (filteredDeviceData["latestDeviceInfo"]["osVersion"]) {
viewModel["osVersion"] = filteredDeviceData["latestDeviceInfo"]["osVersion"]; extensiveDeviceInfo["OS Version"] = filteredDeviceData["latestDeviceInfo"]["osVersion"];
} }
if (filteredDeviceData["latestDeviceInfo"]["connectionType"]) { if (filteredDeviceData["latestDeviceInfo"]["connectionType"]) {
viewModel["connectionType"] = filteredDeviceData["latestDeviceInfo"]["connectionType"]; extensiveDeviceInfo["Connection Type"] = filteredDeviceData["latestDeviceInfo"]["connectionType"];
} }
if (filteredDeviceData["latestDeviceInfo"]["ssid"]) { if (filteredDeviceData["latestDeviceInfo"]["ssid"]) {
viewModel["ssid"] = filteredDeviceData["latestDeviceInfo"]["ssid"]; extensiveDeviceInfo["SSID"] = filteredDeviceData["latestDeviceInfo"]["ssid"];
} }
if (filteredDeviceData["latestDeviceInfo"]["updatedTime"]) { if (filteredDeviceData["latestDeviceInfo"]["updatedTime"]) {
viewModel["lastUpdatedTime"] = filteredDeviceData["latestDeviceInfo"]["updatedTime"]. viewModel["lastUpdatedTime"] = filteredDeviceData["latestDeviceInfo"]["updatedTime"].
@ -190,6 +189,7 @@ function onRequest(context) {
viewModel["cpuUsage"] = {}; viewModel["cpuUsage"] = {};
viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"]; viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"];
extensiveDeviceInfo["CPU Usage"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"];
viewModel["ramUsage"] = {}; viewModel["ramUsage"] = {};
if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
@ -222,6 +222,7 @@ function onRequest(context) {
viewModel["externalMemory"]["usage"] = 0; viewModel["externalMemory"]["usage"] = 0;
} }
} }
viewModel["extensiveDeviceInfo"] = extensiveDeviceInfo;
if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) { if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = false; viewModel["deviceInfoAvailable"] = false;
} }

Loading…
Cancel
Save