Changes to geo dashboard ui in /devicemgt

revert-70aa11f8
Rasika Perera 8 years ago
parent d37aafff48
commit 76f4457462

@ -704,8 +704,12 @@ data-device-location="{{lastLocation}}"></span>
}); });
{{#if showGeoFencingTools}} {{#if showGeoFencingTools}}
var locationItems = geoLocationLink.closest('li'); var locationItems = geoLocationLink.closest('li');
var geoToolsMenu = $("<ul/>", {class: 'collapse list-group geo-tools'}).appendTo(locationItems); var geoToolsMenu = $("<ul/>", {class: 'collapse list-group geo-tools active'}).appendTo(locationItems);
geoPublicUri = $("#geo-charts").data("geo-public-uri"); geoPublicUri = $("#geo-charts").data("geo-public-uri");
var realtTime = createGeoToolListItem('javascript:enableRealTime()',
'Return to Real Time View', 'fw fw-undo', geoToolsMenu);
realtTime.css("display", "none");
realtTime.attr("id", "realTimeShow");
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/speed_alert.html', createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/speed_alert.html',
'Set Speed Alert', 'glyphicon glyphicon-dashboard', geoToolsMenu); 'Set Speed Alert', 'glyphicon glyphicon-dashboard', geoToolsMenu);
createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/stationery_alert.html', createGeoToolListItem(geoPublicUri + '/assets/html_templates/modal/stationery_alert.html',

