picture display ready

This commit is contained in:
Senad Uka
2016-10-08 16:02:59 +02:00
parent d469c91e3e
commit 4b2b9526de
10 changed files with 97 additions and 22 deletions

View File

@@ -130,21 +130,6 @@ Api.addRoute('picture/:id', {
'time': new Date()
}
});
},
get: function() {
var id = this.urlParams.id;
var res = this.response;
var picture_src = "/images/noImage.png";
var pictureEntry = Picture.findOne({
controller_id: id
});
if (pictureEntry) {
var imageData = pictureEntry.picture_base64;
picture_src = "data:image/jpeg;charset=utf-8;base64," + imageData;
}
return {
picture: picture_src
};
}
});

View File

@@ -52,6 +52,17 @@ function setInValveTo(controller_id, nextState) {
}
function requestNewPicture(controller_id) {
var state = controller_state(controller_id);
ControllerState.update(state._id, {
'$set': {
'state.picture_requested': 'true',
'time': new Date(),
'set_by': 'server'
}
});
};
function openInValve(controller_id) {
var state = controller_state(controller_id);
var config = state.config;
@@ -174,5 +185,6 @@ Meteor.methods({
openInValve: openInValve,
closeInValve: closeInValve,
clearLog: clearLog,
saveControllerConfig: saveControllerConfig
saveControllerConfig: saveControllerConfig,
requestNewPicture: requestNewPicture
});

View File

@@ -16,3 +16,11 @@ Meteor.publish("controller_state", function(controllerId) {
controller_id: controllerId
});
});
// This code only runs on the server
Meteor.publish("pictures", function(controllerId) {
return Picture.find({
controller_id: controllerId
});
});