Skip to content

Commit

Permalink
#1163 Configure recordings for rooms.
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Fiebig <t.fiebig@tudelft.nl>
  • Loading branch information
2 people authored and yanosz committed May 21, 2020
1 parent 7411eba commit 943822b
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 31 deletions.
26 changes: 23 additions & 3 deletions app/assets/javascripts/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,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() {
Expand All @@ -161,6 +161,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) {
Expand Down Expand Up @@ -193,6 +196,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) {
Expand All @@ -203,12 +209,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)

})
}

Expand Down Expand Up @@ -269,4 +278,15 @@ function removeSharedUser(target) {
parentLI.removeChild(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()
}
}
4 changes: 3 additions & 1 deletion app/controllers/concerns/joiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,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
Expand Down Expand Up @@ -254,8 +254,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

Expand Down Expand Up @@ -284,14 +286,16 @@ 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
end

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.
Expand Down
8 changes: 8 additions & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def notify_waiting
ActionCable.server.broadcast("#{uid}_waiting_channel", action: "started")
end

def settings_hash
JSON.parse(room_settings || "{}")
end

def recording?
settings_hash["recording"]
end

private

# Generates a uid for the room and BigBlueButton.
Expand Down
2 changes: 2 additions & 0 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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

Expand Down
29 changes: 28 additions & 1 deletion app/views/admins/components/_room_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,31 @@
</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.recordings") %></label>
<label class="form-label text-muted"><%= t("administrator.room_configuration.recordings.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 Recording") %>
</button>
<div class="dropdown-menu">
<%= button_to admin_update_room_configuration_path(setting: "Room Configuration Recording", 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 Recording", 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 Recording", value: "disabled"), class: "dropdown-item", "data-disable": "" do %>
<%= t("administrator.room_configuration.options.disabled") %>
<% end %>
</div>
</div>
</div>
</div>
</div>


</div>
1 change: 1 addition & 0 deletions app/views/rooms/components/_room_event.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<div class="row pt-9">
<div class="col-lg-12 col-sm-12">
<h4 class="text-left"><%= t("room.invited") %></h4>
<h4 class="text-left text-danger"><%= t("room.recording_present") if @room.recording?%></h4>
<h1 class="display-3 text-left mb-3 font-weight-400"><%= @room.name %></h1>
<hr class="mt-2 float-left w-25">
</div>
Expand Down
11 changes: 9 additions & 2 deletions app/views/shared/modals/_create_room_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>

<% 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 <%= "enabled-setting" if moderator == "enabled" %>">
Expand All @@ -78,7 +77,15 @@
<span class="custom-switch-indicator float-right cursor-pointer"></span>
</label>
<% end %>

<% recording = room_configuration("Room Configuration Recording") %>
<% if recording != "disabled" %>
<label class="custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block <%= "enabled-setting" if recording == "enabled" %>">
<span class="custom-switch-description"><%= t("modal.room_settings.recording")%></span>
<%= f.check_box :recording, class: "not-running-only custom-switch-input", data: { default: recording == "enabled" }, checked: false %>
<span class="float-right cursor-pointer running-only text-danger" style="display: none"><%= t("modal.room_settings.session_active")%></span>
<span class="custom-switch-indicator not-running-only float-right cursor-pointer"></span>
</label>
<% end %>
<label id="auto-join-label" class="create-only custom-switch pl-0 mt-3 mb-3 w-100 text-left d-inline-block">
<span class="custom-switch-description"><%= t("modal.create_room.auto_join") %></span>
<%= f.check_box :auto_join, class: "custom-switch-input", checked: false %>
Expand Down
28 changes: 14 additions & 14 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ class Application < Rails::Application

# Use standalone BigBlueButton server.
config.bigbluebutton_endpoint = if ENV["BIGBLUEBUTTON_ENDPOINT"].present?
ENV["BIGBLUEBUTTON_ENDPOINT"]
else
config.bigbluebutton_endpoint_default
end
ENV["BIGBLUEBUTTON_ENDPOINT"]
else
config.bigbluebutton_endpoint_default
end

config.bigbluebutton_secret = if ENV["BIGBLUEBUTTON_SECRET"].present?
ENV["BIGBLUEBUTTON_SECRET"]
else
config.bigbluebutton_secret_default
end
ENV["BIGBLUEBUTTON_SECRET"]
else
config.bigbluebutton_secret_default
end

# Fix endpoint format if required.
config.bigbluebutton_endpoint += "/" unless config.bigbluebutton_endpoint.ends_with?('/')
Expand Down Expand Up @@ -144,12 +144,12 @@ class Application < Rails::Application

