From 32ec2bacceb73745217ad3fed403807eef3327bb Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 29 May 2018 15:28:29 -0400 Subject: [PATCH] restructure app --- Gemfile.lock | 18 -- app/assets/javascripts/meetings.js | 0 app/assets/stylesheets/application.scss | 8 + app/assets/stylesheets/meetings.scss | 3 - app/controllers/application_controller.rb | 4 +- app/controllers/main_controller.rb | 1 - app/controllers/meetings_controller.rb | 46 ----- app/controllers/rooms_controller.rb | 77 ++++---- app/models/meeting.rb | 156 ---------------- app/models/room.rb | 169 +++++++++++++++++- app/models/user.rb | 5 +- app/views/layouts/application.html.erb | 5 + app/views/main/_invite_join.html.erb | 15 -- app/views/main/index.html.erb | 47 +---- app/views/meetings/show.html.erb | 11 -- app/views/rooms/join.html.erb | 4 +- app/views/rooms/sessions.html.erb | 17 +- app/views/rooms/show.html.erb | 11 +- app/views/shared/_center_panel.html.erb | 21 --- app/views/shared/_header.html.erb | 22 ++- app/views/shared/_meeting_name_form.html.erb | 3 - app/views/shared/_signup.html.erb | 17 -- app/views/shared/_title.html.erb | 7 - .../shared/components/_room_block.html.erb | 27 +++ .../shared/components/_subtitle.html.erb | 6 + .../shared/modals/_create_room_modal.html.erb | 11 +- app/views/users/settings.html.erb | 11 +- config/routes.rb | 23 +-- db/migrate/20180504131705_create_rooms.rb | 2 + db/migrate/20180504131713_create_meetings.rb | 11 -- db/schema.rb | 17 +- 31 files changed, 303 insertions(+), 472 deletions(-) delete mode 100644 app/assets/javascripts/meetings.js delete mode 100644 app/assets/stylesheets/meetings.scss delete mode 100644 app/controllers/meetings_controller.rb delete mode 100644 app/models/meeting.rb delete mode 100644 app/views/main/_invite_join.html.erb delete mode 100644 app/views/meetings/show.html.erb delete mode 100644 app/views/shared/_center_panel.html.erb delete mode 100644 app/views/shared/_meeting_name_form.html.erb delete mode 100644 app/views/shared/_signup.html.erb delete mode 100644 app/views/shared/_title.html.erb create mode 100644 app/views/shared/components/_room_block.html.erb create mode 100644 app/views/shared/components/_subtitle.html.erb delete mode 100644 db/migrate/20180504131713_create_meetings.rb diff --git a/Gemfile.lock b/Gemfile.lock index 66c9d0d0..b3cb64d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,6 @@ GEM remote: https://rubygems.org/ specs: - action_interceptor (1.1.0) - rails (>= 3.1) actioncable (5.0.7) actionpack (= 5.0.7) nio4r (>= 1.2, < 3.0) @@ -79,12 +77,6 @@ GEM faraday (0.12.2) multipart-post (>= 1.2, < 3) ffi (1.9.23) - fine_print (3.1.0) - action_interceptor (>= 1.0) - jquery-rails - rails (>= 3.1) - responders - squeel font-awesome-sass (5.0.13) sassc (>= 1.11) globalid (0.4.1) @@ -141,8 +133,6 @@ GEM omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack - polyamorous (1.1.0) - activerecord (>= 3.0) popper_js (1.12.9) puma (3.11.4) rack (2.0.5) @@ -179,9 +169,6 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -227,10 +214,6 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) - squeel (1.2.3) - activerecord (>= 3.0) - activesupport (>= 3.0) - polyamorous (~> 1.1.0) tabler-rubygem (0.1.2) autoprefixer-rails (>= 6.0.3) thor (0.20.0) @@ -265,7 +248,6 @@ DEPENDENCIES dotenv-rails factory_bot_rails faker - fine_print font-awesome-sass (~> 5.0.13) jbuilder (~> 2.5) jquery-rails diff --git a/app/assets/javascripts/meetings.js b/app/assets/javascripts/meetings.js deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index bc449f51..1197a293 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -48,6 +48,10 @@ $rule-color: lightblue; padding-bottom: 56.25%; } +a { + text-decoration: none !important; +} + .start-block { background-color: white; border: 3px solid lightblue; @@ -66,6 +70,10 @@ iframe{ height: 100%; } +.subtitle { + font-size: 25px; +} + html, body { width: 100%; height: 100%; diff --git a/app/assets/stylesheets/meetings.scss b/app/assets/stylesheets/meetings.scss deleted file mode 100644 index 13905b3b..00000000 --- a/app/assets/stylesheets/meetings.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Meetings 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 70ea0dda..44971d21 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,9 +47,9 @@ class ApplicationController < ActionController::Base def default_meeting_options { user_is_moderator: false, - meeting_logout_url: request.base_url + logout_room_path(@room.uid), + meeting_logout_url: request.base_url + logout_room_path(@room), meeting_recorded: true, - moderator_message: "To invite someone to the meeting, send them this link:\n\n#{request.base_url + room_path(@room.uid)}" + moderator_message: "To invite someone to the meeting, send them this link:\n\n#{request.base_url + room_path(@room)}" } end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 38a8ae1d..e0a46491 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -4,7 +4,6 @@ class MainController < ApplicationController # GET / def index - @meeting = Meeting.new end private diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb deleted file mode 100644 index ef6a591e..00000000 --- a/app/controllers/meetings_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class MeetingsController < ApplicationController - - # GET /m/:meeting_uid - def show - @meeting = Meeting.find_by(uid: params[:meeting_uid]) - if @meeting - - else - # Handle meeting doesn't exist. - - end - end - - # POST /m/:meeting_uid - def join - meeting = Meeting.find_by(uid: params[:meeting_uid]) - if meeting - # If the user is logged in, join using their authenticated name. - if current_user - redirect_to meeting.join_path(current_user.name) - # Otherwise, use their inputed join name. - elsif params[:join_name] - redirect_to meeting.join_path(params[:join_name]) - end - else - # Handle meeting doesn't exist. - - end - end - - # POST /m - def create - meeting = Meeting.new(meeting_params) - if meeting.save - redirect_to meeting_path(meeting_uid: meeting.uid) - else - redirect_to root_path - end - end - - private - - def meeting_params - params.require(:meeting).permit(:name) - end -end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index df4214c4..7456cee2 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -1,27 +1,46 @@ class RoomsController < ApplicationController - before_action :find_room, :verify_room_ownership - skip_before_action :verify_room_ownership, only: [:show, :join, :wait] + before_action :find_room, except: :create - # GET /r/:room_uid + #before_action :verify_room_ownership + #skip_before_action :verify_room_ownership, only: [:create, :show, :join, :wait] + + # POST /r + def create + room = Room.new(name: room_params[:name]) + room.user = current_user + + if room.save + redirect_to room + else + + end + end + + # GET/POST /r/:room_uid def show opts = default_meeting_options - if @meeting.is_running? + 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 @meeting.join_path(current_user.name, opts) + redirect_to @room.join_path(current_user, opts) end else # If you're unauthenticated, you must enter a name to join the meeting. - redirect_to join_room_path(@room.uid) + if params[:join_name] + redirect_to @room.join_path(params[:join_name], opts) + else + # Render the join page so they can supply their name. + render :join + end end else # 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.uid) + redirect_to wait_room_path(@room) end end end @@ -31,47 +50,19 @@ class RoomsController < ApplicationController # Join the user in and start the meeting. opts = default_meeting_options opts[:user_is_moderator] = true - redirect_to @meeting.join_path(current_user.name, opts) - end - # GET /r/:room_uid/join - def join - if @meeting.is_running? - opts = default_meeting_options - - if current_user - # If the user exists, join them in. - opts[:user_is_moderator] = @room.owned_by?(current_user) - redirect_to @meeting.join_path(current_user.name, opts) - else - # If they are unauthenticated, prompt for 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 - if @room.owned_by?(current_user) - # Redirect owner to room. - redirect_to room_path(@room.uid) - else - # Otherwise, they have to wait for the meeting to start. - redirect_to wait_room_path(@room.uid) - end - end + redirect_to @room.join_path(current_user, opts) end # GET/POST /r/:room_uid/wait def wait - if @meeting.is_running? + if @room.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) + 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 @meeting.join_path(params[:unauthenticated_join_name], default_meeting_options) + redirect_to @room.join_path(params[:unauthenticated_join_name], default_meeting_options) end end end @@ -79,7 +70,7 @@ class RoomsController < ApplicationController # GET /r/:room_uid/logout def logout # Redirect the owner to their room. - redirect_to room_path(@room.uid) + redirect_to root_path end # GET /r/:room_uid/sessions @@ -89,6 +80,10 @@ class RoomsController < ApplicationController private + def room_params + params.require(:room).permit(:name, :auto_join) + end + # Find the room from the uid. def find_room @room = Room.find_by(uid: params[:room_uid]) @@ -97,8 +92,6 @@ class RoomsController < ApplicationController # Handle room doesn't exist. end - - @meeting = @room.meeting end # Ensure the user is logged into the room they are accessing. diff --git a/app/models/meeting.rb b/app/models/meeting.rb deleted file mode 100644 index 5ee2c4b4..00000000 --- a/app/models/meeting.rb +++ /dev/null @@ -1,156 +0,0 @@ -class Meeting < ApplicationRecord - - before_create :generate_meeting_id - - validates :name, presence: true - - belongs_to :room, optional: true - - RETURNCODE_SUCCESS = "SUCCESS" - - # Creates a meeting on the BigBlueButton server. - def start_meeting(options = {}) - create_options = { - record: options[:meeting_recorded].to_s, - logoutURL: options[:meeting_logout_url] || '', - moderatorPW: random_password(12), - attendeePW: random_password(12), - moderatorOnlyMessage: options[:moderator_message] - } - - #meeting_options.merge!( - #{ "meta_room-id": options[:room_owner], - # "meta_meeting-name": options[:meeting_name]} - #) if options[:room_owner] - - # Send the create request. - begin - bbb.create_meeting(name, uid, create_options) - rescue BigBlueButton::BigBlueButtonException => exc - puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}" - end - end - - # Returns a URL to join a user into a meeting. - def join_path(username, options = {}) - # Create the meeting if it isn't running. - start_meeting(options) unless is_running? - - # Set meeting options. - options[:meeting_logout_url] ||= nil - options[:moderator_message] ||= '' - options[:user_is_moderator] ||= false - options[:meeting_recorded] ||= false - - #options[:wait_for_moderator] ||= false - #options[:meeting_name] ||= name - #options[:room_owner] ||= nil - - return call_invalid_res if !bbb - - # Get the meeting info. - meeting_info = bbb.get_meeting_info(uid, nil) - - # Determine the password to use when joining. - password = if options[:user_is_moderator] - meeting_info[:moderatorPW] - else - meeting_info[:attendeePW] - end - - # Generate the join URL. - 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 - bbb.get_meeting_info(uid, nil) - return true - rescue BigBlueButton::BigBlueButtonException => exc - return false - end - end - - private - - def bbb_endpoint - Rails.configuration.bigbluebutton_endpoint - end - - def bbb_secret - Rails.configuration.bigbluebutton_secret - end - - # Sets a BigBlueButtonApi object for interacting with the API. - def bbb - @bbb ||= if Rails.configuration.loadbalanced_configuration - lb_user = retrieve_loadbalanced_credentials(self.room.user.provider) - BigBlueButton::BigBlueButtonApi.new(remove_slash(lb_user["apiURL"]), lb_user["secret"], "0.8") - else - BigBlueButton::BigBlueButtonApi.new(remove_slash(bbb_endpoint), bbb_secret, "0.8") - end - end - - # Rereives the loadbalanced BigBlueButton credentials for a user. - def retrieve_loadbalanced_credentials(provider) - # Include Omniauth accounts under the Greenlight provider. - provider = "greenlight" if Rails.configuration.providers.include?(provider.to_sym) - - # Build the URI. - uri = encode_bbb_url( - Rails.configuration.loadbalancer_endpoint, - Rails.configuration.loadbalancer_secret, - {name: provider} - ) - - # Make the request. - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = (uri.scheme == 'https') - response = http.get(uri.request_uri) - - unless response.kind_of?(Net::HTTPSuccess) - raise "Error retrieving provider credentials: #{response.code} #{response.message}" - end - - # Parse XML. - doc = XmlSimple.xml_in(response.body, 'ForceArray' => false) - - # Return the user credentials if the request succeeded on the loadbalancer. - return doc['user'] if doc['returncode'] == RETURNCODE_SUCCESS - - raise "User with provider #{provider} does not exist." if doc['messageKey'] == "noSuchUser" - raise "API call #{url} failed with #{doc['messageKey']}." - end - - # Builds a request to retrieve credentials from the load balancer. - def encode_bbb_url(base_url, secret, params) - encoded_params = OAuth::Helper.normalize(params) - string = "getUser" + encoded_params + secret - checksum = OpenSSL::Digest.digest('sha1', string).unpack("H*").first - - URI.parse("#{base_url}?#{encoded_params}&checksum=#{checksum}") - end - - # Removes trailing forward slash from a URL. - def remove_slash(s) - s.nil? ? nil : s.chomp("/") - end - - # Generates a BigBlueButton meeting id from a meeting token. - def generate_meeting_id - self.uid = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + name + Time.now.to_i.to_s).to_s - end - - # Generates a random password for a meeting. - def random_password(length) - o = ([('a'..'z'), ('A'..'Z')].map do |i| i.to_a end).flatten - ((0...length).map do o[rand(o.length)] end).join - end -end diff --git a/app/models/room.rb b/app/models/room.rb index beb18f51..fc371990 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,23 +1,174 @@ class Room < ApplicationRecord - before_create :set_uid + before_create :generate_uids belongs_to :user has_one :meeting + RETURNCODE_SUCCESS = "SUCCESS" + + def to_param + uid + end + # Determines if a user owns a room. def owned_by?(user) return false if user.nil? - user.room == self + user.rooms.include?(self) + end + + # Checks if a room is running on the BigBlueButton server. + def is_running? + begin + bbb.get_meeting_info(bbb_id, nil) + return true + rescue BigBlueButton::BigBlueButtonException => exc + return false + end + end + + # Determines the invite URL for the room. + def invite_path + "/r/#{uid}" + end + + # Creates a meeting on the BigBlueButton server. + def start_session(options = {}) + create_options = { + record: options[:meeting_recorded].to_s, + logoutURL: options[:meeting_logout_url] || '', + moderatorPW: random_password(12), + attendeePW: random_password(12), + moderatorOnlyMessage: options[:moderator_message] + } + + #meeting_options.merge!( + #{ "meta_room-id": options[:room_owner], + # "meta_meeting-name": options[:meeting_name]} + #) if options[:room_owner] + + # Send the create request. + begin + bbb.create_meeting(name, bbb_id, create_options) + rescue BigBlueButton::BigBlueButtonException => exc + puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}" + end + end + + # Returns a URL to join a user into a meeting. + def join_path(user, options = {}) + user = user.name if user.is_a?(User) + + # Create the meeting if it isn't running. + start_session(options) unless is_running? + + # Set meeting options. + options[:meeting_logout_url] ||= nil + options[:moderator_message] ||= '' + options[:user_is_moderator] ||= false + options[:meeting_recorded] ||= false + + #options[:wait_for_moderator] ||= false + #options[:meeting_name] ||= name + #options[:room_owner] ||= nil + + return call_invalid_res if !bbb + + # Get the meeting info. + meeting_info = bbb.get_meeting_info(bbb_id, nil) + + # Determine the password to use when joining. + password = if options[:user_is_moderator] + meeting_info[:moderatorPW] + else + meeting_info[:attendeePW] + end + + # Generate the join URL. + bbb.join_meeting_url(bbb_id, user, password) + end + + # Fetches all recordings for a meeting. + def recordings + res = bbb.get_recordings(meetingID: bbb_id) + res[:recordings] end private - # Generates a uid for the room. - def set_uid - digest = user.id.to_s + user.provider + user.username - digest += user.uid unless user.uid.nil? - - self.uid = [user.name.split(' ').first.downcase, Digest::SHA1.hexdigest(digest)[0..7]].join('-') + def bbb_endpoint + Rails.configuration.bigbluebutton_endpoint end -end \ No newline at end of file + + def bbb_secret + Rails.configuration.bigbluebutton_secret + end + + # Sets a BigBlueButtonApi object for interacting with the API. + def bbb + @bbb = BigBlueButton::BigBlueButtonApi.new(remove_slash(bbb_endpoint), bbb_secret, "0.8") + #@bbb ||= if Rails.configuration.loadbalanced_configuration + # lb_user = retrieve_loadbalanced_credentials(self.room.user.provider) + # BigBlueButton::BigBlueButtonApi.new(remove_slash(lb_user["apiURL"]), lb_user["secret"], "0.8") + #else + # BigBlueButton::BigBlueButtonApi.new(remove_slash(bbb_endpoint), bbb_secret, "0.8") + #end + end + + # Generates a uid for the room and BigBlueButton. + def generate_uids + self.uid = [user.firstname, (0...8).map { (65 + rand(26)).chr }.join].join('-') + self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s + end + + # Rereives the loadbalanced BigBlueButton credentials for a user. + def retrieve_loadbalanced_credentials(provider) + # Include Omniauth accounts under the Greenlight provider. + provider = "greenlight" if Rails.configuration.providers.include?(provider.to_sym) + + # Build the URI. + uri = encode_bbb_url( + Rails.configuration.loadbalancer_endpoint, + Rails.configuration.loadbalancer_secret, + {name: provider} + ) + + # Make the request. + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = (uri.scheme == 'https') + response = http.get(uri.request_uri) + + unless response.kind_of?(Net::HTTPSuccess) + raise "Error retrieving provider credentials: #{response.code} #{response.message}" + end + + # Parse XML. + doc = XmlSimple.xml_in(response.body, 'ForceArray' => false) + + # Return the user credentials if the request succeeded on the loadbalancer. + return doc['user'] if doc['returncode'] == RETURNCODE_SUCCESS + + raise "User with provider #{provider} does not exist." if doc['messageKey'] == "noSuchUser" + raise "API call #{url} failed with #{doc['messageKey']}." + end + + # Builds a request to retrieve credentials from the load balancer. + def encode_bbb_url(base_url, secret, params) + encoded_params = OAuth::Helper.normalize(params) + string = "getUser" + encoded_params + secret + checksum = OpenSSL::Digest.digest('sha1', string).unpack("H*").first + + URI.parse("#{base_url}?#{encoded_params}&checksum=#{checksum}") + end + + # Removes trailing forward slash from a URL. + def remove_slash(s) + s.nil? ? nil : s.chomp("/") + end + + # Generates a random password for a meeting. + def random_password(length) + o = ([('a'..'z'), ('A'..'Z')].map do |i| i.to_a end).flatten + ((0...length).map do o[rand(o.length)] end).join + end +end diff --git a/app/models/user.rb b/app/models/user.rb index a664d32b..f2189b0e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ class User < ApplicationRecord after_create :initialize_room before_save { email.downcase! unless email.nil? } - has_one :room + has_many :rooms validates :name, length: { maximum: 24 }, presence: true validates :username, presence: true @@ -89,7 +89,6 @@ class User < ApplicationRecord # Initializes a room for the user. def initialize_room - room = Room.create(user_id: self.id) - Meeting.create(room_id: room.id, name: "Example") + Room.create(user_id: self.id, name: firstname + "'s Room") end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 18d007ef..f04e4d32 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -33,6 +33,11 @@ <%= yield %> <%= render "shared/footer" %> + + + <% if current_user %> + <%= render "shared/modals/create_room_modal" %> + <% end %> diff --git a/app/views/main/_invite_join.html.erb b/app/views/main/_invite_join.html.erb deleted file mode 100644 index aff12bac..00000000 --- a/app/views/main/_invite_join.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index 0913c1bc..8eab997f 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -2,7 +2,6 @@ <% if current_user %>

