Hook the new config menu with a new update_room_conf api method

master
Daniel Berteaud 10 years ago
parent b9e3597111
commit cdc4d71e68
  1. 3
      lib/Vroom/Constants.pm
  2. 1
      lib/Vroom/I18N/en.pm
  3. 1
      lib/Vroom/I18N/fr.pm
  4. 47
      public/js/vroom.js
  5. 27
      vroom.pl

@ -167,7 +167,8 @@ use constant API_ACTIONS => {
email_notification => 1, email_notification => 1,
promote_peer => 1, promote_peer => 1,
wipe_data => 1, wipe_data => 1,
delete_room => 1 delete_room => 1,
update_room_conf => 1
}, },
participant => { participant => {
ping => 1, ping => 1,

@ -142,6 +142,7 @@ our %Lexicon = (
"NOTIFICATION_ON_JOIN" => "Email addresses to notify when someone joins this room", "NOTIFICATION_ON_JOIN" => "Email addresses to notify when someone joins this room",
"s_WILL_BE_NOTIFIED" => "%s will receive a notification each time someone joins this room", "s_WILL_BE_NOTIFIED" => "%s will receive a notification each time someone joins this room",
"s_WONT_BE_NOTIFIED_ANYMORE" => "%s won't be notified anymore", "s_WONT_BE_NOTIFIED_ANYMORE" => "%s won't be notified anymore",
"ROOM_CONFIG_UPDATED" => "Room configuration has been updated",
"s_JOINED_ROOM_s" => "%s joined room %s", "s_JOINED_ROOM_s" => "%s joined room %s",
"SOMEONE" => "Someone", "SOMEONE" => "Someone",
"SOMEONE_JOINED_A_ROOM" => "Someone joined a video conference room, and your address is configured to receive " . "SOMEONE_JOINED_A_ROOM" => "Someone joined a video conference room, and your address is configured to receive " .

@ -149,6 +149,7 @@ our %Lexicon = (
"NOTIFICATION_ON_JOIN" => "Email à notifier lorsque quelqu'un rejoint ce salon", "NOTIFICATION_ON_JOIN" => "Email à notifier lorsque quelqu'un rejoint ce salon",
"s_WILL_BE_NOTIFIED" => "%s recevra une notification à chaque fois qu'une personne rejoint ce salon", "s_WILL_BE_NOTIFIED" => "%s recevra une notification à chaque fois qu'une personne rejoint ce salon",
"s_WONT_BE_NOTIFIED_ANYMORE" => "%s ne recevra plus les notifications pour ce salon", "s_WONT_BE_NOTIFIED_ANYMORE" => "%s ne recevra plus les notifications pour ce salon",
"ROOM_CONFIG_UPDATED" => "La configuration du salon a été mise à jour",
"s_JOINED_ROOM_s" => "%s a rejoint le salon %s", "s_JOINED_ROOM_s" => "%s a rejoint le salon %s",
"SOMEONE" => "Quelqu'un", "SOMEONE" => "Quelqu'un",
"SOMEONE_JOINED_A_ROOM" => "Quelqu'un a rejoint un salon de vidéo conférence, et votre adresse est configurée " . "SOMEONE_JOINED_A_ROOM" => "Quelqu'un a rejoint un salon de vidéo conférence, et votre adresse est configurée " .

@ -2031,6 +2031,8 @@ function initVroom(room) {
$('#ownerPassFields').hide(200); $('#ownerPassFields').hide(200);
} }
}); });
// Create a new input field
function addEmailInputField(val){ function addEmailInputField(val){
var parentEl = $('.email-list'), var parentEl = $('.email-list'),
currentEntry = parentEl.find('.email-entry:last'), currentEntry = parentEl.find('.email-entry:last'),
@ -2051,6 +2053,51 @@ function initVroom(room) {
$(this).parents('.email-entry:first').remove(); $(this).parents('.email-entry:first').remove();
}); });
// Submit the configuration form
$('#configureRoomForm').submit(function(e){
e.preventDefault();
// TODO: validate password and email here
// or disable the submit button and validate as you type ?
var locked = $('#lockedSet').bootstrapSwitch('state'),
askForName = $('#askForNameSet').bootstrapSwitch('state'),
joinPass = ($('#joinPassSet').bootstrapSwitch('state')) ?
$('#joinPass').val() : false,
ownerPass = ($('#ownerPassSet').bootstrapSwitch('state')) ?
$('#ownerPass').val() : false,
emails = [];
$('input[name="emails[]"]').each(function(){
emails.push($(this).val());
});
$.ajax({
data: {
req: JSON.stringify({
action: 'update_room_conf',
param: {
room: roomName,
locked: locked,
ask_for_name: askForName,
join_password: joinPass,
owner_password: ownerPass,
emails: emails
}
})
},
error: function() {
$.notify(locale.ERROR_OCCURRED, 'error');
},
success: function(data) {
$('#ownerPass,#ownerPassConfirm,#joinPass,#joinPassConfirm').val('');
if (data.status == 'success'){
$.notify(data.msg, 'info');
webrtc.sendToAll('room_conf_updated');
}
else{
$.notify(data.msg, 'error');
}
}
});
});
$('#ownerPassButton').change(function(){ $('#ownerPassButton').change(function(){
var action = ($(this).is(':checked')) ? 'set':'unset'; var action = ($(this).is(':checked')) ? 'set':'unset';
if (action == 'set'){ if (action == 'set'){

@ -1336,6 +1336,33 @@ any '/api' => sub {
} }
); );
} }
# Update room configuration
elsif ($req->{action} eq 'update_room_conf'){
$room->{locked} = ($req->{param}->{locked}) ? '1' : '0';
$room->{ask_for_name} = ($req->{param}->{ask_for_name}) ? '1' : '0';
foreach my $pass (qw/join_password owner_password/){
if (!$req->{param}->{$pass}){
$room->{$pass} = undef;
}
elsif ($req->{param}->{$pass} ne ''){
$room->{$pass} = Crypt::SaltedHash->new(algorithm => 'SHA-256')->add($req->{param}->{$pass})->generate;
}
}
if ($self->modify_room($room)){
return $self->render(
json => {
status => 'success',
msg => $self->l('ROOM_CONFIG_UPDATED')
}
);
}
return $self->render(
json => {
status => 'error',
msg => $self->l('ERROR_OCCURRED')
}
);
}
# Handle password (join and owner) # Handle password (join and owner)
elsif ($req->{action} eq 'set_join_password'){ elsif ($req->{action} eq 'set_join_password'){
$room->{join_password} = ($req->{param}->{password} && $req->{param}->{password} ne '') ? $room->{join_password} = ($req->{param}->{password} && $req->{param}->{password} ne '') ?

Loading…
Cancel
Save