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);
}
}
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"];
try {
utility.startTenantFlow(carbonUser);
@ -175,10 +195,24 @@ deviceModule = function () {
if (device["deviceInfo"]) {
filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"];
}
//location related verification and modifications
// adding the location histry for the movement path.
var locationHistory = {};
locationHistory.locations = locationData;
locationHistory.times = locationTimeData;
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["status"] = "success";
return response;

@ -37,6 +37,7 @@
{{#zone "content"}}
{{#if canView}}
{{#if exists}}
{{#zone "contentTitle"}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
@ -172,6 +173,25 @@
{{/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>
{{/if}}
{{else}}
<h1 class="page-sub-title">
Permission Denied

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