GRN-11: Ability to configure room specific settings (#348)
* Added the ability to set room settings on create or update * Added room settings alerts and made fixes to other alerts * Small bug fixes related to rubocop and the create room modal * Update test case and fixed issue with small edge case * Update room.js
This commit is contained in:
parent
992c154c10
commit
2e8670a8ab
|
@ -51,4 +51,72 @@ $(document).on('turbolinks:load', function(){
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Display and update all fields related to creating a room in the createRoomModal
|
||||
$("#create-room").click(function(){
|
||||
$("#create-room-name").val("")
|
||||
$("#createRoomModal form").attr("action", "/")
|
||||
updateDropdown($(".dropdown-item[value='default']"))
|
||||
$("#room_mute_on_join").prop("checked", false)
|
||||
$("#auto-join-label").addClass("mt-3 mb-6")
|
||||
|
||||
//show all elements & their children with a create-only class
|
||||
$(".create-only").each(function() {
|
||||
$(this).show()
|
||||
if($(this).children().length > 0) $(this).children().show()
|
||||
})
|
||||
|
||||
//hide all elements & their children with a update-only class
|
||||
$(".update-only").each(function() {
|
||||
$(this).hide()
|
||||
if($(this).children().length > 0) $(this).children().hide()
|
||||
})
|
||||
})
|
||||
|
||||
// Display and update all fields related to creating a room in the createRoomModal
|
||||
$(".update-room").click(function(){
|
||||
var room_block_uid = $(this).closest("#room-block").data("room-uid")
|
||||
$("#create-room-name").val($(this).closest("tbody").find("#room-name h4").text())
|
||||
$("#createRoomModal form").attr("action", "/" + room_block_uid + "/update_settings")
|
||||
$("#auto-join-label").removeClass("mt-3 mb-6")
|
||||
|
||||
//show all elements & their children with a update-only class
|
||||
$(".update-only").each(function() {
|
||||
$(this).show()
|
||||
if($(this).children().length > 0) $(this).children().show()
|
||||
})
|
||||
|
||||
//hide all elements & their children with a create-only class
|
||||
$(".create-only").each(function() {
|
||||
$(this).hide()
|
||||
if($(this).children().length > 0) $(this).children().hide()
|
||||
})
|
||||
|
||||
updateCurrentSettings($(this).closest("#room-block").data("room-settings"))
|
||||
})
|
||||
|
||||
//Update the createRoomModal to show the correct current settings
|
||||
function updateCurrentSettings(settings){
|
||||
//set checkbox
|
||||
if(settings.muteOnStart){
|
||||
$("#room_mute_on_join").prop("checked", true)
|
||||
} else { //default option
|
||||
$("#room_mute_on_join").prop("checked", false)
|
||||
}
|
||||
|
||||
//set dropdown value
|
||||
if (settings.joinViaHtml5) {
|
||||
updateDropdown($(".dropdown-item[value='html5']"))
|
||||
} else if (settings.joinViaHtml5 == false) {
|
||||
updateDropdown($(".dropdown-item[value='flash']"))
|
||||
} else { //default option
|
||||
updateDropdown($(".dropdown-item[value='default']"))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Updates the dropdown element to show the clicked/correct text
|
||||
function updateDropdown(element) {
|
||||
$("#dropdown-trigger").text(element.text())
|
||||
$("#room_client").val(element.val())
|
||||
}
|
||||
|
|
|
@ -51,3 +51,8 @@
|
|||
.edit_hover_class:hover a {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
#room-settings-dropdown-label {
|
||||
vertical-align: middle;
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ class PasswordResetsController < ApplicationController
|
|||
@user.send_password_reset_email(reset_link)
|
||||
redirect_to root_url, notice: I18n.t("email_sent")
|
||||
else
|
||||
redirect_to new_password_reset_path, notice: I18n.t("no_user_email_exists")
|
||||
redirect_to new_password_reset_path, alert: I18n.t("no_user_email_exists")
|
||||
end
|
||||
rescue => e
|
||||
logger.error "Error in email delivery: #{e}"
|
||||
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("delivery_error"))
|
||||
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("delivery_error"))
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -44,13 +44,14 @@ class PasswordResetsController < ApplicationController
|
|||
|
||||
def update
|
||||
if params[:user][:password].empty?
|
||||
flash.now[:notice] = I18n.t("password_empty_notice")
|
||||
flash.now[:alert] = I18n.t("password_empty_notice")
|
||||
render 'edit'
|
||||
elsif params[:user][:password] != params[:user][:password_confirmation]
|
||||
flash.now[:notice] = I18n.t("password_different_notice")
|
||||
flash.now[:alert] = I18n.t("password_different_notice")
|
||||
render 'edit'
|
||||
elsif current_user.update_attributes(user_params)
|
||||
redirect_to root_path, notice: I18n.t("password_reset_success")
|
||||
flash[:success] = I18n.t("password_reset_success")
|
||||
redirect_to root_path
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
|
@ -73,7 +74,7 @@ class PasswordResetsController < ApplicationController
|
|||
# Checks expiration of reset token.
|
||||
def check_expiration
|
||||
if current_user.password_reset_expired?
|
||||
redirect_to new_password_reset_url, notice: I18n.t("expired_reset_token")
|
||||
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,17 +27,22 @@ class RoomsController < ApplicationController
|
|||
|
||||
# POST /
|
||||
def create
|
||||
redirect_to root_path unless current_user
|
||||
redirect_to(root_path) && return unless current_user
|
||||
|
||||
@room = Room.new(name: room_params[:name])
|
||||
@room.owner = current_user
|
||||
@room.room_settings = create_room_settings_string(room_params[:mute_on_join], room_params[:client])
|
||||
|
||||
if @room.save
|
||||
if room_params[:auto_join] == "1"
|
||||
start
|
||||
else
|
||||
flash[:success] = I18n.t("room.create_room_success")
|
||||
redirect_to @room
|
||||
end
|
||||
else
|
||||
flash[:alert] = I18n.t("room.create_room_error")
|
||||
redirect_to current_user.main_room
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -60,9 +65,9 @@ class RoomsController < ApplicationController
|
|||
def update
|
||||
if params[:setting] == "rename_block"
|
||||
@room = Room.find_by!(uid: params[:room_block_uid])
|
||||
update_room_attributes
|
||||
update_room_attributes("name")
|
||||
elsif params[:setting] == "rename_header"
|
||||
update_room_attributes
|
||||
update_room_attributes("name")
|
||||
elsif params[:setting] == "rename_recording"
|
||||
@room.update_recording(params[:record_id], "meta_name" => params[:record_name])
|
||||
end
|
||||
|
@ -86,6 +91,10 @@ class RoomsController < ApplicationController
|
|||
# Determine if the user needs to join as a moderator.
|
||||
opts[:user_is_moderator] = @room.owned_by?(current_user)
|
||||
|
||||
# Check if the user has specified which client to use
|
||||
room_settings = JSON.parse(@room[:room_settings])
|
||||
opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"]
|
||||
|
||||
if current_user
|
||||
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
|
||||
else
|
||||
|
@ -112,10 +121,15 @@ class RoomsController < ApplicationController
|
|||
opts = default_meeting_options
|
||||
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"] if room_settings["muteOnStart"]
|
||||
opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"]
|
||||
|
||||
begin
|
||||
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
|
||||
rescue BigBlueButton::BigBlueButtonException => exc
|
||||
redirect_to room_path, notice: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
||||
redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
|
||||
end
|
||||
|
||||
# Notify users that the room has started.
|
||||
|
@ -123,6 +137,24 @@ class RoomsController < ApplicationController
|
|||
NotifyUserWaitingJob.set(wait: 5.seconds).perform_later(@room)
|
||||
end
|
||||
|
||||
# POST /:room_uid/update_settings
|
||||
def update_settings
|
||||
begin
|
||||
raise "Room name can't be blank" if room_params[:name].empty?
|
||||
|
||||
@room = Room.find_by!(uid: params[:room_uid])
|
||||
# Update the rooms settings
|
||||
update_room_attributes("settings")
|
||||
# Update the rooms name if it has been changed
|
||||
update_room_attributes("name") if @room.name != room_params[:name]
|
||||
rescue StandardError
|
||||
flash[:alert] = I18n.t("room.update_settings_error")
|
||||
else
|
||||
flash[:success] = I18n.t("room.update_settings_success")
|
||||
end
|
||||
redirect_to room_path
|
||||
end
|
||||
|
||||
# GET /:room_uid/logout
|
||||
def logout
|
||||
# Redirect the correct page.
|
||||
|
@ -149,14 +181,32 @@ class RoomsController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def update_room_attributes
|
||||
def update_room_attributes(update_type)
|
||||
if @room.owned_by?(current_user) && @room != current_user.main_room
|
||||
@room.update_attributes(name: params[:room_name])
|
||||
if update_type.eql? "name"
|
||||
@room.update_attributes(name: params[:room_name] || room_params[:name])
|
||||
elsif update_type.eql? "settings"
|
||||
room_settings_string = create_room_settings_string(room_params[:mute_on_join], room_params[:client])
|
||||
@room.update_attributes(room_settings: room_settings_string)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_room_settings_string(mute_res, client_res)
|
||||
room_settings = {}
|
||||
room_settings["muteOnStart"] = mute_res == "1" ? true : false
|
||||
|
||||
if client_res.eql? "html5"
|
||||
room_settings["joinViaHtml5"] = true
|
||||
elsif client_res.eql? "flash"
|
||||
room_settings["joinViaHtml5"] = false
|
||||
end
|
||||
|
||||
room_settings.to_json
|
||||
end
|
||||
|
||||
def room_params
|
||||
params.require(:room).permit(:name, :auto_join)
|
||||
params.require(:room).permit(:name, :auto_join, :mute_on_join, :client)
|
||||
end
|
||||
|
||||
# Find the room from the uid.
|
||||
|
|
|
@ -29,11 +29,11 @@ class SessionsController < ApplicationController
|
|||
def create
|
||||
user = User.find_by(email: session_params[:email])
|
||||
if user && !user.greenlight_account?
|
||||
redirect_to root_path, notice: I18n.t("invalid_login_method")
|
||||
redirect_to root_path, alert: I18n.t("invalid_login_method")
|
||||
elsif user.try(:authenticate, session_params[:password])
|
||||
login(user)
|
||||
else
|
||||
redirect_to root_path, notice: I18n.t("invalid_credentials")
|
||||
redirect_to root_path, alert: I18n.t("invalid_credentials")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ class SessionsController < ApplicationController
|
|||
|
||||
# POST /auth/failure
|
||||
def omniauth_fail
|
||||
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("omniauth_error"))
|
||||
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("omniauth_error"))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -85,7 +85,8 @@ class UsersController < ApplicationController
|
|||
|
||||
if errors.empty? && @user.save
|
||||
# Notify the user that their account has been updated.
|
||||
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
|
||||
flash[:success] = I18n.t("info_update_success")
|
||||
redirect_to edit_user_path(@user)
|
||||
else
|
||||
# Append custom errors.
|
||||
errors.each { |k, v| @user.errors.add(k, v) }
|
||||
|
@ -93,10 +94,12 @@ class UsersController < ApplicationController
|
|||
end
|
||||
elsif user_params[:email] != @user.email && @user.update_attributes(user_params)
|
||||
@user.update_attributes(email_verified: false)
|
||||
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
|
||||
flash[:success] = I18n.t("info_update_success")
|
||||
redirect_to edit_user_path(@user)
|
||||
elsif @user.update_attributes(user_params)
|
||||
update_locale(@user)
|
||||
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
|
||||
flash[:success] = I18n.t("info_update_success")
|
||||
redirect_to edit_user_path(@user)
|
||||
else
|
||||
render :edit, params: { settings: params[:settings] }
|
||||
end
|
||||
|
@ -178,7 +181,7 @@ class UsersController < ApplicationController
|
|||
private
|
||||
|
||||
def mailer_delivery_fail
|
||||
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("delivery_error"))
|
||||
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("delivery_error"))
|
||||
end
|
||||
|
||||
def verification_link(user)
|
||||
|
|
|
@ -52,6 +52,7 @@ class Room < ApplicationRecord
|
|||
moderatorPW: random_password(12),
|
||||
attendeePW: random_password(12),
|
||||
moderatorOnlyMessage: options[:moderator_message],
|
||||
muteOnStart: options[:mute_on_start] || false,
|
||||
"meta_#{META_LISTED}": false,
|
||||
}
|
||||
|
||||
|
@ -93,6 +94,7 @@ class Room < ApplicationRecord
|
|||
# Generate the join URL.
|
||||
join_opts = {}
|
||||
join_opts[:userID] = uid if uid
|
||||
join_opts[:joinViaHtml5] = options[:join_via_html5] if options[:join_via_html5]
|
||||
|
||||
bbb.join_meeting_url(bbb_id, name, password, join_opts)
|
||||
end
|
||||
|
|
|
@ -13,13 +13,7 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% unless flash.empty? %>
|
||||
<%= render "shared/error_banner" do %>
|
||||
<% flash.each do |key, value| %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render 'shared/flash_messages' unless flash.empty? %>
|
||||
|
||||
<div class="background">
|
||||
<div class="container pt-9 pb-8">
|
||||
|
|
|
@ -13,13 +13,7 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% unless flash.empty? %>
|
||||
<%= render "shared/error_banner" do %>
|
||||
<% flash.each do |key, value| %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render 'shared/flash_messages' unless flash.empty? %>
|
||||
|
||||
<div class="container">
|
||||
<div class="row pt-7">
|
||||
|
@ -47,4 +41,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -13,13 +13,7 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% unless flash.empty? %>
|
||||
<%= render "shared/error_banner" do %>
|
||||
<% flash.each do |key, value| %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render 'shared/flash_messages' unless flash.empty? %>
|
||||
|
||||
<div class="container">
|
||||
<div class="row pt-7">
|
||||
|
|
|
@ -13,13 +13,7 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% unless flash.empty? %>
|
||||
<%= render "shared/error_banner" do %>
|
||||
<% flash.each do |key, value| %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render 'shared/flash_messages' unless flash.empty? %>
|
||||
|
||||
<div class="background pb-1">
|
||||
<div class="container">
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% flash.each do |key, value| %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline-block text-success" %>
|
||||
<% flash.each do |key,value| %>
|
||||
<% if key.eql? "success" %>
|
||||
<%= render "shared/success_banner" do %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% elsif key.eql? "alert" %>
|
||||
<%= render "shared/error_banner" do %>
|
||||
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<div class="d-flex ml-auto">
|
||||
<% if current_user %>
|
||||
<a class="px-5 ml-2 mt-1" href="" data-toggle="modal" data-target="#createRoomModal">
|
||||
<a id="create-room" class="px-5 ml-2 mt-1" href="" data-toggle="modal" data-target="#createRoomModal">
|
||||
<i class="fas fa-plus"></i> <%= t("header.create_room") %>
|
||||
</a>
|
||||
<div class="dropdown">
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<%
|
||||
# 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="alert alert-icon alert-success text-center mb-0">
|
||||
<%= yield %>
|
||||
</div>
|
|
@ -13,7 +13,7 @@
|
|||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<div id="<%= 'home_room_block' if room == current_user.main_room %>" data-room-uid=<%= room.uid %> class="card">
|
||||
<div id="<%= if room == current_user.main_room then 'home_room_block' else 'room-block' end %>" data-room-uid="<%= room.uid %>" data-room-settings=<%= room.room_settings %> class="card">
|
||||
<div class="card-body p-1">
|
||||
<table class="table table-hover table-vcenter text-wrap table-no-border">
|
||||
<tbody class="no-border-top">
|
||||
|
@ -47,14 +47,12 @@
|
|||
<i class="fas fa-ellipsis-v px-4"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu">
|
||||
<!--
|
||||
<%= link_to room, class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %>
|
||||
<% end %>
|
||||
-->
|
||||
<a href="" id="rename-room-button" class="dropdown-item">
|
||||
<i class="dropdown-icon far fa-edit"></i> <%= t("rename") %>
|
||||
</a>
|
||||
<a href="" data-toggle="modal" data-target="#createRoomModal" class="update-room dropdown-item">
|
||||
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %>
|
||||
</a>
|
||||
<a href="" data-toggle="modal" data-target="#deleteRoomModal_<%= room.uid %>"class="dropdown-item">
|
||||
<i class="dropdown-icon far fa-trash-alt"></i> <%= t("delete") %>
|
||||
</a>
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
<div class="modal-body">
|
||||
<div class="card-body p-6">
|
||||
<div class="card-title">
|
||||
<h3><%= t("modal.create_room.title") %></h3>
|
||||
<h3 class="create-only"><%= t("modal.create_room.title") %></h3>
|
||||
<h3 class="update-only"><%= t("modal.room_settings.title") %></h3>
|
||||
</div>
|
||||
|
||||
<%= form_for(:room, url: rooms_path) do |f| %>
|
||||
|
@ -27,21 +28,45 @@
|
|||
<span class="input-icon-addon">
|
||||
<i class="fas fa-chalkboard-teacher"></i>
|
||||
</span>
|
||||
<%= f.text_field :name, id: "room-name", class: "form-control", value: "", placeholder: t("modal.create_room.name_placeholder"), autocomplete: :off %>
|
||||
<%= f.text_field :name, id: "create-room-name", class: "form-control", value: "", placeholder: t("modal.create_room.name_placeholder"), autocomplete: :off %>
|
||||
<div class="invalid-feedback text-left"><%= t("modal.create_room.not_blank") %></div>
|
||||
</div>
|
||||
<label class="custom-switch mt-5 mb-5 float-left">
|
||||
<%= f.check_box :auto_join, class: "custom-switch-input", checked: false %>
|
||||
<span class="custom-switch-indicator"></span>
|
||||
<span class="custom-switch-description"><%= t("modal.create_room.auto_join") %></span>
|
||||
|
||||
<label class="mt-5 mb-3 w-100 text-left d-inline-block">
|
||||
<input type="hidden" name="room[client]" id="room_client">
|
||||
<span id="room-settings-dropdown-label" class="custom-switch-description"><%= t("modal.room_settings.client")%></span>
|
||||
<div id="dropdown-div" class="dropdown float-right">
|
||||
<button id="dropdown-trigger" type="button" class="btn btn-secondary dropdown-toggle px-4" data-toggle="dropdown">
|
||||
<%= t("modal.room_settings.default")%>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="default"><%= t("modal.room_settings.default")%></button>
|
||||
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="html5"><%= t("modal.room_settings.html")%></button>
|
||||
<button type=button class="dropdown-item" onclick="updateDropdown($(this))" value="flash"><%= t("modal.room_settings.flash")%></button>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<div class="form-footer">
|
||||
<%= f.submit t("header.create_room"), id: "create-room-submit", class: "btn btn-outline-primary btn-block btn-pill" %>
|
||||
|
||||
<label class="custom-switch 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 %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
|
||||
<label id="auto-join-label" class="create-only custom-switch mb-6 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 %>
|
||||
<span class="custom-switch-indicator float-right"></span>
|
||||
</label>
|
||||
<div>
|
||||
<%= f.submit t("header.create_room"), id: "create-room-submit", class: "create-only btn btn-outline-primary btn-block btn-pill" %>
|
||||
<%= f.submit t("modal.room_settings.update"), id: "create-room-submit", class: "update-only btn btn-outline-primary btn-block btn-pill" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<p><%= t("modal.create_room.free_delete") %></p>
|
||||
<p class="create-only"><%= t("modal.create_room.free_delete") %></p>
|
||||
<p class="update-only"><%= t("modal.room_settings.footer_text") %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -121,7 +121,15 @@ en:
|
|||
with: Sign in with %{provider}
|
||||
forgot_password: Forgot Password?
|
||||
rename_recording:
|
||||
|
||||
room_settings:
|
||||
title: Room Settings
|
||||
update: Update Room
|
||||
client: Select client type
|
||||
mute: Mute users when they join
|
||||
default: Default
|
||||
html: HTML5
|
||||
flash: Flash
|
||||
footer_text: Adjustment to your room can be done at anytime.
|
||||
rename_room:
|
||||
name_placeholder: Enter a new room name...
|
||||
name_update_success: Room name successfully changed!
|
||||
|
@ -157,6 +165,8 @@ en:
|
|||
confirm: New Password Confirmation
|
||||
update: Update Password
|
||||
room:
|
||||
create_room_error: There was an error creating the room
|
||||
create_room_success: Room created successfully
|
||||
invited: You have been invited to join
|
||||
invite_participants: Invite Participants
|
||||
join: Join
|
||||
|
@ -167,6 +177,8 @@ en:
|
|||
sessions: Sessions
|
||||
settings: Room Settings
|
||||
start: Start
|
||||
update_settings_error: There was an error updating the room settings
|
||||
update_settings_success: Room settings successfully updated
|
||||
wait:
|
||||
message: Oops! The meeting hasn't started yet.
|
||||
auto: You will automatically join when the meeting starts.
|
||||
|
|
|
@ -68,6 +68,7 @@ Rails.application.routes.draw do
|
|||
scope '/:room_uid' do
|
||||
post '/', to: 'rooms#join'
|
||||
patch '/', to: 'rooms#update', as: :update_room
|
||||
post '/update_settings', to: 'rooms#update_settings'
|
||||
post '/start', to: 'rooms#start', as: :start_room
|
||||
get '/logout', to: 'rooms#logout', as: :logout_room
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRoomSettingsToRoom < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :rooms, :room_settings, :string, default: "{ }"
|
||||
end
|
||||
end
|
|
@ -10,17 +10,18 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20181217142710) do
|
||||
ActiveRecord::Schema.define(version: 20190122210632) do
|
||||
|
||||
create_table "rooms", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.string "name"
|
||||
t.string "uid"
|
||||
t.string "bbb_id"
|
||||
t.integer "sessions", default: 0
|
||||
t.integer "sessions", default: 0
|
||||
t.datetime "last_session"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "room_settings", default: "{ }"
|
||||
t.index ["bbb_id"], name: "index_rooms_on_bbb_id"
|
||||
t.index ["last_session"], name: "index_rooms_on_last_session"
|
||||
t.index ["name"], name: "index_rooms_on_name"
|
||||
|
|
|
@ -79,14 +79,19 @@ describe RoomsController, type: :controller do
|
|||
@owner = create(:user)
|
||||
end
|
||||
|
||||
it "should create room with name" do
|
||||
it "should create room with name and correct settings" do
|
||||
@request.session[:user_id] = @owner.id
|
||||
name = Faker::Pokemon.name
|
||||
post :create, params: { room: { name: name } }
|
||||
|
||||
room_params = { name: name, "client": "html5", "mute_on_join": "1" }
|
||||
json_room_settings = "{\"muteOnStart\":true,\"joinViaHtml5\":true}"
|
||||
|
||||
post :create, params: { room: room_params }
|
||||
|
||||
r = @owner.secondary_rooms.last
|
||||
expect(r.name).to eql(name)
|
||||
expect(r.owner).to eql(@owner)
|
||||
expect(r.room_settings).to eql(json_room_settings)
|
||||
expect(response).to redirect_to(r)
|
||||
end
|
||||
|
||||
|
@ -212,6 +217,36 @@ describe RoomsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST #update_settings" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
@secondary_room = create(:room, owner: @user)
|
||||
end
|
||||
|
||||
it "properly updates room name through the room settings modal and redirects to current page" do
|
||||
@request.session[:user_id] = @user.id
|
||||
name = Faker::Pokemon.name
|
||||
|
||||
room_params = { room_uid: @secondary_room.uid, room: { "name": name } }
|
||||
|
||||
expect { post :update_settings, params: room_params }.to change { @secondary_room.reload.name }
|
||||
.from(@secondary_room.name).to(name)
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
|
||||
it "properly updates room settings through the room settings modal and redirects to current page" do
|
||||
@request.session[:user_id] = @user.id
|
||||
|
||||
room_params = { "client": "html5", "mute_on_join": "1", "name": @secondary_room.name }
|
||||
formatted_room_params = "{\"muteOnStart\":true,\"joinViaHtml5\":true}" # JSON string format
|
||||
|
||||
expect { post :update_settings, params: { room_uid: @secondary_room.uid, room: room_params } }
|
||||
.to change { @secondary_room.reload.room_settings }
|
||||
.from(@secondary_room.room_settings).to(formatted_room_params)
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH #update" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
|
|
Reference in New Issue