forked from External/greenlight
only allow room owner to perform recording actions
This commit is contained in:
parent
e400bf41e8
commit
15411d76fa
|
@ -7,11 +7,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
received: function(data) {
|
received: function(data) {
|
||||||
var btn = $("#recordings").find(".recording-update:disabled");
|
var table = $("#recordings").DataTable();
|
||||||
btn.data('published', data.published);
|
var rowData = table.row("#"+data.record_id).data();
|
||||||
btn.find('i').removeClass(getPublishClass(!data.published));
|
rowData.published = data.published
|
||||||
btn.find('i').addClass(getPublishClass(data.published));
|
table.row("#"+data.record_id).data(rowData).draw();
|
||||||
btn.prop("disabled", false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,9 +98,11 @@
|
||||||
render: function(data, type, row) {
|
render: function(data, type, row) {
|
||||||
if (type === 'display') {
|
if (type === 'display') {
|
||||||
var str = "";
|
var str = "";
|
||||||
|
if (row.published) {
|
||||||
for(let i in data) {
|
for(let i in data) {
|
||||||
str += '<a href="'+data[i].url+'">'+data[i].type+'</a> ';
|
str += '<a href="'+data[i].url+'">'+data[i].type+'</a> ';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -125,10 +127,11 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#recordings').on('click', '.recording-update', function(event) {
|
$('#recordings').on('click', '.recording-update', function(event) {
|
||||||
var room = $(this).data('room');
|
var btn = $(this);
|
||||||
var id = $(this).data('id');
|
var room = btn.data('room');
|
||||||
var published = $(this).data('published');
|
var id = btn.data('id');
|
||||||
$(this).prop("disabled", true);
|
var published = btn.data('published');
|
||||||
|
btn.prop("disabled", true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/rooms/'+room+'/recordings/'+id,
|
url: '/rooms/'+room+'/recordings/'+id,
|
||||||
|
@ -136,7 +139,7 @@
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
|
|
||||||
}).fail(function(data) {
|
}).fail(function(data) {
|
||||||
$(this).prop("disabled", false);
|
btn.prop("disabled", false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -147,7 +150,7 @@
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: '/rooms/'+room+'/recordings/'+id
|
url: '/rooms/'+room+'/recordings/'+id
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
$('tr[id="'+id+'"]').remove();
|
recordingsTable.api().row("#"+id).remove().draw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -160,6 +163,9 @@
|
||||||
}
|
}
|
||||||
table = recordingsTable.api();
|
table = recordingsTable.api();
|
||||||
$.get("/rooms/"+window.location.pathname.split('/').pop()+"/recordings", function(data) {
|
$.get("/rooms/"+window.location.pathname.split('/').pop()+"/recordings", function(data) {
|
||||||
|
if (!data.is_owner) {
|
||||||
|
table.column(-1).visible( false );
|
||||||
|
}
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < data.recordings.length; 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);
|
var totalMinutes = Math.round((new Date(data.recordings[i].end_time) - new Date(data.recordings[i].start_time)) / 1000 / 60);
|
||||||
|
|
|
@ -38,12 +38,12 @@ class BbbController < ApplicationController
|
||||||
|
|
||||||
# GET /rooms/:id/recordings
|
# GET /rooms/:id/recordings
|
||||||
def recordings
|
def recordings
|
||||||
user = User.find_by username: params[:id]
|
@user = User.find_by username: params[:id]
|
||||||
if !user
|
if !@user
|
||||||
render head(:not_found) && return
|
render head(:not_found) && return
|
||||||
end
|
end
|
||||||
|
|
||||||
bbb_res = bbb_get_recordings user.username
|
bbb_res = bbb_get_recordings @user.username
|
||||||
render_bbb_response bbb_res, bbb_res[:recordings]
|
render_bbb_response bbb_res, bbb_res[:recordings]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class RecordingUpdatesJob < ApplicationJob
|
||||||
bbb_res = bbb_get_recordings(nil, record_id)
|
bbb_res = bbb_get_recordings(nil, record_id)
|
||||||
if bbb_res[:recordings].first[:published].to_s == published
|
if bbb_res[:recordings].first[:published].to_s == published
|
||||||
ActionCable.server.broadcast "#{room}_recording_updates_channel",
|
ActionCable.server.broadcast "#{room}_recording_updates_channel",
|
||||||
|
record_id: record_id,
|
||||||
published: bbb_res[:recordings].first[:published]
|
published: bbb_res[:recordings].first[:published]
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
json.partial! 'bbb', messageKey: @messageKey, message: @message, status: @status
|
json.partial! 'bbb', messageKey: @messageKey, message: @message, status: @status
|
||||||
unless @response.blank?
|
unless @response.blank?
|
||||||
|
json.is_owner current_user == @user
|
||||||
json.recordings do
|
json.recordings do
|
||||||
unless @response.is_a? Array
|
unless @response.is_a? Array
|
||||||
@response = [@response]
|
@response = [@response]
|
||||||
|
|
Loading…
Reference in New Issue