From 7c80ca3358eb7977231637cf84d4b356ecb08d98 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 29 Jan 2015 21:59:30 +0100 Subject: [PATCH] Implement room removal in the admin area --- lib/Vroom/I18N/en.pm | 2 +- lib/Vroom/I18N/fr.pm | 2 +- public/js/vroom.js | 30 +++++++++++++++++- templates/default/admin.html.ep | 2 +- templates/default/delete_room_modal.html.ep | 34 +++++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 templates/default/delete_room_modal.html.ep diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index 4b3793e..e3f1926 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -158,7 +158,7 @@ our %Lexicon = ( "ROOM_NOW_PERSISTENT" => "This room is now persistent", "ROOM_NO_MORE_PERSISTENT" => "This rooms isn't persistent anymore", "EMAIL_INVITE" => "Email invitation", - "DELETE_THIS_ROOM" => "Delete this room", + "DELETE" => "Delete", "CONFIRM_DELETE" => "Confirm delation", "HELP_SET_DISPLAY_NAME" => "This field lets you type your name which will be displayed for other participants. " . "It must be set before you can use the chat. no need to validate anything, the name " . diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index 2aee2fa..a7f6317 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -164,7 +164,7 @@ our %Lexicon = ( "ROOM_NOW_PERSISTENT" => "Ce salon est maintenant persistant", "ROOM_NO_MORE_PERSISTENT" => "Ce salon n'est plus persistant", "EMAIL_INVITE" => "Invitation par email", - "DELETE_THIS_ROOM" => "Supprimer ce salon", + "DELETE" => "Supprimer", "CONFIRM_DELETE" => "Confirmer la suppression", "HELP_SET_DISPLAY_NAME" => "Ce champs vous permet de saisir le nom qui sera affiché pour les autres personnes. " . "Il est obligatoire avant de pouvoir utiliser le tchat. Pas besoin de valider quoi " . diff --git a/public/js/vroom.js b/public/js/vroom.js index 7db4634..cc742c5 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -384,7 +384,7 @@ function initAdmin(){ // Update display of room list function updateRoomList(filter, min, max){ - $('#deviceList').html(''); + $('#roomList').html(''); var filterRe = new RegExp(filter, "gi"); var i = 0; matches = 0; @@ -486,8 +486,36 @@ function initAdmin(){ getRoomConf(roomName); }); + $(document).on('click', '.btn-remove', function(){ + roomName = $(this).data('room'); + $('#deleteRoomModal').modal('show'); + }); + // Get room list right after loading the page getRooms(); + + // Delete room form + $('#deleteRoomForm').submit(function(e){ + e.preventDefault(); + $.ajax({ + data: { + req: JSON.stringify({ + action: 'delete_room', + param: { + room: roomName, + } + }) + }, + error: function(data){ + $.notify(locale.ERROR_OCCURRED, 'error'); + }, + success: function(data){ + $.notify(data.msg, 'success'); + getRooms(); + $('#deleteRoomModal').modal('hide'); + } + }); + }); } // This is the main function called when you join a room diff --git a/templates/default/admin.html.ep b/templates/default/admin.html.ep index dee4527..b014149 100644 --- a/templates/default/admin.html.ep +++ b/templates/default/admin.html.ep @@ -4,7 +4,7 @@
%= include 'noscript' %= include 'configure_modal' -%= include 'invite_modal' +%= include 'delete_room_modal'
diff --git a/templates/default/delete_room_modal.html.ep b/templates/default/delete_room_modal.html.ep new file mode 100644 index 0000000..b52541c --- /dev/null +++ b/templates/default/delete_room_modal.html.ep @@ -0,0 +1,34 @@ + +