Added room configuration tab to admin panel

This commit is contained in:
farhatahmad 2020-04-06 15:48:42 -04:00
parent 5aa1868f63
commit 5c7062d7c9
14 changed files with 264 additions and 32 deletions

View File

@ -144,10 +144,11 @@ function showCreateRoom(target) {
$("#room_access_code").val(null)
$("#createRoomModal form").attr("action", $("body").data('relative-root'))
$("#room_mute_on_join").prop("checked", false)
$("#room_require_moderator_approval").prop("checked", false)
$("#room_anyone_can_start").prop("checked", false)
$("#room_all_join_moderator").prop("checked", false)
$("#room_mute_on_join").prop("checked", $("#room_mute_on_join").data("default"))
$("#room_require_moderator_approval").prop("checked", $("#room_require_moderator_approval").data("default"))
$("#room_anyone_can_start").prop("checked", $("#room_anyone_can_start").data("default"))
$("#room_all_join_moderator").prop("checked", $("#room_all_join_moderator").data("default"))
//show all elements & their children with a create-only class
$(".create-only").each(function() {
@ -203,11 +204,11 @@ function showDeleteRoom(target) {
function updateCurrentSettings(settings_path){
// Get current room settings and set checkbox
$.get(settings_path, function(room_settings) {
var settings = JSON.parse(room_settings)
$("#room_mute_on_join").prop("checked", settings.muteOnStart)
$("#room_require_moderator_approval").prop("checked", settings.requireModeratorApproval)
$("#room_anyone_can_start").prop("checked", settings.anyoneCanStart)
$("#room_all_join_moderator").prop("checked", settings.joinModerator)
var settings = JSON.parse(room_settings)
$("#room_mute_on_join").prop("checked", $("#room_mute_on_join").data("default") || settings.muteOnStart)
$("#room_require_moderator_approval").prop("checked", $("#room_require_moderator_approval").data("default") || settings.requireModeratorApproval)
$("#room_anyone_can_start").prop("checked", $("#room_anyone_can_start").data("default") || settings.anyoneCanStart)
$("#room_all_join_moderator").prop("checked", $("#room_all_join_moderator").data("default") || settings.joinModerator)
})
}

View File

@ -73,6 +73,10 @@ class AdminsController < ApplicationController
@pagy, @rooms = pagy_array(server_rooms_list)
end
# GET /admins/room_configuration
def room_configuration
end
# MANAGE USERS
# GET /admins/edit/:user_uid
@ -241,6 +245,16 @@ class AdminsController < ApplicationController
redirect_to admin_site_settings_path, flash: { success: I18n.t("administrator.flash.settings") }
end
# ROOM CONFIGURATION
# POST /admins/update_room_configuration
def update_room_configuration
@settings.update_value(params[:setting], params[:value])
flash_message = I18n.t("administrator.flash.room_configuration")
redirect_to admin_room_configuration_path, flash: { success: flash_message }
end
# ROLES
# GET /admins/roles

View File

@ -48,15 +48,15 @@ module Joiner
end
def join_room(opts)
room_settings = JSON.parse(@room[:room_settings])
@room_settings = JSON.parse(@room[:room_settings])
if room_running?(@room.bbb_id) || @room.owned_by?(current_user) || room_settings["anyoneCanStart"]
if room_running?(@room.bbb_id) || @room.owned_by?(current_user) || room_setting_with_config("anyoneCanStart")
# Determine if the user needs to join as a moderator.
opts[:user_is_moderator] = @room.owned_by?(current_user) || room_settings["joinModerator"] || @shared_room
opts[:user_is_moderator] = @room.owned_by?(current_user) || room_setting_with_config("joinModerator") || @shared_room
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
opts[:mute_on_start] = room_settings["muteOnStart"]
opts[:require_moderator_approval] = room_setting_with_config("requireModeratorApproval")
opts[:mute_on_start] = room_setting_with_config("muteOnStart")
if current_user
redirect_to join_path(@room, current_user.name, opts, current_user.uid)
@ -92,4 +92,27 @@ module Joiner
recording_default_visibility: @settings.get_value("Default Recording Visibility") == "public"
}
end
# Gets the room setting based on the option set in the room configuration
def room_setting_with_config(name)
config = case name
when "muteOnStart"
"Room Configuration Mute On Join"
when "requireModeratorApproval"
"Room Configuration Require Moderator"
when "joinModerator"
"Room Configuration All Join Moderator"
when "anyoneCanStart"
"Room Configuration Allow Any Start"
end
case @settings.get_value(config)
when "enabled"
true
when "optional"
@room_settings[name]
when "disabled"
false
end
end
end

View File

@ -160,9 +160,9 @@ class RoomsController < ApplicationController
opts[:user_is_moderator] = true
# Include the user's choices for the room settings
room_settings = JSON.parse(@room[:room_settings])
opts[:mute_on_start] = room_settings["muteOnStart"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
@room_settings = JSON.parse(@room[:room_settings])
opts[:mute_on_start] = room_setting_with_config("muteOnStart")
opts[:require_moderator_approval] = room_setting_with_config("requireModeratorApproval")
begin
redirect_to join_path(@room, current_user.name, opts, current_user.uid)

View File

@ -19,11 +19,20 @@
module AdminsHelper
include Pagy::Frontend
# Server Rooms
# 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.presence || Room.find_by(bbb_id: room_id).owner.username
end
# Get the room status to display in the Server Rooms table
def room_is_running(id)
@running_room_bbb_ids.include?(id)
end
# Site Settings
def admin_invite_registration
controller_name == "admins" && action_name == "index" &&
@settings.get_value("Registration Method") == Rails.configuration.registration_methods[:invite]
@ -85,12 +94,22 @@ module AdminsHelper
@settings.get_value("Room Limit").to_i
end
# Room Configuration
def room_configuration_string(name)
case @settings.get_value(name)
when "enabled"
t("administrator.room_configuration.options.enabled")
when "optional"
t("administrator.room_configuration.options.optional")
when "disabled"
t("administrator.room_configuration.options.disabled")
end
end
# Roles
def edit_disabled
@edit_disabled ||= @selected_role.priority <= current_user.highest_priority_role.priority
end
# Get the room status to display in the Server Rooms table
def room_is_running(id)
@running_room_bbb_ids.include?(id)
end
end

View File

@ -37,4 +37,8 @@ module RoomsHelper
@diff = current_user.rooms.count - limit
@diff.positive? && current_user.rooms.pluck(:id).index(room.id) + 1 > limit
end
def room_configuration(name)
@settings.get_value(name)
end
end

View File

@ -27,7 +27,8 @@ class Ability
else
highest_role = user.highest_priority_role
if highest_role.get_permission("can_edit_site_settings")
can [:site_settings, :update_settings, :coloring, :registration_method], :admin
can [:site_settings, :room_configuration, :update_settings,
:update_room_configuration, :coloring, :registration_method], :admin
end
if highest_role.get_permission("can_edit_roles")

View File

@ -58,6 +58,23 @@ class Setting < ApplicationRecord
Rails.configuration.number_of_rooms_default
when "Shared Access"
Rails.configuration.shared_access_default
when "Room Configuration Mute On Join"
room_config_setting("mute-on-join")
when "Room Configuration Require Moderator"
room_config_setting("require-moderator-approval")
when "Room Configuration Allow Any Start"
room_config_setting("anyone-can-start")
when "Room Configuration All Join Moderator"
room_config_setting("all-join-moderator")
end
end
# Check if the room setting is currently enabled in .env, return disabled if not and return optional if it is
def room_config_setting(name)
if Rails.configuration.room_features.include?(name)
"optional"
else
"disabled"
end
end
end

View File

@ -33,6 +33,9 @@
<%= link_to admin_site_settings_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "site_settings"}" do %>
<span class="icon mr-4"><i class="fas fa-cogs"></i></span><%= t("administrator.site_settings.title") %>
<% end %>
<%= link_to admin_room_configuration_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "room_configuration"}" do %>
<span class="icon mr-4"><i class="fas fa-sliders-h"></i></span><%= t("administrator.room_configuration.title") %>
<% end %>
<% end %>
<% if highest_role.get_permission("can_edit_roles") || highest_role.name == "super_admin" %>
<%= link_to admin_roles_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "roles"}" do %>

View File

@ -0,0 +1,101 @@
<div>
<div class="mb-6 row">
<div class="col-12">
<div class="form-group">
<label class="form-label"><%= t("modal.room_settings.mute") %></label>
<label class="form-label text-muted"><%= t("administrator.room_configuration.mute.info") %></label>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= room_configuration_string("Room Configuration Mute On Join") %>
</button>
<div class="dropdown-menu">
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Mute On Join", value: "enabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.enabled") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Mute On Join", value: "optional"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.optional") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Mute On Join", value: "disabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.disabled") %>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="mb-6 row">
<div class="col-12">
<div class="form-group">
<label class="form-label"><%= t("modal.room_settings.require_approval") %></label>
<label class="form-label text-muted"><%= t("administrator.room_configuration.require_moderator.info") %></label>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= room_configuration_string("Room Configuration Require Moderator") %>
</button>
<div class="dropdown-menu">
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Require Moderator", value: "enabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.enabled") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Require Moderator", value: "optional"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.optional") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Require Moderator", value: "disabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.disabled") %>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="mb-6 row">
<div class="col-12">
<div class="form-group">
<label class="form-label"><%= t("modal.room_settings.start") %></label>
<label class="form-label text-muted"><%= t("administrator.room_configuration.allow_any.info") %></label>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= room_configuration_string("Room Configuration Allow Any Start") %>
</button>
<div class="dropdown-menu">
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Allow Any Start", value: "enabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.enabled") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Allow Any Start", value: "optional"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.optional") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Allow Any Start", value: "disabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.disabled") %>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="mb-6 row">
<div class="col-12">
<div class="form-group">
<label class="form-label"><%= t("modal.room_settings.join_moderator") %></label>
<label class="form-label text-muted"><%= t("administrator.room_configuration.all_moderator.info") %></label>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= room_configuration_string("Room Configuration All Join Moderator") %>
</button>
<div class="dropdown-menu">
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration All Join Moderator", value: "enabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.enabled") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration All Join Moderator", value: "optional"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.optional") %>
<% end %>
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration All Join Moderator", value: "disabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.disabled") %>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -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 <http://www.gnu.org/licenses/>.
%>
<div class="container pt-6">
<%= render "shared/components/subtitle", subtitle: t("administrator.title"), search: false %>
<div class="row">
<div class="col-lg-3 mb-4">
<%= render "admins/components/menu_buttons" %>
</div>
<div id="room_configuration" class="col-lg-9">
<%= render "admins/components/setting_view", setting_id: "room_settings", setting_title: t("administrator.room_configuration.title"), search: false %>
</div>
</div>
</div>

