refactor share button & add ability to disable youtube uploading

This commit is contained in:
Josh 2017-07-28 14:58:51 -04:00
parent 10c2f1f6e5
commit 949fce701c
8 changed files with 56 additions and 40 deletions

View File

@ -166,14 +166,6 @@ class @Recordings
options.title = I18n.mail_recording options.title = I18n.mail_recording
$('#recordings').tooltip(options) $('#recordings').tooltip(options)
options.selector = '.disabled-tooltip'
options.title = I18n.youtube_disabled
$('#recordings').tooltip(options)
options.selector = '.invalid-tooltip'
options.title = I18n.invalid_provider
$('#recordings').tooltip(options)
$(document).one "turbolinks:before-cache", => $(document).one "turbolinks:before-cache", =>
@getTable().api().clear().draw().destroy() @getTable().api().clear().draw().destroy()
@ -375,14 +367,41 @@ class @Recordings
canUpload = res_data['uploadable'] canUpload = res_data['uploadable']
) )
if canUpload == 'true' youtube_button = $('.share-popover').find('.youtube-upload')
$(this).attr('data-popover-body', '.mail_youtube_popover')
else if canUpload == 'invalid_provider' attr = $(this).attr('data-popover-body');
$(this).attr('data-popover-body', '.no_youtube_popover')
else # Check if the cloud button has a popover body.
$(this).attr('data-popover-body', '.mail_popover') if (typeof attr == typeof undefined || attr == false)
switch canUpload
# We can upload the recording.
when 'true'
youtube_button.attr('title', I18n.upload_youtube)
youtube_button.removeClass('disabled-button')
youtube_button.addClass('has-popover')
youtube_button.show()
# Can't upload because uploading is disabled.
when 'uploading_disabled'
youtube_button.hide()
# Can't upload because account is not authenticated with Google.
when 'invalid_provider'
youtube_button.attr('title', I18n.invalid_provider)
youtube_button.addClass('disabled-button')
youtube_button.removeClass('has-popover')
youtube_button.show()
# Can't upload because recording does not contain video.
else
youtube_button.attr('title', I18n.no_video)
youtube_button.addClass('disabled-button')
youtube_button.removeClass('has-popover')
youtube_button.show()
$(this).attr('data-popover-body', '.share-popover')
$(this).popover('show')
else
$(this).popover('hide')
$(this).removeAttr('data-popover-body')
$(this).popover('show')
@getTable().on 'draw.dt', (event) -> @getTable().on 'draw.dt', (event) ->
$('time[data-time-ago]').timeago(); $('time[data-time-ago]').timeago();

View File

@ -95,6 +95,10 @@
text-align: center; text-align: center;
} }
.disabled-button {
opacity: 0.5;
}
.youtube-red { .youtube-red {
color: red; color: red;
} }

View File

@ -202,7 +202,9 @@ class BbbController < ApplicationController
# POST /rooms/:room_id/recordings/can_upload # POST /rooms/:room_id/recordings/can_upload
def can_upload def can_upload
# The recording is uploadable if it contains webcam data and they are logged in through Google. # The recording is uploadable if it contains webcam data and they are logged in through Google.
if current_user.provider != 'google' if Rails.configuration.enable_youtube_uploading == false then
uploadable = 'uploading_disabled'
elsif current_user.provider != 'google'
uploadable = 'invalid_provider' uploadable = 'invalid_provider'
else else
uploadable = (Faraday.head(get_webcams_url(params[:rec_id])).status == 200 && current_user.provider == 'google').to_s uploadable = (Faraday.head(get_webcams_url(params[:rec_id])).status == 200 && current_user.provider == 'google').to_s

View File

