Add buttons to join and delete room on the management page

master
Daniel Berteaud 10 years ago
parent e1753fab12
commit dde7079b1c
  1. 36
      public/js/vroom.js
  2. 39
      templates/default/manage_room.html.ep

@ -343,13 +343,15 @@ function initManage(){
var data = {};
function ajaxifySwitch(sw,data){
function sendAction(data,sw){
$.ajax({
url: rootUrl + 'admin/action',
data: data,
error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error');
sw.bootstrapSwitch('toggleState', true);
if (typeof(sw) == 'object'){
sw.bootstrapSwitch('toggleState', true);
}
},
success: function(data) {
if (data.status === 'success'){
@ -357,7 +359,9 @@ function initManage(){
}
else{
$.notify(data.msg, 'error');
sw.bootstrapSwitch('toggleState', true);
if (typeof(sw) == 'object'){
sw.bootstrapSwitch('toggleState', true);
}
}
}
});
@ -375,12 +379,12 @@ function initManage(){
data = {room: room};
if (param === 'lockSwitch'){
data.action = (state) ? 'lock' : 'unlock';
ajaxifySwitch(sw,data);
sendAction(data,sw);
}
else if (param === 'askForNameSwitch'){
data.action = 'askForName';
data.type = (state) ? 'set' : 'unset';
ajaxifySwitch(sw,data);
sendAction(data,sw);
}
else if (param === 'joinPassSwitch'){
if (state){
@ -391,7 +395,7 @@ function initManage(){
else{
data.action = 'setPassword';
data.type = 'join';
ajaxifySwitch(sw,data);
sendAction(data,sw);
}
}
else if (param === 'ownerPassSwitch'){
@ -402,7 +406,7 @@ function initManage(){
else{
data.action = 'setPassword';
data.type = 'owner';
ajaxifySwitch(sw,data);
sendAction(data,sw);
}
}
// Something isn't implemented yet ?
@ -425,7 +429,7 @@ function initManage(){
data.action = 'setPassword';
data.type = 'join';
data.password = pass
ajaxifySwitch($('#joinPassSwitch'), data);
sendAction(data, $('#joinPassSwitch'));
$('#joinPassSwitch').bootstrapSwitch('toggleState', true);
$('#joinPassModal').modal('hide');
}
@ -445,7 +449,7 @@ function initManage(){
data.action = 'setPassword';
data.type = 'owner';
data.password = pass
ajaxifySwitch($('#ownerPassSwitch'), data);
sendAction(data, $('#ownerPassSwitch'));
$('#ownerPassSwitch').bootstrapSwitch('toggleState', true);
$('#persistentModal').modal('hide');
}
@ -454,6 +458,20 @@ function initManage(){
}
});
// Handle room deletion
$('#deleteRoomButton').click(function(){
$('#deleteRoomModal').modal('show');
data.room = $(this).data('room');
});
$('#confirmDeleteButton').click(function(){
data.action = 'deleteRoom';
sendAction(data);
$('#deleteRoomModal').modal('hide');
setTimeout(function(){
window.location.assign(rootUrl + 'admin');
}, 2000);
});
}
// This is the main function called when you join a room

@ -4,6 +4,33 @@
<div class="container-fluid">
%= include 'owner_password_modal'
%= include 'join_password_modal'
<div class="modal fade" role="dialog" id="deleteRoomModal" aria-labelledby="terminateModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title">
<%=l 'DELETE_ROOM' %>
</h4>
</div>
<div class="modal-body">
<p>
<%=l 'YOU_ARE_ABOUT_TO_DELETE_ROOM' %>
</p>
</div>
<div class="modal-footer">
<button id="confirmDeleteButton" class="btn btn-danger">
<%=l 'CONFIRM_DELETE' %>
</button>
<button class="btn btn-default" data-dismiss="modal" data-target="#terminateModal">
<%=l 'CANCEL' %>
</button>
</div>
</div>
</div>
</div>
%= include 'noscript'
<div class="panel panel-default">
<div class="panel-heading">
@ -71,6 +98,18 @@
</tbody>
</table>
</div>
<div class='row'>
<div class="col-sm-6 col-lg-4 col-xl-3 col-sm-offset-3 col-lg-offset-2">
<a class="btn btn-primary btn-lg btn-full" role="button" href="<%= $self->get_url('/') . $room %>">
<%=l 'JOIN_THIS_ROOM' %>
</a>
</div>
<div class="col-sm-6 col-lg-4 col-xl-3 col-sm-offset-3 col-lg-offset-0">
<button class="btn btn-danger btn-lg btn-full" id="deleteRoomButton" data-room="<%= $room %>">
<%=l 'DELETE_THIS_ROOM' %>
</button>
</div>
</div>
</div>
%=include 'js_common'
<script>

Loading…
Cancel
Save