From b8c876443f936317ee67c7093f02472a0c43af54 Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Fri, 4 Nov 2016 18:28:52 -0400 Subject: [PATCH] add end button to views --- app/assets/javascripts/landing.js | 12 ++++++++++++ app/assets/javascripts/shared.js | 7 +++++++ app/controllers/landing_controller.rb | 5 +++++ app/lib/bbb_api.rb | 12 ++++++++++++ app/views/shared/_join_form.html.erb | 19 ++++++++++++++++--- config/locales/en-us.yml | 1 + 6 files changed, 53 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 32a2b18f..74c09a95 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -34,6 +34,18 @@ }); }); + $('.meeting-end').click (function (event) { + var jqxhr = Meeting.getInstance().endMeeting(); + var btn = $(this); + btn.prop("disabled", true); + jqxhr.done(function(data) { + + }); + jqxhr.fail(function(xhr, status, error) { + console.info("meeting end failed"); + }); + }); + $('.meeting-url-copy').click (function (e) { meetingURL = $('.meeting-url'); meetingURL.select(); diff --git a/app/assets/javascripts/shared.js b/app/assets/javascripts/shared.js index b7d369a4..82e585d8 100644 --- a/app/assets/javascripts/shared.js +++ b/app/assets/javascripts/shared.js @@ -36,6 +36,13 @@ class Meeting { }); }; + endMeeting() { + return $.ajax({ + url: this.url + "/end", + type: 'DELETE' + }); + } + setURL(url) { this.url = url; } diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 80601fa9..5bae7175 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,4 +1,5 @@ class LandingController < ApplicationController + include BbbApi def index if params[:resource] == 'meetings' @@ -29,11 +30,15 @@ class LandingController < ApplicationController def render_room params[:action] = 'rooms' + @user = User.find_by(username: params[:id]) if @user.nil? redirect_to root_path return end + + @meeting_running = bbb_get_meeting_info(@user.username)[:returncode] + render :action => 'rooms' end diff --git a/app/lib/bbb_api.rb b/app/lib/bbb_api.rb index ba20755e..890605de 100644 --- a/app/lib/bbb_api.rb +++ b/app/lib/bbb_api.rb @@ -71,6 +71,13 @@ module BbbApi end end + def bbb_get_meeting_info(id) + meeting_id = bbb_meeting_id(id) + response_data = bbb.get_meeting_info(meeting_id, nil) + rescue BigBlueButton::BigBlueButtonException => exc + response_data = bbb_exception_res exc + end + def bbb_get_recordings(meeting_id, record_id=nil) options={} if record_id @@ -208,5 +215,10 @@ module BbbApi res[:status] = :not_found end res + rescue + { + returncode: false, + status: :internal_server_error + } end end diff --git a/app/views/shared/_join_form.html.erb b/app/views/shared/_join_form.html.erb index 0fc1aa8f..45088889 100644 --- a/app/views/shared/_join_form.html.erb +++ b/app/views/shared/_join_form.html.erb @@ -6,9 +6,22 @@ <%= text_field :nil, :nil, class: 'form-control meeting-user-name', placeholder: t('enter_name') %> <% end %> <% if admin? %> - + <% if @meeting_running %> +
+ +
+
+ +
+ <% else %> + + <% end %> <% elsif current_user %>