ui and settings ready

This commit is contained in:
Senad Uka
2016-10-15 15:58:41 +02:00
parent a85be6c2b6
commit 31b355f381
15 changed files with 269 additions and 16 deletions

41
app/client/alarm/alarm.js Normal file
View File

@@ -0,0 +1,41 @@
function sensor_data_collection() {
var controllerId = Session.get('controller_id');
return SensorData.find({
controllerId: controllerId
}, {
sort: {
created_at: -1
},
limit: 3
});
}
function last_sensor_reading() {
var controller = Session.get('controller_id');
var result = null;
if (controller) {
result = sensor_data_collection();
}
if (result && result.count() > 0) {
return result.fetch()[0];
} else {
return {}
}
}
Template.alarm.helpers({
last_reading: last_sensor_reading,
pretty_time: function(time) {
return moment(time).format("DD.MM.YYYY, HH:mm")
}
});
Template.alarm.events({
'click #run_alarm_settings': function() {
Modal.show('alarm_settings');
}
});
Template.alarm.helpers({
});