only allow room owner to perform recording actions

This commit is contained in:
Zachary Chai
2016-11-01 12:03:00 -04:00
parent e400bf41e8
commit 15411d76fa
5 changed files with 23 additions and 16 deletions

View File

@ -7,11 +7,10 @@
},
{
received: function(data) {
var btn = $("#recordings").find(".recording-update:disabled");
btn.data('published', data.published);
btn.find('i').removeClass(getPublishClass(!data.published));
btn.find('i').addClass(getPublishClass(data.published));
btn.prop("disabled", false);
var table = $("#recordings").DataTable();
var rowData = table.row("#"+data.record_id).data();
rowData.published = data.published
table.row("#"+data.record_id).data(rowData).draw();
}
});
};

View File

@ -98,8 +98,10 @@
render: function(data, type, row) {
if (type === 'display') {
var str = "";
for(let i in data) {
str += '<a href="'+data[i].url+'">'+data[i].type+'</a> ';
if (row.published) {
for(let i in data) {
str += '<a href="'+data[i].url+'">'+data[i].type+'</a> ';
}
}
return str;
}
@ -125,10 +127,11 @@
});
$('#recordings').on('click', '.recording-update', function(event) {
var room = $(this).data('room');
var id = $(this).data('id');
var published = $(this).data('published');
$(this).prop("disabled", true);
var btn = $(this);
var room = btn.data('room');
var id = btn.data('id');
var published = btn.data('published');
btn.prop("disabled", true);
$.ajax({
method: 'PATCH',
url: '/rooms/'+room+'/recordings/'+id,
@ -136,7 +139,7 @@
}).done(function(data) {
}).fail(function(data) {
$(this).prop("disabled", false);
btn.prop("disabled", false);
});
});
@ -147,7 +150,7 @@
method: 'DELETE',
url: '/rooms/'+room+'/recordings/'+id
}).done(function() {
$('tr[id="'+id+'"]').remove();
recordingsTable.api().row("#"+id).remove().draw();
});
});
@ -160,6 +163,9 @@
}
table = recordingsTable.api();
$.get("/rooms/"+window.location.pathname.split('/').pop()+"/recordings", function(data) {
if (!data.is_owner) {
table.column(-1).visible( false );
}
var i;
for (i = 0; i < data.recordings.length; i++) {
var totalMinutes = Math.round((new Date(data.recordings[i].end_time) - new Date(data.recordings[i].start_time)) / 1000 / 60);