Hiding geo-fencing related buttons when geoservices disabled

revert-70aa11f8
Rasika Perera 8 years ago
parent 389173f505
commit 6e748ae799

@ -485,11 +485,13 @@
<div class="popover-content"> <div class="popover-content">
<h6>Information</h6> <h6>Information</h6>
<p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p> <p id="information" class="bg-primary" style="margin: 0px;padding: 0px;"></p>
{{#if geoServicesEnabled}}
<h6>Speed<span class="label label-primary pull-right"><span id="speed"></span> km/h</span></h6> <h6>Speed<span class="label label-primary pull-right"><span id="speed"></span> km/h</span></h6>
<h6>Heading<span id="heading" class="label label-primary pull-right"></span></h6> <h6>Heading<span id="heading" class="label label-primary pull-right"></span></h6>
<button type="button" class="btn btn-info btn-xs" onClick="toggleSpeedGraph();return false;">Speed Graph</button> <button type="button" class="btn btn-info btn-xs" onClick="toggleSpeedGraph();return false;">Speed Graph</button>
<button type="button" class="btn btn-info btn-xs" onClick="focusOnRecentHistorySpatialObject();return false;">Recent History</button> <button type="button" class="btn btn-info btn-xs" onClick="focusOnRecentHistorySpatialObject();return false;">Recent History</button>
<button type="button" class="btn btn-info btn-xs" onClick="popupDateRange();">Full History</button> <button type="button" class="btn btn-info btn-xs" onClick="popupDateRange();">Full History</button>
{{/if}}
</div> </div>
</div> </div>

@ -273,16 +273,20 @@ var getProviderData = function (timeFrom, timeTo) {
deviceId = deviceDetails.data("deviceid"); deviceId = deviceDetails.data("deviceid");
deviceType = deviceDetails.data("type"); deviceType = deviceDetails.data("type");
var serviceUrl = '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + timeFrom + '&to=' + timeTo; if (geoFencingEnabled) {
invokerUtil.get(serviceUrl, var serviceUrl = '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + timeFrom + '&to=' + timeTo;
function (data) { invokerUtil.get(serviceUrl,
tableData = JSON.parse(data); function (data) {
if (tableData.length === 0) { tableData = JSON.parse(data);
showCurrentLocation(tableData); if (tableData.length === 0) {
} showCurrentLocation(tableData);
}, function (message) { }
showCurrentLocation(tableData); }, function (message) {
}); showCurrentLocation(tableData);
});
} else {
showCurrentLocation(tableData);
}
return tableData; return tableData;
}; };
@ -368,7 +372,9 @@ function enableRealTime() {
isBatchModeOn = false; isBatchModeOn = false;
} }
function InitSpatialObject() { var geoFencingEnabled = true;
function InitSpatialObject(geoFencingIsEnabled) {
geoFencingEnabled = geoFencingIsEnabled;
var spatialObject = drawSpatialObject(); var spatialObject = drawSpatialObject();
map.addControl(L.control.focus({position: 'bottomright', marker: spatialObject.marker, zoomLevel: zoomLevel})); map.addControl(L.control.focus({position: 'bottomright', marker: spatialObject.marker, zoomLevel: zoomLevel}));
} }
@ -420,9 +426,11 @@ function drawSpatialObject() {
return true; return true;
} }
var alertsFromDate = new Date(); if (geoFencingEnabled) {
alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours var alertsFromDate = new Date();
getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf()); alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours
getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf());
}
setTimeout(function () { setTimeout(function () {
map.invalidateSize(); map.invalidateSize();

@ -631,7 +631,7 @@ function initializeGeoLocation(geoFencingEnabled) {
$("#proximity_alert").hide(); $("#proximity_alert").hide();
initialLoad(); initialLoad();
InitSpatialObject(); InitSpatialObject(geoFencingEnabled);
if (geoFencingEnabled) { if (geoFencingEnabled) {
initializeSpatialStreamWebSocket(); initializeSpatialStreamWebSocket();

Loading…
Cancel
Save