<%= "Welcome, #{current_user.firstname}." %>

- <%= render "shared/modals/create_room_modal" %> <% else %>

Teach Students Online.

<%= render "shared/modals/video_modal" %> @@ -10,47 +9,19 @@
<% if current_user %> -
- <% 3.times do %> -
-
-
- - - - - - -
- - -
Example Room
-
- Created on June 17th, 2017 -
-
- -
+
+ <% current_user.rooms.each do |room| %> +
+ <%= link_to room do %> + <%= render "shared/components/room_block", room: room %> + <% end %>
-
+ <% end %>
- <% end %> -
- - -
+
<% else %> - <%= render "shared/features" %> + <%= render "shared/features" %> <% end %>
diff --git a/app/views/meetings/show.html.erb b/app/views/meetings/show.html.erb deleted file mode 100644 index ee49dae0..00000000 --- a/app/views/meetings/show.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -

This is an unauthenticated meeting page.

- -<% if current_user %> - <%= link_to "Join", join_meeting_path(uid: @meeting.uid), {method: :post} %> -<% else %> -

Enter a name to join the session.

- <%= form_tag join_meeting_path do %> - <%= text_field_tag "join_name" %> - <%= submit_tag "Join" %> - <% end %> -<% end %> diff --git a/app/views/rooms/join.html.erb b/app/views/rooms/join.html.erb index 101008f2..8d4b7682 100644 --- a/app/views/rooms/join.html.erb +++ b/app/views/rooms/join.html.erb @@ -1,7 +1,7 @@

