Skip to content

Commit

Permalink
GRN2-129: Added server recordings and refactored adminsitrator panel (b…
Browse files Browse the repository at this point in the history
…igbluebutton#662)

* Added server recordings and refactored adminsitrator panel

* Fixed some issues

* Fixed issue with owner email search

* Fixed issue with edit user
  • Loading branch information
farhatahmad authored and jfederico committed Jul 22, 2019
1 parent 8c63f79 commit a055b88
Show file tree
Hide file tree
Showing 38 changed files with 1,088 additions and 640 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/admins.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ $(document).on('turbolinks:load', function(){

window.location.replace(url);
})

/* COLOR SELECTORS */
}

if (controller == "admins" && action == "site_settings") {
loadColourSelectors()
}

Expand Down
41 changes: 41 additions & 0 deletions app/assets/javascripts/recording.js
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

// 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();
});
});
}
});
5 changes: 4 additions & 1 deletion app/assets/javascripts/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
15 changes: 0 additions & 15 deletions app/assets/javascripts/room.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/utilities/_primary_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -130,6 +131,7 @@ input:focus, select:focus {
}

& a {
color: $primary-color !important;
border-color: $primary-color !important;
}

Expand Down
35 changes: 26 additions & 9 deletions app/controllers/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -111,31 +128,31 @@ 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
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
Expand All @@ -144,19 +161,19 @@ 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

# 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,50 @@
# 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 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"
Expand All @@ -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
Expand All @@ -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)) ||
Expand All @@ -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

Expand Down
7 changes: 6 additions & 1 deletion app/controllers/recordings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit a055b88

Please sign in to comment.