forked from External/greenlight
Added a Recordings page where the user can see all recordings (#352)
This commit is contained in:
parent
ef23cae73d
commit
8ff05643dc
|
@ -22,6 +22,7 @@ class RoomsController < ApplicationController
|
||||||
before_action :find_room, except: :create
|
before_action :find_room, except: :create
|
||||||
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
|
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
|
||||||
|
|
||||||
|
include RecordingsHelper
|
||||||
META_LISTED = "gl-listed"
|
META_LISTED = "gl-listed"
|
||||||
|
|
||||||
# POST /
|
# POST /
|
||||||
|
@ -43,7 +44,12 @@ class RoomsController < ApplicationController
|
||||||
# GET /:room_uid
|
# GET /:room_uid
|
||||||
def show
|
def show
|
||||||
if current_user && @room.owned_by?(current_user)
|
if current_user && @room.owned_by?(current_user)
|
||||||
@recordings = @room.recordings
|
recs = @room.recordings
|
||||||
|
# Add the room id to each recording object
|
||||||
|
recs.each do |rec|
|
||||||
|
rec[:room_uid] = @room.uid
|
||||||
|
end
|
||||||
|
@recordings = recs
|
||||||
@is_running = @room.running?
|
@is_running = @room.running?
|
||||||
else
|
else
|
||||||
render :join
|
render :join
|
||||||
|
@ -137,38 +143,10 @@ class RoomsController < ApplicationController
|
||||||
def delete_recording
|
def delete_recording
|
||||||
@room.delete_recording(params[:record_id])
|
@room.delete_recording(params[:record_id])
|
||||||
|
|
||||||
redirect_to current_user.main_room
|
# Redirects to the page that made the initial request
|
||||||
|
redirect_to request.referrer
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper for converting BigBlueButton dates into the desired format.
|
|
||||||
def recording_date(date)
|
|
||||||
date.strftime("%B #{date.day.ordinalize}, %Y.")
|
|
||||||
end
|
|
||||||
helper_method :recording_date
|
|
||||||
|
|
||||||
# Helper for converting BigBlueButton dates into a nice length string.
|
|
||||||
def recording_length(playbacks)
|
|
||||||
# Stats format currently doesn't support length.
|
|
||||||
valid_playbacks = playbacks.reject { |p| p[:type] == "statistics" }
|
|
||||||
return "0 min" if valid_playbacks.empty?
|
|
||||||
|
|
||||||
len = valid_playbacks.first[:length]
|
|
||||||
if len > 60
|
|
||||||
"#{(len / 60).round} hrs"
|
|
||||||
elsif len == 0
|
|
||||||
"< 1 min"
|
|
||||||
else
|
|
||||||
"#{len} min"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
helper_method :recording_length
|
|
||||||
|
|
||||||
# Prevents single images from erroring when not passed as an array.
|
|
||||||
def safe_recording_images(images)
|
|
||||||
Array.wrap(images)
|
|
||||||
end
|
|
||||||
helper_method :safe_recording_images
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_room_attributes
|
def update_room_attributes
|
||||||
|
|
|
@ -20,6 +20,8 @@ class UsersController < ApplicationController
|
||||||
before_action :find_user, only: [:edit, :update, :destroy]
|
before_action :find_user, only: [:edit, :update, :destroy]
|
||||||
before_action :ensure_unauthenticated, only: [:new, :create]
|
before_action :ensure_unauthenticated, only: [:new, :create]
|
||||||
|
|
||||||
|
include RecordingsHelper
|
||||||
|
|
||||||
# POST /u
|
# POST /u
|
||||||
def create
|
def create
|
||||||
# Verify that GreenLight is configured to allow user signup.
|
# Verify that GreenLight is configured to allow user signup.
|
||||||
|
@ -109,6 +111,27 @@ class UsersController < ApplicationController
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /u/:user_uid/recordings
|
||||||
|
def recordings
|
||||||
|
if current_user && current_user.uid == params[:user_uid]
|
||||||
|
@recordings = []
|
||||||
|
current_user.rooms.each do |room|
|
||||||
|
# Check that current user is the room owner
|
||||||
|
next unless room.owner == current_user
|
||||||
|
|
||||||
|
recs = room.recordings
|
||||||
|
# Add the room id to each recording object
|
||||||
|
recs.each do |rec|
|
||||||
|
rec[:room_uid] = room.uid
|
||||||
|
end
|
||||||
|
# Adds an array to another array
|
||||||
|
@recordings.push(*recs)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# GET | POST /terms
|
# GET | POST /terms
|
||||||
def terms
|
def terms
|
||||||
redirect_to '/404' unless Rails.configuration.terms
|
redirect_to '/404' unless Rails.configuration.terms
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module RecordingsHelper
|
||||||
|
# Helper for converting BigBlueButton dates into the desired format.
|
||||||
|
def recording_date(date)
|
||||||
|
date.strftime("%B #{date.day.ordinalize}, %Y.")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Helper for converting BigBlueButton dates into a nice length string.
|
||||||
|
def recording_length(playbacks)
|
||||||
|
# Stats format currently doesn't support length.
|
||||||
|
valid_playbacks = playbacks.reject { |p| p[:type] == "statistics" }
|
||||||
|
return "0 min" if valid_playbacks.empty?
|
||||||
|
|
||||||
|
len = valid_playbacks.first[:length]
|
||||||
|
if len > 60
|
||||||
|
"#{(len / 60).round} hrs"
|
||||||
|
elsif len == 0
|
||||||
|
"< 1 min"
|
||||||
|
else
|
||||||
|
"#{len} min"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Prevents single images from erroring when not passed as an array.
|
||||||
|
def safe_recording_images(images)
|
||||||
|
Array.wrap(images)
|
||||||
|
end
|
||||||
|
end
|
|
@ -40,6 +40,9 @@
|
||||||
<%= link_to current_user.main_room, class: "dropdown-item" do %>
|
<%= link_to current_user.main_room, class: "dropdown-item" do %>
|
||||||
<i class="dropdown-icon fas fa-home"></i> <%= t("header.dropdown.home") %>
|
<i class="dropdown-icon fas fa-home"></i> <%= t("header.dropdown.home") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= link_to get_user_recordings_path(current_user), class: "dropdown-item" do %>
|
||||||
|
<i class="dropdown-icon fas fa-video"></i> <%= t("room.recordings") %>
|
||||||
|
<% end %>
|
||||||
<%= link_to edit_user_path(current_user), class: "dropdown-item" do %>
|
<%= link_to edit_user_path(current_user), class: "dropdown-item" do %>
|
||||||
<i class="dropdown-icon fas fa-cog"></i> <%= t("header.dropdown.settings") %>
|
<i class="dropdown-icon fas fa-cog"></i> <%= t("header.dropdown.settings") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -53,10 +53,10 @@
|
||||||
<button class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown"><i class="dropdown-icon fas fa-link px-2"></i> <%= t("recording.visibility.unlisted") %></button>
|
<button class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown"><i class="dropdown-icon fas fa-link px-2"></i> <%= t("recording.visibility.unlisted") %></button>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||||
<%= button_to update_recording_path(@room, record_id: recording[:recordID], state: "public"), class: "dropdown-item" do %>
|
<%= button_to update_recording_path(room_uid: recording[:room_uid], record_id: recording[:recordID], state: "public"), class: "dropdown-item" do %>
|
||||||
<i class="dropdown-icon fas fa-globe"></i> <%= t("recording.visibility.public") %>
|
<i class="dropdown-icon fas fa-globe"></i> <%= t("recording.visibility.public") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= button_to update_recording_path(@room, record_id: recording[:recordID], state: "unlisted"), class: "dropdown-item" do %>
|
<%= button_to update_recording_path(room_uid: recording[:room_uid], record_id: recording[:recordID], state: "unlisted"), class: "dropdown-item" do %>
|
||||||
<i class="dropdown-icon fas fa-link"></i> <%= t("recording.visibility.unlisted") %>
|
<i class="dropdown-icon fas fa-link"></i> <%= t("recording.visibility.unlisted") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<a class="dropdown-item email-link" data-pres-link="<%= p[:url] %>"><i class="dropdown-icon far fa-envelope"></i> <%= t("recording.email") %></a>
|
<a class="dropdown-item email-link" data-pres-link="<%= p[:url] %>"><i class="dropdown-icon far fa-envelope"></i> <%= t("recording.email") %></a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= button_to delete_recording_path(@room, record_id: recording[:recordID]), method: :delete, class: "dropdown-item" do %>
|
<%= button_to delete_recording_path(room_uid: recording[:room_uid], record_id: recording[:recordID]), method: :delete, class: "dropdown-item" do %>
|
||||||
<i class="dropdown-icon far fa-trash-alt"></i> <%= t("delete") %>
|
<i class="dropdown-icon far fa-trash-alt"></i> <%= t("delete") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<%
|
||||||
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||||
|
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
|
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%
|
||||||
|
# shared/sessions is a partial, meaning it can't be rendered through the controller
|
||||||
|
# without losing all css
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%= render "shared/sessions", recordings: @recordings, only_public: false %>
|
|
@ -52,6 +52,9 @@ Rails.application.routes.draw do
|
||||||
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
|
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
|
||||||
patch '/:user_uid/edit', to: 'users#update', as: :update_user
|
patch '/:user_uid/edit', to: 'users#update', as: :update_user
|
||||||
delete '/:user_uid', to: 'users#destroy', as: :delete_user
|
delete '/:user_uid', to: 'users#destroy', as: :delete_user
|
||||||
|
|
||||||
|
# All user recordings
|
||||||
|
get '/:user_uid/recordings', to: 'users#recordings', as: :get_user_recordings
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handles Omniauth authentication.
|
# Handles Omniauth authentication.
|
||||||
|
|
|
@ -231,4 +231,17 @@ describe UsersController, type: :controller do
|
||||||
expect(response).to render_template(:verify)
|
expect(response).to render_template(:verify)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "GET #recordings" do
|
||||||
|
before do
|
||||||
|
@user1 = create(:user)
|
||||||
|
@user2 = create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to root if the incorrect user tries to access the page" do
|
||||||
|
get :recordings, params: { current_user: @user2, user_uid: @user1.uid }
|
||||||
|
|
||||||
|
expect(response).to redirect_to(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue