Fixing device view page

4.x.x
Rasika Perera 8 years ago
parent c4a0ac4bf3
commit 135b6e8881

@ -1,481 +1,193 @@
{{unit "cdmf.unit.lib.qrcode"}} {{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "content"}} {{#zone "content"}}
{{#if deviceFound}} {{#if deviceFound}}
{{#if isAuthorized}} {{#if isAuthorized}}
<h1 class="page-sub-title device-id device-select" <h1 class="page-sub-title device-id device-select" data-deviceid="{{device.deviceIdentifier}}"
data-deviceid="{{deviceView.deviceIdentifier}}" data-type="{{deviceView.deviceType}}" data-type="{{device.type}}">
data-ownership="{{deviceView.ownership}}"> Device {{device.name}}
Device {{deviceView.name}} {{#if device.viewModel.model}}
{{#if deviceView.model}}
<span class="lbl-device"> <span class="lbl-device">
( {{deviceView.vendor}} {{deviceView.model}} ) ( {{device.viewModel.vendor}} {{device.viewModel.model}} )
</span> </span>
{{/if}} {{/if}}
</h1> </h1>
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;"> <div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media"> <div class="media">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2"> <div id="device_overview">
<div class="thumbnail icon"><i class="square-element text fw fw-mobile"></i></div> <div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
</div> <div class="thumbnail icon">
<div class="media-body asset-desc add-padding-left-5x"> {{#defineZone "device-thumbnail"}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Device <i class="square-element text fw fw-mobile"></i>
Overview {{/defineZone}}
</div> </div>
{{#defineZone "device-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
{{#if deviceView.deviceIdentifier}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Device ID</td>
<td style="padding:10px 15px;">{{deviceView.deviceIdentifier}}</td>
</tr>
{{/if}}
{{#if deviceView.name}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Name</td>
<td style="padding:10px 15px;">{{deviceView.name}}</td>
</tr>
{{/if}}
{{#if deviceView.vendor}}
{{#if deviceView.model}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Model</td>
<td style="padding:10px 15px;">{{deviceView.vendor}} {{deviceView.model}}</td>
</tr>
{{/if}}
{{/if}}
{{#if deviceView.status}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal deviceView.status "ACTIVE"}}<span><i
class="fw fw-ok icon-success"></i>Active</span>{{/equal}}
{{#equal deviceView.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal deviceView.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal deviceView.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
</td>
</tr>
{{/if}}
{{#if deviceView.owner}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
<td style="padding:10px 15px;">{{deviceView.owner}}</td>
</tr>
{{/if}}
{{#if deviceView.ownership}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Ownership</td>
<td style="padding:10px 15px;">{{deviceView.ownership}}</td>
</tr>
{{/if}}
{{#if deviceView.imei}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">IMEI</td>
<td style="padding:10px 15px;">{{deviceView.imei}}</td>
</tr>
{{/if}}
{{#if deviceView.udid}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">UDID</td>
<td style="padding:10px 15px;">{{deviceView.udid}}</td>
</tr>
{{/if}}
{{#if deviceView.osBuildDate}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Firmware Build
Date
</td>
<td style="padding:10px 15px;">{{deviceView.osBuildDate}}</td>
</tr>
{{/if}}
{{#if deviceView.phoneNumber}}
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Phone Number</td>
<td style="padding:10px 15px;">{{deviceView.phoneNumber}}</td>
</tr>
{{/if}}
{{#if deviceView.lastUpdatedTime}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Last Update</td>
<td style="padding:10px 15px;">{{deviceView.lastUpdatedTime}}</td>
</tr>
{{/if}}
</tbody>
</table>
{{/defineZone}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Operations
</div> </div>
<div class="add-margin-top-4x"> <div class="media-body asset-desc add-padding-left-5x">
{{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}} <div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Device Overview - {{label}}</div>
{{unit "cdmf.unit.device.overview-section" device=device}}
{{#defineZone "operation-status"}}{{/defineZone}}
{{#defineZone "device-opetations"}}
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
Operations
</div>
<div class="add-margin-top-4x" style="height: 90px;">
{{unit "cdmf.unit.device.operation-bar" device=device}}
</div>
{{/defineZone}}
</div> </div>
</div> </div>
</div> </div>
<div class="media tab-responsive">
<div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs"> {{#defineZone "device-detail-properties"}}
<ul class="list-group nav nav-pills nav-stacked" role="tablist"> <div class="media">
{{#if deviceView.isNotWindows}} <div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<li role="presentation" class="list-group-item active"> <ul class="list-group" role="tablist">
<a href="#device_details_tab" role="tab" data-toggle="tab" <li class="active"><a class="list-group-item"
aria-controls="device_details_tab"> href="#device_details"
<i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span> role="tab" data-toggle="tab"
</a> aria-controls="device_details">Device
Details</a>
</li> </li>
{{/if}} <li><a class="list-group-item" href="#policies"
{{#if deviceView.isNotWindows}} role="tab"
<li role="presentation" class="list-group-item"> data-toggle="tab" aria-controls="policies">Policies</a>
{{else}}
<li role="presentation" class="list-group-item active">
{{/if}}
<li role="presentation" class="list-group-item">
<a href="#policy_compliance_tab" role="tab" data-toggle="tab"
aria-controls="policy_compliance_tab">
<i class="icon fw fw-policy"></i><span class="hidden-sm">Policy Compliance</span>
</a>
</li>
{{#if deviceView.isNotWindows}}
<li role="presentation" class="list-group-item">
<a href="#device_location_tab" role="tab" data-toggle="tab"
data-lat="{{deviceView.location.latitude}}"
data-long="{{deviceView.location.longitude}}"
aria-controls="device_location_tab">
<i class="icon fw fw-map-location"></i><span
class="hidden-sm">Device Location</span>
</a>
</li> </li>
<li role="presentation" class="list-group-item"> <li><a class="list-group-item" href="#policy_compliance"
<a href="#installed_applications_tab" role="tab" data-toggle="tab" role="tab"
aria-controls="installed_applications_tab"> data-toggle="tab" aria-controls="policy_compliance">Policy
<i class="icon fw fw-application"></i><span class="hidden-sm">Installed Applications</span> Compliance</a>
</a>
</li> </li>
{{/if}} <li><a class="list-group-item" href="#device_location"
{{#if deviceView.isNotRemoved}} role="tab"
data-toggle="tab" aria-controls="device_location">Device
<li role="presentation" class="list-group-item"> Location</a>
<a href="#event_log_tab" role="tab" data-toggle="tab"
aria-controls="event_log_tab">
<i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab"
data-toggle="tab" aria-controls="event_log">Operations
Log</a></li>
</ul>
</div>
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
{{/if}} <div class="panel panel-default tab-pane active"
</ul> id="device_details" role="tabpanel"
</div> aria-labelledby="device_details">
{{#defineZone "device-detail-properties"}} {{unit "cdmf.unit.device.details" device=device}}
<div class="media-body add-padding-left-5x remove-padding-xs"> </div>
<div class="panel-group tab-content remove-padding" id="tabs" data-status="{{deviceView.isNotRemoved}}"role="tablist" <div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-multiselectable="true"> aria-labelledby="policies">
<div class="arrow-left hidden-xs"></div> <div class="panel-heading">Policies</div>
<div class="panel-body">
{{#if deviceView.isNotWindows}} <div id="policy-spinner" class="wr-advance-operations-init hidden">
<div class="panel panel-default" role="tabpanel" id="device_details_tab"> <br>
<div class="panel-heading visible-xs collapsed" id="device_details"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<h4 class="panel-title"> <i class="fw fw-settings fw-spin fw-2x"></i>
<a role="button" data-toggle="collapse" data-parent="#tabs" &nbsp;&nbsp;&nbsp;
href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> Loading Policies . . .
<i class="fw fw-mobile fw-2x"></i> <br>
Device Details <br>
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div> </div>
<div class="panel-heading display-none-xs">Device Details</div> <div id="policy-list-container">
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" <div class="panel-body">
aria-labelledby="device_details"> No policies found
<div class="panel-body ">
<div class="device-detail-body">
<!-- device summary -->
{{#equal deviceView.deviceType "windows"}}
<div class="message message-info">
<h4 class="remove-margin"><i class="icon fw fw-info"></i>Not
available yet</h4>
</div>
{{/equal}}
{{#if deviceView.deviceInfoAvailable}}
{{#if deviceView.BatteryLevel}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">BATTERY</div>
<div>
<div class="tile-icon"><i
class="fw fw-battery"></i></div>
<div class="tile-stats">
{{deviceView.BatteryLevel.value}} %
</div>
</div>
</div>
</div>
</div>
{{/if}}
<!--{{#if deviceView.cpuUsage}}-->
<!--<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">-->
<!--<div class="col-md-12">-->
<!--<div class="wr-stats-board-tile">-->
<!--<div class="tile-name">CPU Usage</div>-->
<!--<div>-->
<!--<div class="tile-icon"><i class="fw fw-dashboard"></i></div>-->
<!--<div class="tile-stats">-->
<!--{{deviceView.cpuUsage.value}} %-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--{{/if}}-->
{{#if deviceView.ramUsage}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">RAM Usage</div>
<div>
<div class="tile-icon"><i
class="fw fw-hardware"></i></div>
<div class="tile-stats">
{{deviceView.ramUsage.value}} %
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if deviceView.internalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">Local Storage</div>
<div>
<div class="tile-icon"><i
class="fw fw-hdd"></i>
</div>
<div class="tile-stats">
{{deviceView.internalMemory.usage}} %
<span class="tile-stats-free">
TOTAL OF {{deviceView.internalMemory.total}} GB
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{#if deviceView.externalMemory}}
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div class="col-md-12">
<div class="wr-stats-board-tile">
<div class="tile-name">External Storage</div>
<div>
<div class="tile-icon"><i
class="fw fw-usb-drive"></i></div>
<div class="tile-stats">
{{deviceView.externalMemory.usage}} %
<span class="tile-stats-free">
TOTAL OF {{deviceView.externalMemory.total}} GB
</span>
</div>
</div>
</div>
</div>
</div>
{{/if}}
{{else}}
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
Battery, RAM and Storage related information are not
available yet.
</h4>
</div>
{{/if}}
</div>
</div> </div>
<br class="c-both" />
</div> </div>
</div> </div>
{{/if}} <a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<div class="panel panel-default visible-xs-block" role="tabpanel" <span class="fw-stack">
id="policy_compliance_tab"> <i class="fw fw-ring fw-stack-2x"></i>
<div class="panel-heading visible-xs collapsed" id="policy_compliance"> <i class="fw fw-policy fw-stack-1x"></i>
<h4 class="panel-title"> </span> Add device specific policy</a>
<a role="button" </div>
data-toggle="collapse" data-parent="#tabs" href="#collapseTwo"
aria-expanded="true" aria-controls="collapseTwo">
<i class="fw fw-policy fw-2x"></i>
Policy Compliance
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Policy Compliance
<span> <div class="panel panel-default tab-pane" id="policy_compliance"
<a href="javascript:void(0);" id="refresh-policy"> role="tabpanel" aria-labelledby="policy_compliance">
<i class="fw fw-refresh"></i> <div class="panel-heading">Policy Compliance <span><a
</a> href="#" id="refresh-policy"><i
</span> class="fw fw-refresh"></i></a></span></div>
</div> <div class="panel-body">
<div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" <div id="policy-spinner"
aria-labelledby="policy_compliance"> class="wr-advance-operations-init hidden">
<div class="panel-body "> <br>
<span class="visible-xs add-padding-2x text-right"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="javascript:void(0);" id="refresh-policy"> <i class="fw fw-settings fw-spin fw-2x"></i>
<i class="fw fw-refresh"></i> &nbsp;&nbsp;&nbsp;
</a> Loading Policy Compliance . . .
</span> <br>
<div id="policy-spinner" <br>
class="wr-advance-operations-init add-padding-bottom-2x add-padding-bottom-4x hidden"> </div>
<i class="fw fw-settings fw-spin fw-2x"></i>Loading Policy <div id="policy-list-container">
Compliance... <div class="panel-body">
</div> Not available yet
<div id="policy-list-container">
</div> </div>
<br class="c-both" />
</div> </div>
</div> </div>
</div> </div>
<div class="panel panel-default visible-xs-block" role="tabpanel" <div class="panel panel-default tab-pane" id="device_location"
id="device_location_tab"> role="tabpanel" aria-labelledby="device_location">
<div class="panel-heading visible-xs collapsed" id="device_location"> <div class="panel-heading">Device Location</div>
<h4 class="panel-title"> <div class="panel-body">
<a role="button" data-toggle="collapse" data-parent="#tabs" <div id="device-location"
href="#collapseThree" aria-expanded="true" aria-controls="collapseThree"> data-lat="{{device.viewModel.location.latitude}}"
<i class="fw fw-map-location fw-2x"></i> data-long="{{device.viewModel.location.longitude}}"
Device Location style="height:450px" class="panel-body">
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</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 class="panel-body">
{{#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">
<i class="icon fw fw-warning"></i>
Device location information is not available.
</h4>
</div>
<p class="add-padding-5x"></p>
<p class="add-padding-5x"></p>
<p class="add-padding-5x"></p>
{{/if}}
</div> </div>
</div> <div id="map-error" class="panel-body">
</div> Not available yet
<div class="panel panel-default visible-xs-block" role="tabpanel"
id="installed_applications_tab">
<div class="panel-heading visible-xs collapsed" id="installed_applications">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#tabs"
href="#collapseFour" aria-expanded="true" aria-controls="collapseFour">
<i class="fw fw-application fw-2x"></i>
Installed Applications
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Installed Applications
<span>
<a href="javascript:void(0);" id="refresh-apps">
<i class="fw fw-refresh"></i>
</a>
</span>
</div>
<div id="collapseFour" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="installed_applications">
<div class="panel-body">
<span class="visible-xs add-padding-2x text-right">
<a href="javascript:void(0);" id="refresh-apps">
<i class="fw fw-refresh"></i>
</a>
</span>
<div id="apps-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Applications
List...
</div>
<div id="applications-list-container">
<div class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
No applications found.
</h4>
<p>Please try refreshing in a while.</p>
</div>
</div>
</div> </div>
<br class="c-both" />
</div> </div>
</div> </div>
<div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab"> <div class="panel panel-default tab-pane" id="event_log"
<div class="panel-heading visible-xs collapsed" id="event_log"> role="tabpanel" aria-labelledby="event_log">
<h4 class="panel-title"> <div class="panel-heading">Operations Log <span><a href="#"
<a role="button" data-toggle="collapse" data-parent="#tabs" id="refresh-operations"><i
href="#collapseFive" aria-expanded="true" aria-controls="collapseFive"> class="fw fw-refresh"></i></a></span></div>
<i class="fw fw-text fw-2x"></i> <div class="panel-body">
Operations Log <div id="operations-spinner"
<i class="caret-updown fw fw-down"></i> class="wr-advance-operations-init hidden">
</a> <br>
</h4> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div> <i class="fw fw-settings fw-spin fw-2x"></i>
<div class="panel-heading display-none-xs"> &nbsp;&nbsp;&nbsp;
Operations Log Loading Operations Log . . .
<br>
<span> <br>
<a href="javascript:void(0);" id="refresh-operations"> </div>
<i class="fw fw-refresh"></i> <div id="operations-log-container">
</a> <div class="panel-body">
</span> Not available yet
</div>
<div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-body">
<span class="visible-xs add-padding-2x text-right">
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Operations Log...
</div>
<div id="operations-log-container">
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
There are no operations, performed yet on this device.
</h4>
</div>
</div> </div>
<table class="table table-striped table-hover table-bordered display data-table" <br class="c-both" />
id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{/defineZone}} </div>
</div>
{{/defineZone}}
</div> </div>
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
@ -493,21 +205,17 @@
{{/if}} {{/if}}
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
{{#if isAuthorized}} {{js "js/device-view.js"}}
<!--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> <script id="policy-list" src="{{@unit.publicUri}}/templates/policy-list.hbs"
<!--suppress HtmlUnknownTarget --> data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" type="text/x-handlebars-template"></script>
data-device-id="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}" <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs"
type="text/x-handlebars-template"></script> data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
<!--suppress HtmlUnknownTarget --> type="text/x-handlebars-template"></script>
<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="{{deviceView.deviceIdentifier}}" data-device-type="{{deviceView.deviceType}}" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
{{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
{{js "js/load-map.js"}}
{{/if}}
{{/zone}} {{/zone}}

@ -1,118 +1,211 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. * in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* KIND, either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
function onRequest(context) { function onRequest(context) {
var log = new Log("detail.js"); var log = new Log("cdmf.unit.device.view/view.js");
var deviceType = context.uriParams.deviceType; var deviceType = context["uriParams"]["deviceType"];
var deviceId = request.getParameter("id"); var deviceId = request.getParameter("id");
var deviceViewData = {};
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { if (deviceType && deviceId) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId)["content"]; var response = deviceModule.viewDevice(deviceType, deviceId);
if (response["status"] == "success") {
deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = true;
var filteredDeviceData = response["content"];
if (device) { // creating deviceView information model from filtered device data
var viewModel = {}; var viewModel = {};
var deviceInfo = (device.properties) ? device.properties.DEVICE_INFO : null; if (filteredDeviceData["type"]) {
if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0) { viewModel["deviceType"] = filteredDeviceData["type"];
deviceInfo = parse(stringify(deviceInfo)); viewModel.isNotWindows = true;
if (device.type == "ios") { if (viewModel["deviceType"] == "windows") {
deviceInfo = parse(deviceInfo); viewModel.isNotWindows = false;
viewModel.imei = device.properties.IMEI; }
viewModel.phoneNumber = deviceInfo.PhoneNumber; }
viewModel.udid = deviceInfo.UDID; if (filteredDeviceData["deviceIdentifier"]) {
viewModel.BatteryLevel = Math.round(deviceInfo.BatteryLevel * 100); viewModel["deviceIdentifier"] = filteredDeviceData["deviceIdentifier"];
viewModel.DeviceCapacity = Math.round(deviceInfo.DeviceCapacity * 100) / 100; }
viewModel.AvailableDeviceCapacity = Math.round(deviceInfo.AvailableDeviceCapacity * 100) / 100; if (filteredDeviceData["name"]) {
viewModel.DeviceCapacityUsed = Math.round((viewModel.DeviceCapacity viewModel["name"] = filteredDeviceData["name"];
- viewModel.AvailableDeviceCapacity) * 100) / 100; }
viewModel.DeviceCapacityPercentage = Math.round(viewModel.AvailableDeviceCapacity if (filteredDeviceData["enrolmentInfo"]) {
/ viewModel.DeviceCapacity * 10000) / 100; if (filteredDeviceData["enrolmentInfo"]["status"]) {
viewModel.location = { viewModel["status"] = filteredDeviceData["enrolmentInfo"]["status"];
latitude: device.properties.LATITUDE, viewModel.isActive = false ;
longitude: device.properties.LONGITUDE viewModel.isNotRemoved = true;
}; if (filteredDeviceData["enrolmentInfo"]["status"]== "ACTIVE") {
} else if (device.type == "android") { viewModel.isActive = true ;
viewModel.imei = device.properties.IMEI; }
viewModel.model = device.properties.DEVICE_MODEL; if (filteredDeviceData["enrolmentInfo"]["status"]== "REMOVED") {
viewModel.vendor = device.properties.VENDOR; viewModel.isNotRemoved = false ;
viewModel.internal_memory = {}; }
viewModel.external_memory = {}; }
viewModel.location = { if (filteredDeviceData["enrolmentInfo"]["owner"]) {
latitude: device.properties.LATITUDE, viewModel["owner"] = filteredDeviceData["enrolmentInfo"]["owner"];
longitude: device.properties.LONGITUDE }
}; if (filteredDeviceData["enrolmentInfo"]["ownership"]) {
var info = {}; viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"];
var infoList = parse(deviceInfo); }
if (infoList != null && infoList != undefined) { }
for (var j = 0; j < infoList.length; j++) { if (filteredDeviceData["initialDeviceInfo"]) {
info[infoList[j].name] = infoList[j].value; 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"]) {
if (deviceType == "android") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"];
viewModel["internalMemory"] = {};
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"] = Math.
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(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;
}
} else if (deviceType == "ios") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"];
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
} }
} }
deviceInfo = info;
viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL;
viewModel.internal_memory.FreeCapacity = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY * 100)/100;
viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY
/ deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100;
viewModel.external_memory.FreeCapacity = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY * 100) / 100;
viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY
/ deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) / 100;
} else if (device.type == "windows") {
viewModel.imei = device.properties.IMEI;
viewModel.model = device.properties.DEVICE_MODEL;
viewModel.vendor = device.properties.VENDOR;
viewModel.internal_memory = {};
viewModel.external_memory = {};
viewModel.location = {
latitude: device.properties.LATITUDE,
longitude: device.properties.LONGITUDE
};
/*var info = {};
if (deviceInfo != null && deviceInfo != undefined){
var infoList = parse(deviceInfo);
if (infoList != null && infoList != undefined) {
for (var j = 0; j < infoList.length; j++) {
info[infoList[j].name] = infoList[j].value;
}
}
deviceInfo = info;
viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL;
viewModel.internal_memory.FreeCapacity = Math.round((deviceInfo.INTERNAL_TOTAL_MEMORY -
deviceInfo.INTERNAL_AVAILABLE_MEMORY) * 100) / 100;
viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY
/ deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100;
viewModel.external_memory.FreeCapacity = Math.round((deviceInfo.EXTERNAL_TOTAL_MEMORY -
deviceInfo.EXTERNAL_AVAILABLE_MEMORY) * 100) / 100;
viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY
/ deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) / 100;
}*/
}else if (device.type == "TemperatureController") {
viewModel.system = device.properties.IMEI;
viewModel.machine = device.properties.DEVICE_MODEL;
viewModel.vendor = device.properties.VENDOR;
viewModel.internal_memory = {};
viewModel.external_memory = {};
} }
device.viewModel = viewModel;
} }
} 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"];
var utility = require("/app/modules/utility.js").utility; viewModel["ramUsage"] = {};
var configs = utility.getDeviceTypeConfig(deviceType); if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) {
return {"device": device, "label" : configs["deviceType"]["label"]}; 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") {
deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = false;
} else if (response["status"] == "notFound") {
deviceViewData["deviceFound"] = false;
}
} else {
deviceViewData["deviceFound"] = false;
} }
log.error(deviceViewData);
return deviceViewData;
} }
Loading…
Cancel
Save