From a055b88eb7bb71b6630b0b7832074e961ac466aa Mon Sep 17 00:00:00 2001
From: farhatahmad <35435341+farhatahmad@users.noreply.github.com>
Date: Mon, 22 Jul 2019 12:46:48 -0400
Subject: [PATCH] GRN2-129: Added server recordings and refactored
adminsitrator panel (#662)
* Added server recordings and refactored adminsitrator panel
* Fixed some issues
* Fixed issue with owner email search
* Fixed issue with edit user
---
app/assets/javascripts/admins.js | 4 +-
app/assets/javascripts/recording.js | 41 ++
app/assets/javascripts/rename.js | 5 +-
app/assets/javascripts/room.js.erb | 15 -
app/assets/javascripts/search.js | 3 +-
app/assets/javascripts/settings.js | 2 +-
app/assets/javascripts/sort.js | 5 +-
.../utilities/_primary_themes.scss | 2 +
app/controllers/admins_controller.rb | 35 +-
.../concerns/recorder.rb} | 50 +-
app/controllers/recordings_controller.rb | 7 +-
app/controllers/rooms_controller.rb | 7 +-
app/controllers/users_controller.rb | 12 +-
app/helpers/admins_helper.rb | 12 +
app/models/room.rb | 32 +-
app/models/user.rb | 28 +-
.../admins/components/_menu_buttons.html.erb | 26 +
.../admins/components/_recordings.html.erb | 91 +++
.../components/_server_recording_row.html.erb | 81 +++
.../admins/components/_setting_view.html.erb | 26 +
.../components/_settings.html.erb} | 0
.../components}/_users.html.erb | 16 +
app/views/admins/edit_user.html.erb | 27 +
app/views/admins/index.html.erb | 22 +-
app/views/admins/server_recordings.html.erb | 27 +
app/views/admins/site_settings.html.erb | 27 +
app/views/rooms/show.html.erb | 2 +-
.../shared/modals/_delete_room_modal.html.erb | 4 +-
app/views/users/edit.html.erb | 6 +-
config/locales/en.yml | 3 +
config/routes.rb | 2 +
lib/bbb_api.rb | 10 +-
spec/concerns/recorder_spec.rb | 567 ++++++++++++++++++
spec/controllers/admins_controller_spec.rb | 18 +-
spec/controllers/rooms_controller_spec.rb | 4 +-
spec/controllers/users_controller_spec.rb | 2 +
spec/models/room_spec.rb | 414 -------------
spec/models/user_spec.rb | 93 ---
38 files changed, 1088 insertions(+), 640 deletions(-)
create mode 100644 app/assets/javascripts/recording.js
rename app/{models/concerns/api_concern.rb => controllers/concerns/recorder.rb} (65%)
create mode 100644 app/views/admins/components/_menu_buttons.html.erb
create mode 100644 app/views/admins/components/_recordings.html.erb
create mode 100644 app/views/admins/components/_server_recording_row.html.erb
create mode 100644 app/views/admins/components/_setting_view.html.erb
rename app/views/{shared/admin_settings/_site_settings.html.erb => admins/components/_settings.html.erb} (100%)
rename app/views/{shared/admin_settings => admins/components}/_users.html.erb (90%)
create mode 100644 app/views/admins/edit_user.html.erb
create mode 100644 app/views/admins/server_recordings.html.erb
create mode 100644 app/views/admins/site_settings.html.erb
create mode 100644 spec/concerns/recorder_spec.rb
diff --git a/app/assets/javascripts/admins.js b/app/assets/javascripts/admins.js
index 55fa3a4378..0b27efe0cc 100644
--- a/app/assets/javascripts/admins.js
+++ b/app/assets/javascripts/admins.js
@@ -43,9 +43,9 @@ $(document).on('turbolinks:load', function(){
window.location.replace(url);
})
-
- /* COLOR SELECTORS */
+ }
+ if (controller == "admins" && action == "site_settings") {
loadColourSelectors()
}
diff --git a/app/assets/javascripts/recording.js b/app/assets/javascripts/recording.js
new file mode 100644
index 0000000000..213ca957b6
--- /dev/null
+++ b/app/assets/javascripts/recording.js
@@ -0,0 +1,41 @@
+// 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 .
+
+// Handle changing of settings tabs.
+$(document).on('turbolinks:load', function(){
+ var controller = $("body").data('controller');
+ var action = $("body").data('action');
+
+ if (controller == "rooms" && action == "show"
+ || controller == "rooms" && action == "update"
+ || controller == "users" && action == "recordings"
+ || controller == "admins" && action == "server_recordings"){
+ // Handle recording emails.
+ $('.email-link').each(function(){
+ $(this).click(function(){
+ var subject = $(".username").text() + " " + t('room.mailer.subject');
+ var body = t('room.mailer.body') + "\n\n" + $(this).attr("data-pres-link");
+ var autogenerated = "\n\n" + t('room.mailer.autogenerated') + "\n";
+ var footer = t('room.mailer.footer');
+
+ var url = "mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body) + encodeURIComponent(autogenerated) + encodeURIComponent(footer);
+ var win = window.open(url, '_blank');
+
+ win.focus();
+ });
+ });
+ }
+});
\ No newline at end of file
diff --git a/app/assets/javascripts/rename.js b/app/assets/javascripts/rename.js
index 2057049812..a8f32c6a8d 100644
--- a/app/assets/javascripts/rename.js
+++ b/app/assets/javascripts/rename.js
@@ -18,7 +18,10 @@ $(document).on('turbolinks:load', function(){
var controller = $("body").data('controller');
var action = $("body").data('action');
- if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update" || controller == "users" && action == "recordings"){
+ if(controller == "rooms" && action == "show"
+ || controller == "rooms" && action == "update"
+ || controller == "users" && action == "recordings"
+ || controller == "admins" && action == "server_recordings"){
// Set a room header rename event
var configure_room_header = function(room_title){
diff --git a/app/assets/javascripts/room.js.erb b/app/assets/javascripts/room.js.erb
index f5be24f0db..1dc1367524 100644
--- a/app/assets/javascripts/room.js.erb
+++ b/app/assets/javascripts/room.js.erb
@@ -39,21 +39,6 @@ $(document).on('turbolinks:load', function(){
}, 2000)
}
});
-
- // Handle recording emails.
- $('.email-link').each(function(){
- $(this).click(function(){
- var subject = $(".username").text() + " " + t('room.mailer.subject');
- var body = t('room.mailer.body') + "\n\n" + $(this).attr("data-pres-link");
- var autogenerated = "\n\n" + t('room.mailer.autogenerated') + "\n";
- var footer = t('room.mailer.footer');
-
- var url = "mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body) + encodeURIComponent(autogenerated) + encodeURIComponent(footer);
- var win = window.open(url, '_blank');
-
- win.focus();
- });
- });
}
// Display and update all fields related to creating a room in the createRoomModal
diff --git a/app/assets/javascripts/search.js b/app/assets/javascripts/search.js
index de2c0f7861..6869ebb540 100644
--- a/app/assets/javascripts/search.js
+++ b/app/assets/javascripts/search.js
@@ -22,7 +22,8 @@ $(document).on('turbolinks:load', function(){
(controller == "rooms" && action == "show") ||
(controller == "rooms" && action == "update") ||
(controller == "rooms" && action == "join") ||
- (controller == "users" && action == "recordings")) {
+ (controller == "users" && action == "recordings") ||
+ (controller == "admins" && action == "server_recordings")) {
// Submit search if the user hits enter
$("#search-input").keypress(function(key) {
var keyPressed = key.which
diff --git a/app/assets/javascripts/settings.js b/app/assets/javascripts/settings.js
index bacd22b47b..42b7418e4c 100644
--- a/app/assets/javascripts/settings.js
+++ b/app/assets/javascripts/settings.js
@@ -20,7 +20,7 @@ $(document).on('turbolinks:load', function(){
var action = $("body").data('action');
// Only run on the settings page.
- if ((controller == "users" && action == "edit") || (controller == "users" && action == "update") || (controller == "admins" && action == "index")){
+ if ((controller == "users" && action == "edit") || (controller == "users" && action == "update")){
var settingsButtons = $('.setting-btn');
var settingsViews = $('.setting-view');
diff --git a/app/assets/javascripts/sort.js b/app/assets/javascripts/sort.js
index a7903de6ef..effa8ea6bf 100644
--- a/app/assets/javascripts/sort.js
+++ b/app/assets/javascripts/sort.js
@@ -18,7 +18,10 @@ $(document).on('turbolinks:load', function(){
var controller = $("body").data('controller');
var action = $("body").data('action');
- if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update" || controller == "users" && action == "recordings"){
+ if(controller == "rooms" && action == "show"
+ || controller == "rooms" && action == "update"
+ || controller == "users" && action == "recordings"
+ || controller == "admins" && action == "server_recordings"){
// Choose active header
// (Name, Length or Users)
diff --git a/app/assets/stylesheets/utilities/_primary_themes.scss b/app/assets/stylesheets/utilities/_primary_themes.scss
index 33d48d3129..c8a37695a7 100644
--- a/app/assets/stylesheets/utilities/_primary_themes.scss
+++ b/app/assets/stylesheets/utilities/_primary_themes.scss
@@ -84,6 +84,7 @@ a {
color: #6e7687 !important;
&:hover {
color: $primary-color !important;
+ background-color: $primary-color-lighten !important;
}
&:active {
background-color: $primary-color-lighten !important;
@@ -130,6 +131,7 @@ input:focus, select:focus {
}
& a {
+ color: $primary-color !important;
border-color: $primary-color !important;
}
diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb
index aa4977d37e..8a128b2302 100644
--- a/app/controllers/admins_controller.rb
+++ b/app/controllers/admins_controller.rb
@@ -20,6 +20,7 @@ class AdminsController < ApplicationController
include Pagy::Backend
include Themer
include Emailer
+ include Recorder
manage_users = [:edit_user, :promote, :demote, :ban_user, :unban_user, :approve]
site_settings = [:branding, :coloring, :coloring_lighten, :coloring_darken,
@@ -40,11 +41,27 @@ def index
@pagy, @users = pagy(user_list)
end
+ # GET /admins/site_settings
+ def site_settings
+ end
+
+ # GET /admins/server_recordings
+ def server_recordings
+ server_rooms = if Rails.configuration.loadbalanced_configuration
+ Room.includes(:owner).where(users: { provider: user_settings_provider }).pluck(:bbb_id)
+ else
+ Room.pluck(:bbb_id)
+ end
+
+ @search, @order_column, @order_direction, recs =
+ all_recordings(server_rooms, @user_domain, params.permit(:search, :column, :direction), true, true)
+ @pagy, @recordings = pagy_array(recs)
+ end
+
# MANAGE USERS
# GET /admins/edit/:user_uid
def edit_user
- render "admins/index", locals: { setting_id: "account" }
end
# POST /admins/promote/:user_uid
@@ -111,7 +128,7 @@ def invite
# POST /admins/branding
def branding
@settings.update_value("Branding Image", params[:url])
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
# POST /admins/color
@@ -119,23 +136,23 @@ def coloring
@settings.update_value("Primary Color", params[:color])
@settings.update_value("Primary Color Lighten", color_lighten(params[:color]))
@settings.update_value("Primary Color Darken", color_darken(params[:color]))
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
def coloring_lighten
@settings.update_value("Primary Color Lighten", params[:color])
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
def coloring_darken
@settings.update_value("Primary Color Darken", params[:color])
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
# POST /admins/room_authentication
def room_authentication
@settings.update_value("Room Authentication", params[:value])
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
# POST /admins/registration_method/:method
@@ -144,11 +161,11 @@ def registration_method
# Only allow change to Join by Invitation if user has emails enabled
if !Rails.configuration.enable_email_verification && new_method == Rails.configuration.registration_methods[:invite]
- redirect_to admins_path,
+ redirect_to admin_site_settings_path,
flash: { alert: I18n.t("administrator.flash.invite_email_verification") }
else
@settings.update_value("Registration Method", new_method)
- redirect_to admins_path,
+ redirect_to admin_site_settings_path,
flash: { success: I18n.t("administrator.flash.registration_method_updated") }
end
end
@@ -156,7 +173,7 @@ def registration_method
# POST /admins/room_limit
def room_limit
@settings.update_value("Room Limit", params[:limit])
- redirect_to admins_path, flash: { success: I18n.t("administrator.flash.settings") }
+ redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
private
diff --git a/app/models/concerns/api_concern.rb b/app/controllers/concerns/recorder.rb
similarity index 65%
rename from app/models/concerns/api_concern.rb
rename to app/controllers/concerns/recorder.rb
index 2b25f586b2..0833e5f83d 100644
--- a/app/models/concerns/api_concern.rb
+++ b/app/controllers/concerns/recorder.rb
@@ -16,11 +16,50 @@
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see .
-module APIConcern
+module Recorder
extend ActiveSupport::Concern
+ include ::BbbApi
+
+ # Fetches all recordings for a room.
+ def recordings(room_bbb_id, provider, search_params = {}, ret_search_params = false)
+ res = bbb(provider).get_recordings(meetingID: room_bbb_id)
+
+ format_recordings(res, search_params, ret_search_params)
+ end
+
+ # Fetches a rooms public recordings.
+ def public_recordings(room_bbb_id, provider, search_params = {}, ret_search_params = false)
+ search, order_col, order_dir, recs = recordings(room_bbb_id, provider, search_params, ret_search_params)
+ [search, order_col, order_dir, recs.select { |r| r[:metadata][:"gl-listed"] == "true" }]
+ end
+
+ # Makes paginated API calls to get recordings
+ def all_recordings(room_bbb_ids, provider, search_params = {}, ret_search_params = false, search_name = false)
+ pag_num = Rails.configuration.pagination_number
+
+ pag_loops = room_bbb_ids.length / pag_num - 1
+
+ res = { recordings: [] }
+
+ (0..pag_loops).each do |i|
+ pag_rooms = room_bbb_ids[pag_num * i, pag_num]
+
+ # bbb.get_recordings returns an object
+ # take only the array portion of the object that is returned
+ full_res = bbb(provider).get_recordings(meetingID: pag_rooms)
+ res[:recordings].push(*full_res[:recordings])
+ end
+
+ last_pag_room = room_bbb_ids[pag_num * (pag_loops + 1), room_bbb_ids.length % pag_num]
+
+ full_res = bbb(provider).get_recordings(meetingID: last_pag_room)
+ res[:recordings].push(*full_res[:recordings])
+
+ format_recordings(res, search_params, ret_search_params, search_name)
+ end
# Format, filter, and sort recordings to match their current use in the app
- def format_recordings(api_res, search_params, ret_search_params)
+ def format_recordings(api_res, search_params, ret_search_params, search_name = false)
search = search_params[:search] || ""
order_col = search_params[:column] && search_params[:direction] != "none" ? search_params[:column] : "end_time"
order_dir = search_params[:column] && search_params[:direction] != "none" ? search_params[:direction] : "desc"
@@ -40,7 +79,7 @@ def format_recordings(api_res, search_params, ret_search_params)
r.delete(:playback)
end
- recs = filter_recordings(api_res, search)
+ recs = filter_recordings(api_res, search, search_name)
recs = sort_recordings(recs, order_col, order_dir)
if ret_search_params
@@ -50,7 +89,7 @@ def format_recordings(api_res, search_params, ret_search_params)
end
end
- def filter_recordings(api_res, search)
+ def filter_recordings(api_res, search, search_name = false)
api_res[:recordings].select do |r|
(!r[:metadata].nil? && ((!r[:metadata][:name].nil? &&
r[:metadata][:name].downcase.include?(search)) ||
@@ -59,7 +98,8 @@ def filter_recordings(api_res, search)
((r[:metadata].nil? || r[:metadata][:name].nil?) &&
r[:name].downcase.include?(search)) ||
r[:participants].include?(search) ||
- !r[:playbacks].select { |p| p[:type].downcase.include?(search) }.empty?
+ !r[:playbacks].select { |p| p[:type].downcase.include?(search) }.empty? ||
+ (search_name && Room.find_by(bbb_id: r[:meetingID]).owner.email.downcase.include?(search))
end
end
diff --git a/app/controllers/recordings_controller.rb b/app/controllers/recordings_controller.rb
index e1313f89af..2c4446ae22 100644
--- a/app/controllers/recordings_controller.rb
+++ b/app/controllers/recordings_controller.rb
@@ -50,6 +50,11 @@ def find_room
# Ensure the user is logged into the room they are accessing.
def verify_room_ownership
- redirect_to root_path unless @room.owned_by?(current_user)
+ if !current_user ||
+ !@room.owned_by?(current_user) ||
+ !current_user.has_cached_role?(:admin) ||
+ !current_user.has_cached_role?(:super_admin)
+ redirect_to root_path
+ end
end
end
diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb
index e8e235408e..1e633d0db9 100644
--- a/app/controllers/rooms_controller.rb
+++ b/app/controllers/rooms_controller.rb
@@ -19,6 +19,7 @@
class RoomsController < ApplicationController
include RecordingsHelper
include Pagy::Backend
+ include Recorder
before_action :validate_accepted_terms, unless: -> { !Rails.configuration.terms }
before_action :validate_verified_email, except: [:show, :join],
@@ -56,7 +57,7 @@ def create
def show
if current_user && @room.owned_by?(current_user)
@search, @order_column, @order_direction, recs =
- @room.recordings(params.permit(:search, :column, :direction), true)
+ recordings(@room.bbb_id, @user_domain, params.permit(:search, :column, :direction), true)
@pagy, @recordings = pagy_array(recs)
@@ -72,7 +73,7 @@ def show
end
@search, @order_column, @order_direction, pub_recs =
- @room.public_recordings(params.permit(:search, :column, :direction), true)
+ public_recordings(@room.bbb_id, @user_domain, params.permit(:search, :column, :direction), true)
@pagy, @public_recordings = pagy_array(pub_recs)
@@ -135,7 +136,7 @@ def join
search_params = params[@room.invite_path] || params
@search, @order_column, @order_direction, pub_recs =
- @room.public_recordings(search_params.permit(:search, :column, :direction), true)
+ public_recordings(@room.bbb_id, @user_domain, search_params.permit(:search, :column, :direction), true)
@pagy, @public_recordings = pagy_array(pub_recs)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0224d90552..c28d1c0f77 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -21,6 +21,7 @@ class UsersController < ApplicationController
include Pagy::Backend
include Emailer
include Registrar
+ include Recorder
before_action :find_user, only: [:edit, :update, :destroy]
before_action :ensure_unauthenticated, only: [:new, :create]
@@ -103,6 +104,8 @@ def edit
# PATCH /u/:user_uid/edit
def update
+ redirect_path = current_user.admin_of?(@user) ? admins_path : edit_user_path(@user)
+
if params[:setting] == "password"
# Update the users password.
errors = {}
@@ -123,7 +126,7 @@ def update
if errors.empty? && @user.save
# Notify the user that their account has been updated.
flash[:success] = I18n.t("info_update_success")
- redirect_to edit_user_path(@user)
+ redirect_to redirect_path
else
# Append custom errors.
errors.each { |k, v| @user.errors.add(k, v) }
@@ -132,11 +135,11 @@ def update
elsif user_params[:email] != @user.email && @user.update_attributes(user_params)
@user.update_attributes(email_verified: false)
flash[:success] = I18n.t("info_update_success")
- redirect_to edit_user_path(@user)
+ redirect_to redirect_path
elsif @user.update_attributes(user_params)
update_locale(@user)
flash[:success] = I18n.t("info_update_success")
- redirect_to edit_user_path(@user)
+ redirect_to redirect_path
else
render :edit, params: { settings: params[:settings] }
end
@@ -165,7 +168,8 @@ def destroy
def recordings
if current_user && current_user.uid == params[:user_uid]
@search, @order_column, @order_direction, recs =
- current_user.all_recordings(params.permit(:search, :column, :direction), true)
+ all_recordings(current_user.rooms.pluck(:bbb_id), current_user.provider,
+ params.permit(:search, :column, :direction), true)
@pagy, @recordings = pagy_array(recs)
else
redirect_to root_path
diff --git a/app/helpers/admins_helper.rb b/app/helpers/admins_helper.rb
index af23f73110..4019328394 100644
--- a/app/helpers/admins_helper.rb
+++ b/app/helpers/admins_helper.rb
@@ -19,6 +19,18 @@
module AdminsHelper
include Pagy::Frontend
+ # Returns the action method of the current page
+ def active_page
+ route = Rails.application.routes.recognize_path(request.env['PATH_INFO'])
+
+ route[:action]
+ end
+
+ # Gets the email of the room owner to which the recording belongs to
+ def recording_owner_email(room_id)
+ Room.find_by(bbb_id: room_id).owner.email
+ end
+
def display_invite
current_page?(admins_path) && invite_registration
end
diff --git a/app/models/room.rb b/app/models/room.rb
index dc0b5af27e..728278fd1d 100644
--- a/app/models/room.rb
+++ b/app/models/room.rb
@@ -19,7 +19,6 @@
require 'bbb_api'
class Room < ApplicationRecord
- include ::APIConcern
include ::BbbApi
before_create :setup
@@ -40,7 +39,7 @@ def owned_by?(user)
# Checks if a room is running on the BigBlueButton server.
def running?
- bbb.is_meeting_running?(bbb_id)
+ bbb(owner.provider).is_meeting_running?(bbb_id)
end
# Determines the invite path for the room.
@@ -62,7 +61,7 @@ def start_session(options = {})
# Send the create request.
begin
- meeting = bbb.create_meeting(name, bbb_id, create_options)
+ meeting = bbb(owner.provider).create_meeting(name, bbb_id, create_options)
# Update session info.
unless meeting[:messageKey] == 'duplicateWarning'
update_attributes(sessions: sessions + 1, last_session: DateTime.now)
@@ -84,10 +83,10 @@ def join_path(name, options = {}, uid = nil)
options[:user_is_moderator] ||= false
options[:meeting_recorded] ||= false
- return call_invalid_res unless bbb
+ return call_invalid_res unless bbb(owner.provider)
# Get the meeting info.
- meeting_info = bbb.get_meeting_info(bbb_id, nil)
+ meeting_info = bbb(owner.provider).get_meeting_info(bbb_id, nil)
# Determine the password to use when joining.
password = if options[:user_is_moderator]
@@ -101,7 +100,7 @@ def join_path(name, options = {}, uid = nil)
join_opts[:userID] = uid if uid
join_opts[:joinViaHtml5] = options[:join_via_html5] if options[:join_via_html5]
- bbb.join_meeting_url(bbb_id, name, password, join_opts)
+ bbb(owner.provider).join_meeting_url(bbb_id, name, password, join_opts)
end
# Notify waiting users that a meeting has started.
@@ -111,7 +110,7 @@ def notify_waiting
# Retrieves all the users in a room.
def participants
- res = bbb.get_meeting_info(bbb_id, nil)
+ res = bbb(owner.provider).get_meeting_info(bbb_id, nil)
res[:attendees].map do |att|
User.find_by(uid: att[:userID], name: att[:fullName])
end
@@ -120,27 +119,18 @@ def participants
[]
end
- # Fetches all recordings for a room.
- def recordings(search_params = {}, ret_search_params = false)
- res = bbb.get_recordings(meetingID: bbb_id)
-
- format_recordings(res, search_params, ret_search_params)
- end
-
- # Fetches a rooms public recordings.
- def public_recordings(search_params = {}, ret_search_params = false)
- search, order_col, order_dir, recs = recordings(search_params, ret_search_params)
- [search, order_col, order_dir, recs.select { |r| r[:metadata][:"gl-listed"] == "true" }]
+ def recording_count
+ bbb(owner.provider).get_recordings(meetingID: bbb_id)[:recordings].length
end
def update_recording(record_id, meta)
meta[:recordID] = record_id
- bbb.send_api_request("updateRecordings", meta)
+ bbb(owner.provider).send_api_request("updateRecordings", meta)
end
# Deletes a recording from a room.
def delete_recording(record_id)
- bbb.delete_recordings(record_id)
+ bbb(owner.provider).delete_recordings(record_id)
end
private
@@ -155,7 +145,7 @@ def setup
# Deletes all recordings associated with the room.
def delete_all_recordings
- record_ids = recordings.map { |r| r[:recordID] }
+ record_ids = bbb(owner.provider).get_recordings(meetingID: bbb_id)[:recordings].pluck(:recordID)
delete_recording(record_ids) unless record_ids.empty?
end
diff --git a/app/models/user.rb b/app/models/user.rb
index ba914f9b17..6ed05a76e8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -20,7 +20,6 @@
class User < ApplicationRecord
rolify
- include ::APIConcern
include ::BbbApi
attr_accessor :reset_token
@@ -118,31 +117,8 @@ def self.admins_search(string)
end
def self.admins_order(column, direction)
- order("#{column} #{direction}")
- end
-
- def all_recordings(search_params = {}, ret_search_params = false)
- pag_num = Rails.configuration.pagination_number
-
- pag_loops = rooms.length / pag_num - 1
-
- res = { recordings: [] }
-
- (0..pag_loops).each do |i|
- pag_rooms = rooms[pag_num * i, pag_num]
-
- # bbb.get_recordings returns an object
- # take only the array portion of the object that is returned
- full_res = bbb.get_recordings(meetingID: pag_rooms.pluck(:bbb_id))
- res[:recordings].push(*full_res[:recordings])
- end
-
- last_pag_room = rooms[pag_num * (pag_loops + 1), rooms.length % pag_num]
-
- full_res = bbb.get_recordings(meetingID: last_pag_room.pluck(:bbb_id))
- res[:recordings].push(*full_res[:recordings])
-
- format_recordings(res, search_params, ret_search_params)
+ # Arel.sql to avoid sql injection
+ order(Arel.sql("#{column} #{direction}"))
end
# Activates an account and initialize a users main room
diff --git a/app/views/admins/components/_menu_buttons.html.erb b/app/views/admins/components/_menu_buttons.html.erb
new file mode 100644
index 0000000000..7dfcc8ffc6
--- /dev/null
+++ b/app/views/admins/components/_menu_buttons.html.erb
@@ -0,0 +1,26 @@
+<%
+# 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 .
+%>
+
+
+ <%= link_to admins_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "index"}" do %>
+ <%= t("administrator.users.title") %>
+ <% end %>
+ <%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "site_settings"}" do %>
+ <%= t("administrator.site_settings.title") %>
+ <% end %>
+ <%= link_to admin_recordings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "server_recordings"}" do %>
+ <%= t("administrator.recordings.title") %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/admins/components/_recordings.html.erb b/app/views/admins/components/_recordings.html.erb
new file mode 100644
index 0000000000..2ffa9ee958
--- /dev/null
+++ b/app/views/admins/components/_recordings.html.erb
@@ -0,0 +1,91 @@
+<%
+# 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 .
+%>
+
+
+ <% else %>
+ <% @recordings.each do |recording| %>
+ <%= render "admins/components/server_recording_row", recording: recording %>
+ <% end %>
+ <% end %>
+
+
+ <% if !@recordings.empty?%>
+
+ <%== pagy_bootstrap_nav(@pagy) %>
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/admins/components/_server_recording_row.html.erb b/app/views/admins/components/_server_recording_row.html.erb
new file mode 100644
index 0000000000..c62347553e
--- /dev/null
+++ b/app/views/admins/components/_server_recording_row.html.erb
@@ -0,0 +1,81 @@
+<%
+# 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 .
+%>
+
+
+ <% p = recording[:playbacks].find do |p| p.key?(:length) end %>
+ <% if p %>
+ <%= t("recording.email") %>
+
+ <% end %>
+ <%= button_to delete_recording_path(meetingID: recording[:meetingID], record_id: recording[:recordID]), method: :delete, class: "dropdown-item" do %>
+ <%= t("delete") %>
+ <% end %>
+
+
+
+
diff --git a/app/views/admins/components/_setting_view.html.erb b/app/views/admins/components/_setting_view.html.erb
new file mode 100644
index 0000000000..1b2eb6ecf3
--- /dev/null
+++ b/app/views/admins/components/_setting_view.html.erb
@@ -0,0 +1,26 @@
+<%
+# 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 .
+%>
+
+<%= content_tag(:div, id: setting_id, class: "setting-view card") do %>
+
+<% end %>
diff --git a/app/views/shared/admin_settings/_site_settings.html.erb b/app/views/admins/components/_settings.html.erb
similarity index 100%
rename from app/views/shared/admin_settings/_site_settings.html.erb
rename to app/views/admins/components/_settings.html.erb
diff --git a/app/views/shared/admin_settings/_users.html.erb b/app/views/admins/components/_users.html.erb
similarity index 90%
rename from app/views/shared/admin_settings/_users.html.erb
rename to app/views/admins/components/_users.html.erb
index df8422fae2..5d1ad1bd40 100644
--- a/app/views/shared/admin_settings/_users.html.erb
+++ b/app/views/admins/components/_users.html.erb
@@ -13,6 +13,21 @@
# with BigBlueButton; if not, see .
%>
+<%
+# 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 .
+%>
+
<% if @role.present? %>
<%= render "shared/components/admins_tags" %>
<% end %>
@@ -146,3 +161,4 @@
<%= render "shared/modals/invite_user_modal" %>
+
diff --git a/app/views/admins/edit_user.html.erb b/app/views/admins/edit_user.html.erb
new file mode 100644
index 0000000000..54beeb8ec4
--- /dev/null
+++ b/app/views/admins/edit_user.html.erb
@@ -0,0 +1,27 @@
+<%
+# 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 .
+%>
+
+
diff --git a/app/views/admins/server_recordings.html.erb b/app/views/admins/server_recordings.html.erb
new file mode 100644
index 0000000000..a07b19cbcd
--- /dev/null
+++ b/app/views/admins/server_recordings.html.erb
@@ -0,0 +1,27 @@
+<%
+# 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 .
+%>
+
+
diff --git a/app/views/admins/site_settings.html.erb b/app/views/admins/site_settings.html.erb
new file mode 100644
index 0000000000..c246ce7153
--- /dev/null
+++ b/app/views/admins/site_settings.html.erb
@@ -0,0 +1,27 @@
+<%
+# 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 .
+%>
+
+