GRN2-206: Remove support for the flash client Fixes(#654) (#661)

* Remove ability to specify flash client

* Always join via html5

* Fix styling and tests
This commit is contained in:
shawn-higgins1
2019-07-24 09:37:59 -04:00
committed by Jesus Federico
parent 4e31366012
commit 0934919e44
8 changed files with 14 additions and 59 deletions

View File

@ -48,7 +48,6 @@ $(document).on('turbolinks:load', function(){
$("#room_access_code").val(null)
$("#createRoomModal form").attr("action", $("body").data('relative-root'))
updateDropdown($(".dropdown-item[value='default']"))
$("#room_mute_on_join").prop("checked", false)
$("#room_require_moderator_approval").prop("checked", false)
$("#room_anyone_can_start").prop("checked", false)
@ -117,24 +116,9 @@ $(document).on('turbolinks:load', function(){
} else { //default option
$("#room_anyone_can_start").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())
}
function generateAccessCode(){
const accessCodeLength = 6
var validCharacters = "0123456789"

View File

@ -38,7 +38,7 @@ 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[:require_moderator_approval], room_params[:anyone_can_start])
if @room.save
@ -147,7 +147,6 @@ class RoomsController < ApplicationController
# 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"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
begin
@ -203,7 +202,7 @@ 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[:require_moderator_approval], room_params[:anyone_can_start])
@room.update_attributes(room_settings: room_settings_string)
elsif update_type.eql? "access_code"
@ -212,25 +211,19 @@ class RoomsController < ApplicationController
end
end
def create_room_settings_string(mute_res, client_res, require_approval_res, start_res)
def create_room_settings_string(mute_res, require_approval_res, start_res)
room_settings = {}
room_settings["muteOnStart"] = mute_res == "1"
room_settings["requireModeratorApproval"] = require_approval_res == "1"
if client_res.eql? "html5"
room_settings["joinViaHtml5"] = true
elsif client_res.eql? "flash"
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, :access_code,
:require_moderator_approval, :anyone_can_start)
end
@ -307,8 +300,6 @@ class RoomsController < ApplicationController
opts[:user_is_moderator] = @room.owned_by?(current_user) ||
(room_settings["anyoneCanStart"] && !@room.running?)
# Check if the user has specified which client to use
opts[:join_via_html5] = room_settings["joinViaHtml5"] if room_settings["joinViaHtml5"]
opts[:require_moderator_approval] = room_settings["requireModeratorApproval"]
if current_user

View File

@ -104,7 +104,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]
join_opts[:join_via_html5] = true
join_opts[:guest] = true if options[:require_moderator_approval] && !options[:user_is_moderator]

View File

@ -43,23 +43,6 @@
</span>
</div>
<% if Rails.configuration.room_features.include? "default-client" %>
<label class="mt-3 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>
<% end %>
<% if Rails.configuration.room_features.include? "mute-on-join" %>
<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.mute")%></span>