diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 71ee1e66..2fb3e843 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -9,5 +9,4 @@ this.App || (this.App = {}); App.cable = ActionCable.createConsumer(); - }).call(this); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f67f4025..a0347fcf 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -79,6 +79,10 @@ a { font-size: 20px; } +.join-button { + width: 60%; +} + iframe{ position: absolute; top: 0; diff --git a/app/channels/waiting_channel.rb b/app/channels/waiting_channel.rb new file mode 100644 index 00000000..8c28e236 --- /dev/null +++ b/app/channels/waiting_channel.rb @@ -0,0 +1,5 @@ +class WaitingChannel < ApplicationCable::Channel + def subscribed + stream_from "#{params[:uid]}_waiting_channel" + end +end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 9d9e2b33..e08c5185 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -24,49 +24,31 @@ class RoomsController < ApplicationController # GET /r/:room_uid def show - opts = default_meeting_options - - if @room.is_running? - if current_user - # If you don't own the room but the meeting is running, join up. - if !@room.owned_by?(current_user) - opts[:user_is_moderator] = false - redirect_to @room.join_path(current_user, opts) - end - else - # Render the join page so they can supply their name. - render :join - end + if current_user && @room.owned_by?(current_user) + @recordings = @room.recordings else - # If the room isn't running, go to join page to enter a name. - if !@room.owned_by?(current_user) - render :join - end - - # If the meeting isn't running and you don't own the room, go to the waiting page. - #if !@room.owned_by?(current_user) - # redirect_to wait_room_path(@room) - #end + render :join end - - # NOTE: TEST TO MAKE SURE THIS DOESN'T FIRE WHEN THEY ARE NOT OWNER AND REDIRECTED. - @recordings = @room.recordings end # POST /r/:room_uid def join opts = default_meeting_options + # Assign join name if passed. + if params[@room.invite_path] + @join_name = params[@room.invite_path][:join_name] + end + if @room.is_running? - # If you're unauthenticated, you must enter a name to join the meeting. - if params[@room.invite_path][:join_name] - redirect_to @room.join_path(params[@room.invite_path][:join_name], opts) - else + if current_user redirect_to @room.join_path(current_user, opts) + elsif join_name = params[:join_name] || params[@room.invite_path][:join_name] + redirect_to @room.join_path(join_name, opts) end else # They need to wait until the meeting begins. - + render :wait end end @@ -85,19 +67,10 @@ class RoomsController < ApplicationController opts[:user_is_moderator] = true redirect_to @room.join_path(current_user, opts) - end - # GET/POST /r/:room_uid/wait - def wait - if @room.is_running? - if current_user - # If they are logged in and waiting, use their account name. - redirect_to @room.join_path(current_user, default_meeting_options) - elsif !params[:unauthenticated_join_name].blank? - # Otherwise, use the name they submitted on the wating page. - redirect_to @room.join_path(params[:unauthenticated_join_name], default_meeting_options) - end - end + # Notify users that the room has started. + # Delay 5 seconds to allow for server start, although the request will retry until it succeeds. + NotifyUserWaitingJob.set(wait: 5.seconds).perform_later(@room) end # GET /r/:room_uid/logout @@ -110,11 +83,6 @@ class RoomsController < ApplicationController end end - # GET /r/:room_uid/sessions - def sessions - - end - # POST /r/:room_uid/home def home current_user.main_room = @room diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a7fd0af2..95138c44 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,7 @@ class UsersController < ApplicationController before_action :find_user, only: [:edit, :update] + before_action :ensure_unauthenticated, only: [:new, :create] # POST /users def create @@ -15,6 +16,11 @@ class UsersController < ApplicationController end end + # GET /signup + def new + @user = User.new + end + # GET /users/:user_uid/edit def edit if current_user @@ -64,6 +70,10 @@ class UsersController < ApplicationController end end + def ensure_unauthenticated + redirect_to current_user.main_room if current_user + end + def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation, :new_password, :provider) end diff --git a/app/jobs/notify_user_waiting_job.rb b/app/jobs/notify_user_waiting_job.rb new file mode 100644 index 00000000..3c399c5a --- /dev/null +++ b/app/jobs/notify_user_waiting_job.rb @@ -0,0 +1,7 @@ +class NotifyUserWaitingJob < ApplicationJob + queue_as :default + + def perform(room) + room.notify_waiting + end +end diff --git a/app/models/room.rb b/app/models/room.rb index a4ba46de..4e45862a 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -51,6 +51,7 @@ class Room < ApplicationRecord # Increment room sessions. self.sessions += 1 + self.last_session = DateTime.now self.save #meeting_options.merge!( @@ -84,7 +85,7 @@ class Room < ApplicationRecord return call_invalid_res if !bbb # Get the meeting info. - meeting_info = bbb.get_meeting_info(bbb_id, nil) + meeting_info = bbb.get_meeting_info(bbb_id, nil) # Determine the password to use when joining. password = if options[:user_is_moderator] @@ -101,6 +102,13 @@ class Room < ApplicationRecord end end + # Notify waiting users that a meeting has started. + def notify_waiting + ActionCable.server.broadcast("#{uid}_waiting_channel", { + action: "started" + }) + end + # Fetches all recordings for a meeting. def recordings res = bbb.get_recordings(meetingID: bbb_id) diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index ef57f4c2..f382ad7b 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -1,10 +1,10 @@
-

Welcome to Greenlight.

+

Welcome to BigBlueButton.

A simple front end for your BigBlueButton Open Source Web Conferencing Server.

- <%= link_to "https://www.google.com", class: "p-3", target: "_blank" do %> + <%= link_to "https://www.youtube.com/watch?v=yGX3JCv7OVM&feature=youtu.be", class: "p-3", target: "_blank" do %>

Watch a tutorial on using Greenlight

<% end %>
diff --git a/app/views/rooms/join.html.erb b/app/views/rooms/join.html.erb index e95e9f3c..dd051be3 100644 --- a/app/views/rooms/join.html.erb +++ b/app/views/rooms/join.html.erb @@ -1,36 +1,14 @@ -
-
-
-
-

You have been invited to join

-

<%= @room.name %>

-
-
+<%= render 'shared/room_event' do %> + <%= form_for room_path, method: :post do |f| %> +
+ <% if current_user %> + <%= f.submit "Join", class: "btn btn-primary px-7 main-large join-button"%> + <% else %> + <%= f.text_field :join_name, class: "form-control main-large", placeholder: "Enter your name!" %> + + <%= f.submit "Join", class: "btn btn-primary px-7 main-large" %> + + <% end %>
- -
-
- <% if @room.owner.image.nil? %> - <%= @room.owner.name.first %> - <% else %> - - <% end %> -
<%= @room.owner.name %> (Owner)
-
-
- <%= form_for room_path, method: :post do |f| %> -
- <% if current_user %> - <%= f.submit "Join", class: "btn btn-primary px-7 main-large btn-block"%> - <% else %> - <%= f.text_field :join_name, class: "form-control main-large", placeholder: "Enter your name!" %> - - <%= f.submit "Join", class: "btn btn-primary px-7 main-large" %> - - <% end %> -
- <% end %> -
-
-
-
+ <% end %> +<% end %> diff --git a/app/views/rooms/wait.html.erb b/app/views/rooms/wait.html.erb index f0693a53..c21093e5 100644 --- a/app/views/rooms/wait.html.erb +++ b/app/views/rooms/wait.html.erb @@ -1,7 +1,45 @@ -

Waiting for meeting to start...

-

You will be redirected when the meeing starts...

+<%= render 'shared/room_event' do %> +
+
+

Oops! The meeting hasn't started yet.

+

You will automatically join when the meeting starts.

+
+
+
+
+
+<% end %> -<% 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/shared/_header.html.erb b/app/views/shared/_header.html.erb index 51394ecf..9c12efa2 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -44,11 +44,10 @@
<% else %> - - - + <%= link_to "Login", "#loginModal", :class => "btn btn-pill btn-outline-primary mx-2", "data-toggle": "modal" %> + <%= link_to "Signup", signup_path, :class => "btn btn-pill btn-outline-primary mx-2" %> + <%= render "shared/modals/login_modal" %> - <%= render "shared/modals/signup_modal" %> <% end %> diff --git a/app/views/shared/_room_event.html.erb b/app/views/shared/_room_event.html.erb new file mode 100644 index 00000000..4c1fbb2a --- /dev/null +++ b/app/views/shared/_room_event.html.erb @@ -0,0 +1,26 @@ +
+
+
+
+

You have been invited to join

+

<%= @room.name %>

+
+
+
+ +
+
+ <% if @room.owner.image.nil? %> + <%= @room.owner.name.first %> + <% else %> + + <% end %> +
<%= @room.owner.name %> (Owner)
+
+ +
+ <%= yield %> +
+
+
+
diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb index 9cb1e620..368dcdcc 100644 --- a/app/views/shared/components/_room_block.html.erb +++ b/app/views/shared/components/_room_block.html.erb @@ -14,16 +14,17 @@

<%= room.name %>

- Last Session on <%= recording_date(room.created_at) %> + <% if room.sessions > 0 %> + Last session on <%= recording_date(room.last_session) %> + <% else %> + This room has no sessions, yet! + <% end %>