open recordings in new tab and hide from viewers when unpublished

This commit is contained in:
Zachary Chai 2016-11-18 17:05:44 -05:00
parent 6620df9c65
commit 25bccb7699
3 changed files with 30 additions and 12 deletions

View File

@ -7,17 +7,20 @@
}, },
{ {
received: function(data) { received: function(data) {
var table = $("#recordings").DataTable(); var recordings = Recordings.getInstance();
var table = recordings.table.api()
var row = table.row("#"+data.record_id); var row = table.row("#"+data.record_id);
if (data.action === 'update') { if (data.action === 'update') {
var rowData = row.data(); var rowData = row.data();
rowData.published = data.published rowData.published = data.published
table.row("#"+data.record_id).data(rowData).draw(); table.row("#"+data.record_id).data(rowData);
recordings.draw();
var published = (data.published) ? 'published' : 'unpublished'; var published = (data.published) ? 'published' : 'unpublished';
showAlert(I18n['recording_'+published], 4000); showAlert(I18n['recording_'+published], 4000);
} else if (data.action === 'delete') { } else if (data.action === 'delete') {
row.remove().draw(); row.remove();
recordings.draw();
showAlert(I18n.recording_deleted, 4000); showAlert(I18n.recording_deleted, 4000);
} }

View File

@ -9,17 +9,19 @@ class @Recordings
data: [], data: [],
rowId: 'id', rowId: 'id',
paging: false, paging: false,
searching: false, dom: 'lrtip',
info: false, info: false,
order: [[ 0, "desc" ]], order: [[ 0, "desc" ]],
language: { language: {
emptyTable: I18n.no_recordings emptyTable: I18n.no_recordings,
zeroRecords: I18n.no_recordings
}, },
columns: [ columns: [
{ data: "start_time" }, { data: "start_time" },
{ data: "previews", orderable: false }, { data: "previews", orderable: false },
{ data: "duration" }, { data: "duration" },
{ data: "playbacks", orderable: false }, { data: "playbacks", orderable: false },
{ data: "published", visible: false },
{ data: "id", orderable: false } { data: "id", orderable: false }
], ],
columnDefs: [ columnDefs: [
@ -38,6 +40,7 @@ class @Recordings
render: (data, type, row) -> render: (data, type, row) ->
if type == 'display' if type == 'display'
str = '' str = ''
if row.published
for d in data for d in data
str += '<img height="50" width="50" src="'+d.url+'" alt="'+d.alt+'"></img> ' str += '<img height="50" width="50" src="'+d.url+'" alt="'+d.alt+'"></img> '
return str return str
@ -50,7 +53,7 @@ class @Recordings
str = '' str = ''
if row.published if row.published
for d in data for d in data
str += '<a href="'+d.url+'">'+d.type_i18n+'</a> ' str += '<a href="'+d.url+'" target="_blank">'+d.type_i18n+'</a> '
return str return str
return data return data
}, },
@ -95,12 +98,17 @@ class @Recordings
@initialized: -> @initialized: ->
return $.fn.DataTable.isDataTable('#recordings') && _recordingsInstance return $.fn.DataTable.isDataTable('#recordings') && _recordingsInstance
draw: ->
if !@isOwner()
@table.api().columns(4).search('true')
@table.api().columns.adjust().draw()
# refresh the recordings from the server # refresh the recordings from the server
refresh: -> refresh: ->
_this = this
table_api = this.table.api() table_api = this.table.api()
$.get "/rooms/"+Meeting.getInstance().getId()+"/recordings", (data) -> $.get "/rooms/"+Meeting.getInstance().getId()+"/recordings", (data) =>
if !data.is_owner @setOwner(data.is_owner)
if !@owner
table_api.column(-1).visible(false) table_api.column(-1).visible(false)
for recording in data.recordings for recording in data.recordings
totalMinutes = Math.round((new Date(recording.end_time) - new Date(recording.start_time)) / 1000 / 60) totalMinutes = Math.round((new Date(recording.end_time) - new Date(recording.start_time)) / 1000 / 60)
@ -109,7 +117,7 @@ class @Recordings
return new Date(b.start_time) - new Date(a.start_time) return new Date(b.start_time) - new Date(a.start_time)
table_api.clear() table_api.clear()
table_api.rows.add(data.recordings) table_api.rows.add(data.recordings)
table_api.columns.adjust().draw() @draw()
# setup click handlers for the action buttons # setup click handlers for the action buttons
setupActionHandlers: -> setupActionHandlers: ->
@ -145,3 +153,9 @@ class @Recordings
).fail((data) -> ).fail((data) ->
btn.prop('disabled', false) btn.prop('disabled', false)
) )
isOwner: ->
@owner
setOwner: (owner) ->
@owner = owner

View File

@ -20,6 +20,7 @@
<th><%= t('thumbnails') %></th> <th><%= t('thumbnails') %></th>
<th><%= t('duration') %></th> <th><%= t('duration') %></th>
<th><%= t('views') %></th> <th><%= t('views') %></th>
<th>published</th>
<th><%= t('actions') %></th> <th><%= t('actions') %></th>
</thead> </thead>
</table> </table>