The join the meeting, enter a name.

Enter a name to start a session.

-<%= form_tag join_room_path(room_uid: @room.uid) do %> +<%= form_tag room_path(@room) do %> <%= text_field_tag "join_name" %> <%= submit_tag "Join" %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/rooms/sessions.html.erb b/app/views/rooms/sessions.html.erb index dcbc8c2f..078af1dd 100644 --- a/app/views/rooms/sessions.html.erb +++ b/app/views/rooms/sessions.html.erb @@ -1,17 +1,6 @@
-
-
-

Sessions

- -
-
-
+ <%= render "shared/components/subtitle", subtitle: "Sessions" %>
@@ -82,9 +71,9 @@ Sessions

-<%= @meeting.recordings %> +<%= @room.recordings %> -<% @meeting.recordings.each do |rec| %> +<% @room.recordings.each do |rec| %>

<%= rec[:metadata][:meetingName] %>

<% Array.wrap(rec[:playback][:format]).each do |form| %> <%= link_to form[:type], form[:url] %> diff --git a/app/views/rooms/show.html.erb b/app/views/rooms/show.html.erb index 1b50ba61..6e504a1e 100644 --- a/app/views/rooms/show.html.erb +++ b/app/views/rooms/show.html.erb @@ -1,20 +1,15 @@

