ui and settings ready
This commit is contained in:
41
app/client/alarm/alarm.js
Normal file
41
app/client/alarm/alarm.js
Normal 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({
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user