From ba0a869cdd28ba592b6f3bddf283fdff157f5510 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 19 Jul 2017 20:46:47 +0530 Subject: [PATCH] Avoid calling geo service when geoFencing disabled --- .../modules/business-controllers/device.js | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 6c67dfa4f2b..5cca9bd3077 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -73,19 +73,22 @@ deviceModule = function () { } var userName = carbonUser.username + "@" + carbonUser.domain; 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 geoServicesEnabled = devicemgtProps.serverConfig.geoLocationConfiguration.isEnabled; + if (geoServicesEnabled) { + 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 + '?from=' + fromDate + '&to=' + toDate; + 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 = {};