merge-requests/1/head
hasuniea 8 years ago
commit 54ca0cacc5

@ -257,7 +257,11 @@ var InitiateViewOption = null;
"Loading policy compliance related data " + "Loading policy compliance related data " +
"was not successful. please try refreshing in a while." + "was not successful. please try refreshing in a while." +
"</h4>" + "</h4>" +
"</div>"); "</div>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>"
);
} }
); );
} }
@ -269,7 +273,11 @@ var InitiateViewOption = null;
"<i class='icon fw fw-info'></i>" + "<i class='icon fw fw-info'></i>" +
"There is currently no effective policy applied for this device." + "There is currently no effective policy applied for this device." +
"</h4>" + "</h4>" +
"</div>"); "</div>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>"
);
} }
}, },
// error-callback // error-callback
@ -282,7 +290,11 @@ var InitiateViewOption = null;
"Loading policy compliance related data " + "Loading policy compliance related data " +
"was not successful. please try refreshing in a while." + "was not successful. please try refreshing in a while." +
"</h4>" + "</h4>" +
"</div>"); "</div>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>" +
"<p class='add-padding-5x'></p>"
);
} }
); );
} }

@ -5,11 +5,12 @@
{{#zone "content"}} {{#zone "content"}}
{{#if deviceFound}} {{#if deviceFound}}
{{#if isAuthorized}} {{#if isAuthorized}}
<h1 class="page-sub-title device-id device-select" data-deviceid="{{device.deviceIdentifier}}" data-type="{{device.type}}" data-ownership="{{device.viewModel.ownership}}"> <h1 class="page-sub-title device-id device-select"
Device {{device.name}} data-deviceid="{{deviceView.deviceIdentifier}}" data-type="{{deviceView.deviceType}}" data-ownership="{{deviceView.ownership}}">
{{#if device.viewModel.model}} Device {{deviceView.name}}
{{#if deviceView.model}}
<span class="lbl-device"> <span class="lbl-device">
( {{device.viewModel.vendor}} {{device.viewModel.model}} ) ( {{deviceView.vendor}} {{deviceView.model}} )
</span> </span>
{{/if}} {{/if}}
</h1> </h1>
@ -23,77 +24,77 @@
{{#defineZone "device-detail-properties"}} {{#defineZone "device-detail-properties"}}
<table class="table table-responsive table-striped" id="members"> <table class="table table-responsive table-striped" id="members">
<tbody> <tbody>
{{#if device.viewModel.deviceIdentifier}} {{#if deviceView.deviceIdentifier}}
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Device ID</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Device ID</td>
<td style="padding:10px 15px;">{{device.viewModel.deviceIdentifier}}</td> <td style="padding:10px 15px;">{{deviceView.deviceIdentifier}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.deviceName}} {{#if deviceView.name}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Name</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Name</td>
<td style="padding:10px 15px;">{{device.viewModel.deviceName}}</td> <td style="padding:10px 15px;">{{deviceView.name}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.vendor}} {{#if deviceView.vendor}}
{{#if device.viewModel.model}} {{#if deviceView.model}}
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Model</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Model</td>
<td style="padding:10px 15px;">{{device.viewModel.vendor}} {{device.viewModel.model}}</td> <td style="padding:10px 15px;">{{deviceView.vendor}} {{deviceView.model}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if device.status}} {{#if deviceView.status}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;"> <td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i>&nbsp;&nbsp;Active</span>{{/equal}} {{#equal deviceView.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i>&nbsp;&nbsp;Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i>&nbsp;&nbsp;Inactive</span>{{/equal}} {{#equal deviceView.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i>&nbsp;&nbsp;Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i>&nbsp;&nbsp;Blocked</span>{{/equal}} {{#equal deviceView.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i>&nbsp;&nbsp;Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i>&nbsp;&nbsp;Removed</span>{{/equal}} {{#equal deviceView.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i>&nbsp;&nbsp;Removed</span>{{/equal}}
</td> </td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.owner}} {{#if deviceView.owner}}
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
<td style="padding:10px 15px;">{{device.viewModel.owner}}</td> <td style="padding:10px 15px;">{{deviceView.owner}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.ownership}} {{#if deviceView.ownership}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Ownership</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Ownership</td>
<td style="padding:10px 15px;">{{device.viewModel.ownership}}</td> <td style="padding:10px 15px;">{{deviceView.ownership}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.imei}} {{#if deviceView.imei}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">IMEI</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">IMEI</td>
<td style="padding:10px 15px;">{{device.viewModel.imei}}</td> <td style="padding:10px 15px;">{{deviceView.imei}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.udid}} {{#if deviceView.udid}}
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">UDID</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">UDID</td>
<td style="padding:10px 15px;">{{device.viewModel.udid}}</td> <td style="padding:10px 15px;">{{deviceView.udid}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.os_build_date}} {{#if deviceView.osBuildDate}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Firmware Build Date</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Firmware Build Date</td>
<td style="padding:10px 15px;">{{device.viewModel.os_build_date}}</td> <td style="padding:10px 15px;">{{deviceView.osBuildDate}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.phoneNumber}} {{#if deviceView.phoneNumber}}
<tr role="row" class="odd"> <tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Phone Number</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Phone Number</td>
<td style="padding:10px 15px;">{{device.viewModel.phoneNumber}}</td> <td style="padding:10px 15px;">{{deviceView.phoneNumber}}</td>
</tr> </tr>
{{/if}} {{/if}}
{{#if device.viewModel.lastUpdatedTime}} {{#if deviceView.lastUpdatedTime}}
<tr role="row" class="even"> <tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Last Update</td> <td class="sorting_1" style="padding:10px 15px; width: 15%;">Last Update</td>
<td style="padding:10px 15px;">{{device.viewModel.lastUpdatedTime}}</td> <td style="padding:10px 15px;">{{deviceView.lastUpdatedTime}}</td>
</tr> </tr>
{{/if}} {{/if}}
</tbody> </tbody>
@ -101,7 +102,7 @@
{{/defineZone}} {{/defineZone}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Operations</div> <div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Operations</div>
<div class="add-margin-top-4x"> <div class="add-margin-top-4x">
{{unit "mdm.unit.device.operation-bar" deviceType=device.type ownership=device.viewModel.ownership}} {{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}}
</div> </div>
</div> </div>
</div> </div>
@ -120,8 +121,8 @@
</li> </li>
<li role="presentation" class="list-group-item"> <li role="presentation" class="list-group-item">
<a href="#device_location_tab" role="tab" data-toggle="tab" <a href="#device_location_tab" role="tab" data-toggle="tab"
data-lat="{{device.viewModel.location.latitude}}" data-lat="{{deviceView.location.latitude}}"
data-long="{{device.viewModel.location.longitude}}" data-long="{{deviceView.location.longitude}}"
aria-controls="device_location_tab"> aria-controls="device_location_tab">
<i class="icon fw fw-map-location"></i><span class="hidden-sm">Device Location</span> <i class="icon fw fw-map-location"></i><span class="hidden-sm">Device Location</span>
</a> </a>
@ -158,13 +159,13 @@
<div class="panel-body "> <div class="panel-body ">
<div class="device-detail-body"> <div class="device-detail-body">
<!-- device summary --> <!-- device summary -->
{{#equal device.type "windows"}} {{#equal deviceView.deviceType "windows"}}
<div class="message message-info"> <div class="message message-info">
<h4 class="remove-margin"><i class="icon fw fw-info"></i>Not available yet</h4> <h4 class="remove-margin"><i class="icon fw fw-info"></i>Not available yet</h4>
</div> </div>
{{/equal}} {{/equal}}
{{#if device.viewModel.deviceInfo}} {{#if deviceView.deviceInfoAvailable}}
{{#if device.viewModel.BatteryLevel}} {{#if deviceView.BatteryLevel}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12"> <div class="col-md-12">
<div class="wr-stats-board-tile"> <div class="wr-stats-board-tile">
@ -172,14 +173,14 @@
<div> <div>
<div class="tile-icon"><i class="fw fw-battery"></i></div> <div class="tile-icon"><i class="fw fw-battery"></i></div>
<div class="tile-stats"> <div class="tile-stats">
{{device.viewModel.BatteryLevel.value}} % {{deviceView.BatteryLevel.value}} %
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{/if}} {{/if}}
<!--{{#if device.viewModel.cpuUsage}}--> <!--{{#if deviceView.cpuUsage}}-->
<!--<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">--> <!--<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">-->
<!--<div class="col-md-12">--> <!--<div class="col-md-12">-->
<!--<div class="wr-stats-board-tile">--> <!--<div class="wr-stats-board-tile">-->
@ -187,14 +188,14 @@
<!--<div>--> <!--<div>-->
<!--<div class="tile-icon"><i class="fw fw-dashboard"></i></div>--> <!--<div class="tile-icon"><i class="fw fw-dashboard"></i></div>-->
<!--<div class="tile-stats">--> <!--<div class="tile-stats">-->
<!--{{device.viewModel.cpuUsage.value}} %--> <!--{{deviceView.cpuUsage.value}} %-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<!--</div>--> <!--</div>-->
<!--{{/if}}--> <!--{{/if}}-->
{{#if device.viewModel.ramUsage}} {{#if deviceView.ramUsage}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12"> <div class="col-md-12">
<div class="wr-stats-board-tile"> <div class="wr-stats-board-tile">
@ -202,14 +203,14 @@
<div> <div>
<div class="tile-icon"><i class="fw fw-hardware"></i></div> <div class="tile-icon"><i class="fw fw-hardware"></i></div>
<div class="tile-stats"> <div class="tile-stats">
{{device.viewModel.ramUsage.value}} % {{deviceView.ramUsage.value}} %
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{#if device.viewModel.internalMemory}} {{#if deviceView.internalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12"> <div class="col-md-12">
<div class="wr-stats-board-tile"> <div class="wr-stats-board-tile">
@ -217,9 +218,9 @@
<div> <div>
<div class="tile-icon"><i class="fw fw-hdd"></i></div> <div class="tile-icon"><i class="fw fw-hdd"></i></div>
<div class="tile-stats"> <div class="tile-stats">
{{device.viewModel.internalMemory.usage}} % {{deviceView.internalMemory.usage}} %
<span class="tile-stats-free"> <span class="tile-stats-free">
TOTAL OF {{device.viewModel.internalMemory.total}} GB TOTAL OF {{deviceView.internalMemory.total}} GB
</span> </span>
</div> </div>
</div> </div>
@ -227,7 +228,7 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{#if device.viewModel.externalMemory}} {{#if deviceView.externalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12"> <div class="col-md-12">
<div class="wr-stats-board-tile"> <div class="wr-stats-board-tile">
@ -235,9 +236,9 @@
<div> <div>
<div class="tile-icon"><i class="fw fw-usb-drive"></i></div> <div class="tile-icon"><i class="fw fw-usb-drive"></i></div>
<div class="tile-stats"> <div class="tile-stats">
{{device.viewModel.externalMemory.usage}} % {{deviceView.externalMemory.usage}} %
<span class="tile-stats-free"> <span class="tile-stats-free">
TOTAL OF {{device.viewModel.externalMemory.total}} GB TOTAL OF {{deviceView.externalMemory.total}} GB
</span> </span>
</div> </div>
</div> </div>
@ -284,16 +285,11 @@
<i class="fw fw-refresh"></i> <i class="fw fw-refresh"></i>
</a> </a>
</span> </span>
<div id="policy-spinner" class="wr-advance-operations-init hidden"> <div id="policy-spinner"
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Policy Compliance... class="wr-advance-operations-init add-padding-bottom-2x add-padding-bottom-4x hidden">
<i class="fw fw-settings fw-spin fw-2x"></i>&nbsp;&nbsp;Loading Policy Compliance...
</div> </div>
<div id="policy-list-container"> <div id="policy-list-container">
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
There is currently no effective policy applied for this device.
</h4>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -311,16 +307,22 @@
<div class="panel-heading display-none-xs">Device Location</div> <div class="panel-heading display-none-xs">Device Location</div>
<div id="collapseThree" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="device_location"> <div id="collapseThree" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="device_location">
<div class="panel-body"> <div class="panel-body">
<div id="map-error" class="message message-danger"> {{#if deviceView.location}}
<div id="device-location"
data-lat="{{deviceView.location.latitude}}"
data-long="{{deviceView.location.longitude}}">
</div>
{{else}}
<div id="map-error" class="message message-warning">
<h4 class="remove-margin"> <h4 class="remove-margin">
<i class="icon fw fw-error"></i> <i class="icon fw fw-warning"></i>
&nbsp;Device location cannot be retrieved. &nbsp;Device location information is not available.
</h4> </h4>
</div> </div>
<div id="device-location" <p class="add-padding-5x"></p>
data-lat="{{device.viewModel.location.latitude}}" <p class="add-padding-5x"></p>
data-long="{{device.viewModel.location.longitude}}"> <p class="add-padding-5x"></p>
</div> {{/if}}
</div> </div>
</div> </div>
</div> </div>
@ -440,15 +442,15 @@
{{#if isAuthorized}} {{#if isAuthorized}}
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs" <script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs" <script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/device-detail.js"}} {{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>

@ -18,136 +18,166 @@
function onRequest(context) { function onRequest(context) {
// var log = new Log("view.js"); // var log = new Log("view.js");
var deviceType = context.uriParams.deviceType; var deviceType = context["uriParams"]["deviceType"];
var deviceId = request.getParameter("id"); var deviceId = request.getParameter("id");
var deviceData = {}; var deviceViewData = {};
if (deviceType && deviceId) { if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId); var response = deviceModule.viewDevice(deviceType, deviceId);
if (response["status"] == "success") { if (response["status"] == "success") {
deviceData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceData["isAuthorized"] = true; deviceViewData["isAuthorized"] = true;
var device = response["content"]; var filteredDeviceData = response["content"];
// creating deviceView information model from filtered device data
var viewModel = {}; var viewModel = {};
var deviceInfo = device["properties"]["DEVICE_INFO"]; if (filteredDeviceData["type"]) {
if (deviceInfo && String(deviceInfo.toString()).length > 0) { viewModel["deviceType"] = filteredDeviceData["type"];
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);
} }
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);
}
}
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"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"];
viewModel["location"] = { viewModel["internalMemory"] = {};
latitude: device["properties"]["LATITUDE"], viewModel["internalMemory"]["total"] = Math.
longitude: device["properties"]["LONGITUDE"] round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100;
}; if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) {
var info = {}; viewModel["internalMemory"]["usage"] = Math.
var infoList = parse(deviceInfo); round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] -
if (infoList != null && infoList != undefined) { filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"])
for (var j = 0; j < infoList.length; j++) { / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
info[infoList[j].name] = infoList[j].value; } else {
} viewModel["internalMemory"]["usage"] = 0;
} }
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("+"));
viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["externalMemory"]["usage"] = Math.
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;
}
}
}
}
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"] = {};
viewModel["BatteryLevel"]["value"] = device["deviceInfo"]["batteryLevel"]; viewModel["BatteryLevel"]["value"] = filteredDeviceData["latestDeviceInfo"]["batteryLevel"];
viewModel["cpuUsage"] = {}; viewModel["cpuUsage"] = {};
viewModel["cpuUsage"]["value"] = device["deviceInfo"]["cpuUsage"]; viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"];
viewModel["ramUsage"] = {}; viewModel["ramUsage"] = {};
if (device["deviceInfo"]["totalRAMMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
viewModel["ramUsage"]["value"] = Math. viewModel["ramUsage"]["value"] = Math.
round((device["deviceInfo"]["totalRAMMemory"] - device["deviceInfo"]["availableRAMMemory"]) round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] -
/ device["deviceInfo"]["totalRAMMemory"] * 10000) / 100; filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"])
/ filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100;
} else { } else {
viewModel["ramUsage"]["value"] = 0; viewModel["ramUsage"]["value"] = 0;
} }
viewModel["internalMemory"] = {}; viewModel["internalMemory"] = {};
viewModel["externalMemory"] = {};
viewModel["internalMemory"]["total"] = Math. viewModel["internalMemory"]["total"] = Math.
round(device["deviceInfo"]["internalTotalMemory"] * 100) / 100; round(filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 100) / 100;
if (device["deviceInfo"]["internalTotalMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) {
viewModel["internalMemory"]["usage"] = Math. viewModel["internalMemory"]["usage"] = Math.
round((device["deviceInfo"]["internalTotalMemory"] - device["deviceInfo"]["internalAvailableMemory"]) round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] -
/ device["deviceInfo"]["internalTotalMemory"] * 10000) / 100; filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100;
} else { } else {
viewModel["internalMemory"]["usage"] = 0; viewModel["internalMemory"]["usage"] = 0;
} }
viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math. viewModel["externalMemory"]["total"] = Math.
round(device["deviceInfo"]["externalTotalMemory"] * 100) / 100; round(filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 100) / 100;
if (device["deviceInfo"]["externalTotalMemory"] != 0) { if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) {
viewModel["externalMemory"]["usage"] = Math. viewModel["externalMemory"]["usage"] = Math.
round((device["deviceInfo"]["externalTotalMemory"] - device["deviceInfo"]["externalAvailableMemory"]) round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] -
/ device["deviceInfo"]["externalTotalMemory"] * 10000) / 100; filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"])
/ filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100;
} else { } else {
viewModel["externalMemory"]["usage"] = 0; viewModel["externalMemory"]["usage"] = 0;
} }
} else {
viewModel["deviceInfo"] = false;
} }
} else if (device["type"] == "windows") { if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) {
viewModel["imei"] = device["properties"]["IMEI"]; viewModel["deviceInfoAvailable"] = false;
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;
deviceViewData["deviceView"] = viewModel;
} else if (response["status"] == "unauthorized") { } else if (response["status"] == "unauthorized") {
deviceData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceData["isAuthorized"] = false; deviceViewData["isAuthorized"] = false;
} else if (response["status"] == "notFound") { } else if (response["status"] == "notFound") {
deviceData["deviceFound"] = false; deviceViewData["deviceFound"] = false;
} }
return deviceData; } else {
deviceViewData["deviceFound"] = false;
} }
return deviceViewData;
} }
Loading…
Cancel
Save