added back watering route and hopefully fixed bug with graph

This commit is contained in:
Senad Uka
2017-05-24 18:45:37 +02:00
parent 81652c8c64
commit 947a9c6a43
4 changed files with 12 additions and 8 deletions

View File

@@ -29,12 +29,14 @@ var createChart = function() {
self.temperatures = [];
Tracker.autorun(function() {
sensor_data_collection().forEach(function(sensorReading) {
self.labels.push(moment(sensorReading.lastBoxContact).format('ddd DD.MM. HH:mm:ss'));
for (var i = 0; i < sensorReading.temperatures.length; i++) {
if (!self.temperatures[i]) {
self.temperatures[i] = [];
if (sensorReading.temperatures) {
self.labels.push(moment(sensorReading.lastBoxContact).format('ddd DD.MM. HH:mm:ss'));
for (var i = 0; i < sensorReading.temperatures.length; i++) {
if (!self.temperatures[i]) {
self.temperatures[i] = [];
}
self.temperatures[i].push(sensorReading.temperatures[i]);
}
self.temperatures[i].push(sensorReading.temperatures[i]);
}
});
});
@@ -187,7 +189,6 @@ Template.log.onRendered(function() {
Template.log.resized = function() {
createChart();
return Session.get('resize');
}

View File

@@ -1,5 +1,7 @@
Tracker.autorun(function() {
var id = Session.get('controller_id');
Session.set("orientation", new Date());
Session.set("resize", new Date());
if (id) {
Meteor.subscribe("sensor_data", id);
Meteor.subscribe("controller_state", id);
@@ -9,6 +11,6 @@ Tracker.autorun(function() {
Session.set("orientation", new Date());
});
window.addEventListener('resize', function(){
Session.set("resized", new Date());
Session.set("resize", new Date());
});
});

View File

@@ -34,7 +34,7 @@ function saveParamsAndGo(where) {
Template.tabs.events({
'click .start': function() {
saveParamsAndGo('/');
saveParamsAndGo('/water');
},
'click .weather': function() {
saveParamsAndGo('/weather');

View File

@@ -19,6 +19,7 @@ function safeRoute(route) {
}
Router.route('/', safeRoute('alarm'));
Router.route('/water', safeRoute('start'));
Router.route('/alarm', safeRoute('alarm'));
Router.route('/log', safeRoute('log'));
Router.route('/surveillance', safeRoute('surveillance'));