From 69c3cd3b5a69fc2120ef65c45ce1aa5dee1421b8 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 6 Mar 2015 18:30:03 +0100 Subject: [PATCH] Display number of members in room in the admin area The number should be quite accurate, as it's now counting socket.io peers --- lib/Vroom/I18N/en.pm | 1 + lib/Vroom/I18N/fr.pm | 1 + public/js/vroom.js | 1 + templates/default/admin_manage_rooms.html.ep | 3 +++ vroom.pl | 7 ++++++- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index 50d4bae..d658cf7 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -156,6 +156,7 @@ our %Lexicon = ( "EMAIL_INVITE" => "Email invitation", "DELETE" => "Delete", "CONFIRM_DELETE" => "Confirm delation", + "ROOM_WILL_BE_DELETED" => "This room, and its configuration will be deleted", "LOGOUT" => "Leave the room", "LEAVE_THIS_ROOM" => "Leave the room", "ARE_YOU_SURE_YOU_WANT_TO_LEAVE" => "Are you sure you want to leave this room ?", diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index be3e484..73d1cd3 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -162,6 +162,7 @@ our %Lexicon = ( "EMAIL_INVITE" => "Invitation par email", "DELETE" => "Supprimer", "CONFIRM_DELETE" => "Confirmer la suppression", + "ROOM_WILL_BE_DELETED" => "Le salon, ainsi que sa configuration seront définitivement supprimés", "LOGOUT" => "Quitter le salon", "LEAVE_THIS_ROOM" => "Quitter le salon", "ARE_YOU_SURE_YOU_WANT_TO_LEAVE" => "Êtes-vous sûr de vouloir quitter le salon ?", diff --git a/public/js/vroom.js b/public/js/vroom.js index c3a3869..951744c 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -423,6 +423,7 @@ function initAdminRooms(){ .append($('').html(stringEscape(obj.name))) .append($('').html(stringEscape(create)).addClass('hidden-xs')) .append($('').html(stringEscape(activity)).addClass('hidden-xs')) + .append($('').html(obj.members).addClass('hidden-xs')) .append($('') .append($('
').addClass('btn-group') .append($('').addClass('btn btn-default').attr('href',rootUrl + obj.name) diff --git a/templates/default/admin_manage_rooms.html.ep b/templates/default/admin_manage_rooms.html.ep index c8c6985..05cfcf6 100644 --- a/templates/default/admin_manage_rooms.html.ep +++ b/templates/default/admin_manage_rooms.html.ep @@ -34,6 +34,9 @@ <%=l 'LAST_ACTIVITY' %> + + <%=l 'NUMBER_OF_PARTICIPANTS' %> + <%=l 'MANAGE' %> diff --git a/vroom.pl b/vroom.pl index 71f7328..c8044e2 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1290,11 +1290,16 @@ any '/api' => sub { # Here are method not tied to a room if ($req->{action} eq 'get_room_list'){ my $rooms = $self->get_room_list; - # Blank out a few param we don't need foreach my $r (keys %{$rooms}){ + # Blank out a few param we don't need foreach my $p (qw/join_password owner_password owner token etherpad_group/){ delete $rooms->{$r}->{$p}; } + # Count active users + $rooms->{$r}->{members} = 0; + foreach my $peer (keys %$peers){ + $rooms->{$r}->{members}++ if ($peers->{$peer}->{room} eq $r); + } } return $self->render( json => {