@ -297,7 +297,8 @@ function focusOnSpatialObject(objectId) {
return true; return true;
} }
map.setView(spatialObject.marker.getLatLng(), zoomLevel, {animate: true}); // TODO: check the map._layersMaxZoom and set the zoom level accordingly map.setView(spatialObject.marker.getLatLng(), zoomLevel, {animate: true});
// TODO: check the map._layersMaxZoom and set the zoom level accordingly
$('#objectInfo').find('#objectInfoId').html(selectedSpatialObject); $('#objectInfo').find('#objectInfoId').html(selectedSpatialObject);
spatialObject.marker.openPopup(); spatialObject.marker.openPopup();
@ -305,7 +306,7 @@ function focusOnSpatialObject(objectId) {
$('#objectInfo').animate({width: 'toggle'}, 100); $('#objectInfo').animate({width: 'toggle'}, 100);
toggled = true; toggled = true;
} }
getAlertsHistory(objectId); getAlertsHistory(deviceType, deviceId, new Date($('#timeFrom').val()).getTime(), new Date($('#timeTo').val()).getTime());
spatialObject.drawPath(); spatialObject.drawPath();
setTimeout(function () { setTimeout(function () {
createChart(); createChart();
@ -470,7 +471,7 @@ function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
clearMap(); clearMap();
var fromDate = new Date(timeFrom); var fromDate = new Date(timeFrom);
var toDate = new Date(timeTo); var toDate = new Date(timeTo);
var tableData = getProviderData(fromDate.valueOf() / 1000, toDate.valueOf() / 1000); var tableData = getProviderData(fromDate.valueOf(), toDate.valueOf());
for (var i = 0; i < tableData.length; i++) { for (var i = 0; i < tableData.length; i++) {
var data = tableData[i]; var data = tableData[i];
var geoMessage = { var geoMessage = {
@ -507,7 +508,8 @@ function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
return true; return true;
} }
map.setView(spatialObject.marker.getLatLng(), zoomLevel, {animate: true}); // TODO: check the map._layersMaxZoom and set the zoom level accordingly map.setView(spatialObject.marker.getLatLng(), zoomLevel, {animate: true});
// TODO: check the map._layersMaxZoom and set the zoom level accordingly
$('#objectInfo').find('#objectInfoId').html(selectedSpatialObject); $('#objectInfo').find('#objectInfoId').html(selectedSpatialObject);
spatialObject.marker.openPopup(); spatialObject.marker.openPopup();
@ -515,7 +517,7 @@ function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
$('#objectInfo').animate({width: 'toggle'}, 100); $('#objectInfo').animate({width: 'toggle'}, 100);
toggled = true; toggled = true;
} }
getAlertsHistory(objectId); getAlertsHistory(deviceType, deviceId, new Date($('#timeFrom').val()).getTime(), new Date($('#timeTo').val()).getTime());
spatialObject.drawPath(); spatialObject.drawPath();
setTimeout(function () { setTimeout(function () {
createChart(); createChart();
@ -539,4 +541,5 @@ function createGeoToolListItem(link, text, icon, menuRoot) {
anchor.attr('data-toggle', 'modal'); anchor.attr('data-toggle', 'modal');
anchor.attr('data-target', '#commonModal'); anchor.attr('data-target', '#commonModal');
$("<i/>", {class: icon}).prependTo(anchor); $("<i/>", {class: icon}).prependTo(anchor);
return listItem;
} }

@ -29,7 +29,7 @@ var ApplicationOptions = {
} }
}, },
constance:{ constance:{
CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.FusedSpatialEvent', CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'iot.per.device.stream.geo.FusedSpatialEvent',
CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.AlertsNotifications', CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'org.wso2.geo.AlertsNotifications',
CEP_Traffic_STREAM_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'DefaultWebsocketOutputAdaptorOnTrafficStream', CEP_Traffic_STREAM_WEB_SOCKET_OUTPUT_ADAPTOR_NAME: 'DefaultWebsocketOutputAdaptorOnTrafficStream',
CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket', CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME: 'secured-websocket',

@ -487,13 +487,21 @@ function removeGeoFence(geoFenceElement, id) {
}); });
} }
function getAlertsHistory(objectId) { function getAlertsHistory(deviceType, deviceId, timeFrom, timeTo) {
var timeRange = '';
$.getJSON("/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts_history.jag?objectId=" + objectId, function (data) { if (timeFrom && timeTo) {
timeRange = '?from=' + timeFrom + '&to=' + timeTo;
}
var serviceUrl = '/api/device-mgt/v1.0/geo-services/alerts/history/' + deviceType + '/' + deviceId + timeRange;
invokerUtil.get(serviceUrl,
function (data) {
var alertsContainer = $('#showAlertsArea').empty(); var alertsContainer = $('#showAlertsArea').empty();
$.each(data, function (key, val) { var alerts = JSON.parse(data);
var alertDOMElement = document.createElement('a'); // Reason for using document.createElement (performance issue) http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent $.each(alerts, function (key, val) {
var alertDOMElement = document.createElement('a'); // Reason for using
// document.createElement
// (performance issue)
// http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent
switch (val.STATE) { switch (val.STATE) {
case "NORMAL": case "NORMAL":
// $(alertDOMElement).addClass("list-group-item list-group-item-info"); // $(alertDOMElement).addClass("list-group-item list-group-item-info");
@ -521,6 +529,8 @@ function getAlertsHistory(objectId) {
alertsContainer.append(alertDOMElement); alertsContainer.append(alertDOMElement);
}); });
}, function (message) {
console.log(message);
}); });
} }

@ -650,7 +650,7 @@ function initializeGeoLocation() {
var wsEndPoint = geoCharts.data("ws-endpoint"); var wsEndPoint = geoCharts.data("ws-endpoint");
wsToken = geoCharts.data("ws-token"); wsToken = geoCharts.data("ws-token");
geoPublicUri = geoCharts.data("geo-public-uri"); geoPublicUri = geoCharts.data("geo-public-uri");
webSocketURL = wsEndPoint + userDomain + "/org.wso2.geo.FusedSpatialEvent/1.0.0?" webSocketURL = wsEndPoint + userDomain + "/iot.per.device.stream.geo.FusedSpatialEvent/1.0.0?"
+ "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken; + "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken;
alertWebSocketURL = wsEndPoint + userDomain + "/org.wso2.geo.AlertsNotifications/1.0.0?" alertWebSocketURL = wsEndPoint + userDomain + "/org.wso2.geo.AlertsNotifications/1.0.0?"
+ "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken; + "deviceId=" + deviceId + "&deviceType=" + deviceType + "&websocketToken=" + wsToken;

Loading…
Cancel
Save