diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
index 4dbde58f80..ee92e8e654 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
@@ -432,7 +432,7 @@
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
index 8eea24e5ad..5faad97b48 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
@@ -29,8 +29,6 @@ $('body').on('hidden.bs.modal', '.modal', function () {
/*Map layer configurations*/
var map;
-initialLoad();
-
function initialLoad() {
if (document.getElementById('map') == null) {
setTimeout(initialLoad, 500); // give everything some time to render
@@ -47,17 +45,18 @@ function initialLoad() {
}
function setPageTitle() {
- var hash = window.parent.location.hash;
- if(hash) {
- var startIdx = hash.indexOf("/") + 1;
- var lastIdx = hash.length;
- var deviceInfoString = hash.substring(startIdx,lastIdx);
- var deviceInfo = JSON.parse(deviceInfoString);
- if(deviceInfo) {
- var newTitle = "[ " + deviceInfo.device.id + "]" + " - Geo Dashboard [" + deviceInfo.device.type + "]";
- window.parent.document.title = newTitle;
- }
- }
+ var hash = window.parent.location.hash;
+ if(hash) {
+ var startIdx = hash.indexOf("/") + 1;
+ var lastIdx = hash.length;
+ var deviceInfoString = hash.substring(startIdx,lastIdx);
+ var deviceInfo = JSON.parse(deviceInfoString);
+ if(deviceInfo) {
+ var newTitle = "[ " + deviceInfo.device.id + "]" + " - Geo Dashboard [" + deviceInfo.device.type + "]";
+ window.parent.document.title = newTitle;
+ $("#title").val(newTitle)
+ }
+ }
}
//function success(position) {
@@ -291,7 +290,9 @@ function focusOnSpatialObject(objectId) {
});
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
console.log("Selected " + objectId + " type " + spatialObject.type);
@@ -354,6 +355,66 @@ function enableRealTime() {
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 " + deviceId + " 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) {
if (!timeFrom) {
notifyError('No start time provided to show history. Please provide a suitable value' + timeFrom);
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
index ced06d0491..8f10a93342 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
@@ -602,6 +602,8 @@ var webSocketOnAlertError = function (e) {
var webSocketOnOpen = function () {
websocket.set_opened();
+ initialLoad();
+ InitSpatialObject();
$.UIkit.notify({
message: 'You Are Connected to Spatial Stream !!',
status: 'success',