mirror of
https://github.com/dani/vroom.git
synced 2024-06-30 15:23:41 +02:00
Handle configuration changes in the new admin page
This commit is contained in:
parent
8fa6fad617
commit
22b1d69802
|
@ -229,6 +229,65 @@ $('#ownerPassSet').on('switchChange.bootstrapSwitch', function(event, state) {
|
|||
});
|
||||
|
||||
|
||||
// Submit the configuration form
|
||||
$('#configureRoomForm').submit(function(e){
|
||||
e.preventDefault();
|
||||
// check if passwords match
|
||||
if ($('#joinPassSet').bootstrapSwitch('state')){
|
||||
if ($('#joinPass').val() !== $('#joinPassConfirm').val()){
|
||||
$('#joinPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($('#ownerPassSet').bootstrapSwitch('state')){
|
||||
if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){
|
||||
$('#ownerPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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'){
|
||||
$('#configureModal').modal('hide');
|
||||
// Hide passwords inputs too
|
||||
$('#joinPassFields,#ownerPassFields').hide();
|
||||
$.notify(data.msg, 'info');
|
||||
$('#configureRoomForm').trigger('room_conf_updated');
|
||||
}
|
||||
else{
|
||||
$.notify(data.msg, 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Used on the index page
|
||||
function initIndex(){
|
||||
|
@ -398,7 +457,8 @@ function initAdmin(){
|
|||
}
|
||||
|
||||
$(document).on('click', '.btn-configure', function(){
|
||||
getRoomConf($(this).data('room'));
|
||||
roomName = $(this).data('room');
|
||||
getRoomConf(roomName);
|
||||
});
|
||||
|
||||
// Get room list right after loading the page
|
||||
|
@ -1654,63 +1714,10 @@ function initVroom(room) {
|
|||
});
|
||||
});
|
||||
|
||||
// Submit the configuration form
|
||||
$('#configureRoomForm').submit(function(e){
|
||||
e.preventDefault();
|
||||
// check if passwords match
|
||||
if ($('#joinPassSet').bootstrapSwitch('state')){
|
||||
if ($('#joinPass').val() !== $('#joinPassConfirm').val()){
|
||||
$('#joinPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($('#ownerPassSet').bootstrapSwitch('state')){
|
||||
if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){
|
||||
$('#ownerPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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'){
|
||||
$('#configureModal').modal('hide');
|
||||
// Hide passwords inputs too
|
||||
$('#joinPassFields,#ownerPassFields').hide();
|
||||
$.notify(data.msg, 'info');
|
||||
// The configuration formed has been submited successfuly
|
||||
// Lets announce it to the other peers
|
||||
$('#configureRoomForm').on('room_conf_updated', function(){
|
||||
webrtc.sendToAll('room_conf_updated');
|
||||
}
|
||||
else{
|
||||
$.notify(data.msg, 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Choose another color. Useful if two peers have the same
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
var rootUrl = '<%= $self->get_url('/'); %>';
|
||||
var currentLang = '<%= $self->languages %>';
|
||||
var api_key = '<%= ($self->session('key')) ? $self->session('key') : '' %>';
|
||||
var roomName;
|
||||
</script>
|
||||
<% foreach my $js (qw(jquery-1.11.1.min.js bootstrap.min.js notify-combined.min.js bootstrap-switch.min.js vroom.js)){
|
||||
%>
|
||||
|
|
Loading…
Reference in New Issue
Block a user