saving and temperature works
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<h1> Temperatura </h1>
|
||||
<div class="jumbotron text-center center-block" >
|
||||
{{#with last_reading}}
|
||||
<div class="huge_text"> {{temperatureValue}}°C</div>
|
||||
<div class="huge_text"> {{ all_temperatures }}</div>
|
||||
<div>{{pretty_time created_at}}</div>
|
||||
{{/with}}
|
||||
<button id="run_alarm_settings" class="btn btn-default"> <i class="fa fa-wrench"></i> Podešavanje </button>
|
||||
@@ -27,6 +27,15 @@ Template.alarm.helpers({
|
||||
last_reading: last_sensor_reading,
|
||||
pretty_time: function(time) {
|
||||
return moment(time).format("DD.MM.YYYY, HH:mm")
|
||||
},
|
||||
all_temperatures: function() {
|
||||
var result="";
|
||||
var temperatures = last_sensor_reading().temperatures;
|
||||
|
||||
for(var i in temperatures) {
|
||||
result += '' + parseFloat(temperatures[i]).toFixed(1) + ' °C ';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
|
||||
Template.settings.helpers({
|
||||
timeSelected: function(time) {
|
||||
var config = controller_state().config;
|
||||
return config.automaticTimeOfDay == time;
|
||||
},
|
||||
|
||||
dayChecked: function(day) {
|
||||
var config = controller_state().config;
|
||||
var days = config.automaticDaysOfWeek || [];
|
||||
return days.includes(day)
|
||||
},
|
||||
|
||||
manualInflowChecked: function(day) {
|
||||
var config = controller_state().config;
|
||||
return config.manualInflow;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
Template.settings.events({
|
||||
'click #save_settings': function() {
|
||||
var instance = Template.instance();
|
||||
selectedTime = instance.$('#time_of_day').val();
|
||||
selectedDays = [];
|
||||
instance.$('.day_checkbox').each(function() {
|
||||
if (this.checked) {
|
||||
selectedDays.push(instance.$(this).val());
|
||||
}
|
||||
});
|
||||
var manualInflow = instance.$('#manual_inflow').is(':checked');
|
||||
console.log("MI ", manualInflow);
|
||||
var controller_id = Session.get('controller_id');
|
||||
Meteor.call('saveControllerConfig', controller_id, selectedTime, selectedDays, manualInflow);
|
||||
}
|
||||
});
|
||||
|
||||
Template.sensorData.helpers({
|
||||
created_at_formatted: function() {
|
||||
return moment(this.created_at).format("DD.MM.YYYY, HH:mm")
|
||||
}
|
||||
});
|
||||
@@ -17,25 +17,25 @@
|
||||
<td>ako je temperatura niža od
|
||||
</td>
|
||||
<td>
|
||||
<input name="min_temperature" type="number" min="-20" max="50" />°C</td>
|
||||
<input required name="min_temperature" id="min_temperature" type="number" min="-20" max="50" step="0.1" value={{ config 'minTemperature'}} />°C</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ako je temperatura viša od
|
||||
</td>
|
||||
<td>
|
||||
<input name="max_temperature" type="number" min="-20" max="50" />°C</td>
|
||||
<input required name="max_temperature" id="max_temperature" type="number" min="-20" max="50" step="0.1" value={{ config 'maxTemperature'}} />°C</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ako se Zoblak Alarm Kutija ne javi
|
||||
</td>
|
||||
<td>
|
||||
<input name="timeout_box" type="number" min="1" max="90" /> minuta </td>
|
||||
<input required name="timeout_box" id="timeout_box" type="number" min="1" max="90" value={{ config 'timeoutBox'}} /> minuta </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ako se bar jedan mobitel ne javi
|
||||
</td>
|
||||
<td>
|
||||
<input name="timeout_phone" type="number" min="1" max="90" /> minuta </td>
|
||||
<input required name="timeout_phone" id="timeout_phone" type="number" min="1" max="90" value={{ config 'timeoutPhone'}} /> minuta </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -46,27 +46,27 @@
|
||||
<td>1.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_1" type="text" placeholder="06xxxxxxxx" />
|
||||
<input required name="sms1" type="tel" id="sms1" placeholder="+3876xxxxxxxx" value={{ config 'sms1'}} />
|
||||
</td>
|
||||
<tr>
|
||||
<td>2.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_2" type="text" placeholder="06xxxxxxxx" />
|
||||
<input required name="sms2" type="tel" id="sms2" placeholder="+3876xxxxxxxx" value={{ config 'sms2'}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_3" type="text" placeholder="06xxxxxxxx" />
|
||||
<input required name="sms3" type="tel" id="sms3" placeholder="+3876xxxxxxxx" value={{ config 'sms3'}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_4" type="text" placeholder="06xxxxxxxx" />
|
||||
<input required name="sms4" type="tel" id="sms4" placeholder="+3876xxxxxxxx" value={{ config 'sms4'}}/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
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")
|
||||
}
|
||||
});
|
||||
@@ -6,27 +6,3 @@ Template.body.helpers({
|
||||
return Session.get("templateName");
|
||||
}
|
||||
});
|
||||
|
||||
controller_state = function() {
|
||||
var controller = Session.get('controller_id');
|
||||
var result = {}
|
||||
if (controller) {
|
||||
result = ControllerState.findOne({
|
||||
controller_id: controller
|
||||
});
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = {}
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
accessible = function(feature) {
|
||||
var controller = controller_state();
|
||||
|
||||
console.log('cotnroller ', controller);
|
||||
if (!controller.features) return false;
|
||||
|
||||
return controller.features[feature] === true;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
|
||||
Template.settings.helpers({
|
||||
timeSelected: function(time) {
|
||||
var config = controller_state().config;
|
||||
var config = Meteor.zoblak.client.controller_state().config;
|
||||
return config.automaticTimeOfDay == time;
|
||||
},
|
||||
|
||||
dayChecked: function(day) {
|
||||
var config = controller_state().config;
|
||||
var config = Meteor.zoblak.client.controller_state().config;
|
||||
var days = config.automaticDaysOfWeek || [];
|
||||
return days.includes(day)
|
||||
},
|
||||
|
||||
manualInflowChecked: function(day) {
|
||||
var config = controller_state().config;
|
||||
var config = Meteor.zoblak.client.controller_state().config;
|
||||
return config.manualInflow;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Tracker.autorun(function() {
|
||||
});
|
||||
|
||||
Router.route('/', function() {
|
||||
if (accessible('start')) {
|
||||
if (Meteor.zoblak.client.accessible('start')) {
|
||||
Session.set('templateName', 'start');
|
||||
} else {
|
||||
Session.set('templateName', 'no_access')
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
function controller_state() {
|
||||
var controllerId = Session.get('controller_id');
|
||||
result = ControllerState.findOne({});
|
||||
if (!result) {
|
||||
result = {}
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
function sensor_data_collection() {
|
||||
var controllerId = Session.get('controller_id');
|
||||
@@ -44,7 +36,7 @@ Template.state.helpers({
|
||||
|
||||
bucket_image: function() {
|
||||
var sensor = last_sensor_reading();
|
||||
var stateObject = controller_state();
|
||||
var stateObject = Meteor.zoblak.client.controller_state();
|
||||
if (sensor) {
|
||||
if (parseInt(sensor.tankFull) === 0 && stateObject.state.in_valve === 'open' && stateObject.state.out_valve === 'closed') return "/images/barrellFillingUp.png";
|
||||
else if (parseInt(sensor.tankFull) === 1 && (stateObject.state.out_valve === 'closed')) return "/images/barrellFull.png";
|
||||
@@ -74,7 +66,7 @@ Template.state.helpers({
|
||||
},
|
||||
|
||||
water_now_button_class: function() {
|
||||
var stateObject = controller_state();
|
||||
var stateObject = Meteor.zoblak.client.controller_state();
|
||||
if (stateObject.state && (stateObject.state.out_valve === 'open' || stateObject.state.out_valve === 'opening')) {
|
||||
return 'hidden btn btn-success';
|
||||
} else {
|
||||
@@ -82,7 +74,7 @@ Template.state.helpers({
|
||||
}
|
||||
},
|
||||
stop_button_class: function() {
|
||||
var stateObject = controller_state();
|
||||
var stateObject = Meteor.zoblak.client.controller_state();
|
||||
if (stateObject.state && (stateObject.state.out_valve === 'closed' || stateObject.state.out_valve === 'closing')) {
|
||||
return 'hidden btn btn-success';
|
||||
} else {
|
||||
@@ -91,7 +83,7 @@ Template.state.helpers({
|
||||
},
|
||||
|
||||
start_inflow_button_class: function() {
|
||||
var stateObject = controller_state();
|
||||
var stateObject = Meteor.zoblak.client.controller_state();
|
||||
if(stateObject.config && stateObject.config.manualInflow && stateObject.state.out_valve === 'closed' && ( stateObject.state.in_valve === 'closed' || stateObject.state.in_valve === 'closing')) {
|
||||
return 'btn btn-danger'
|
||||
} else {
|
||||
@@ -100,7 +92,7 @@ Template.state.helpers({
|
||||
},
|
||||
|
||||
stop_inflow_button_class: function() {
|
||||
var stateObject = controller_state();
|
||||
var stateObject = Meteor.zoblak.client.controller_state();
|
||||
if(stateObject.config && stateObject.config.manualInflow && stateObject.state.out_valve === 'closed' && ( stateObject.state.in_valve === 'open' || stateObject.state.in_valve === 'opening')) {
|
||||
return 'btn btn-danger'
|
||||
} else {
|
||||
@@ -159,7 +151,7 @@ Template.state.events({
|
||||
},
|
||||
|
||||
'click #bucket_image': function() {
|
||||
Modal.show('state_details', controller_state());
|
||||
Modal.show('state_details', Meteor.zoblak.client.controller_state());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
function controller_state() {
|
||||
var controllerId = Session.get('controller_id');
|
||||
result = ControllerState.findOne({});
|
||||
if (!result) {
|
||||
result = {}
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
function picture() {
|
||||
var controllerId = Session.get('controller_id');
|
||||
|
||||
@@ -15,7 +15,7 @@ Template.tabs.helpers({
|
||||
return Session.get('controller_id');
|
||||
},
|
||||
|
||||
accessible: accessible
|
||||
accessible: Meteor.zoblak.client.accessible
|
||||
});
|
||||
|
||||
Template.tabs.events({
|
||||
|
||||
Reference in New Issue
Block a user