picture display ready
This commit is contained in:
49
app/client/surveillance.js
Normal file
49
app/client/surveillance.js
Normal file
@@ -0,0 +1,49 @@
|
||||
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');
|
||||
result = Picture.findOne({
|
||||
controller_id: controllerId
|
||||
});
|
||||
console.log("rez je", result);
|
||||
if (!result) {
|
||||
result = {}
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Template.surveillance.helpers({
|
||||
controller_state: controller_state,
|
||||
picture_src: function() {
|
||||
var picture_base64 = picture().picture_base64;
|
||||
var picture_src = '/images/noImage.png';
|
||||
if (picture_base64) {
|
||||
picture_src = 'data:image/jpeg;charset=utf-8;base64,' + picture_base64;
|
||||
}
|
||||
return picture_src;
|
||||
},
|
||||
picture_time: function() {
|
||||
var picture_entry = picture();
|
||||
if (picture_entry) {
|
||||
return moment(picture_entry.time).fromNow();
|
||||
} else {
|
||||
return "Nikad!";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.surveillance.events({
|
||||
'click #request_new_picture': function() {
|
||||
var controller_id = Session.get('controller_id');
|
||||
Meteor.call('requestNewPicture', controller_id)
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user