saving and temperature works
This commit is contained in:
53
app/client/alarm_settings.js
Normal file
53
app/client/alarm_settings.js
Normal file
@@ -0,0 +1,53 @@
|
||||
controller_state = function() {
|
||||
var controller = Session.get('controller_id');
|
||||
var result = {}
|
||||
if (controller) {
|
||||
result = ControllerState.findOne({
|
||||
controller_id: controller
|
||||
});
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = {}
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
config = function() {
|
||||
return Meteor.zoblak.client.controller_state().config;
|
||||
}
|
||||
|
||||
|
||||
Template.alarm_settings.helpers({
|
||||
config: function(property) {
|
||||
|
||||
console.log('asking for property', property);
|
||||
console.log('config is', config());
|
||||
var result = config()[property];
|
||||
console.log('returning', result);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
Template.alarm_settings.events({
|
||||
'click #save_settings': function() {
|
||||
var controller_id = Meteor.zoblak.client.controller_state().controller_id;
|
||||
var instance = Template.instance();
|
||||
var minTemperature = instance.$('#min_temperature').val();
|
||||
var maxTemperature = instance.$('#max_temperature').val();
|
||||
var timeoutBox = instance.$('#timeout_box').val();
|
||||
var timeoutPhone = instance.$('#timeout_phone').val();
|
||||
var sms1 = instance.$('#sms1').val();
|
||||
var sms2 = instance.$('#sms2').val();
|
||||
var sms3 = instance.$('#sms3').val();
|
||||
var sms4 = instance.$('#sms4').val();
|
||||
|
||||
Meteor.call('saveAlarmSettings', controller_id, minTemperature, maxTemperature, timeoutBox, timeoutPhone, [sms1, sms2, sms3, sms4]);
|
||||
}
|
||||
});
|
||||
|
||||
Template.sensorData.helpers({
|
||||
created_at_formatted: function() {
|
||||
return moment(this.created_at).format("DD.MM.YYYY, HH:mm")
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user