Merge pull request #532 from Megala21/new_3.0.x

Adding show path facility to geo-dashboard
revert-dabc3590
Kamidu Sachith Punchihewa 8 years ago committed by GitHub
commit 2119ee768e

@ -432,7 +432,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button> <button class="close" type="button" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"> <h4 id = "title" class="modal-title">
WSO2 Geo Dashboard WSO2 Geo Dashboard
</h4> </h4>
</div> </div>

@ -29,8 +29,6 @@ $('body').on('hidden.bs.modal', '.modal', function () {
/*Map layer configurations*/ /*Map layer configurations*/
var map; var map;
initialLoad();
function initialLoad() { function initialLoad() {
if (document.getElementById('map') == null) { if (document.getElementById('map') == null) {
setTimeout(initialLoad, 500); // give everything some time to render setTimeout(initialLoad, 500); // give everything some time to render
@ -47,17 +45,18 @@ function initialLoad() {
} }
function setPageTitle() { function setPageTitle() {
var hash = window.parent.location.hash; var hash = window.parent.location.hash;
if(hash) { if(hash) {
var startIdx = hash.indexOf("/") + 1; var startIdx = hash.indexOf("/") + 1;
var lastIdx = hash.length; var lastIdx = hash.length;
var deviceInfoString = hash.substring(startIdx,lastIdx); var deviceInfoString = hash.substring(startIdx,lastIdx);
var deviceInfo = JSON.parse(deviceInfoString); var deviceInfo = JSON.parse(deviceInfoString);
if(deviceInfo) { if(deviceInfo) {
var newTitle = "[ " + deviceInfo.device.id + "]" + " - Geo Dashboard [" + deviceInfo.device.type + "]"; var newTitle = "[ " + deviceInfo.device.id + "]" + " - Geo Dashboard [" + deviceInfo.device.type + "]";
window.parent.document.title = newTitle; window.parent.document.title = newTitle;
} $("#title").val(newTitle)
} }
}
} }
//function success(position) { //function success(position) {
@ -291,7 +290,9 @@ function focusOnSpatialObject(objectId) {
}); });
return false; return false;
} }
clearFocus(); // Clear current focus if any if (selectedSpatialObject != objectId) {
clearFocus(); // Clear current focus if any
}
selectedSpatialObject = objectId; // (global) Why not use 'var' other than implicit declaration http://stackoverflow.com/questions/1470488/what-is-the-function-of-the-var-keyword-and-when-to-use-it-or-omit-it#answer-1471738 selectedSpatialObject = objectId; // (global) Why not use 'var' other than implicit declaration http://stackoverflow.com/questions/1470488/what-is-the-function-of-the-var-keyword-and-when-to-use-it-or-omit-it#answer-1471738
console.log("Selected " + objectId + " type " + spatialObject.type); console.log("Selected " + objectId + " type " + spatialObject.type);
@ -354,6 +355,66 @@ function enableRealTime() {
isBatchModeOn = false; isBatchModeOn = false;
} }
function InitSpatialObject() {
var fromDate = new Date();
fromDate.setHours(fromDate.getHours() - 2);
var toDate = new Date();
console.log(fromDate + " " + toDate);
var tableData = getProviderData(fromDate.valueOf(), toDate.valueOf());
for (var i = 0; i < tableData.length; i++) {
var data = tableData[i];
var geoMessage = {
"messageType": "Point",
"type": "Feature",
"id": data.id,
"deviceId": data.id,
"deviceType": data.type,
"properties": {
"speed": data.speed,
"heading": data.heading,
"state": data.state,
"information": data.information,
"notify": data.notify,
"type": data.type
},
"geometry": {
"type": "Point",
"coordinates": [data.longitude, data.latitude]
}
};
processPointMessage(geoMessage);
}
var spatialObject = currentSpatialObjects[deviceId];// (local)
if (!spatialObject) {
$.UIkit.notify({
message: "Spatial Object <span style='color:red'>" + deviceId + "</span> not in the Map!!",
status: 'warning',
timeout: ApplicationOptions.constance.NOTIFY_WARNING_TIMEOUT,
pos: 'top-center'
});
return false;
}
selectedSpatialObject = deviceId;
if (spatialObject.type == "area") {
spatialObject.focusOn(map);
return true;
}
map.setView(spatialObject.marker.getLatLng(), 15, {animate: true}); // TODO: check the map._layersMaxZoom and set the zoom level accordingly
$('#objectInfo').find('#objectInfoId').html(selectedSpatialObject);
spatialObject.marker.openPopup();
if (!toggled) {
$('#objectInfo').animate({width: 'toggle'}, 100);
toggled = true;
}
spatialObject.drawPath();
setTimeout(function () {
createChart();
chart.load({columns: [spatialObject.speedHistory.getArray()]});
}, 100);
}
function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) { function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
if (!timeFrom) { if (!timeFrom) {
notifyError('No start time provided to show history. Please provide a suitable value' + timeFrom); notifyError('No start time provided to show history. Please provide a suitable value' + timeFrom);

@ -602,6 +602,8 @@ var webSocketOnAlertError = function (e) {
var webSocketOnOpen = function () { var webSocketOnOpen = function () {
websocket.set_opened(); websocket.set_opened();
initialLoad();
InitSpatialObject();
$.UIkit.notify({ $.UIkit.notify({
message: 'You Are Connected to Spatial Stream !!', message: 'You Are Connected to Spatial Stream !!',
status: 'success', status: 'success',

Loading…
Cancel
Save