This is a room.

<%= @room.user.name %>

-

<%= @room.meeting.uid %>

<%= @room.uid %>

-<%= link_to 'Sessions', sessions_path %> -<%= link_to 'Settings', root_path %> -

Click below to join the meeting.

-<% if @room.meeting.is_running? %> +<% if @room.is_running? %>

meeting is already running

<% else %> - <%= link_to "Start Meeting", start_room_path(@room.uid) %> + <%= link_to "Start Room", start_room_path(@room) %> <% end %>

- -<%= link_to 'Logout', logout_path %> +<%= link_to "Sessions", sessions_path(@room) %> diff --git a/app/views/shared/_center_panel.html.erb b/app/views/shared/_center_panel.html.erb deleted file mode 100644 index 0f3dcaed..00000000 --- a/app/views/shared/_center_panel.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
-
-
- <% if bigbluebutton_endpoint_default? %> -
<%= t('warning_bigbluebutton_endpoint_default') %>
- <% end %> -

- <%= yield :title %> -

- <%= yield %> -
- <%= yield :footer %> - -
-
-
-
\ No newline at end of file diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index d4f0a462..a8d2bff0 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -1,9 +1,9 @@
- + <%= link_to root_path, class: "header-brand" do %> <%= image_tag("bbb_logo.png", class: "header-brand-img") %> - + <% end %>
<% if current_user %> @@ -24,10 +24,22 @@ <%= current_user.subtitle %> +
- <%= link_to logout_path do %> - - <% end %> <% else %> <%= render "shared/modals/login_modal" %> diff --git a/app/views/shared/_meeting_name_form.html.erb b/app/views/shared/_meeting_name_form.html.erb deleted file mode 100644 index 1f6e8d37..00000000 --- a/app/views/shared/_meeting_name_form.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/app/views/shared/_signup.html.erb b/app/views/shared/_signup.html.erb deleted file mode 100644 index b10a25f4..00000000 --- a/app/views/shared/_signup.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - \ No newline at end of file diff --git a/app/views/shared/_title.html.erb b/app/views/shared/_title.html.erb deleted file mode 100644 index 7348aef4..00000000 --- a/app/views/shared/_title.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% title_class ||= '' %> -
-
-

