From d466a426cb4252ed81bd234d8b9a263bcb71ac39 Mon Sep 17 00:00:00 2001 From: yanosz Date: Thu, 21 May 2020 15:07:16 +0200 Subject: [PATCH] Co-authored-by: Tobias Fiebig --- app/assets/javascripts/room.js | 26 +++++++++++++++-- app/controllers/concerns/joiner.rb | 4 ++- app/controllers/rooms_controller.rb | 10 +++++-- app/models/room.rb | 8 +++++ app/models/setting.rb | 2 ++ .../admins/components/_room_settings.html.erb | 29 ++++++++++++++++++- .../rooms/components/_room_event.html.erb | 1 + .../shared/modals/_create_room_modal.html.erb | 11 +++++-- config/application.rb | 28 +++++++++--------- config/locales/en.yml | 6 ++++ sample.env | 3 +- spec/controllers/rooms_controller_spec.rb | 12 ++++---- 12 files changed, 109 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/room.js b/app/assets/javascripts/room.js index 8137d0c6d7..8bd14f3454 100644 --- a/app/assets/javascripts/room.js +++ b/app/assets/javascripts/room.js @@ -138,11 +138,11 @@ function showCreateRoom(target) { $("#room_access_code").val(null) $("#createRoomModal form").attr("action", $("body").data('relative-root')) - $("#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")) + $("#room_recording").prop("checked", $("#room_recording").data("default")) //show all elements & their children with a create-only class $(".create-only").each(function() { @@ -155,6 +155,9 @@ function showCreateRoom(target) { $(this).attr('style',"display:none !important") if($(this).children().length > 0) { $(this).children().attr('style',"display:none !important") } }) + + runningSessionWarningVisibilty(false) + } function showUpdateRoom(target) { @@ -187,6 +190,9 @@ function showUpdateRoom(target) { $("#create-room-access-code").text(getLocalizedString("modal.create_room.access_code_placeholder")) $("#room_access_code").val(null) } + + runningSessionWarningVisibilty(false) + } function showDeleteRoom(target) { @@ -197,12 +203,15 @@ function showDeleteRoom(target) { //Update the createRoomModal to show the correct current settings function updateCurrentSettings(settings_path){ // Get current room settings and set checkbox - $.get(settings_path, function(room_settings) { - var settings = JSON.parse(room_settings) + $.get(settings_path, function(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) + $("#room_recording").prop("checked", $("#room_recording").data("default") || settings.recording) + + runningSessionWarningVisibilty(settings.running) + }) } @@ -264,3 +273,14 @@ function removeSharedUser(target) { parentLI.classList.add("remove-shared") } } + +// Show a "Session Running warning" for each room setting, which cannot be changed during a running session +function runningSessionWarningVisibilty(isRunning) { + if(isRunning) { + $(".running-only").show() + $(".not-running-only").hide() + } else { + $(".running-only").hide() + $(".not-running-only").show() + } +} diff --git a/app/controllers/concerns/joiner.rb b/app/controllers/concerns/joiner.rb index 3295de21fc..b8d24878b1 100644 --- a/app/controllers/concerns/joiner.rb +++ b/app/controllers/concerns/joiner.rb @@ -87,7 +87,7 @@ def default_meeting_options { user_is_moderator: false, meeting_logout_url: request.base_url + logout_room_path(@room), - meeting_recorded: true, + meeting_recorded: @room.recording?, moderator_message: "#{invite_msg}\n\n#{request.base_url + room_path(@room)}", host: request.host, recording_default_visibility: @settings.get_value("Default Recording Visibility") == "public" @@ -105,6 +105,8 @@ def room_setting_with_config(name) "Room Configuration All Join Moderator" when "anyoneCanStart" "Room Configuration Allow Any Start" + when "recording" + "Room Configuration Recording" end case @settings.get_value(config) diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index c9ef641787..13917aa796 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -171,7 +171,7 @@ def start @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") - + opts[:record] = room_setting_with_config("recording") begin redirect_to join_path(@room, current_user.name, opts, current_user.uid) rescue BigBlueButton::BigBlueButtonException => e @@ -261,8 +261,10 @@ def shared_users # GET /:room_uid/room_settings def room_settings # Respond with JSON object of the room_settings + status = { running: room_running?(@room.bbb_id) } + settings = @room.settings_hash respond_to do |format| - format.json { render body: @room.room_settings.to_json } + format.json { render body: status.merge(settings).to_json } end end @@ -291,6 +293,7 @@ def create_room_settings_string(options) "requireModeratorApproval": options[:require_moderator_approval] == "1", "anyoneCanStart": options[:anyone_can_start] == "1", "joinModerator": options[:all_join_moderator] == "1", + "recording": options[:recording] == "1", } room_settings.to_json @@ -298,7 +301,8 @@ def create_room_settings_string(options) def room_params params.require(:room).permit(:name, :auto_join, :mute_on_join, :access_code, - :require_moderator_approval, :anyone_can_start, :all_join_moderator) + :require_moderator_approval, :anyone_can_start, :all_join_moderator, + :recording) end # Find the room from the uid. diff --git a/app/models/room.rb b/app/models/room.rb index 02d0b7cc89..9726c74b14 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -98,6 +98,14 @@ def self.order_by_status(table, ids) table.order(Arel.sql(order_string)) end + def settings_hash + JSON.parse(room_settings || "{}") + end + + def recording? + settings_hash["recording"] + end + private # Generates a uid for the room and BigBlueButton. diff --git a/app/models/setting.rb b/app/models/setting.rb index 38b0a9b4b0..dd924af42b 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -70,6 +70,8 @@ def default_value(name) room_config_setting("anyone-can-start") when "Room Configuration All Join Moderator" room_config_setting("all-join-moderator") + when "Room Configuration Recording" + room_config_setting("recording") end end diff --git a/app/views/admins/components/_room_settings.html.erb b/app/views/admins/components/_room_settings.html.erb index 19a00959b1..d4f8835b5a 100644 --- a/app/views/admins/components/_room_settings.html.erb +++ b/app/views/admins/components/_room_settings.html.erb @@ -98,4 +98,31 @@ - \ No newline at end of file + +
+
+
+ + + +
+
+
+ + + diff --git a/app/views/rooms/components/_room_event.html.erb b/app/views/rooms/components/_room_event.html.erb index 45adc4dadb..bba7748c55 100644 --- a/app/views/rooms/components/_room_event.html.erb +++ b/app/views/rooms/components/_room_event.html.erb @@ -18,6 +18,7 @@

<%= t("room.invited") %>

+

<%= t("room.recording_present") if @room.recording?%>

<%= @room.name %>


diff --git a/app/views/shared/modals/_create_room_modal.html.erb b/app/views/shared/modals/_create_room_modal.html.erb index 2534d5b81c..1244a940f6 100644 --- a/app/views/shared/modals/_create_room_modal.html.erb +++ b/app/views/shared/modals/_create_room_modal.html.erb @@ -69,7 +69,6 @@ <% end %> - <% moderator = room_configuration("Room Configuration All Join Moderator") %> <% if moderator != "disabled" %> <% end %> - + <% recording = room_configuration("Room Configuration Recording") %> + <% if recording != "disabled" %> + + <% end %>