diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag index 25d50b9c0..a66ff17de 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag @@ -33,6 +33,9 @@ } else if(action === 'getData'){ print(providerAPI.getData(id, type, timeFrom, timeTo)); return; + } else if(action === 'getAlerts'){ + print(providerAPI.getAlerts(id)); + return; } }()); diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js index b74f8d7eb..6927917ad 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js @@ -34,6 +34,7 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; var JS_MIN_VALUE = "-9007199254740992"; var tableName = "ORG_WSO2_GEO_FUSEDSPATIALEVENT"; + var alertTable = "ORG_WSO2_GEO_ALERTSNOTIFICATION"; var typeMap = { "bool": "string", @@ -130,9 +131,9 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; "query": luceneQuery, "start": 0, "count": limit, - "sortBy" : [{ - "field" : "timeStamp", - "sortType" : "ASC" + "sortBy": [{ + "field": "timeStamp", + "sortType": "ASC" }] }; result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage(); @@ -151,4 +152,28 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush; return data; }; + getAlerts = function (deviceId) { + var limit = 50; + var result; + //if there's a filter present, we should perform a Lucene search instead of reading the table + var luceneQuery = 'id:"' + deviceId; + var filter = { + "query": luceneQuery, + "start": 0, + "count": limit, + "sortBy": [{ + "field": "timeStamp", + "sortType": "ASC" + }] + }; + result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage(); + result = JSON.parse(result); + var data = []; + for (var i = 0; i < result.length; i++) { + var values = result[i].values; + data.push(values); + } + return data; + }; + }()); diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js index 10ad7582f..7533bd9fa 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/geo_remote.js @@ -509,38 +509,43 @@ function removeGeoFence(geoFenceElement, id) { } function getAlertsHistory(objectId) { - $.getJSON("/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/get_alerts_history.jag?objectId=" + objectId, function (data) { - var alertsContainer = $('#showAlertsArea').empty(); - $.each(data, 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) { - case "NORMAL": + $.ajax({ + url: '/portal/store/carbon.super/fs/gadget/geo-dashboard/controllers/gadget-controller.jag?action=getAlerts&id=' + objectId, + method: "GET", + contentType: "application/json", + async: false, + success: function (data) { + var alertsContainer = $('#showAlertsArea').empty(); + $.each(data, 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) { + case "NORMAL": // $(alertDOMElement).addClass("list-group-item list-group-item-info"); - return; - case "WARNING": - $(alertDOMElement).addClass("list-group-item list-group-item-warning"); - break; - case "ALERTED": - $(alertDOMElement).addClass("list-group-item list-group-item-danger"); - break; - case "OFFLINE": - $(alertDOMElement).addClass("list-group-item list-group-item-success"); - break; - } - $(alertDOMElement).html(val.INFORMATION); - $(alertDOMElement).css({marginTop: "5px"}); - $(alertDOMElement).attr('onClick', 'showAlertInMap(this)'); - - // Set HTML5 data attributes for later use - $(alertDOMElement).attr('data-id', val.ID); - $(alertDOMElement).attr('data-latitude', val.LATITUDE); - $(alertDOMElement).attr('data-longitude', val.LONGITUDE); - $(alertDOMElement).attr('data-state', val.STATE); - $(alertDOMElement).attr('data-information', val.INFORMATION); - - alertsContainer.append(alertDOMElement); - }); + return; + case "WARNING": + $(alertDOMElement).addClass("list-group-item list-group-item-warning"); + break; + case "ALERTED": + $(alertDOMElement).addClass("list-group-item list-group-item-danger"); + break; + case "OFFLINE": + $(alertDOMElement).addClass("list-group-item list-group-item-success"); + break; + } + $(alertDOMElement).html(val.INFORMATION); + $(alertDOMElement).css({marginTop: "5px"}); + $(alertDOMElement).attr('onClick', 'showAlertInMap(this)'); + + // Set HTML5 data attributes for later use + $(alertDOMElement).attr('data-id', val.ID); + $(alertDOMElement).attr('data-latitude', val.LATITUDE); + $(alertDOMElement).attr('data-longitude', val.LONGITUDE); + $(alertDOMElement).attr('data-state', val.STATE); + $(alertDOMElement).attr('data-information', val.INFORMATION); + + alertsContainer.append(alertDOMElement); + }); + } }); } diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml deleted file mode 100644 index 4c84e8231..000000000 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WSO2_GEO_DB - alerts_history - insert - - - diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml new file mode 100644 index 000000000..f1fb17d2c --- /dev/null +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/Geo-Publisher-RDBMS-GeoAlertNotifications.xml @@ -0,0 +1,66 @@ + + + + + id + false + true + false + false + STRING + + + state + false + true + false + false + STRING + + + information + false + false + false + false + STRING + + + timeStamp + false + true + false + false + LONG + + + latitude + false + false + false + false + DOUBLE + + + longitude + false + false + false + false + DOUBLE + + + type + false + true + false + false + STRING + + + + Geo-Publisher-RDBMS-GeoAlertNotifications:1.0.0 + + false + EVENT_STORE + \ No newline at end of file diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml index 43f32df8c..12af7705a 100755 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Publisher-RDBMS-GeoAlertNotifications_1.0.0/artifact.xml @@ -16,6 +16,6 @@ ~ under the License. --> - - Geo-Publisher-RDBMS-GeoAlertNotifications-1.0.0.xml + + Geo-Publisher-RDBMS-GeoAlertNotifications.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml index f968318fc..0409c62b0 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml @@ -1,55 +1,55 @@ + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginBottom="8dp" android:visibility="gone" /> + android:layout_height="153dp" + android:fillViewport="false" + > + android:layout_height="wrap_content" android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" android:hint="@string/prompt_username" + android:id="@+id/username" + android:inputType="text" + android:maxLines="1" android:singleLine="true" + /> + android:layout_height="wrap_content" android:hint="@string/prompt_password" + android:inputType="textPassword" + android:maxLines="1" android:singleLine="true" + /> + android:layout_width="match_parent" + android:layout_height="wrap_content" android:hint="@string/hostname" + android:id="@+id/hostname" + android:text="https://localhost:8243" + android:inputType="text" + android:maxLines="1" android:singleLine="true"/>