Merge pull request #857 from rasika/geo-fence-issues

Avoid calling geo service when geoFencing disabled
4.x.x
Madhawa Perera 7 years ago committed by GitHub
commit 8934dc2055

@ -73,19 +73,22 @@ deviceModule = function () {
} }
var userName = carbonUser.username + "@" + carbonUser.domain; var userName = carbonUser.username + "@" + carbonUser.domain;
var locationHistory = []; var locationHistory = [];
try { var geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled;
var fromDate = new Date(); if (geoServicesEnabled) {
fromDate.setHours(fromDate.getHours() - 2); try {
var toDate = new Date(); var fromDate = new Date();
var serviceUrl = devicemgtProps["httpsURL"] + '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId; fromDate.setHours(fromDate.getHours() - 2);
serviceInvokers.XMLHttp.get(serviceUrl, var toDate = new Date();
function (backendResponse) { var serviceUrl = devicemgtProps["httpsURL"] + '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + fromDate + '&to=' + toDate;
if (backendResponse.status === 200 && backendResponse.responseText) { serviceInvokers.XMLHttp.get(serviceUrl,
locationHistory = JSON.parse(backendResponse.responseText); function (backendResponse) {
} if (backendResponse.status === 200 && backendResponse.responseText) {
}); locationHistory = JSON.parse(backendResponse.responseText);
} catch (e) { }
log.error(e.message, e); });
} catch (e) {
log.error(e.message, e);
}
} }
var locationInfo = {}; var locationInfo = {};

Loading…
Cancel
Save