View File

@ -43,34 +43,38 @@
</span>
</div>
<% if Rails.configuration.room_features.include? "mute-on-join" %>
<% mute = room_configuration("Room Configuration Mute On Join") %>
<% if mute != "disabled" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.room_settings.mute")%></span>
<%= f.check_box :mute_on_join, class: "custom-switch-input", checked: false %>
<%= f.check_box :mute_on_join, class: "custom-switch-input", data: { default: mute == "enabled" }, checked: false %>
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>
<% if Rails.configuration.room_features.include? "require-moderator-approval" %>
<% require_approval = room_configuration("Room Configuration Require Moderator") %>
<% if require_approval != "disabled" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.room_settings.require_approval")%></span>
<%= f.check_box :require_moderator_approval, class: "custom-switch-input", checked: false %>
<%= f.check_box :require_moderator_approval, class: "custom-switch-input", data: { default: require_approval == "enabled" }, checked: false %>
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>
<% if Rails.configuration.room_features.include? "anyone-can-start" %>
<% any_start = room_configuration("Room Configuration Allow Any Start") %>
<% if any_start != "disabled" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.room_settings.start")%></span>
<%= f.check_box :anyone_can_start, class: "custom-switch-input", checked: false %>
<%= f.check_box :anyone_can_start, class: "custom-switch-input", data: { default: any_start == "enabled" }, checked: false %>
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>
<% if Rails.configuration.room_features.include? "all-join-moderator" %>
<% moderator = room_configuration("Room Configuration All Join Moderator") %>
<% if moderator != "disabled" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.room_settings.join_moderator")%></span>
<%= f.check_box :all_join_moderator, class: "custom-switch-input", checked: false %>
<%= f.check_box :all_join_moderator, class: "custom-switch-input", data: { default: moderator == "enabled" }, checked: false %>
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>

