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
$('#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", =>
@getTable().api().clear().draw().destroy()
@ -374,15 +366,42 @@ class @Recordings
}).success((res_data) ->
canUpload = res_data['uploadable']
)
youtube_button = $('.share-popover').find('.youtube-upload')
attr = $(this).attr('data-popover-body');
# Check if the cloud button has a popover body.
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()
if canUpload == 'true'
$(this).attr('data-popover-body', '.mail_youtube_popover')
else if canUpload == 'invalid_provider'
$(this).attr('data-popover-body', '.no_youtube_popover')
$(this).attr('data-popover-body', '.share-popover')
$(this).popover('show')
else
$(this).attr('data-popover-body', '.mail_popover')
$(this).popover('show')
$(this).popover('hide')
$(this).removeAttr('data-popover-body')
@getTable().on 'draw.dt', (event) ->
$('time[data-time-ago]').timeago();

View File

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

View File

@ -202,7 +202,9 @@ class BbbController < ApplicationController
# POST /rooms/:room_id/recordings/can_upload
def can_upload
# 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'
else
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>
</form>
</div>
<div class='mail_youtube_popover'>
<div class='share-popover'>
<button type="button" class="btn btn-default mail-recording mail-tooltip">
<%= icon('envelope-o') %>
</button>
<button type="button" class="btn btn-default has-popover youtube-upload youtube-tooltip"
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>
</button>
</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">
<button type="button" class="btn btn-default btn-success recording-update" data-visibility="published">
<%= t('client.published') %>