changes to the jaggery app

application-manager-new
Rasika 10 years ago
parent d4283a39e8
commit c0b573e473

@ -136,5 +136,27 @@
</configuration>
</definition>
</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-configuration>

@ -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();
}

@ -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) {

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

@ -1,4 +1,34 @@
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;
}
//
//{
// "devices": [
// {"name":"device1",
// "id" : 1234
// },
// {"name":"device2",
// "id" : 5678}
//]
//}

@ -28,7 +28,8 @@
<span class="middle padding-bottom-double">Switch Fan</span>
</div>
<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>
</div>
@ -44,22 +45,28 @@
<div class="row margin-double">
<div class="chart1">
<h2 class="grey ">Temperature</h2><hr>
<h2 class="grey ">Temperature</h2>
<hr>
<svg></svg>
</div><hr>
</div>
<hr>
</div>
<div class="row margin-double padding-double "></div>
<div class="row margin-double">
<div class="chart2">
<h2 class="grey ">Fan Status</h2><hr>
<h2 class="grey ">Fan Status</h2>
<hr>
<svg></svg>
</div><hr>
</div>
<hr>
</div>
<div class="row margin-double">
<div class="chart3">
<h2 class="grey ">Bulb Status</h2><hr>
<h2 class="grey ">Bulb Status</h2>
<hr>
<svg></svg>
</div><hr>
</div>
<hr>
</div>
</div>
</div>

@ -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",

Loading…
Cancel
Save