finish delete recording feature

This commit is contained in:
Zachary Chai
2016-11-08 16:03:24 -05:00
parent 93b5e9a1b3
commit 83bdf4c387
8 changed files with 68 additions and 16 deletions

View File

@ -8,17 +8,19 @@
{
received: function(data) {
var table = $("#recordings").DataTable();
var rowData = table.row("#"+data.record_id).data();
rowData.published = data.published
table.row("#"+data.record_id).data(rowData).draw();
var publish = (data.published) ? 'publish' : 'unpublish';
var row = table.row("#"+data.record_id);
if (data.action === 'update') {
var rowData = row.data();
rowData.published = data.published
table.row("#"+data.record_id).data(rowData).draw();
// show alert success alert
$('.alert-template .alert-message').html($('.'+publish+'-alert').html());
$('#alerts').html($('.alert-template').html());
setTimeout(function() {
$('#alerts > .alert').alert('close');
}, 4000);
var publish = (data.published) ? 'publish' : 'unpublish';
showAlert($('.'+publish+'-alert').html(), 4000);
} else if (data.action === 'delete') {
row.remove().draw();
showAlert($('.delete-alert').html(), 4000);
}
}
});
};

View File

@ -187,14 +187,18 @@
});
$('#recordings').on('click', '.recording-delete', function(event) {
var btn = $(this);
var row = recordingsTable.api().row($(this).closest('tr')).data();
var url = $('.meeting-url').val();
var id = row.id;
btn.prop('disabled', true);
$.ajax({
method: 'DELETE',
url: url+'/recordings/'+id
}).done(function() {
recordingsTable.api().row("#"+id).remove().draw();
}).fail(function(data) {
btn.prop('disabled', false);
});
});

View File

@ -76,3 +76,18 @@ var loopJoin = function() {
console.info("meeting join failed");
});
}
var showAlert = function(html, timeout_delay) {
if (!html) {
return;
}
$('.alert-template .alert-message').html(html);
$('#alerts').html($('.alert-template').html());
if (timeout_delay) {
setTimeout(function() {
$('#alerts > .alert').alert('close');
}, timeout_delay);
}
}