forked from External/greenlight
* Room setting to allow anyone to start a room * Update sample.env * merge v2.2.1
This commit is contained in:
committed by
Jesus Federico
parent
b23f94dfb5
commit
d3a9ae32a9
@ -50,6 +50,7 @@ $(document).on('turbolinks:load', function(){
|
||||
$("#createRoomModal form").attr("action", $("body").data('relative-root'))
|
||||
updateDropdown($(".dropdown-item[value='default']"))
|
||||
$("#room_mute_on_join").prop("checked", false)
|
||||
$("#room_anyone_can_start").prop("checked", false)
|
||||
|
||||
//show all elements & their children with a create-only class
|
||||
$(".create-only").each(function() {
|
||||
@ -104,6 +105,12 @@ $(document).on('turbolinks:load', function(){
|
||||
$("#room_mute_on_join").prop("checked", false)
|
||||
}
|
||||
|
||||
if(settings.anyoneCanStart){
|
||||
$("#room_anyone_can_start").prop("checked", true)
|
||||
} else { //default option
|
||||
$("#room_anyone_can_start").prop("checked", false)
|
||||
}
|
||||
|
||||
//set dropdown value
|
||||
if (settings.joinViaHtml5) {
|
||||
updateDropdown($(".dropdown-item[value='html5']"))
|
||||
|
@ -38,7 +38,8 @@ class RoomsController < ApplicationController
|
||||
|
||||
@room = Room.new(name: room_params[:name], access_code: room_params[:access_code])
|
||||
@room.owner = current_user
|
||||
@room.room_settings = create_room_settings_string(room_params[:mute_on_join], room_params[:client])
|
||||
@room.room_settings = create_room_settings_string(room_params[:mute_on_join], room_params[:client],
|
||||
room_params[:anyone_can_start])
|
||||
|
||||
if @room.save
|
||||
if room_params[:auto_join] == "1"
|
||||
@ -55,13 +56,15 @@ class RoomsController < ApplicationController
|
||||
|
||||
# GET /:room_uid
|
||||
def show
|
||||
@is_running = @room.running?
|
||||
@anyone_can_start = JSON.parse(@room[:room_settings])["anyoneCanStart"]
|
||||
|
||||
if current_user && @room.owned_by?(current_user)
|
||||
@search, @order_column, @order_direction, recs =
|
||||
recordings(@room.bbb_id, @user_domain, params.permit(:search, :column, :direction), true)
|
||||
|
||||
@pagy, @recordings = pagy_array(recs)
|
||||
|
||||
@is_running = @room.running?
|
||||
else
|
||||
# Get users name
|
||||
@name = if current_user
|
||||
@ -199,7 +202,8 @@ class RoomsController < ApplicationController
|
||||
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_settings_string = create_room_settings_string(room_params[:mute_on_join], room_params[:client],
|
||||
room_params[:anyone_can_start])
|
||||
@room.update_attributes(room_settings: room_settings_string)
|
||||
elsif update_type.eql? "access_code"
|
||||
@room.update_attributes(access_code: room_params[:access_code])
|
||||
@ -207,7 +211,7 @@ class RoomsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def create_room_settings_string(mute_res, client_res)
|
||||
def create_room_settings_string(mute_res, client_res, start_res)
|
||||
room_settings = {}
|
||||
room_settings["muteOnStart"] = mute_res == "1"
|
||||
|
||||
@ -217,11 +221,13 @@ class RoomsController < ApplicationController
|
||||
room_settings["joinViaHtml5"] = false
|
||||
end
|
||||
|
||||
room_settings["anyoneCanStart"] = start_res == "1"
|
||||
|
||||
room_settings.to_json
|
||||
end
|
||||
|
||||
def room_params
|
||||
params.require(:room).permit(:name, :auto_join, :mute_on_join, :client, :access_code)
|
||||
params.require(:room).permit(:name, :auto_join, :mute_on_join, :client, :access_code, :anyone_can_start)
|
||||
end
|
||||
|
||||
# Find the room from the uid.
|
||||
@ -289,12 +295,15 @@ class RoomsController < ApplicationController
|
||||
end
|
||||
|
||||
def join_room(opts)
|
||||
if @room.running? || @room.owned_by?(current_user)
|
||||
room_settings = JSON.parse(@room[:room_settings])
|
||||
|
||||
if @room.running? || @room.owned_by?(current_user) || room_settings["anyoneCanStart"]
|
||||
|
||||
# Determine if the user needs to join as a moderator.
|
||||
opts[:user_is_moderator] = @room.owned_by?(current_user)
|
||||
opts[:user_is_moderator] = @room.owned_by?(current_user) ||
|
||||
(room_settings["anyoneCanStart"] && !@room.running?)
|
||||
|
||||
# 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
|
||||
|
@ -40,7 +40,7 @@
|
||||
placeholder: t("enter_your_name"),
|
||||
value: "#{@name}",
|
||||
readonly: !current_user.nil? %>
|
||||
<%= f.submit t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %>
|
||||
<%= f.submit (!@is_running && @anyone_can_start)? t("room.start") : t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -68,6 +68,14 @@
|
||||
</label>
|
||||
<% end %>
|
||||
|
||||
<% if Rails.configuration.room_features.include? "anyone-can-start" %>
|
||||
<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 %>
|
||||
<span class="custom-switch-indicator float-right"></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 %>
|
||||
|
Reference in New Issue
Block a user