fix the user view related issues and device location out dated issue

revert-70aa11f8
kamidu 8 years ago
parent 1f572998f8
commit e205fd97cd

@ -98,6 +98,26 @@ deviceModule = function () {
locationTimeData.push(gpsReadingTimes); locationTimeData.push(gpsReadingTimes);
} }
} }
var locationInfo = {};
try {
var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/location";
serviceInvokers.XMLHttp.get(
url,
function (backendResponse) {
if (backendResponse.status == 200 && backendResponse.responseText) {
var device = parse(backendResponse.responseText);
locationInfo.latitude = device.latitude;
locationInfo.longitude = device.longitude;
locationInfo.updatedOn = device.updatedTime;
}
});
} catch (e) {
log.error(e.message, e);
}
var utility = require('/app/modules/utility.js')["utility"]; var utility = require('/app/modules/utility.js')["utility"];
try { try {
utility.startTenantFlow(carbonUser); utility.startTenantFlow(carbonUser);
@ -175,10 +195,24 @@ deviceModule = function () {
if (device["deviceInfo"]) { if (device["deviceInfo"]) {
filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"]; filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"];
} }
//location related verification and modifications
// adding the location histry for the movement path.
var locationHistory = {}; var locationHistory = {};
locationHistory.locations = locationData; locationHistory.locations = locationData;
locationHistory.times = locationTimeData; locationHistory.times = locationTimeData;
filteredDeviceData["locationHistory"] = locationHistory; filteredDeviceData["locationHistory"] = locationHistory;
//checking for the latest location information.
if (filteredDeviceData.latestDeviceInfo.location && locationInfo) {
var infoDate = new Date(filteredDeviceData.latestDeviceInfo.location.updatedTime);
var locationDate = new Date(locationInfo.updatedOn);
if (infoDate < locationDate) {
filteredDeviceData.latestDeviceInfo.location.longitude = locationInfo.longitude;
filteredDeviceData.latestDeviceInfo.location.latitude = locationInfo.latitude;
}
}
response["content"] = filteredDeviceData; response["content"] = filteredDeviceData;
response["status"] = "success"; response["status"] = "success";
return response; return response;

@ -37,99 +37,100 @@
{{#zone "content"}} {{#zone "content"}}
{{#if canView}} {{#if canView}}
{{#zone "contentTitle"}} {{#if exists}}
<div class="row wr-device-board"> {{#zone "contentTitle"}}
<div class="col-lg-12 wr-secondary-bar"> <div class="row wr-device-board">
<label class="device-id device-select" data-username="{{user.username}}"> <div class="col-lg-12 wr-secondary-bar">
{{#if user.firstname}} <label class="device-id device-select" data-username="{{user.username}}">
{{user.firstname}} {{user.lastname}} {{#if user.firstname}}
{{else}} {{user.firstname}} {{user.lastname}}
{{user.username}} {{else}}
{{/if}} {{user.username}}
</label> {{/if}}
</label>
</div>
</div> </div>
</div> {{/zone}}
{{/zone}}
<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 class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
<div class="thumbnail icon" style="margin-bottom: 43px"><i <div class="thumbnail icon" style="margin-bottom: 43px"><i
class="square-element text fw fw-user"></i> class="square-element text fw fw-user"></i>
</div> </div>
<div class="media"> <div class="media">
{{#unless isCloud}} {{#unless isCloud}}
{{#if editPermitted}} {{#if editPermitted}}
<button class="wr-btn" <button class="wr-btn"
onclick="location.href='{{@app.context}}/users/edit-user?username={{user.username}}';" onclick="location.href='{{@app.context}}/users/edit-user?username={{user.username}}';"
id="sortUpdateBtn" id="sortUpdateBtn"
style="width: 100%; vertical-align: bottom; background-color: #7fa030;"><span><i style="width: 100%; vertical-align: bottom; background-color: #7fa030;"><span><i
class="fw fw-edit"></i> Edit</span></button> class="fw fw-edit"></i> Edit</span></button>
{{/if}} {{/if}}
{{/unless}} {{/unless}}
</div>
</div> </div>
</div> <div class="media-body asset-desc add-padding-left-5x">
<div class="media-body asset-desc add-padding-left-5x"> <div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Profile Overview
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Profile Overview </div>
{{#defineZone "user-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 7%;">Username</td>
<td style="padding:10px 15px;">{{user.username}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">First Name</td>
<td style="padding:10px 15px;">{{user.firstname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Last Name</td>
<td style="padding:10px 15px;">{{user.lastname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Email</td>
<td style="padding:10px 15px;">{{user.emailAddress}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Roles</td>
<td style="padding:10px 15px;">
{{#each userRoles}}
<option selected="selected">{{this}}</option>
{{/each}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
</div> </div>
{{#defineZone "user-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 7%;">Username</td>
<td style="padding:10px 15px;">{{user.username}}</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1" style="padding:10px 15px;">First Name</td>
<td style="padding:10px 15px;">{{user.firstname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Last Name</td>
<td style="padding:10px 15px;">{{user.lastname}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Email</td>
<td style="padding:10px 15px;">{{user.emailAddress}}</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Roles</td>
<td style="padding:10px 15px;">
{{#each userRoles}}
<option selected="selected">{{this}}</option>
{{/each}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
</div>
</div>
<div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist">
<li class="active"><a class="list-group-item" href="#enrolled_devices" role="tab"
data-toggle="tab" aria-controls="enrolled_devices">Enrolled Devices</a>
</li>
</ul>
</div> </div>
{{#defineZone "user-enrolled-devices"}} <div class="media">
<div class="media-body add-padding-left-5x remove-padding-xs tab-content"> <div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<div class="panel-group tab-content"> <ul class="list-group" role="tablist">
<div class="panel panel-default tab-pane active" id="enrolled_devices" <li class="active"><a class="list-group-item" href="#enrolled_devices" role="tab"
role="tabpanel" aria-labelledby="enrolled_devices"> data-toggle="tab" aria-controls="enrolled_devices">Enrolled Devices</a>
<div class="panel-heading">Enrolled Devices by </li>
{{#if user.firstname}} </ul>
{{user.firstname}} {{user.lastname}} </div>
{{else}} {{#defineZone "user-enrolled-devices"}}
{{user.username}} <div class="media-body add-padding-left-5x remove-padding-xs tab-content">
{{/if}} <div class="panel-group tab-content">
</div> <div class="panel panel-default tab-pane active" id="enrolled_devices"
<div class="panel-body"> role="tabpanel" aria-labelledby="enrolled_devices">
<div id="enrolled_devices-container"> <div class="panel-heading">Enrolled Devices by
<div class="panel-body"> {{#if user.firstname}}
{{#each devices}} {{user.firstname}} {{user.lastname}}
<div class="wr-list-group wr-sortable policy-list"> {{else}}
{{user.username}}
{{/if}}
</div>
<div class="panel-body">
<div id="enrolled_devices-container">
<div class="panel-body">
{{#each devices}}
<div class="wr-list-group wr-sortable policy-list">
<span class="list-group-item" id="{{id}}"> <span class="list-group-item" id="{{id}}">
<div class="row"> <div class="row">
<div class="col-lg-3 clearfix"> <div class="col-lg-3 clearfix">
@ -160,18 +161,37 @@
</div> </div>
</div> </div>
</span> </span>
</div> </div>
{{/each}} {{/each}}
</div>
<br class="c-both"/>
</div> </div>
<br class="c-both"/>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> {{/defineZone}}
{{/defineZone}} </div>
</div>
{{else}}
<div id="user-created-msg" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">User not found.</p>
<br>Please click <b>"Add A New User"</b>, if you wish to add user or click
<b>"View User List"</b> to navigate to the user list.
<hr/>
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/users'">View User List
</button>
<a href="{{@app.context}}/user/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another User
</a>
</div>
</div> </div>
</div> {{/if}}
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Permission Denied Permission Denied

@ -21,7 +21,7 @@ function onRequest(context) {
var username = request.getParameter("username"); var username = request.getParameter("username");
var user = userModule.getUser(username)["content"]; var user = userModule.getUser(username)["content"];
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var isExsistingUser = false;
var userName = request.getParameter("username"); var userName = request.getParameter("username");
var user, userRoles, devices; var user, userRoles, devices;
@ -32,6 +32,7 @@ function onRequest(context) {
if (response["status"] == "success") { if (response["status"] == "success") {
user = response["content"]; user = response["content"];
user.domain = response["userDomain"]; user.domain = response["userDomain"];
isExsistingUser = true;
} }
response = userModule.getRolesByUsername(userName); response = userModule.getRolesByUsername(userName);
@ -49,5 +50,5 @@ function onRequest(context) {
var isCloud = deviceMgtProps.isCloud; var isCloud = deviceMgtProps.isCloud;
return {"user": user, "userRoles": userRoles, "devices": devices, "canView": canView, "isCloud" : isCloud}; return {"exists": isExsistingUser, "user": user, "userRoles": userRoles, "devices": devices, "canView": canView, "isCloud" : isCloud};
} }

Loading…
Cancel
Save