add ability to change recording visibility

This commit is contained in:
Josh 2018-06-18 14:25:30 -04:00
parent b2b2c641da
commit 5d5cfd1b7d
5 changed files with 58 additions and 11 deletions

View File

@ -97,7 +97,7 @@ class RoomsController < ApplicationController
# POST /:room_uid/:record_id
def update_recording
meta = {
"meta_#{META_LISTED}": (params[:state] == "public")
"meta_#{META_LISTED}" => (params[:state] == "public")
}
res = @room.update_recording(params[:record_id], meta)

View File

@ -7,6 +7,7 @@ class Room < ApplicationRecord
belongs_to :owner, class_name: 'User', foreign_key: :user_id
RETURNCODE_SUCCESS = "SUCCESS"
META_LISTED = "gl-listed"
# Determines if a user owns a room.
def owned_by?(user)
@ -32,13 +33,11 @@ class Room < ApplicationRecord
moderatorPW: random_password(12),
attendeePW: random_password(12),
moderatorOnlyMessage: options[:moderator_message],
"meta_gl-listed": false
"meta_#{META_LISTED}": false
}
# Increment room sessions.
self.sessions += 1
self.last_session = DateTime.now
self.save
# Update session info.
self.update_attributes(sessions: sessions + 1, last_session: DateTime.now)
#meeting_options.merge!(
#{ "meta_room-id": options[:room_owner],
@ -131,7 +130,7 @@ class Room < ApplicationRecord
# Fetches a rooms public recordings.
def public_recordings
recordings.select do |r| r[:metadata]["gl-listed"] end
recordings.select do |r| r[:metadata][:"gl-listed"] == "true" end
end
def update_recording(record_id, meta)

View File

@ -15,7 +15,9 @@
<th class="text-left">Users</th>
<th class="text-left">Visibility</th>
<th>Formats</th>
<th class="text-center"><i class="icon-settings"></i></th>
<% unless only_public %>
<th class="text-center"><i class="icon-settings"></i></th>
<% end %>
</tr>
</thead>
<tbody>
@ -27,7 +29,11 @@
</tr>
<% else %>
<% recordings.each do |recording| %>
<%= render "shared/components/recording_row", recording: recording %>
<% if only_public %>
<%= render "shared/components/public_recording_row", recording: recording %>
<% else %>
<%= render "shared/components/recording_row", recording: recording %>
<% end %>
<% end %>
<% end %>
</tbody>

View File

@ -0,0 +1,42 @@
<tr>
<td>
<div><%= recording[:name] %></div>
<div class="small text-muted">
Recorded on <%= recording_date(recording[:startTime]) %>
</div>
</td>
<td>
<% p = recording[:playbacks].find do |p| p[:type] == "presentation" end %>
<% if p %>
<% p[:preview][:images][:image].each do |img| %>
<%= image_tag(img[:content].strip, class: "thumbnail px-2") %>
<% end %>
<% end %>
</td>
<td class="text-left">
<div class="small text-muted text-uppercase">
Length
</div>
<%= recording_length(recording[:startTime], recording[:endTime]) %>
</td>
<td class="text-left">
<div class="small text-muted text-uppercase">
Users
</div>
<%= recording[:participants] %>
</td>
<td class="text-left">
<div class="dropdown">
<% if recording[:metadata][:"gl-listed"] == "true" %>
<i class="dropdown-icon fe fe-globe px-2"></i> Public
<% else %>
<i class="dropdown-icon fe fe-link px-2"></i> Unlisted
<% end %>
</div>
</td>
<td>
<% recording[:playbacks].each do |p| %>
<%= link_to p[:type].capitalize, p[:url], class: "btn btn-sm btn-primary", target: "_blank" %>
<% end %>
</td>
</tr>

View File

@ -9,7 +9,7 @@
<% p = recording[:playbacks].find do |p| p[:type] == "presentation" end %>
<% if p %>
<% p[:preview][:images][:image].each do |img| %>
<%= image_tag(img[:content], class: "thumbnail px-2") %>
<%= image_tag(img[:content].strip, class: "thumbnail px-2") %>
<% end %>
<% end %>
</td>
@ -27,7 +27,7 @@
</td>
<td class="text-left">
<div class="dropdown">
<% if recording[:metadata]["gl-listed"] %>
<% if recording[:metadata][:"gl-listed"] == "true" %>
<button class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown"><i class="dropdown-icon fe fe-globe px-2"></i> Public</button>
<% else %>
<button class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown"><i class="dropdown-icon fe fe-link px-2"></i> Unlisted</button>