# Default registration method if the user does not specify one
config.registration_method_default = if ENV["DEFAULT_REGISTRATION"] == "invite"
config.registration_methods[:invite]
elsif ENV["DEFAULT_REGISTRATION"] == "approval"
config.registration_methods[:approval]
else
config.registration_methods[:open]
end
config.registration_methods[:invite]
elsif ENV["DEFAULT_REGISTRATION"] == "approval"
config.registration_methods[:approval]
else
config.registration_methods[:open]
end

# Default limit on number of rooms users can create
config.number_of_rooms_default = 15
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ en:
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 privileges in BigBlueButton when they join the meeting.
recordings:
info: Records a recording of the room and enables moderators to set recording markers
options:
disabled: Disabled
enabled: Always Enabled
Expand Down Expand Up @@ -386,10 +388,13 @@ en:
update: Update Room
client: Select client type
join_moderator: All users join as moderators
recordings: Enable room recordings
mute: Mute users when they join
require_approval: Require moderator approval before joining
start: Allow any user to start this meeting
footer_text: Adjustment to your room can be done at anytime.
recording: Record sessions
session_active: Active session
rename_room:
name_placeholder: Enter a new room name...
share_access:
Expand Down Expand Up @@ -493,6 +498,7 @@ en:
enter_the_access_code: Enter the room's access code
invalid_provider: You have entered an invalid url. Please check the url and try again.
invited: You have been invited to join
recording_present: The session is going to be recorded. This includes voice and video from your side.
invite_participants: Invite Participants
join: Join
last_session: Last session on %{session}
Expand Down
3 changes: 2 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ RELATIVE_URL_ROOT=/b
# require-moderator-approval: Require moderators to approve new users before they can join the room
# anyone-can-start: Allows anyone with the join url to start the room in BigBlueButton
# all-join-moderator: All users join as moderators in BigBlueButton
ROOM_FEATURES=mute-on-join,require-moderator-approval,anyone-can-start,all-join-moderator
# Recording: Sessions can be recorded
ROOM_FEATURES=mute-on-join,require-moderator-approval,anyone-can-start,all-join-moderator,recording

# Specify the maximum number of records to be sent to the BigBlueButton API in one call
# Default is set to 25 records
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def random_valid_room_params
room_params = { name: name, "mute_on_join": "1",
"require_moderator_approval": "1", "anyone_can_start": "1", "all_join_moderator": "1" }
json_room_settings = "{\"muteOnStart\":true,\"requireModeratorApproval\":true," \
"\"anyoneCanStart\":true,\"joinModerator\":true}"
"\"anyoneCanStart\":true,\"joinModerator\":true,\"recording\":false}"

post :create, params: { room: room_params }

Expand All @@ -186,12 +186,12 @@ def random_valid_room_params
@owner.main_room.update_attribute(:room_settings, { "muteOnStart": true, "requireModeratorApproval": true,
"anyoneCanStart": true, "joinModerator": true }.to_json)

json_room_settings = "{\"muteOnStart\":true,\"requireModeratorApproval\":true," \
json_room_settings = "{\"running\":false,\"muteOnStart\":true,\"requireModeratorApproval\":true," \
"\"anyoneCanStart\":true,\"joinModerator\":true}"

get :room_settings, params: { room_uid: @owner.main_room }, format: :json

expect(JSON.parse(response.body)).to eql(json_room_settings)
expect(JSON.parse(response.body).to_json).to eql(json_room_settings)
end

it "should redirect to root if not logged in" do
Expand Down Expand Up @@ -567,9 +567,9 @@ def random_valid_room_params
it "properly updates room settings through the room settings modal and redirects to current page" do
@request.session[:user_id] = @user.id

room_params = { "mute_on_join": "1", "name": @secondary_room.name }
room_params = { "mute_on_join": "1", "name": @secondary_room.name, "recording": "1" }
formatted_room_params = "{\"muteOnStart\":true,\"requireModeratorApproval\":false," \
"\"anyoneCanStart\":false,\"joinModerator\":false}" # JSON string format
"\"anyoneCanStart\":false,\"joinModerator\":false,\"recording\":true}" # JSON string format

expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } }
.to change { @secondary_room.reload.room_settings }
Expand All @@ -592,7 +592,7 @@ def random_valid_room_params

room_params = { "mute_on_join": "1", "name": @secondary_room.name }
formatted_room_params = "{\"muteOnStart\":true,\"requireModeratorApproval\":false," \
"\"anyoneCanStart\":false,\"joinModerator\":false}" # JSON string format
"\"anyoneCanStart\":false,\"joinModerator\":false,\"recording\":false}" # JSON string format

expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } }
.to change { @secondary_room.reload.room_settings }
Expand Down

0 comments on commit 943822b

Please sign in to comment.