ui and settings ready
This commit is contained in:
14
app/client/alarm/alarm.html
Normal file
14
app/client/alarm/alarm.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<template name="alarm">
|
||||
|
||||
<div class="hello">
|
||||
<h1> Temperatura </h1>
|
||||
<div class="jumbotron text-center center-block" >
|
||||
{{#with last_reading}}
|
||||
<div class="huge_text"> {{temperatureValue}}°C</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>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
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({
|
||||
|
||||
});
|
||||
84
app/client/alarm/alarm_settings.html
Normal file
84
app/client/alarm/alarm_settings.html
Normal file
@@ -0,0 +1,84 @@
|
||||
<template name="alarm_settings">
|
||||
<div class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Podešavanje Alarma</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<h3>Alarmiraj:</h3>
|
||||
<table class="table">
|
||||
|
||||
|
||||
<tr>
|
||||
<td>ako je temperatura niža od
|
||||
</td>
|
||||
<td>
|
||||
<input name="min_temperature" type="number" min="-20" max="50" />°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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ako se Zoblak Alarm Kutija ne javi
|
||||
</td>
|
||||
<td>
|
||||
<input name="timeout_box" type="number" min="1" max="90" /> 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>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<h3>U slučaju kritične situacije - javi SMS-om na telefone: </h3>
|
||||
<table class="table">
|
||||
<td>1.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_1" type="text" placeholder="06xxxxxxxx" />
|
||||
</td>
|
||||
<tr>
|
||||
<td>2.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_2" type="text" placeholder="06xxxxxxxx" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_3" type="text" placeholder="06xxxxxxxx" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4.
|
||||
</td>
|
||||
<td>
|
||||
<input name="sms_4" type="text" placeholder="06xxxxxxxx" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="save_settings" class="btn btn-default" name="save_settings" data-dismiss="modal">Zapamti</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
43
app/client/alarm/alarm_settings.js
Normal file
43
app/client/alarm/alarm_settings.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
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")
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user