changes to the jaggery app

merge-requests/1/head
Rasika 10 years ago
parent d4283a39e8
commit c0b573e473

@ -136,5 +136,27 @@
</configuration> </configuration>
</definition> </definition>
</datasource> </datasource>
<datasource>
<name>WSO2IOT_STATS_DB</name>
<jndiConfig>
<name>jdbc/WSO2IOT_STATS_DB</name>
</jndiConfig>
<description>The datasource used for analyzer data</description>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/IOT_STATS_DB;AUTO_SERVER=TRUE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
</datasources> </datasources>
</datasources-configuration> </datasources-configuration>

@ -31,8 +31,6 @@ var result;
if (uriMatcher.match("/{context}/api/device/sketch/")) { if (uriMatcher.match("/{context}/api/device/sketch/")) {
sketchType = request.getParameter("type"); sketchType = request.getParameter("type");
log.error("#################");
log.error(sketchType);
if(!sketchType){log.error("Sketch Type is empty");} if(!sketchType){log.error("Sketch Type is empty");}
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
@ -41,9 +39,9 @@ if (uriMatcher.match("/{context}/api/device/sketch/")) {
exit(); exit();
} }
serviceUrl = "http://localhost:9763/WSO2ConnectedDevices-1.0" + fireAlarmManagerService = "http://localhost:9763/iotdevices/FireAlarmManager";
".0/FireAlarmDeviceManager/downloadSketch"; sketchDownloadEndPoint = fireAlarmManagerService + "/downloadSketch";
response.sendRedirect(serviceUrl + "?type="+sketchType+"&owner="+user.username); response.sendRedirect(sketchDownloadEndPoint + "?type="+sketchType+"&owner="+user.username);
exit(); exit();
} }

@ -51,11 +51,15 @@ function getUsername() {
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
if (user) { if (user) {
log.info("username: "+ user.username);
return user.username; return user.username;
} else { } else {
log.info("username is null");
return null; return null;
} }
} }
function getData(user, deviceId, from, to) { function getData(user, deviceId, from, to) {

@ -10,6 +10,11 @@
</div> </div>
</div> </div>
{{#each devices.devices}}
{{name}}<br/>
{{id}}<br/><br/>
{{/each}}
<div class="row margin-double padding-double"> <div class="row margin-double padding-double">
<table class="table table-hover border"> <table class="table table-hover border">
<thead> <thead>
@ -20,6 +25,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr class="border-top"> <tr class="border-top">
<th scope="row">001</th> <th scope="row">001</th>
<td>RaspberryPi</td> <td>RaspberryPi</td>
@ -90,7 +97,6 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
{{/zone}} {{/zone}}

@ -1,4 +1,34 @@
function onRequest(context) { function onRequest(context) {
context.myDevicePath = "mydevice"; 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; return context;
} }
//
//{
// "devices": [
// {"name":"device1",
// "id" : 1234
// },
// {"name":"device2",
// "id" : 5678}
//]
//}

@ -28,7 +28,8 @@
<span class="middle padding-bottom-double">Switch Fan</span> <span class="middle padding-bottom-double">Switch Fan</span>
</div> </div>
<div class="btn-black padding-top padding-bottom" onclick="changeImage()"> <div class="btn-black padding-top padding-bottom" onclick="changeImage()">
<span> <img id="myImage" onclick="changeImage()" src="{{self.publicURL}}/images/bulb-off.png" > </span> <span> <img id="myImage" onclick="changeImage()"
src="{{self.publicURL}}/images/bulb-off.png"> </span>
<span class="middle padding-bottom-double">Switch Bulb</span> <span class="middle padding-bottom-double">Switch Bulb</span>
</div> </div>
@ -44,22 +45,28 @@
<div class="row margin-double"> <div class="row margin-double">
<div class="chart1"> <div class="chart1">
<h2 class="grey ">Temperature</h2><hr> <h2 class="grey ">Temperature</h2>
<hr>
<svg></svg> <svg></svg>
</div><hr> </div>
<hr>
</div> </div>
<div class="row margin-double padding-double "></div> <div class="row margin-double padding-double "></div>
<div class="row margin-double"> <div class="row margin-double">
<div class="chart2"> <div class="chart2">
<h2 class="grey ">Fan Status</h2><hr> <h2 class="grey ">Fan Status</h2>
<hr>
<svg></svg> <svg></svg>
</div><hr> </div>
<hr>
</div> </div>
<div class="row margin-double"> <div class="row margin-double">
<div class="chart3"> <div class="chart3">
<h2 class="grey ">Bulb Status</h2><hr> <h2 class="grey ">Bulb Status</h2>
<hr>
<svg></svg> <svg></svg>
</div><hr> </div>
<hr>
</div> </div>
</div> </div>
</div> </div>

@ -38,7 +38,6 @@ var configObject = {
$('#date-range1').dateRangePicker(configObject) $('#date-range1').dateRangePicker(configObject)
.bind('datepicker-apply', function (event, dateRange) { .bind('datepicker-apply', function (event, dateRange) {
fromDate = dateRange.date1 != "Invalid Date" ? dateRange.date1.getTime() / 1000 : null; fromDate = dateRange.date1 != "Invalid Date" ? dateRange.date1.getTime() / 1000 : null;
toDate = dateRange.date2 != "Invalid Date" ? dateRange.date2.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 () { $('#btn-draw-graphs').on('click', function () {
var deviceId = $('#device-id').val(); var deviceId = $('#device-id').val();
console.log(deviceId); console.log(deviceId);
console.log(dateRange.date1.toString());
getStats(deviceId, fromDate, toDate); getStats(deviceId, fromDate, toDate);
}) })
@ -63,6 +63,10 @@ function getStats(deviceId, from, to) {
requestData['to'] = to; requestData['to'] = to;
} }
console.log("from: "+from);
console.log("to:" +to);
var getStatsRequest = $.ajax({ var getStatsRequest = $.ajax({
url: "api/stats", url: "api/stats",
method: "GET", method: "GET",

Loading…
Cancel
Save