forked from External/greenlight
one meeting per room
This commit is contained in:
parent
0f8a4734b2
commit
1ddc3172eb
|
@ -1,29 +0,0 @@
|
|||
$(document).on("turbolinks:load", function() {
|
||||
|
||||
var action = $("body").data('action');
|
||||
var controller = $("body").data('controller');
|
||||
|
||||
// If the user is on the waiting screen.
|
||||
if (controller == 'meetings' && action == 'wait') {
|
||||
|
||||
setTimeout(refresh, 10000);
|
||||
}
|
||||
});
|
||||
|
||||
// Send a request to the meeting wait endpoint.
|
||||
// This checks if the meeting is running on the
|
||||
// server and will auto join the user if it is.
|
||||
var refresh = function() {
|
||||
$.ajax({
|
||||
url: window.location.pathname,
|
||||
type: 'POST',
|
||||
data: {
|
||||
unauthenticated_join_name: $('#unauthenticated_join_name_').val()
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(refresh, 10000);
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,27 @@
|
|||
$(document).on("turbolinks:load", function() {
|
||||
var action = $("body").data('action');
|
||||
var controller = $("body").data('controller');
|
||||
|
||||
// If the user is on the waiting screen.
|
||||
if (controller == 'rooms' && action == 'wait') {
|
||||
setTimeout(refresh, 10000);
|
||||
}
|
||||
});
|
||||
|
||||
// Send a request to the meeting wait endpoint.
|
||||
// This checks if the meeting is running on the
|
||||
// server and will auto join the user if it is.
|
||||
var refresh = function() {
|
||||
$.ajax({
|
||||
url: window.location.pathname,
|
||||
type: 'POST',
|
||||
data: {
|
||||
unauthenticated_join_name: $('#unauthenticated_join_name_').val()
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(refresh, 10000);
|
||||
}
|
|
@ -39,9 +39,6 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# Ensure the user is logged into the room they are accessing.
|
||||
def verify_room_ownership
|
||||
return unless params.include?(:room_uid)
|
||||
@room = Room.find_by(uid: params[:room_uid])
|
||||
|
||||
# Redirect to correct room or root if not logged in.
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
|
|
|
@ -1,102 +1,14 @@
|
|||
class MeetingsController < ApplicationController
|
||||
|
||||
before_action :verify_room_ownership
|
||||
skip_before_action :verify_room_ownership, only: [:join, :wait]
|
||||
|
||||
# GET /rooms/:room_uid/meetings
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
# POST /rooms/:room_uid/meetings
|
||||
def create
|
||||
@meeting = Meeting.new(meeting_params(@room))
|
||||
|
||||
if @meeting.save
|
||||
# Create the meeting on the BigBlueButton server and join the user into the meeting.
|
||||
redirect_to join_meeting_path(room_uid: @room.uid, meeting_uid: @meeting.uid)
|
||||
else
|
||||
# Meeting couldn't be created, handle error.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid/join
|
||||
def join
|
||||
@meeting = Meeting.find_by(uid: params[:meeting_uid])
|
||||
|
||||
if @meeting
|
||||
opts = default_meeting_options
|
||||
if @meeting.is_running?
|
||||
if current_user
|
||||
# Check if the current user is the room/session owner.
|
||||
opts[:user_is_moderator] = @meeting.room.owned_by?(current_user)
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# If the unauthenticated user has supplied a join name.
|
||||
if params[:join_name]
|
||||
redirect_to @meeting.join_path(params[:join_name], opts)
|
||||
else
|
||||
# Render the join page so they can supply their name.
|
||||
render :join
|
||||
end
|
||||
end
|
||||
else
|
||||
# Only start the meeting if owner is joining first.
|
||||
if current_user && @meeting.room.owned_by?(current_user)
|
||||
opts[:user_is_moderator] = true
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# Send the user to a polling page that will auto join them when it starts.
|
||||
# The wait action/page handles input of name for unauthenticated users.
|
||||
redirect_to wait_meeting_path(room_uid: @meeting.room.uid, meeting_uid: @meeting.uid)
|
||||
end
|
||||
end
|
||||
else
|
||||
# Handle meeting doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/meetings/:meeting_uid/wait
|
||||
def wait
|
||||
@meeting = Meeting.find_by(uid: params[:meeting_uid])
|
||||
|
||||
if @meeting
|
||||
if @meeting.is_running?
|
||||
if current_user
|
||||
# If they are logged in and waiting, use their account name.
|
||||
redirect_to @meeting.join_path(current_user.name, default_meeting_options)
|
||||
elsif !params[:unauthenticated_join_name].blank?
|
||||
# Otherwise, use the name they submitted on the wating page.
|
||||
redirect_to @meeting.join_path(params[:unauthenticated_join_name], default_meeting_options)
|
||||
end
|
||||
end
|
||||
else
|
||||
# Handle meeting doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def meeting_params(room)
|
||||
params.require(:meeting).permit(:name).merge!(room: room)
|
||||
#params.require(:meeting).permit(:name).merge!(room_id: room.id)
|
||||
end
|
||||
|
||||
def default_meeting_options
|
||||
{
|
||||
user_is_moderator: false,
|
||||
meeting_logout_url: request.base_url + room_path(room_uid: @meeting.room.uid),
|
||||
meeting_recorded: true,
|
||||
moderator_message: "To invite someone to the meeting, send them this link:
|
||||
#{request.base_url + join_meeting_path(room_uid: @meeting.room.uid, meeting_uid: @meeting.uid)}"
|
||||
}
|
||||
end
|
||||
#def meeting_params(room)
|
||||
# params.require(:meeting).permit(:name).merge!(room: room)
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,82 @@
|
|||
class RoomsController < ApplicationController
|
||||
|
||||
before_action :verify_room_ownership
|
||||
before_action :find_room, :verify_room_ownership
|
||||
skip_before_action :verify_room_ownership, only: [:join, :wait]
|
||||
|
||||
# GET /rooms/:room_uid
|
||||
def index
|
||||
@meeting = Meeting.new
|
||||
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/join
|
||||
def join
|
||||
if @meeting
|
||||
opts = default_meeting_options
|
||||
if @meeting.is_running?
|
||||
if current_user
|
||||
# Check if the current user is the room/session owner.
|
||||
opts[:user_is_moderator] = @meeting.room.owned_by?(current_user)
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# If the unauthenticated user has supplied a join name.
|
||||
if params[:join_name]
|
||||
redirect_to @meeting.join_path(params[:join_name], opts)
|
||||
else
|
||||
# Render the join page so they can supply their name.
|
||||
render :join
|
||||
end
|
||||
end
|
||||
else
|
||||
# Only start the meeting if owner is joining first.
|
||||
if current_user && @room.owned_by?(current_user)
|
||||
opts[:user_is_moderator] = true
|
||||
redirect_to @meeting.join_path(current_user.name, opts)
|
||||
else
|
||||
# Send the user to a polling page that will auto join them when it starts.
|
||||
# The wait action/page handles input of name for unauthenticated users.
|
||||
redirect_to wait_room_path(room_uid: @room.uid)
|
||||
end
|
||||
end
|
||||
else
|
||||
# Handle room doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rooms/:room_uid/wait
|
||||
def wait
|
||||
if @room
|
||||
if @meeting.is_running?
|
||||
if current_user
|
||||
# If they are logged in and waiting, use their account name.
|
||||
redirect_to @meeting.join_path(current_user.name, default_meeting_options)
|
||||
elsif !params[:unauthenticated_join_name].blank?
|
||||
# Otherwise, use the name they submitted on the wating page.
|
||||
redirect_to @meeting.join_path(params[:unauthenticated_join_name], default_meeting_options)
|
||||
end
|
||||
end
|
||||
else
|
||||
# Handle room doesn't exist.
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Find the room from the uid.
|
||||
def find_room
|
||||
@room = Room.find_by(uid: params[:room_uid])
|
||||
@meeting = @room.meeting
|
||||
end
|
||||
|
||||
# Default, unconfigured meeting options.
|
||||
def default_meeting_options
|
||||
{
|
||||
user_is_moderator: false,
|
||||
meeting_logout_url: request.base_url + room_path(room_uid: @room.uid),
|
||||
meeting_recorded: true,
|
||||
moderator_message: "To invite someone to the meeting, send them this link:
|
||||
#{request.base_url + join_room_path(room_uid: @room.uid)}"
|
||||
}
|
||||
end
|
||||
end
|
|
@ -3,9 +3,10 @@ class Room < ApplicationRecord
|
|||
before_create :set_uid
|
||||
|
||||
belongs_to :user
|
||||
has_many :meetings
|
||||
has_one :meeting
|
||||
|
||||
def owned_by?(user)
|
||||
return false if user.nil?
|
||||
user.room == self
|
||||
end
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class User < ApplicationRecord
|
|||
|
||||
# Initializes a room for the user.
|
||||
def initialize_room
|
||||
self.room = Room.new
|
||||
self.save!
|
||||
room = Room.create(user_id: self.id)
|
||||
Meeting.create(room_id: room.id, name: "Example")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
<p>This is a room.</p>
|
||||
|
||||
<p><%= @room.user.name %><p>
|
||||
<p><%= @room.meeting.uid %><p>
|
||||
<p><%= @room.uid %><p>
|
||||
|
||||
<%= link_to 'Sessions', root_path %>
|
||||
<%= link_to 'Recordings', root_path %>
|
||||
<%= link_to 'Settings', root_path %>
|
||||
|
||||
<p>Enter a name to start a session.</p>
|
||||
<%= form_for @meeting do |f| %>
|
||||
<%= f.text_field :name %>
|
||||
<%= f.submit "Start" %>
|
||||
<p>Click below to join the meeting.</p>
|
||||
|
||||
<% if @room.meeting.is_running? %>
|
||||
<p>meeting is already running</p>
|
||||
<% else %>
|
||||
<%= form_tag join_room_path, method: :get do %>
|
||||
<%= submit_tag 'Start Meeting' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<br><br><br><br><br>
|
||||
<p>Previous Sessions</p>
|
||||
<% current_user.room.meetings.each do |m| %>
|
||||
<p><%= m.name + " " + m.is_running?.to_s + " " + m.recordings.to_s %></p>
|
||||
<% end %>
|
||||
<br>
|
||||
<br><br>
|
||||
|
||||
<%= link_to 'Logout', logout_path %>
|
|
@ -1,13 +1,11 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
# Room and Meeting routes.
|
||||
scope '/rooms' do
|
||||
scope '/:room_uid' do
|
||||
scope '/rooms/:room_uid' do
|
||||
get '/', to: 'rooms#index', as: :room
|
||||
resources :meetings, only: [:index, :show, :create], param: :meeting_uid
|
||||
match '/meetings/:meeting_uid/join', to: 'meetings#join', as: :join_meeting, via: [:get, :post]
|
||||
match '/meetings/:meeting_uid/wait', to: 'meetings#wait', as: :wait_meeting, via: [:get, :post]
|
||||
end
|
||||
match '/join', to: 'rooms#join', as: :join_room, via: [:get, :post]
|
||||
match '/wait', to: 'rooms#wait', as: :wait_room, via: [:get, :post]
|
||||
resources :meetings, only: [:index], param: :meeting_uid
|
||||
end
|
||||
|
||||
# Signup routes.
|
||||
|
|
Loading…
Reference in New Issue