@ -79,36 +79,16 @@
<p id = 'youtube-footer'><%= t('youtube_footer') %></p> <p id = 'youtube-footer'><%= t('youtube_footer') %></p>
</form> </form>
</div> </div>
<div class='mail_youtube_popover'> <div class='share-popover'>
<button type="button" class="btn btn-default mail-recording mail-tooltip"> <button type="button" class="btn btn-default mail-recording mail-tooltip">
<%= icon('envelope-o') %> <%= icon('envelope-o') %>
</button> </button>
<button type="button" class="btn btn-default has-popover youtube-upload youtube-tooltip" <button type="button" class="btn btn-default has-popover youtube-upload youtube-tooltip"
data-placement="top" data-popover-body=".youtube-popover" data-placement="top" data-popover-body=".youtube-popover"
data-popover-title="<%= t('upload_to_youtube') %>" > data-popover-title="<%= t('upload_to_youtube') %>">
<div class = 'youtube-red'> <%= icon('youtube-play') %> </div> <div class = 'youtube-red'> <%= icon('youtube-play') %> </div>
</button> </button>
</div> </div>
<div class='mail_popover'>
<button type="button" class="btn btn-default mail-recording mail-tooltip fa-2x">
<%= icon('envelope-o') %>
</button>
<div class="tooltip-wrapper disabled disabled-tooltip">
<button type="button" class="btn btn-default" disabled>
<%= icon('youtube-play') %>
</button>
</div>
</div>
<div class='no_youtube_popover'>
<button type="button" class="btn btn-default mail-recording mail-tooltip fa-2x">
<%= icon('envelope-o') %>
</button>
<div class="tooltip-wrapper disabled invalid-tooltip">
<button type="button" class="btn btn-default" disabled>
<%= icon('youtube-play') %>
</button>
</div>
</div>
<div class="recording-visibility-popover"> <div class="recording-visibility-popover">
<button type="button" class="btn btn-default btn-success recording-update" data-visibility="published"> <button type="button" class="btn btn-default btn-success recording-update" data-visibility="published">
<%= t('client.published') %> <%= t('client.published') %>

View File

@ -43,6 +43,7 @@ module Greenlight
config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS'] == "true" config.use_webhooks = ENV['GREENLIGHT_USE_WEBHOOKS'] == "true"
config.mail_notifications = ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] == "true" config.mail_notifications = ENV['GREENLIGHT_MAIL_NOTIFICATIONS'] == "true"
config.disable_guest_access = ENV['DISABLE_GUEST_ACCESS'] == "true" config.disable_guest_access = ENV['DISABLE_GUEST_ACCESS'] == "true"
config.enable_youtube_uploading = ENV['ENABLE_YOUTUBE_UPLOADING'] == "true"
# SMTP and action mailer # SMTP and action mailer
if config.mail_notifications if config.mail_notifications

View File

@ -11,7 +11,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, provider :google_oauth2,
ENV['GOOGLE_OAUTH2_ID'], ENV['GOOGLE_OAUTH2_ID'],
ENV['GOOGLE_OAUTH2_SECRET'], ENV['GOOGLE_OAUTH2_SECRET'],
scope: ['profile', 'email', 'youtube', 'youtube.upload'], scope: ENV['ENABLE_YOUTUBE_UPLOADING'] == 'true' ? ['profile', 'email', 'youtube', 'youtube.upload'] : ['profile', 'email'] ,
access_type: 'online', access_type: 'online',
name: 'google', name: 'google',
hd: ENV['GOOGLE_OAUTH2_HD'].blank? ? nil : ENV['GOOGLE_OAUTH2_HD'] hd: ENV['GOOGLE_OAUTH2_HD'].blank? ? nil : ENV['GOOGLE_OAUTH2_HD']

View File

@ -57,6 +57,7 @@ en-US:
meeting_started: Meeting was started meeting_started: Meeting was started
no_recordings: No Recordings no_recordings: No Recordings
no_recordings_yet: No Recordings (Yet!) no_recordings_yet: No Recordings (Yet!)
no_video: Recording did not contain any video.
play_recording: Play recording play_recording: Play recording
publish_recording: Publish recording publish_recording: Publish recording
published: Everyone published: Everyone
@ -75,7 +76,6 @@ en-US:
upload_youtube: Youtube upload_youtube: Youtube
user_waiting_body: "%{user} is waiting to join %{meeting}!" user_waiting_body: "%{user} is waiting to join %{meeting}!"
user_waiting_title: A user is waiting user_waiting_title: A user is waiting
youtube_disabled: Recording did not contain any video.
copied: Copied copied: Copied
copy_error: Use Ctrl-c to copy copy_error: Use Ctrl-c to copy
create_your_session: Create your own meeting create_your_session: Create your own meeting

10
env
View File

@ -65,6 +65,16 @@ LDAP_PASSWORD=
# the application when recordings are done). # the application when recordings are done).
GREENLIGHT_USE_WEBHOOKS=false GREENLIGHT_USE_WEBHOOKS=false
# Enable uploading to Youtube (optional)
#
# When this is enabled, users will be able to directly upload their recordings
# to Youtube. If you plan to enable this, you should follow the steps outlined
# in our docs for setting up the Youtube data API.
#
# http://docs.bigbluebutton.org/install/green-light.html#8-enabling-uploading-to-youtube-optional
#
ENABLE_YOUTUBE_UPLOADING=false
# Slack Integration (optional) # Slack Integration (optional)
# #
# You will need to register an incoming-webhook for your slack channel # You will need to register an incoming-webhook for your slack channel