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

Geo Fencing improvements
revert-70aa11f8
Madhawa Perera 7 years ago committed by GitHub
commit 28060d011d

@ -745,24 +745,37 @@
geoPublicUri = $("#geo-charts").data("geo-public-uri");
{{#if geoServicesEnabled}}
var geoToolsMenu = $('#location-action-bar');
var realtTime = createGeoToolListItem('javascript:enableRealTime()',
'Return to Real Time View', 'fw fw-undo', geoToolsMenu);
var refreshMap = createGeoToolListItem('javascript:void(0);', 'Refresh', 'fw fw-refresh', geoToolsMenu, true);
refreshMap.addClass("geo-alert");
refreshMap.on("click", function(){enableRealTime();});
var realtTime = createGeoToolListItem('javascript:void(0);', 'Return to Real Time View', 'fw fw-undo', geoToolsMenu, true);
realtTime.on("click", function(){enableRealTime();});
realtTime.css("display", "none");
realtTime.attr("id", "realTimeShow");
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/speed_alert.html',
var speedAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/speed_alert.html',
'Set Speed Alert', 'glyphicon glyphicon-dashboard', geoToolsMenu);
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/stationery_alert.html',
speedAlert.addClass("geo-alert");
var stationaryAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/stationery_alert.html',
'Add Stationary Alert', 'glyphicon glyphicon-link', geoToolsMenu);
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/within_alert.html',
stationaryAlert.addClass("geo-alert");
var withinAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/within_alert.html',
'Add Geofence Alert', 'glyphicon glyphicon-log-in', geoToolsMenu);
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/exit_alert.html',
withinAlert.addClass("geo-alert");
var exitAlert = createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/exit_alert.html',
'Add Geofence Exit Alert', 'glyphicon glyphicon-log-out', geoToolsMenu);
exitAlert.addClass("geo-alert");
{{/if}}
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('#dateRangePopup').dialog('close');
})
$('#dateRangePopup.ui-dialog-content').dialog('close');
});
});
</script>
{{/zone}}

@ -35,12 +35,12 @@ var zoomLevel = 15;
var tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
var attribution = "&copy; <a href='https://openstreetmap.org/copyright'>OpenStreetMap</a> contributors";
function initialLoad() {
function initialLoad(geoFencingEnabled) {
if (document.getElementById('map') == null) {
setTimeout(initialLoad, 500); // give everything some time to render
} else {
initializeMap();
processAfterInitializationMap();
processAfterInitializationMap(geoFencingEnabled);
$("#loading").hide();
}
}
@ -111,7 +111,7 @@ var geoAlertsBar;
var groupedOverlays;
var layerControl;
function processAfterInitializationMap() {
function processAfterInitializationMap(geoFencingEnabled) {
attributionControl = L.control({
position: "bottomright"
});
@ -123,7 +123,9 @@ function processAfterInitializationMap() {
map.addControl(L.control.fullscreen({position: 'bottomright'}));
geoAlertsBar = L.control.geoAlerts({position: 'topright'});
map.addControl(geoAlertsBar);
if (geoFencingEnabled) {
map.addControl(geoAlertsBar);
}
groupedOverlays = {
"Web Map Service layers": {}
@ -277,6 +279,7 @@ var getProviderData = function (timeFrom, timeTo) {
var serviceUrl = '/api/device-mgt/v1.0/geo-services/stats/' + deviceType + '/' + deviceId + '?from=' + timeFrom + '&to=' + timeTo;
invokerUtil.get(serviceUrl,
function (data) {
if(data === ""){showCurrentLocation(tableData);}
tableData = JSON.parse(data);
if (tableData.length === 0) {
showCurrentLocation(tableData);
@ -359,7 +362,8 @@ function notifyError(message) {
}
function enableRealTime() {
document.getElementById('realTimeShow').style.display = 'none';
$("#realTimeShow").hide();
$(".geo-alert").show();
spatialObject = currentSpatialObjects[selectedSpatialObject];
if (spatialObject) {
spatialObject.removePath();
@ -368,8 +372,13 @@ function enableRealTime() {
selectedSpatialObject = null;
clearFocus();
clearMap();
document.getElementById('objectInfo').style.display = 'none';
isBatchModeOn = false;
initializeGeoLocation(geoFencingEnabled);
}
function disableRealTime(){
$(".geo-alert").hide();
$("#realTimeShow").show();
}
var geoFencingEnabled = true;
@ -456,7 +465,7 @@ function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
notifyError('No end time provided to show history. Please provide a suitable value' + timeTo);
} else {
$('#dateRangePopup').dialog('close');
document.getElementById('realTimeShow').style.display = 'block';
disableRealTime();
isBatchModeOn = true;
clearFocus(); // Clear current focus if any
clearMap();
@ -524,11 +533,13 @@ function clearFocus() {
}
}
function createGeoToolListItem(link, text, icon, menuRoot) {
function createGeoToolListItem(link, text, icon, menuRoot, noModal) {
var listItem = $("<div/>", { class: 'action-btn filter'}).appendTo(menuRoot);
var anchor = $("<a/>", {href: link, text: ' ' + text}).appendTo(listItem);
anchor.attr('data-toggle', 'modal');
anchor.attr('data-target', '#commonModal');
if(!noModal){
anchor.attr('data-toggle', 'modal');
anchor.attr('data-target', '#commonModal');
}
$("<i/>", {class: icon}).prependTo(anchor);
return listItem;
}

@ -630,7 +630,7 @@ function initializeGeoLocation(geoFencingEnabled) {
+ "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken;
$("#proximity_alert").hide();
initialLoad();
initialLoad(geoFencingEnabled);
InitSpatialObject(geoFencingEnabled);
if (geoFencingEnabled) {

Loading…
Cancel
Save