Skip to content

Commit

Permalink
Merge branch 'master' into translations_en-yml--master_hy
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Apr 28, 2020
2 parents 937083a + fef02ee commit 7e01334
Show file tree
Hide file tree
Showing 21 changed files with 922 additions and 60 deletions.
19 changes: 10 additions & 9 deletions app/assets/javascripts/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
})
}

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/rooms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@
text-decoration: line-through;
}

.enabled-setting {
background: lightgray;
pointer-events: none;
}
14 changes: 14 additions & 0 deletions app/controllers/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def server_rooms
@pagy, @rooms = pagy_array(server_rooms_list)
end

# GET /admins/room_configuration
def room_configuration
end

# MANAGE USERS

# GET /admins/edit/:user_uid
Expand Down Expand Up @@ -241,6 +245,16 @@ def log_level
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
Expand Down
33 changes: 28 additions & 5 deletions app/controllers/concerns/joiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def save_recent_rooms
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)
Expand Down Expand Up @@ -94,6 +94,29 @@ def default_meeting_options
}
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

private

def fetch_guest_id
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def create

# GET /:room_uid
def show
@anyone_can_start = JSON.parse(@room[:room_settings])["anyoneCanStart"]
@room_settings = @room[:room_settings]
@anyone_can_start = room_setting_with_config("anyoneCanStart")
@room_running = room_running?(@room.bbb_id)
@shared_room = room_shared_with_user

Expand Down Expand Up @@ -160,9 +161,9 @@ def start
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)
Expand Down
29 changes: 24 additions & 5 deletions app/helpers/admins_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -85,12 +94,22 @@ def room_limit_number
@settings.get_value("Room Limit").to_i
end

def edit_disabled
@edit_disabled ||= @selected_role.priority <= current_user.highest_priority_role.priority
# 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

# Get the room status to display in the Server Rooms table
def room_is_running(id)
@running_room_bbb_ids.include?(id)
# Roles

def edit_disabled
@edit_disabled ||= @selected_role.priority <= current_user.highest_priority_role.priority
end
end
4 changes: 4 additions & 0 deletions app/helpers/rooms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ def current_room_exceeds_limit(room)
@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
3 changes: 2 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def initialize(user)
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")
Expand Down
17 changes: 17 additions & 0 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ def default_value(name)
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
3 changes: 3 additions & 0 deletions app/views/admins/components/_menu_buttons.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
101 changes: 101 additions & 0 deletions app/views/admins/components/_room_settings.html.erb
Original file line number Diff line number Diff line change
@@ -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>
27 changes: 27 additions & 0 deletions app/views/admins/room_configuration.html.erb
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 7e01334

Please sign in to comment.