forked from External/greenlight
GRN2-269: Pulling room settings using GET instead of data-attributes (#953)
* GRN2-269: Pulling room settings using GET instead of data-attributes * GRN2-269: added test case and fixed documentation * GRN2:269: rubocop fix * GRN2-269: Fixed test case
This commit is contained in:
parent
c75c624a1a
commit
92da1f6f87
|
@ -161,6 +161,7 @@ function showCreateRoom(target) {
|
||||||
function showUpdateRoom(target) {
|
function showUpdateRoom(target) {
|
||||||
var modal = $(target)
|
var modal = $(target)
|
||||||
var update_path = modal.closest("#room-block").data("path")
|
var update_path = modal.closest("#room-block").data("path")
|
||||||
|
var settings_path = modal.data("settings-path")
|
||||||
$("#create-room-name").val(modal.closest("#room-block").find("#room-name-text").text())
|
$("#create-room-name").val(modal.closest("#room-block").find("#room-name-text").text())
|
||||||
$("#createRoomModal form").attr("action", update_path)
|
$("#createRoomModal form").attr("action", update_path)
|
||||||
|
|
||||||
|
@ -176,7 +177,7 @@ function showUpdateRoom(target) {
|
||||||
if($(this).children().length > 0) { $(this).children().attr('style',"display:none !important") }
|
if($(this).children().length > 0) { $(this).children().attr('style',"display:none !important") }
|
||||||
})
|
})
|
||||||
|
|
||||||
updateCurrentSettings(modal.closest("#room-block").data("room-settings"))
|
updateCurrentSettings(settings_path)
|
||||||
|
|
||||||
var accessCode = modal.closest("#room-block").data("room-access-code")
|
var accessCode = modal.closest("#room-block").data("room-access-code")
|
||||||
|
|
||||||
|
@ -195,12 +196,15 @@ function showDeleteRoom(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the createRoomModal to show the correct current settings
|
//Update the createRoomModal to show the correct current settings
|
||||||
function updateCurrentSettings(settings){
|
function updateCurrentSettings(settings_path){
|
||||||
//set checkbox
|
// Get current room settings and set checkbox
|
||||||
$("#room_mute_on_join").prop("checked", settings.muteOnStart)
|
$.get(settings_path, function(room_settings) {
|
||||||
$("#room_require_moderator_approval").prop("checked", settings.requireModeratorApproval)
|
var settings = JSON.parse(room_settings)
|
||||||
$("#room_anyone_can_start").prop("checked", settings.anyoneCanStart)
|
$("#room_mute_on_join").prop("checked", settings.muteOnStart)
|
||||||
$("#room_all_join_moderator").prop("checked", settings.joinModerator)
|
$("#room_require_moderator_approval").prop("checked", settings.requireModeratorApproval)
|
||||||
|
$("#room_anyone_can_start").prop("checked", settings.anyoneCanStart)
|
||||||
|
$("#room_all_join_moderator").prop("checked", settings.joinModerator)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateAccessCode(){
|
function generateAccessCode(){
|
||||||
|
|
|
@ -248,6 +248,14 @@ class RoomsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /:room_uid/room_settings
|
||||||
|
def room_settings
|
||||||
|
# Respond with JSON object of the room_settings
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render body: @room.room_settings.to_json }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# GET /:room_uid/logout
|
# GET /:room_uid/logout
|
||||||
def logout
|
def logout
|
||||||
logger.info "Support: #{current_user.present? ? current_user.email : 'Guest'} has left room #{@room.uid}"
|
logger.info "Support: #{current_user.present? ? current_user.email : 'Guest'} has left room #{@room.uid}"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<div id="room-block" data-path="<%= update_settings_path(room) %>" data-room-settings=<%= room.room_settings %> data-room-access-code="<%= room.access_code %>" class="card">
|
<div id="room-block" data-path="<%= update_settings_path(room) %>" data-room-access-code="<%= room.access_code %>" class="card">
|
||||||
<div class="card-body p-1">
|
<div class="card-body p-1">
|
||||||
<table class="table table-hover table-vcenter text-wrap table-no-border">
|
<table class="table table-hover table-vcenter text-wrap table-no-border">
|
||||||
<tbody class="no-border-top">
|
<tbody class="no-border-top">
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<i class="fas fa-ellipsis-v px-4"></i>
|
<i class="fas fa-ellipsis-v px-4"></i>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-md-left">
|
<div class="dropdown-menu dropdown-menu-right dropdown-menu-md-left">
|
||||||
<a href="" data-toggle="modal" data-target="#createRoomModal" class="update-room dropdown-item">
|
<a href="" data-toggle="modal" data-target="#createRoomModal" class="update-room dropdown-item" data-settings-path="<%= room_settings_path(room) %>">
|
||||||
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %>
|
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %>
|
||||||
</a>
|
</a>
|
||||||
<% if shared_access_allowed %>
|
<% if shared_access_allowed %>
|
||||||
|
|
|
@ -112,6 +112,7 @@ Rails.application.routes.draw do
|
||||||
scope '/:room_uid' do
|
scope '/:room_uid' do
|
||||||
post '/', to: 'rooms#join'
|
post '/', to: 'rooms#join'
|
||||||
patch '/', to: 'rooms#update', as: :update_room
|
patch '/', to: 'rooms#update', as: :update_room
|
||||||
|
get '/room_settings', to: 'rooms#room_settings'
|
||||||
post '/update_settings', to: 'rooms#update_settings'
|
post '/update_settings', to: 'rooms#update_settings'
|
||||||
post '/update_shared_access', to: 'rooms#shared_access', as: :room_shared_access
|
post '/update_shared_access', to: 'rooms#shared_access', as: :room_shared_access
|
||||||
delete '/remove_shared_access', to: 'rooms#remove_shared_access', as: :room_remove_shared_access
|
delete '/remove_shared_access', to: 'rooms#remove_shared_access', as: :room_remove_shared_access
|
||||||
|
|
|
@ -180,6 +180,20 @@ describe RoomsController, type: :controller do
|
||||||
expect(response).to redirect_to(r)
|
expect(response).to redirect_to(r)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should respond with JSON object of the room_settings" do
|
||||||
|
@request.session[:user_id] = @owner.id
|
||||||
|
|
||||||
|
@owner.main_room.update_attribute(:room_settings, { "muteOnStart": true, "requireModeratorApproval": true,
|
||||||
|
"anyoneCanStart": true, "joinModerator": true }.to_json)
|
||||||
|
|
||||||
|
json_room_settings = "{\"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)
|
||||||
|
end
|
||||||
|
|
||||||
it "should redirect to root if not logged in" do
|
it "should redirect to root if not logged in" do
|
||||||
expect do
|
expect do
|
||||||
name = Faker::Games::Pokemon.name
|
name = Faker::Games::Pokemon.name
|
||||||
|
|
Loading…
Reference in New Issue