Fix error handling for lock/unlock

master
Daniel Berteaud 11 years ago
parent dec8da6a44
commit 96d8a0eaa6
  1. 22
      public/js/vroom.js
  2. 7
      public/vroom.pl

@ -580,20 +580,24 @@ function initVroom(room) {
room: roomName room: roomName
}, },
error: function(data) { error: function(data) {
var msg = (data && data.msg) ? data.msg : locale.ERROR_OCCURED; $.notify(locale.ERROR_OCCURED, 'error');
$.notify(msg, 'error');
}, },
success: function(data) { success: function(data) {
$.notify(data.msg, 'info'); if (data.status == 'success'){
if (action === 'lock'){ $.notify(data.msg, 'info');
$("#lockLabel").addClass('btn-danger'); if (action === 'lock'){
webrtc.sendToAll('room_locked', {}); $("#lockLabel").addClass('btn-danger');
webrtc.sendToAll('room_locked', {});
}
else{
$("#lockLabel").removeClass('btn-danger');
webrtc.sendToAll('room_unlocked', {});
}
} }
else{ else{
$("#lockLabel").removeClass('btn-danger'); $.notify(data.msg, 'error');
webrtc.sendToAll('room_unlocked', {});
} }
} }
}); });
}); });

@ -517,14 +517,15 @@ post '/action' => sub {
unless ($res){ unless ($res){
return $self->render( return $self->render(
json => { json => {
msg => $self->l('ERROR_OCCURED'), msg => $self->l('ERROR_OCCURED'),
status => 'error'
}, },
status => '500'
); );
} }
return $self->render( return $self->render(
json => { json => {
msg => $success, msg => $success,
status => 'success'
} }
); );
} }

Loading…
Cancel
Save