diff --git a/app/assets/javascripts/errors.coffee b/app/assets/javascripts/errors.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/errors.coffee @@ -0,0 +1,3 @@ +# 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/ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1bf2c6ce..0c7451b0 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -85,6 +85,13 @@ a { width: 60%; } +.center-page { + position: absolute; + top: 50%; + left:50%; + transform: translate(-50%,-50%); +} + iframe{ position: absolute; top: 0; diff --git a/app/assets/stylesheets/errors.scss b/app/assets/stylesheets/errors.scss new file mode 100644 index 00000000..03da2c4f --- /dev/null +++ b/app/assets/stylesheets/errors.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Errors 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/application_controller.rb b/app/controllers/application_controller.rb index e9d6f23b..cced7164 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,14 +35,6 @@ class ApplicationController < ActionController::Base end helper_method :allow_greenlight_users? - # Generate a URL to start a meeting. - def owner_meeting_url - opts = default_meeting_options - opts[:user_is_moderator] = true - @room.meeting.join_path(current_user.name, opts) - end - helper_method :owner_meeting_url - # Determines if a form field needs the is-invalid class. def form_is_invalid?(obj, key) 'is-invalid' if !obj.errors.messages[key].empty? diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 00000000..fd44434d --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,14 @@ +class ErrorsController < ApplicationController + + def not_found + render status: 404 + end + + def unprocessable + render status: 422 + end + + def internal_error + render status: 500 + end +end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 8aed5af7..10769815 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -35,14 +35,18 @@ class RoomsController < ApplicationController opts = default_meeting_options # Assign join name if passed. - if params[@room.invite_path] + if params[@room.invite_path][:join_name] @join_name = params[@room.invite_path][:join_name] + else + # Join name not passed. + return end if @room.is_running? 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(current_user.name, opts, current_user.uid) + else + join_name = params[@room.invite_path][:join_name] redirect_to @room.join_path(join_name, opts) end else @@ -65,7 +69,7 @@ class RoomsController < ApplicationController opts = default_meeting_options opts[:user_is_moderator] = true - redirect_to @room.join_path(current_user, opts) + redirect_to @room.join_path(current_user.name, opts, current_user.uid) # Notify users that the room has started. # Delay 5 seconds to allow for server start, although the request will retry until it succeeds. diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb new file mode 100644 index 00000000..8e3b415c --- /dev/null +++ b/app/helpers/errors_helper.rb @@ -0,0 +1,2 @@ +module ErrorsHelper +end diff --git a/app/models/room.rb b/app/models/room.rb index 4e45862a..a8244ed0 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -7,7 +7,6 @@ class Room < ApplicationRecord belongs_to :owner, class_name: 'User', foreign_key: :user_id has_one :meeting - ROOM_ICONS = %w(circle star certificate play cloud heart square bookmark cog) RETURNCODE_SUCCESS = "SUCCESS" # Determines if a user owns a room. @@ -21,19 +20,6 @@ class Room < ApplicationRecord bbb.is_meeting_running?(bbb_id) end - # Retrieves all the users in a room. - def participants - begin - res = bbb.get_meeting_info(bbb_id, nil) - res[:attendees].map do |att| - User.find_by(uid: att[:userID], name: att[:fullName]) - end - rescue BigBlueButton::BigBlueButtonException => exc - # The meeting is most likely not running. - [] - end - end - # Determines the invite URL for the room. def invite_path "/r/#{uid}" @@ -68,7 +54,7 @@ class Room < ApplicationRecord end # Returns a URL to join a user into a meeting. - def join_path(user, options = {}) + def join_path(name, options = {}, uid = nil) # Create the meeting if it isn't running. start_session(options) unless is_running? @@ -95,10 +81,10 @@ class Room < ApplicationRecord end # Generate the join URL. - if user.is_a?(User) - bbb.join_meeting_url(bbb_id, user.name, password, {userID: user.uid}) + if uid + bbb.join_meeting_url(bbb_id, name, password, {userID: uid}) else - bbb.join_meeting_url(bbb_id, user, password) + bbb.join_meeting_url(bbb_id, name, password) end end @@ -109,6 +95,19 @@ class Room < ApplicationRecord }) end + # Retrieves all the users in a room. + def participants + begin + res = bbb.get_meeting_info(bbb_id, nil) + res[:attendees].map do |att| + User.find_by(uid: att[:userID], name: att[:fullName]) + end + rescue BigBlueButton::BigBlueButtonException => exc + # The meeting is most likely not running. + [] + end + end + # Fetches all recordings for a meeting. def recordings res = bbb.get_recordings(meetingID: bbb_id) @@ -168,8 +167,6 @@ class Room < ApplicationRecord def setup self.uid = [owner.firstname, (0...9).map { (65 + rand(26)).chr }.join].join('-').downcase self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s - - self.icon = ROOM_ICONS.sample end # Rereives the loadbalanced BigBlueButton credentials for a user. diff --git a/app/views/errors/internal_error.html.erb b/app/views/errors/internal_error.html.erb new file mode 100644 index 00000000..01489b7a --- /dev/null +++ b/app/views/errors/internal_error.html.erb @@ -0,0 +1,7 @@ +
<%= subtitle %>
You may have mistyped the address or the page may have moved.
-If you are the application owner check the logs for more information.
-Maybe you tried to change something you didn't have access to.
-If you are the application owner check the logs for more information.
-If you are the application owner check the logs for more information.
-