Added geo-fencing to the devicemgt app

revert-70aa11f8
Rasika Perera 8 years ago
parent ea3ed9c444
commit 7b0295ff01

@ -176,7 +176,8 @@
"perm:ios:get-restrictions",
"perm:ios:wipe-data",
"perm:admin",
"perm:devicetype:deployment"
"perm:devicetype:deployment",
"perm:geo-service:analytics"
],
"isOAuthEnabled": true,
"backendRestEndpoints": {

@ -69,35 +69,22 @@ deviceModule = function () {
throw constants["ERRORS"]["USER_NOT_FOUND"];
}
var userName = carbonUser.username + "@" + carbonUser.domain;
var locationDataSet = [];
switch (deviceType) {
case 'android':
locationDataSet = batchProvider.getData(userName, deviceId, deviceType);
break;
case 'android_sense':
locationDataSet = batchProvider.getData(userName, deviceId, deviceType);
break;
}
var locationData = [];
var locationTimeData = [];
if (locationDataSet != null) {
for (var i = 0; i < locationDataSet.length; i++) {
var gpsReading = {};
var gpsReadingTimes = {};
gpsReading.lat = locationDataSet[i].latitude;
gpsReading.lng = locationDataSet[i].longitude;
if (deviceType == "android") {
gpsReadingTimes.time = locationDataSet[i].timeStamp;
} else {
gpsReadingTimes.time = locationDataSet[i].meta_timestamp;
}
locationData.push(gpsReading);
locationTimeData.push(gpsReadingTimes);
var locationHistory = [];
try {
var fromDate = new Date();
fromDate.setHours(fromDate.getHours() - 2);
var toDate = new Date();
var serviceUrl = devicemgtProps["httpsURL"] + '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId;
serviceInvokers.XMLHttp.get(serviceUrl,
function (backendResponse) {
if (backendResponse.status === 200 && backendResponse.responseText) {
locationHistory = JSON.parse(backendResponse.responseText);
}
});
} catch (e) {
log.error(e.message, e);
}
var locationInfo = {};
try {
var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/location";
@ -110,14 +97,12 @@ deviceModule = function () {
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);
@ -192,16 +177,35 @@ deviceModule = function () {
}
}
}
if (device["deviceInfo"]) {
filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"];
} else {
filteredDeviceData["latestDeviceInfo"] = {};
filteredDeviceData["latestDeviceInfo"]["location"] = {};
}
//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 based on historical data.
if (locationHistory) {
var infoDate;
var locationDate;
var historicalLatestLoc = locationHistory[locationHistory.length - 1];
if (historicalLatestLoc && filteredDeviceData.latestDeviceInfo && filteredDeviceData.latestDeviceInfo.location) {
infoDate = new Date(filteredDeviceData.latestDeviceInfo.location.updatedTime);
locationDate = new Date(historicalLatestLoc.values.timeStamp);
}
if (infoDate < locationDate || filteredDeviceData.latestDeviceInfo.length === 0) {
filteredDeviceData.latestDeviceInfo.location = {};
filteredDeviceData.latestDeviceInfo.location.longitude = historicalLatestLoc.values.longitude;
filteredDeviceData.latestDeviceInfo.location.latitude = historicalLatestLoc.values.latitude;
filteredDeviceData.latestDeviceInfo.location.updatedTime = historicalLatestLoc.values.timeStamp;
}
}
//checking for the latest location information.
if (filteredDeviceData.latestDeviceInfo.location && locationInfo) {
var infoDate = new Date(filteredDeviceData.latestDeviceInfo.location.updatedTime);
@ -209,11 +213,10 @@ deviceModule = function () {
if (infoDate < locationDate) {
filteredDeviceData.latestDeviceInfo.location.longitude = locationInfo.longitude;
filteredDeviceData.latestDeviceInfo.location.latitude = locationInfo.latitude;
}
filteredDeviceData.latestDeviceInfo.location.updatedTime = locationInfo.updatedOn;
}
}
response["content"] = filteredDeviceData;
response["status"] = "success";
return response;
@ -277,28 +280,6 @@ deviceModule = function () {
return response;
};
/*
@Updated
*/
// publicMethods.getLicense = function (deviceType) {
// var url;
// var license;
// if (deviceType == "windows") {
// url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license";
// } else if (deviceType == "ios") {
// url = mdmProps["httpsURL"] + "/ios-enrollment/license/";
// }
// if (url != null && url != undefined) {
// serviceInvokers.XMLHttp.get(url, function (responsePayload) {
// license = responsePayload.text;
// }, function (responsePayload) {
// return null;
// });
// }
// return license;
// };
publicMethods.getDevices = function (userName) {
var url = devicemgtProps["httpsURL"] +
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices";

@ -19,6 +19,8 @@
{{#zone "content"}}
{{#if deviceFound}}
{{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"></span>
{{#defineZone "device-details-header"}}
<h1 class="page-sub-title device-id device-select" data-deviceid="{{device.deviceIdentifier}}"
data-type="{{device.type}}">

@ -34,6 +34,7 @@ function onRequest(context) {
var viewModel = {};
if (filteredDeviceData["type"]) {
viewModel["deviceType"] = filteredDeviceData["type"];
viewModel["type"] = filteredDeviceData["type"];
viewModel.isNotWindows = true;
if (viewModel["deviceType"] == "windows") {
viewModel.isNotWindows = false;

@ -37,6 +37,11 @@ var invokerUtil = function () {
acceptTypeValue = acceptType;
}
var synchronous = false;
if (isSynchronous) {
synchronous = true;
}
if(contentTypeValue == "application/json"){
restAPIRequestDetails["requestPayload"] = JSON.stringify(requestPayload);
}
@ -46,6 +51,7 @@ var invokerUtil = function () {
contentType: contentTypeValue,
data: JSON.stringify(restAPIRequestDetails),
accept: acceptTypeValue,
async : synchronous,
success: successCallback,
error: function (jqXHR) {
if (jqXHR.status == 401) {
@ -61,22 +67,22 @@ var invokerUtil = function () {
$.ajax(request);
};
publicMethods.get = function (requestURL, successCallback, errorCallback, contentType, acceptType) {
publicMethods.get = function (requestURL, successCallback, errorCallback, contentType, acceptType, isSynchronous) {
var requestPayload = null;
privateMethods.execute("GET", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType);
privateMethods.execute("GET", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous);
};
publicMethods.post = function (requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType) {
privateMethods.execute("POST", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType);
publicMethods.post = function (requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous) {
privateMethods.execute("POST", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous);
};
publicMethods.put = function (requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType) {
privateMethods.execute("PUT", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType);
publicMethods.put = function (requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous) {
privateMethods.execute("PUT", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous);
};
publicMethods.delete = function (requestURL, successCallback, errorCallback, contentType, acceptType) {
publicMethods.delete = function (requestURL, successCallback, errorCallback, contentType, acceptType, isSynchronous) {
var requestPayload = null;
privateMethods.execute("DELETE", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType);
privateMethods.execute("DELETE", requestURL, requestPayload, successCallback, errorCallback, contentType, acceptType, isSynchronous);
};
return publicMethods;

@ -266,3 +266,7 @@ header .username {
.add-padding-top-3x {
padding-top: 15px !important;
}
ul#noty_topRight_layout_container li{
margin-bottom: 10px;
}

@ -429,11 +429,11 @@ a.ctrl-filter-category:hover {
.btn {
display: inline-block;
padding: 8px 20px;
/*padding: 8px 20px;*/
margin-bottom: 0;
font-size: 16px;
/*font-size: 16px;*/
font-weight: normal;
line-height: 1.42857143;
/*line-height: 1.42857143;*/
text-align: center;
white-space: nowrap;
vertical-align: middle;
@ -446,7 +446,7 @@ a.ctrl-filter-category:hover {
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 0;
/*border-radius: 0;*/
transition: background 0.2s;
}

@ -26,4 +26,42 @@
{{#zone "bottomJs" override=false}}
{{!-- Responsive JS Library--}}
{{js "js/responsive-text.js"}}
<script type="text/javascript">
$.noty.defaults = {
layout: 'topRight',
theme: 'metroui', // or relax
type: 'alert', // success, error, warning, information, notification
text: '', // [string|html] can be HTML or STRING
dismissQueue: true, // [boolean] If you want to use queue feature set this true
force: false, // [boolean] adds notification to the beginning of queue when set to true
maxVisible: 5, // [integer] you can set max visible notification count for dismissQueue true option,
template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
timeout: 3000, // [integer|boolean] delay for closing event in milliseconds. Set false for sticky notifications
progressBar: false, // [boolean] - displays a progress bar
animation: {
open: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceInLeft'
close: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceOutLeft'
easing: 'swing',
speed: 500 // opening & closing animation speed
},
closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications
modal: false, // [boolean] if true adds an overlay
killer: false, // [boolean] if true closes all notifications and shows itself
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {},
onCloseClick: function() {},
},
buttons: false // [boolean|array] an array of buttons, for creating confirmation dialogs.
};
</script>
{{/zone}}

@ -7837,7 +7837,7 @@ ul.sidebar-messages > li {
* noty styles
* ======================================================================== */
#noty_topRight_layout_container {
position: absolute !important;
position: fixed !important;
}
#noty_topRight_layout_container, #noty_topLeft_layout_container {

@ -8,7 +8,7 @@ $.noty.layouts.topRight = {
selector: 'ul#noty_topRight_layout_container',
style : function() {
$(this).css({
top : 20,
top : 0,
right : 20,
position : 'fixed',
width : '310px',

Loading…
Cancel
Save