<%= title %>

- <%= yield %> -
-
\ No newline at end of file diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb new file mode 100644 index 00000000..babda55c --- /dev/null +++ b/app/views/shared/components/_room_block.html.erb @@ -0,0 +1,27 @@ +
+
+ + + + + + +
+ + +
<%= room.name %>
+
+ Created on <%= room.created_at.strftime("%B #{room.created_at.day.ordinalize}, %Y") %> +
+
+ +
+
+
diff --git a/app/views/shared/components/_subtitle.html.erb b/app/views/shared/components/_subtitle.html.erb new file mode 100644 index 00000000..8b9a16d0 --- /dev/null +++ b/app/views/shared/components/_subtitle.html.erb @@ -0,0 +1,6 @@ +
+
+

<%= subtitle %>

+
+
+
diff --git a/app/views/shared/modals/_create_room_modal.html.erb b/app/views/shared/modals/_create_room_modal.html.erb index 7022e05b..dbe9df77 100644 --- a/app/views/shared/modals/_create_room_modal.html.erb +++ b/app/views/shared/modals/_create_room_modal.html.erb @@ -8,28 +8,27 @@

-
+ <%= form_for(:room, url: create_room_path) do |f| %>
- + <%= f.text_field :name, class: "form-control", placeholder: "Enter a room name...", autocomplete: :off %>
-
+ <% end %>
-
diff --git a/app/views/users/settings.html.erb b/app/views/users/settings.html.erb index a380727a..af1add04 100644 --- a/app/views/users/settings.html.erb +++ b/app/views/users/settings.html.erb @@ -1,11 +1,6 @@
-
-
-

