temperature sensors enabled / disabled ui

This commit is contained in:
Senad Uka
2017-01-07 12:40:21 +01:00
parent a06a22857d
commit d1e216b0fd
5 changed files with 129 additions and 27 deletions

View File

@@ -24,12 +24,37 @@ Meteor.zoblak.client = {
if (!controller.features) return false;
return controller.features[feature] === true;
},
sensor_data_collection: function() {
var controllerId = Session.get('controller_id');
return SensorData.find({
controllerId: controllerId
}, {
sort: {
created_at: -1
},
limit: 3
});
},
last_sensor_reading: function() {
var controller = Session.get('controller_id');
var result = null;
if (controller) {
result = Meteor.zoblak.client.sensor_data_collection();
}
if (result && result.count() > 0) {
return result.fetch()[0];
} else {
return {}
}
}
}
Meteor.zoblak.shared = {
valid_temperature: function(value) {
return (parseFloat(value) > -40 && parseFloat(value) < 50);
return (parseFloat(value) > -40 && parseFloat(value) < 50);
}
}
@@ -61,7 +86,7 @@ Meteor.zoblak.server = {
var controller_id = ids[index];
try {
whatToDo(controller_id);
} catch(err) {
} catch (err) {
console.log('Cannot call ', whatToDo, controller_id, err);
}
}