From e6d01ef1b98eacd1ba12675c7e9ebe94affa23e0 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 8 May 2018 10:41:03 -0400 Subject: [PATCH] implement wait for moderator --- app/assets/javascripts/meetings.js | 29 +++++++++++++++++++ .../{meetings.coffee => users.coffee} | 0 app/assets/stylesheets/users.scss | 3 ++ app/controllers/meetings_controller.rb | 23 +++++++++++++-- app/controllers/users_controller.rb | 2 ++ app/helpers/users_helper.rb | 2 ++ app/models/meeting.rb | 7 ++++- app/views/meetings/wait.html.erb | 8 ++++- app/views/rooms/index.html.erb | 2 +- test/controllers/users_controller_test.rb | 7 +++++ 10 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/meetings.js rename app/assets/javascripts/{meetings.coffee => users.coffee} (100%) create mode 100644 app/assets/stylesheets/users.scss create mode 100644 app/controllers/users_controller.rb create mode 100644 app/helpers/users_helper.rb create mode 100644 test/controllers/users_controller_test.rb diff --git a/app/assets/javascripts/meetings.js b/app/assets/javascripts/meetings.js new file mode 100644 index 00000000..284ff9dd --- /dev/null +++ b/app/assets/javascripts/meetings.js @@ -0,0 +1,29 @@ +$(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); +} \ No newline at end of file diff --git a/app/assets/javascripts/meetings.coffee b/app/assets/javascripts/users.coffee similarity index 100% rename from app/assets/javascripts/meetings.coffee rename to app/assets/javascripts/users.coffee diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 00000000..31a2eacb --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index d34df678..3efc3137 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -42,7 +42,7 @@ class MeetingsController < ApplicationController if params[:join_name] redirect_to @meeting.join_path(params[:join_name], opts) else - # Render the join page so they can supploy their name. + # Render the join page so they can supply their name. render :join end end @@ -54,15 +54,33 @@ class MeetingsController < ApplicationController 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. - render :wait + 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 @@ -75,6 +93,7 @@ class MeetingsController < ApplicationController { 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)}" } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 00000000..1c6eb415 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,2 @@ +class UsersController < ApplicationController +end \ No newline at end of file diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 00000000..2310a240 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/models/meeting.rb b/app/models/meeting.rb index e82858f8..20728330 100644 --- a/app/models/meeting.rb +++ b/app/models/meeting.rb @@ -38,7 +38,6 @@ class Meeting < ApplicationRecord options[:meeting_logout_url] ||= nil options[:moderator_message] ||= '' options[:user_is_moderator] ||= false - options[:meeting_recorded] ||= false #options[:wait_for_moderator] ||= false @@ -61,6 +60,12 @@ class Meeting < ApplicationRecord bbb.join_meeting_url(uid, username, password) end + # Fetches all recordings for a meeting. + def recordings + res = bbb.get_recordings(meetingID: uid) + res[:recordings] + end + # Checks if a meeting is running on the BigBlueButton server. def is_running? begin diff --git a/app/views/meetings/wait.html.erb b/app/views/meetings/wait.html.erb index eb8394e5..f0693a53 100644 --- a/app/views/meetings/wait.html.erb +++ b/app/views/meetings/wait.html.erb @@ -1 +1,7 @@ -

waiting for meeting to start...

\ No newline at end of file +

Waiting for meeting to start...

+

You will be redirected when the meeing starts...

+ +<% unless current_user %> +

Input a name for when the meeting starts.

+ <%= text_field(:unauthenticated_join_name, nil) %> +<% end %> \ No newline at end of file diff --git a/app/views/rooms/index.html.erb b/app/views/rooms/index.html.erb index 694ddc40..22002561 100644 --- a/app/views/rooms/index.html.erb +++ b/app/views/rooms/index.html.erb @@ -15,7 +15,7 @@




Previous Sessions

<% current_user.room.meetings.each do |m| %> -

<%= m.name + " " + m.is_running?.to_s %>

+

<%= m.name + " " + m.is_running?.to_s + " " + m.recordings.to_s %>

<% end %>
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 00000000..6c3da770 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UsersControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end