View File

@ -101,6 +101,7 @@ en:
registration_method_updated: Registration method successfully updated
reset_password: The user has been sent an email to reset their password. (Please ask them to check their spam folder if they haven't received it)
restored: User has been successfully restored
room_configuration: Room Configuration successfully changed
settings: Site Settings successfully changed
unauthorized: You are not authorized to perform actions on this user
recordings:
@ -127,6 +128,20 @@ en:
colour:
title: Role Colour
info: Set the colour that will be associated with the role
room_configuration:
title: Room Configuration
mute:
info: Automatically mutes the user when they join the BigBlueButton meeting
require_moderator:
info: Prompts the moderator of the BigBlueButton meeting when a user tries to join. If the user is approved, they will be able to join the meeting.
allow_any:
info: Allows any user to start the meeting at any time. By default, only the room owner can start the meeting.
all_moderator:
info: Gives all users moderator priveleges in BigBlueButton when they join the meeting.
options:
disabled: Disabled
enabled: Always Enabled
optional: Optional
rooms:
title: Server Rooms
table:

View File

@ -41,6 +41,7 @@ Rails.application.routes.draw do
get '/rooms', to: 'admins#server_rooms', as: :admin_rooms
get '/recordings', to: 'admins#server_recordings', as: :admin_recordings
get '/site_settings', to: 'admins#site_settings', as: :admin_site_settings
get '/room_configuration', to: 'admins#room_configuration', as: :admin_room_configuration
get '/roles', to: 'admins#roles', as: :admin_roles
# Manage Users
get '/edit/:user_uid', to: 'admins#edit_user', as: :admin_edit_user
@ -58,6 +59,8 @@ Rails.application.routes.draw do
post '/clear_cache', to: 'admins#clear_cache', as: :admin_clear_cache
post '/clear_auth', to: 'admins#clear_auth', as: :admin_clear_auth
post '/log_level', to: 'admins#log_level', as: :admin_log_level
# Room Configuration
post '/update_room_configuration', to: 'admins#update_room_configuration', as: :admin_update_room_configuration
# Roles
post '/role', to: 'admins#new_role', as: :admin_new_role
patch 'roles/order', to: 'admins#change_role_order', as: :admin_roles_order