From 061f9c794a9d8c94cce6ef517301e85917799c2a Mon Sep 17 00:00:00 2001 From: jfederico Date: Wed, 19 Oct 2016 13:43:58 -0400 Subject: [PATCH] Refactored meetings resource and breaked up view into components --- app/assets/javascripts/landing.js | 3 +- app/controllers/bbb_controller.rb | 2 +- app/controllers/landing_controller.rb | 10 +-- app/helpers/bbb_helper.rb | 4 +- app/views/landing/_footer_message.html.erb | 3 + .../landing/_footer_oauth_append.html.erb | 19 ++++++ app/views/landing/_join_form.html.erb | 28 ++++++++ app/views/landing/_sharing_text.html.erb | 6 ++ app/views/landing/index.html.erb | 68 ------------------- app/views/landing/meeting.html.erb | 14 ++++ app/views/landing/room.html.erb | 37 ++++++---- config/routes.rb | 9 +-- 12 files changed, 108 insertions(+), 95 deletions(-) create mode 100644 app/views/landing/_footer_message.html.erb create mode 100644 app/views/landing/_footer_oauth_append.html.erb create mode 100644 app/views/landing/_join_form.html.erb create mode 100644 app/views/landing/_sharing_text.html.erb delete mode 100644 app/views/landing/index.html.erb create mode 100644 app/views/landing/meeting.html.erb diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 4aeefe17..b3e24d18 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -15,6 +15,7 @@ } }); }); + $('#url_form_button').click (function (event) { $.ajax({ url : $(this).data ('url'), @@ -36,7 +37,7 @@ $(document).on("turbolinks:load", function() { if ($("body[data-controller=landing]").get(0)) { - if ($("body[data-action=index]").get(0)) { + if ($("body[data-action=meeting]").get(0) || $("body[data-action=room]").get(0)) { initIndex(); } } diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 926aa33c..3a3c9c11 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -8,7 +8,7 @@ class BbbController < ApplicationController elsif ( !params.has_key?(:name) ) render_response("missing_parameter", "user name was not included", :bad_request) else - bbb_join_url = helpers.bbb_join_url(params[:id], false, params[:name], false) + bbb_join_url = helpers.bbb_join_url(params[:id], false, params[:name], false, ) if bbb_join_url[:returncode] logger.info "#Execute the redirect" render_response("ok", "execute the redirect", :ok, {:join_url => bbb_join_url[:join_url]}) diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 6965767c..d2ac0059 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,21 +1,23 @@ class LandingController < ApplicationController - def index - @refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id)) + def meeting + @refreshable = (params[:resource] == 'meetings' && !params.has_key?(:id)) @meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token - @meeting_url = landing_url(@meeting_token) + @resource_url = meeting_url(@meeting_token) end # GET /token.json def new_meeting respond_to do |format| - meeting_url = landing_url(helpers.new_meeting_token) + meeting_url = meeting_url(helpers.new_meeting_token) format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status } end end def room @room_name = params[:name] + @meeting_token = @room_name + @resource_url = room_url(@meeting_token) @user = User.find_by(username: @room_name) if @user.nil? redirect_to root_path diff --git a/app/helpers/bbb_helper.rb b/app/helpers/bbb_helper.rb index 94901495..91130568 100644 --- a/app/helpers/bbb_helper.rb +++ b/app/helpers/bbb_helper.rb @@ -13,7 +13,7 @@ module BbbHelper return password end - def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false) + def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false, meeting_logout_url=nil) bbb ||= BigBlueButton::BigBlueButtonApi.new(bbb_endpoint + "api", bbb_secret, "0.8", true) if !bbb return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." } @@ -28,7 +28,7 @@ module BbbHelper logger.info "Message for the log file #{exc.key}: #{exc.message}" # Prepare parameters for create - logout_url = "#{request.base_url}/meeting/#{meeting_token}" + logout_url = meeting_logout_url || logout_url = "#{request.base_url}" moderator_password = random_password(12) viewer_password = random_password(12) meeting_options = {:record => meeting_recorded.to_s, :logoutURL => logout_url, :moderatorPW => moderator_password, :attendeePW => viewer_password } diff --git a/app/views/landing/_footer_message.html.erb b/app/views/landing/_footer_message.html.erb new file mode 100644 index 00000000..40f7b7f2 --- /dev/null +++ b/app/views/landing/_footer_message.html.erb @@ -0,0 +1,3 @@ + diff --git a/app/views/landing/_footer_oauth_append.html.erb b/app/views/landing/_footer_oauth_append.html.erb new file mode 100644 index 00000000..8aa4a36f --- /dev/null +++ b/app/views/landing/_footer_oauth_append.html.erb @@ -0,0 +1,19 @@ + + diff --git a/app/views/landing/_join_form.html.erb b/app/views/landing/_join_form.html.erb new file mode 100644 index 00000000..0e55c48b --- /dev/null +++ b/app/views/landing/_join_form.html.erb @@ -0,0 +1,28 @@ +
+ +

+
+
+
+ <%= @resource_url %> +
+ <% if @refreshable %> + + <% end %> +
+
+

+ + +
+
+
+ + +
+ +
+
+
diff --git a/app/views/landing/_sharing_text.html.erb b/app/views/landing/_sharing_text.html.erb new file mode 100644 index 00000000..ba6f925d --- /dev/null +++ b/app/views/landing/_sharing_text.html.erb @@ -0,0 +1,6 @@ +
+

Hi Everyone

+

The meeting will be at this URL

+

<%= @resource_url %>

+

Please join!

+
diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb deleted file mode 100644 index 1390a279..00000000 --- a/app/views/landing/index.html.erb +++ /dev/null @@ -1,68 +0,0 @@ - - -
- -
-
- - <% if @refreshable %> -

-
-
-
- <%= @meeting_url %> -
- -
-
-

- <% end %> - - -
-
-
- - -
- -
-
-
- -
-

Hi Everyone

-

The meeting will be at this URL

-

<%= @meeting_url %>

-

Please join!

-
- - - - -
- -
- - diff --git a/app/views/landing/meeting.html.erb b/app/views/landing/meeting.html.erb new file mode 100644 index 00000000..09d83a96 --- /dev/null +++ b/app/views/landing/meeting.html.erb @@ -0,0 +1,14 @@ + +
+ +
+ <%= render 'landing/join_form' %> + + <%= render 'landing/sharing_text' %> + + <%= render 'landing/footer_message' %> + + <%= render 'landing/footer_oauth_append' %> +
+ +
diff --git a/app/views/landing/room.html.erb b/app/views/landing/room.html.erb index fc853c47..e20a3125 100644 --- a/app/views/landing/room.html.erb +++ b/app/views/landing/room.html.erb @@ -1,19 +1,26 @@ -
-
-
- <% if admin? %> - <%= current_user.name %> - <%= link_to "Logout", "/logout" %> - <% else %> - <%= link_to "Login", "/auth/twitter" %> - <% end %> -
-
-
-
-