From 055d422e23a257163383766ec18b1bee301a873e Mon Sep 17 00:00:00 2001 From: charitha Date: Fri, 10 Aug 2018 15:26:04 +0530 Subject: [PATCH] Publish geo alerts to cdm notifications --- .../cdmf.unit.geo-dashboard/public/js/app.js | 22 +++++++++---------- .../src/main/resources/dbscripts/cdm/h2.sql | 6 ++--- .../main/resources/dbscripts/cdm/mssql.sql | 6 ++--- .../main/resources/dbscripts/cdm/mysql.sql | 6 ++--- .../main/resources/dbscripts/cdm/oracle.sql | 6 ++--- .../resources/dbscripts/cdm/postgresql.sql | 6 ++--- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js index 266433f1c4..805ec7a3ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js @@ -122,10 +122,10 @@ function processAfterInitializationMap(geoFencingEnabled) { }; map.addControl(L.control.fullscreen({position: 'bottomright'})); - geoAlertsBar = L.control.geoAlerts({position: 'topright'}); - if (geoFencingEnabled) { - map.addControl(geoAlertsBar); - } + // geoAlertsBar = L.control.geoAlerts({position: 'topright'}); + // if (geoFencingEnabled) { + // map.addControl(geoAlertsBar); + // } groupedOverlays = { "Web Map Service layers": {} @@ -256,7 +256,7 @@ function focusOnSpatialObject(objectId) { // TODO: check the map._layersMaxZoom and set the zoom level accordingly spatialObject.marker.openPopup(); - getAlertsHistory(deviceType, deviceId, new Date($('#timeFromCal').val()).getTime(), new Date($('#timeToCal').val()).getTime()); + // getAlertsHistory(deviceType, deviceId, new Date($('#timeFromCal').val()).getTime(), new Date($('#timeToCal').val()).getTime()); spatialObject.drawPath(); if (speedGraphControl) { setTimeout(function () { @@ -435,11 +435,11 @@ function drawSpatialObject() { return true; } - if (geoFencingEnabled) { - var alertsFromDate = new Date(); - alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours - getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf()); - } + // if (geoFencingEnabled) { + // var alertsFromDate = new Date(); + // alertsFromDate.setHours(alertsFromDate.getHours() - 24); //last 24 hours + // getAlertsHistory(deviceType, deviceId, alertsFromDate.valueOf(), toDate.valueOf()); + // } setTimeout(function () { map.invalidateSize(); @@ -513,7 +513,7 @@ function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) { // TODO: check the map._layersMaxZoom and set the zoom level accordingly spatialObject.marker.openPopup(); - getAlertsHistory(deviceType, deviceId, new Date($('#timeFromCal').val()).getTime(), new Date($('#timeToCal').val()).getTime()); + // getAlertsHistory(deviceType, deviceId, new Date($('#timeFromCal').val()).getTime(), new Date($('#timeToCal').val()).getTime()); spatialObject.drawPath(); if (speedGraphControl) { setTimeout(function () { diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 9601b77742..6117eff996 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -396,16 +396,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, DESCRIPTION VARCHAR(1000) NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 204fedd387..7d0427a304 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -439,16 +439,14 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D CREATE TABLE DM_NOTIFICATION ( NOTIFICATION_ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, DESCRIPTION VARCHAR(1000) NULL, LAST_UPDATED_TIMESTAMP DATETIME2 NOT NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT FL_DM_NOTIFICATION FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT FK_DM_OPERATION_NOTIFICATION FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index b79a23f79e..ce2379f621 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -454,16 +454,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, DESCRIPTION VARCHAR(1000) NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; -- END NOTIFICATION TABLES -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index cc89ec76f3..c0007256b8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -749,16 +749,14 @@ WHEN (NEW.ID IS NULL) CREATE TABLE DM_NOTIFICATION ( NOTIFICATION_ID NUMBER(10) NOT NULL, DEVICE_ID NUMBER(10) NOT NULL, - OPERATION_ID NUMBER(10) NOT NULL, + OPERATION_ID NUMBER(10) NULL, TENANT_ID NUMBER(10) NOT NULL, STATUS VARCHAR2(10) NULL, DESCRIPTION VARCHAR2(1000) NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL, CONSTRAINT PK_DM_NOTIFICATION PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT FK_DM_DEVICE_NOTIFICATION FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID), - CONSTRAINT FK_DM_OPERATION_NOTIFICATION FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) + DM_DEVICE (ID) ) / diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 7f74ab5246..83a85c6bb2 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -397,15 +397,13 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID BIGSERIAL NOT NULL PRIMARY KEY, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, DESCRIPTION VARCHAR(1000) NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END --