changes to the jaggery app

application-manager-new
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}
//]
//}

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

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