Manage room persistence in admin area

master
Daniel Berteaud 10 years ago
parent 244bafe336
commit 5e82b9c529
  1. 3
      public/js/vroom.js
  2. 10
      templates/default/configure_modal.html.ep
  3. 25
      vroom.pl

@ -287,6 +287,7 @@ $('#configureRoomForm').submit(function(e){
$('#joinPass').val() : false, $('#joinPass').val() : false,
ownerPass = ($('#ownerPassSet').bootstrapSwitch('state')) ? ownerPass = ($('#ownerPassSet').bootstrapSwitch('state')) ?
$('#ownerPass').val() : false, $('#ownerPass').val() : false,
persistent = $('#persistentSet').bootstrapSwitch('state'),
emails = []; emails = [];
$('input[name="emails[]"]').each(function(){ $('input[name="emails[]"]').each(function(){
emails.push($(this).val()); emails.push($(this).val());
@ -301,6 +302,7 @@ $('#configureRoomForm').submit(function(e){
ask_for_name: askForName, ask_for_name: askForName,
join_password: joinPass, join_password: joinPass,
owner_password: ownerPass, owner_password: ownerPass,
persistent: persistent,
emails: emails emails: emails
} }
}) })
@ -517,6 +519,7 @@ function initAdmin(){
$('#askForNameSet').bootstrapSwitch('state', data.ask_for_name == 'yes'); $('#askForNameSet').bootstrapSwitch('state', data.ask_for_name == 'yes');
$('#joinPassSet').bootstrapSwitch('state', data.join_auth == 'yes'); $('#joinPassSet').bootstrapSwitch('state', data.join_auth == 'yes');
$('#ownerPassSet').bootstrapSwitch('state', data.owner_auth == 'yes'); $('#ownerPassSet').bootstrapSwitch('state', data.owner_auth == 'yes');
$('#persistentSet').bootstrapSwitch('state', data.persistent == 'yes');
$('#configureModal').modal('show'); $('#configureModal').modal('show');
} }
}); });

@ -71,6 +71,16 @@
<input id="ownerPassConfirm" type="password" class="form-control" placeholder="<%=l 'CONFIRM_PASSWORD' %>"/> <input id="ownerPassConfirm" type="password" class="form-control" placeholder="<%=l 'CONFIRM_PASSWORD' %>"/>
</div> </div>
</div> </div>
<% if (defined(stash("admin")) && stash("admin") eq '1'){ %>
<div class="form-group">
<label class="col-sm-4 control-label" for="persistentSet">
<%=l 'PERSISTENT' %>
</label>
<div class="col-sm-8">
<input type="checkbox" class="bs-switch" id="persistentSet">
</div>
</div>
<% } %>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label" for="emailNotifications"> <label class="col-sm-4 control-label" for="emailNotifications">
<%=l 'NOTIFICATION_ON_JOIN' %> <%=l 'NOTIFICATION_ON_JOIN' %>

@ -1028,29 +1028,15 @@ get '/about' => sub {
get '/help' => 'help'; get '/help' => 'help';
# Route for the admin pages # Route for the admin pages
get '/admin/:room' => { room => '' } => sub { get '/admin' => sub {
my $self = shift; my $self = shift;
my $room = $self->stash('room');
# Someone accessing /admin is considered an admin # Someone accessing /admin is considered an admin
# For now, the auth is handled outside of VROOM itself # For now, the auth is handled outside of VROOM itself
$self->login; $self->login;
$self->make_key_admin($self->session('key')); $self->make_key_admin($self->session('key'));
if ($room eq ''){
$self->purge_rooms; $self->purge_rooms;
return $self->render('admin'); return $self->render('admin',
} admin => 1
my $data = $self->get_room_by_name($room);
if (!$data){
return $self->render('error',
err => 'ERROR_ROOM_s_DOESNT_EXIST',
msg => sprintf ($self->l("ERROR_ROOM_s_DOESNT_EXIST"), $room),
room => $room
);
}
$self->purge_participants;
return $self->render('manage_room',
room => $room,
participants => scalar keys %{$self->get_participants_list($room)}
); );
}; };
@ -1407,6 +1393,10 @@ any '/api' => sub {
elsif ($req->{action} eq 'update_room_conf'){ elsif ($req->{action} eq 'update_room_conf'){
$room->{locked} = ($req->{param}->{locked}) ? '1' : '0'; $room->{locked} = ($req->{param}->{locked}) ? '1' : '0';
$room->{ask_for_name} = ($req->{param}->{ask_for_name}) ? '1' : '0'; $room->{ask_for_name} = ($req->{param}->{ask_for_name}) ? '1' : '0';
# Room persistence can only be set by admins
if ($self->key_can_do_this(token => $token, action => 'set_persistent')){
$room->{persistent} = ($req->{param}->{persistent}) ? '1' : '0';
}
foreach my $pass (qw/join_password owner_password/){ foreach my $pass (qw/join_password owner_password/){
if ($req->{param}->{$pass} eq Mojo::JSON->false){ if ($req->{param}->{$pass} eq Mojo::JSON->false){
$room->{$pass} = undef; $room->{$pass} = undef;
@ -1589,6 +1579,7 @@ any '/api' => sub {
join_auth => ($room->{join_password}) ? 'yes' : 'no', join_auth => ($room->{join_password}) ? 'yes' : 'no',
locked => ($room->{locked}) ? 'yes' : 'no', locked => ($room->{locked}) ? 'yes' : 'no',
ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no', ask_for_name => ($room->{ask_for_name}) ? 'yes' : 'no',
persistent => ($room->{persistent}) ? 'yes' : 'no',
notif => $self->get_notification($room->{name}), notif => $self->get_notification($room->{name}),
status => 'success' status => 'success'
} }

Loading…
Cancel
Save