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){
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}
//]
//}

@ -1,74 +1,81 @@
{{#zone "topCss"}}
<link href="{{self.publicURL}}/css/nv.d3.css" rel="stylesheet" />
<link href="{{self.publicURL}}/css/daterangepicker.css" rel="stylesheet"/>
<link href="{{self.publicURL}}/css/nv.d3.css" rel="stylesheet"/>
<link href="{{self.publicURL}}/css/daterangepicker.css" rel="stylesheet"/>
{{/zone}}
{{#zone "topJs"}}
<!-- -->
<script src="{{self.publicURL}}/js/d3.min.js"></script>
<script src="{{self.publicURL}}/js/nv.d3.js"></script>
<script src="{{self.publicURL}}/js/stream_layers.js"></script>
<script src="{{self.publicURL}}/js/moment.min.js"></script>
<script src="{{self.publicURL}}/js/jquery.daterangepicker.js"></script>
<!-- -->
<script src="{{self.publicURL}}/js/d3.min.js"></script>
<script src="{{self.publicURL}}/js/nv.d3.js"></script>
<script src="{{self.publicURL}}/js/stream_layers.js"></script>
<script src="{{self.publicURL}}/js/moment.min.js"></script>
<script src="{{self.publicURL}}/js/jquery.daterangepicker.js"></script>
{{/zone}}
{{#zone "main"}}
<div class="container container-bg white-bg">
<div class="container container-bg white-bg">
<div class=" margin-top-double">
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
<div class="col-lg-12 margin-top-double">
<h1 class="grey ">Device Cloud</h1>
<hr>
</div>
</div>
<div class="row float-right margin-top-minus">
<div class="btn-black padding-top padding-bottom">
<span> <img src="{{self.publicURL}}/images/temp.png" > </span>
<span class="middle padding-bottom-double">Read Temp</span></div>
<div class="btn-black padding-top padding-bottom">
<span> <img src="{{self.publicURL}}/images/fan.png" > </span>
<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 class="middle padding-bottom-double">Switch Bulb</span>
</div >
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
<div class="col-lg-12 margin-top-double">
<h1 class="grey ">Device Cloud</h1>
<hr>
</div>
</div>
<div class="row float-right margin-top-minus">
<div class="btn-black padding-top padding-bottom">
<span> <img src="{{self.publicURL}}/images/temp.png"> </span>
<span class="middle padding-bottom-double">Read Temp</span></div>
<div class="btn-black padding-top padding-bottom">
<span> <img src="{{self.publicURL}}/images/fan.png"> </span>
<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 class="middle padding-bottom-double">Switch Bulb</span>
</div>
<div class="right margin-right">
<input class="right margin-right" id="date-range1" size="60" value="">
<button type="button" id="btn-draw-graphs" class="btn btn-primary">
Draw Graphs
</button>
</div>
</div>
<div class="right margin-right">
<input class="right margin-right" id="date-range1" size="60" value="">
<button type="button" id="btn-draw-graphs" class="btn btn-primary">
Draw Graphs
</button>
</div>
</div>
<div class="clear"></div>
<div class="clear"></div>
<div class="row margin-double">
<div class="chart1">
<h2 class="grey ">Temperature</h2><hr>
<svg></svg>
</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>
<svg></svg>
</div><hr>
</div>
<div class="row margin-double">
<div class="chart3">
<h2 class="grey ">Bulb Status</h2><hr>
<svg></svg>
</div><hr>
</div>
<div class="row margin-double">
<div class="chart1">
<h2 class="grey ">Temperature</h2>
<hr>
<svg></svg>
</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>
<svg></svg>
</div>
<hr>
</div>
<div class="row margin-double">
<div class="chart3">
<h2 class="grey ">Bulb Status</h2>
<hr>
<svg></svg>
</div>
<hr>
</div>
</div>
<!-- TODO : Move these scripts to a bottomJs zone.
</div>
<!-- TODO : Move these scripts to a bottomJs zone.
When they are moved the script tags get repeated for some reason :-(
-->
<script src="{{self.publicURL}}/js/graph_util.js"></script>
<script src="{{self.publicURL}}/js/bulb.js"></script>
<script src="{{self.publicURL}}/js/temperature_graph.js"></script>
<script src="{{self.publicURL}}/js/fan_status_graph.js"></script>
<script src="{{self.publicURL}}/js/bulb_status_graph.js"></script>
-->
<script src="{{self.publicURL}}/js/graph_util.js"></script>
<script src="{{self.publicURL}}/js/bulb.js"></script>
<script src="{{self.publicURL}}/js/temperature_graph.js"></script>
<script src="{{self.publicURL}}/js/fan_status_graph.js"></script>
<script src="{{self.publicURL}}/js/bulb_status_graph.js"></script>
{{/zone}}

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