diff --git a/modules/distribution/src/repository/conf/datasources/master-datasources.xml b/modules/distribution/src/repository/conf/datasources/master-datasources.xml index 54c9d384..b874088c 100755 --- a/modules/distribution/src/repository/conf/datasources/master-datasources.xml +++ b/modules/distribution/src/repository/conf/datasources/master-datasources.xml @@ -136,5 +136,27 @@ + + + WSO2IOT_STATS_DB + + jdbc/WSO2IOT_STATS_DB + + The datasource used for analyzer data + + + jdbc:h2:repository/database/IOT_STATS_DB;AUTO_SERVER=TRUE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + diff --git a/modules/distribution/src/repository/jaggeryapps/iot/api/device-api.jag b/modules/distribution/src/repository/jaggeryapps/iot/api/device-api.jag index 2eb45651..00bea457 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/api/device-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iot/api/device-api.jag @@ -31,8 +31,6 @@ var result; if (uriMatcher.match("/{context}/api/device/sketch/")) { sketchType = request.getParameter("type"); - log.error("#################"); - log.error(sketchType); if(!sketchType){log.error("Sketch Type is empty");} var user = session.get(constants.USER_SESSION_KEY); @@ -41,9 +39,9 @@ if (uriMatcher.match("/{context}/api/device/sketch/")) { exit(); } - serviceUrl = "http://localhost:9763/WSO2ConnectedDevices-1.0" + - ".0/FireAlarmDeviceManager/downloadSketch"; - response.sendRedirect(serviceUrl + "?type="+sketchType+"&owner="+user.username); + fireAlarmManagerService = "http://localhost:9763/iotdevices/FireAlarmManager"; + sketchDownloadEndPoint = fireAlarmManagerService + "/downloadSketch"; + response.sendRedirect(sketchDownloadEndPoint + "?type="+sketchType+"&owner="+user.username); exit(); } diff --git a/modules/distribution/src/repository/jaggeryapps/iot/api/stats-api.jag b/modules/distribution/src/repository/jaggeryapps/iot/api/stats-api.jag index 3c1383c2..984946fd 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/api/stats-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iot/api/stats-api.jag @@ -51,11 +51,15 @@ function getUsername() { var user = session.get(constants.USER_SESSION_KEY); if (user) { + log.info("username: "+ user.username); return user.username; } else { + log.info("username is null"); return null; } + + } function getData(user, deviceId, from, to) { diff --git a/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.hbs b/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.hbs index bf798907..86d5fac3 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.hbs @@ -10,6 +10,11 @@ + {{#each devices.devices}} + {{name}}
+ {{id}}

+ {{/each}} +
@@ -20,6 +25,8 @@ + + @@ -90,7 +97,6 @@
001 RaspberryPi
-
{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.js b/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.js index 58f46fd6..6cde4b35 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.js +++ b/modules/distribution/src/repository/jaggeryapps/iot/units/alldevices/alldevices.js @@ -1,4 +1,34 @@ -function onRequest(context){ +function onRequest(context) { context.myDevicePath = "mydevice"; + + var constants = require("/modules/constants.js"); + var httpReq = new XMLHttpRequest(); + var user = session.get(constants.USER_SESSION_KEY); + var endPoint = "http://localhost:9763/iotdevices/DevicesManager/getDevices?username=" + user.username; + // + httpReq.open("GET", endPoint, false); + log.info("%%%%"); + log.info(httpReq.response); + + context.devices = { + "devices": [ + {"name":"device1", + "id" : 1234 + }, + {"name":"device2", + "id" : 5678} + ] + }; return context; -} \ No newline at end of file +} + +// +//{ +// "devices": [ +// {"name":"device1", +// "id" : 1234 +// }, +// {"name":"device2", +// "id" : 5678} +//] +//} diff --git a/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/mydevice.hbs b/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/mydevice.hbs index b346c406..b2613adb 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/mydevice.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/mydevice.hbs @@ -1,74 +1,81 @@ {{#zone "topCss"}} - - + + {{/zone}} {{#zone "topJs"}} - - - - - - + + + + + + {{/zone}} {{#zone "main"}} -
+
-
-
-

Device Cloud

-
-
-
-
-
- - Read Temp
-
- - Switch Fan -
-
- - Switch Bulb -
+
+
+

Device Cloud

+
+
+
+
+
+ + Read Temp
+
+ + Switch Fan +
+
+ + Switch Bulb +
-
- - -
-
+
+ + +
+
-
+
-
-
-

Temperature


- -

-
-
-
-
-

Fan Status


- -

-
-
-
-

Bulb Status


- -

-
+
+
+

Temperature

+
+ +
+
+
+
+
+
+

Fan Status

+
+ +
+
+
+
+
+

Bulb Status

+
+
+
+
- - - - - - + --> + + + + + {{/zone}} diff --git a/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/public/js/graph_util.js b/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/public/js/graph_util.js index 2ce1474e..f6b78fa4 100644 --- a/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/public/js/graph_util.js +++ b/modules/distribution/src/repository/jaggeryapps/iot/units/mydevice/public/js/graph_util.js @@ -38,7 +38,6 @@ var configObject = { $('#date-range1').dateRangePicker(configObject) .bind('datepicker-apply', function (event, dateRange) { - fromDate = dateRange.date1 != "Invalid Date" ? dateRange.date1.getTime() / 1000 : null; toDate = dateRange.date2 != "Invalid Date" ? dateRange.date2.getTime() / 1000 : null; }); @@ -46,6 +45,7 @@ $('#date-range1').dateRangePicker(configObject) $('#btn-draw-graphs').on('click', function () { var deviceId = $('#device-id').val(); console.log(deviceId); + console.log(dateRange.date1.toString()); getStats(deviceId, fromDate, toDate); }) @@ -63,6 +63,10 @@ function getStats(deviceId, from, to) { requestData['to'] = to; } + + console.log("from: "+from); + console.log("to:" +to); + var getStatsRequest = $.ajax({ url: "api/stats", method: "GET",