42 lines
776 B
JavaScript
42 lines
776 B
JavaScript
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({
|
|
|
|
});
|