Settings

-
-
-
+ <%= render "shared/components/subtitle", subtitle: "Settings" %>
@@ -108,7 +103,7 @@ settingsButtons = $('.setting-btn'); settingsViews = $('.setting-view'); -$(window).on('load', function(){ +$(document).ready(function(){ settingsButtons.each(function(i, btn) { if(i != 0){ $(settingsViews[i]).hide(); } $(btn).click(function(){ @@ -122,4 +117,4 @@ $(window).on('load', function(){ }); }); }); - \ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index fa6a0cb4..bc28887b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,20 +1,15 @@ Rails.application.routes.draw do # Room routes. - scope '/r/:room_uid' do - get '/', to: 'rooms#show', as: :room - get '/start', to: 'rooms#start', as: :start_room - get '/join', to: 'rooms#join', as: :join_room - match '/wait', to: 'rooms#wait', as: :wait_room, via: [:get, :post] - get '/logout', to: 'rooms#logout', as: :logout_room - get '/sessions', to: 'rooms#sessions', as: :sessions - end - - # Meeting routes. - scope '/m' do - post '/', to: 'meetings#create', as: :create_meeting - get '/:meeting_uid', to: 'meetings#show', as: :meeting - post '/:meeting_uid', to: 'meetings#join', as: :join_meeting + scope '/r' do + post '/', to: 'rooms#create', as: :create_room + scope '/:room_uid' do + match '/', to: 'rooms#show', as: :room, via: [:get, :post] + get '/start', to: 'rooms#start', as: :start_room + match '/wait', to: 'rooms#wait', as: :wait_room, via: [:get, :post] + get '/logout', to: 'rooms#logout', as: :logout_room + get '/sessions', to: 'rooms#sessions', as: :sessions + end end # Signup routes. diff --git a/db/migrate/20180504131705_create_rooms.rb b/db/migrate/20180504131705_create_rooms.rb index 0f02ff10..2ba7ba75 100644 --- a/db/migrate/20180504131705_create_rooms.rb +++ b/db/migrate/20180504131705_create_rooms.rb @@ -2,7 +2,9 @@ class CreateRooms < ActiveRecord::Migration[5.0] def change create_table :rooms do |t| t.belongs_to :user, index: true + t.string :name, index: true t.string :uid, index: true + t.string :bbb_id, index: true t.timestamps end diff --git a/db/migrate/20180504131713_create_meetings.rb b/db/migrate/20180504131713_create_meetings.rb deleted file mode 100644 index 6acccce5..00000000 --- a/db/migrate/20180504131713_create_meetings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateMeetings < ActiveRecord::Migration[5.0] - def change - create_table :meetings do |t| - t.belongs_to :room, index: true - t.string :name, index: true - t.string :uid, index: true - - t.timestamps - end - end -end diff --git a/db/schema.rb b/db/schema.rb index 433b72d9..47860038 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,24 +10,17 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180504131713) do - - create_table "meetings", force: :cascade do |t| - t.integer "room_id" - t.string "name" - t.string "uid" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["name"], name: "index_meetings_on_name" - t.index ["room_id"], name: "index_meetings_on_room_id" - t.index ["uid"], name: "index_meetings_on_uid" - end +ActiveRecord::Schema.define(version: 20180504131705) do create_table "rooms", force: :cascade do |t| t.integer "user_id" + t.string "name" t.string "uid" + t.string "bbb_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["bbb_id"], name: "index_rooms_on_bbb_id" + t.index ["name"], name: "index_rooms_on_name" t.index ["uid"], name: "index_rooms_on_uid" t.index ["user_id"], name: "index_rooms_on_user_id" end