diff --git a/web/app/assets/images/google_signin.png b/web/app/assets/images/google_signin.png new file mode 100644 index 000000000..408190f1f Binary files /dev/null and b/web/app/assets/images/google_signin.png differ diff --git a/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss b/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss index 3eb894abe..b8f27aede 100644 --- a/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss +++ b/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss @@ -40,5 +40,13 @@ } clear: left; } + + .google_login_button { + vertical-align: middle; + } + + .signed_in_to_google { + color: yellow; + } } diff --git a/web/app/controllers/sessions_controller.rb b/web/app/controllers/sessions_controller.rb index 7a2bb8ca7..6c772cd4a 100644 --- a/web/app/controllers/sessions_controller.rb +++ b/web/app/controllers/sessions_controller.rb @@ -150,6 +150,10 @@ class SessionsController < ApplicationController render 'oauth_complete', :layout => "landing" end + def has_google_auth + render :json => {has_google_auth: (!!current_user && !!UserAuthorization.google_auth(current_user).first)} + end + def redirect_after_signin(default) redirect_to(params['redirect-to'].blank? ? default : params['redirect-to']) end diff --git a/web/app/views/dialogs/_recordingFinishedDialog.html.haml b/web/app/views/dialogs/_recordingFinishedDialog.html.haml index ae4c58afa..fc3d53eff 100644 --- a/web/app/views/dialogs/_recordingFinishedDialog.html.haml +++ b/web/app/views/dialogs/_recordingFinishedDialog.html.haml @@ -23,12 +23,16 @@ .field.w100.left{:purpose => "description"} %label{:for => "description"} Description: %textarea#claim-recording-description.w100{:name => "description"} - .field.left{:purpose => "save_video"} - %input{:checked => "checked", :name => "save_video", :type => "checkbox"}/ - %label{:for => "save_video"} Save Video to Computer - .field.left{:purpose => "upload_to_youtube"} - %input{:checked => "checked", :name => "upload_to_youtube", :type => "checkbox"}/ - %label{:for => "upload_to_youtube"} Upload Video to YouTube + / TODO VRFS-1849: Uncomment this when rest of feature developed: + / .field.left{:purpose => "save_video"} + / %input{:checked => "checked", :name => "save_video", :type => "checkbox"}/ + / %label{:for => "save_video"} Save Video to Computer + / .field.left{:purpose => "upload_to_youtube"} + / %span + / %input{:checked => "checked", :name => "upload_to_youtube", :type => "checkbox"}/ + / %label{:for => "upload_to_youtube"} Upload Video to YouTube + / %span + / = render(:partial => "shared/google_login") .field.left{:purpose => "is_public"} %input{:checked => "checked", :name => "is_public", :type => "checkbox"}/ %label{:for => "is_public"} Public Recording diff --git a/web/app/views/layouts/client.html.erb b/web/app/views/layouts/client.html.erb index 2565a4ec7..2c4238803 100644 --- a/web/app/views/layouts/client.html.erb +++ b/web/app/views/layouts/client.html.erb @@ -30,6 +30,7 @@ <% else %> <%= render "layouts/social_meta" %> <% end %> + <%= yield(:extra_js) %> <%= yield %> diff --git a/web/app/views/shared/_google_login.html.slim b/web/app/views/shared/_google_login.html.slim new file mode 100644 index 000000000..a190c6366 --- /dev/null +++ b/web/app/views/shared/_google_login.html.slim @@ -0,0 +1,26 @@ +-content_for :extra_js do + javascript: + // Check for google authorization using AJAX and show/hide the + // google login button / "signed in" label as appropriate: + $(window).on('focus', function() { + $.ajax({ + type: "GET", + dataType: "json", + url: "/auth/has_google_auth" + }).success(function(data) { + if(data.has_google_auth) { + $("input.google_login_button").addClass("hidden") + $("span.signed_in_to_google").removeClass("hidden") + if (window._oauth_win) { + window._oauth_win.close() + } + } else { + $("span.signed_in_to_google").addClass("hidden") + $("input.google_login_button").removeClass("hidden") + } + }) + }); + +-google_auth = (current_user.nil?) ? nil : !!JamRuby::UserAuthorization.google_auth(current_user).first +span.signed_in_to_google class=((!google_auth) ? "hidden" : "") ="(Signed in)" +input.google_login_button class=((google_auth) ? "hidden" : "") type='image' onclick='window._oauth_win = window.open("/auth/google_login", "_blank", "height=500,width=500,menubar=no,resizable=no,status=no");' src="/assets/google_signin.png" height="30px" diff --git a/web/config/routes.rb b/web/config/routes.rb index e42189fc6..6c35fb87c 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -30,6 +30,7 @@ SampleApp::Application.routes.draw do # oauth match '/auth/:provider/callback', :to => 'sessions#oauth_callback' match '/auth/failure', :to => 'sessions#failure' + match '/auth/has_google_auth', :to => 'sessions#has_google_auth' # session info page match '/sessions/:id/details' => 'music_sessions#session_info', :via => :get, :as => 'music_scheduled_session_detail'