From 34695c716bda5a1ff77c608467eed6275d0ea261 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Tue, 4 Nov 2014 12:31:38 -0600 Subject: [PATCH 1/5] VRFS-1849 : Show google login link beside the "Upload to Youtube" link. --- web/app/assets/images/google_signin.png | Bin 0 -> 3093 bytes .../dialogs/recordingFinishedDialog.css.scss | 8 ++++++++ .../dialogs/_recordingFinishedDialog.html.haml | 7 +++++-- web/app/views/shared/_google_login.html.slim | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 web/app/assets/images/google_signin.png create mode 100644 web/app/views/shared/_google_login.html.slim diff --git a/web/app/assets/images/google_signin.png b/web/app/assets/images/google_signin.png new file mode 100644 index 0000000000000000000000000000000000000000..408190f1fcfa3655b55ac5bd62cf6121559b4765 GIT binary patch literal 3093 zcmZ8j2{cr18^3cK8mY`=7c~eIveZ9BWnz#pWZ#WsDO*{>KXSp3_K58P0AQctd4f3r zAn@?s2gMDq2jjgh0D$+4A>o{5=-?dL_r9Z*DD>0R1j+wERdqZz(s*xX{@UxG+o3o;qUM^TB7KGgs@^@|h|4&BPTdApnZOG!no=0DwZn zF@gXV4ikw2AOHcNu>k%7Z+97)d=?X~6A2=BB&uFAxV-A8k+;{mO}Ke>acvK*ykKT` z3j>Yk9fOiJuINy}znsScZhL4-AV328`lrc!)Z(RYv72ZtKJC<{#c>s6=x*{o06~Sc zn$aYFiGQ|5D#)xSZWt_HQ02fK;JYmnWhRKlBT*25!GcIUghC@gSdIe_Xe>y8;7}1# zcmS3$SOAvc$YGhI{&q(AN<-nrm90rW`R5Tdv9Jxwg%Bq*H{ILvIfe>NzSRXzPPIEk zj;b_{A!=c{@GxC|xbKOj+Oz1ZQXjU1O)0c}sT@C~Wn}-0@Z|R8AiL6&Mfz@@y^F6S zuC6^e!_K2+->;j#6Wf_bJ6;_Ud-c_}{2c~>Qu!M^{d-usB!8>!7eTf;RkCu+)4?yd zoZDs8qy6I0eTwS#4}JDOH*<;9&Ck5Krk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mJg3A literal 0 HcmV?d00001 diff --git a/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss b/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss index 3eb894abe..3d6208565 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 { + + } + + .signed_in_to_google { + color: yellow; + } } diff --git a/web/app/views/dialogs/_recordingFinishedDialog.html.haml b/web/app/views/dialogs/_recordingFinishedDialog.html.haml index ae4c58afa..07f493cb3 100644 --- a/web/app/views/dialogs/_recordingFinishedDialog.html.haml +++ b/web/app/views/dialogs/_recordingFinishedDialog.html.haml @@ -27,8 +27,11 @@ %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 + %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/shared/_google_login.html.slim b/web/app/views/shared/_google_login.html.slim new file mode 100644 index 000000000..676749773 --- /dev/null +++ b/web/app/views/shared/_google_login.html.slim @@ -0,0 +1,5 @@ +-google_auth = JamRuby::UserAuthorization.google_auth(current_user).first +-if google_auth + span.signed_in_to_google="(Signed in)" +-else + input.google_login_button 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" From cbb1a71ffad4a019e1aacb1a2cd0bcacea3214ed Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Tue, 4 Nov 2014 13:28:04 -0600 Subject: [PATCH 2/5] Check current_user for nil, as this dialog is included at a higher level than originally expected. --- web/app/views/shared/_google_login.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/views/shared/_google_login.html.slim b/web/app/views/shared/_google_login.html.slim index 676749773..d5c0592fd 100644 --- a/web/app/views/shared/_google_login.html.slim +++ b/web/app/views/shared/_google_login.html.slim @@ -1,4 +1,4 @@ --google_auth = JamRuby::UserAuthorization.google_auth(current_user).first +-google_auth = (current_user.nil?) ? nil : JamRuby::UserAuthorization.google_auth(current_user).first -if google_auth span.signed_in_to_google="(Signed in)" -else From 5ee531d9442c51b4cd76f800892b847fb32c5a5e Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Tue, 4 Nov 2014 14:59:53 -0600 Subject: [PATCH 3/5] More resilient reference to image. --- web/app/views/shared/_google_login.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/views/shared/_google_login.html.slim b/web/app/views/shared/_google_login.html.slim index d5c0592fd..3402eb8b3 100644 --- a/web/app/views/shared/_google_login.html.slim +++ b/web/app/views/shared/_google_login.html.slim @@ -2,4 +2,4 @@ -if google_auth span.signed_in_to_google="(Signed in)" -else - input.google_login_button 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" + input.google_login_button 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" From f1b32336cdd32671ac3bc8a7f8b13df65d7db4d1 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Tue, 4 Nov 2014 15:55:50 -0600 Subject: [PATCH 4/5] VRFS-1849 : Hide UI for youtube upload until the rest of feature implemented. --- .../_recordingFinishedDialog.html.haml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/web/app/views/dialogs/_recordingFinishedDialog.html.haml b/web/app/views/dialogs/_recordingFinishedDialog.html.haml index 07f493cb3..fc3d53eff 100644 --- a/web/app/views/dialogs/_recordingFinishedDialog.html.haml +++ b/web/app/views/dialogs/_recordingFinishedDialog.html.haml @@ -23,15 +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"} - %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") + / 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 From 7dc80c10ce6ed841067e1d55520696d19a0468c5 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Thu, 6 Nov 2014 13:16:58 -0600 Subject: [PATCH 5/5] VRFS-1849: Check for google authorization using AJAX and show/hide the google login button / "signed in" label as appropriate: --- .../dialogs/recordingFinishedDialog.css.scss | 2 +- web/app/controllers/sessions_controller.rb | 4 +++ web/app/views/layouts/client.html.erb | 1 + web/app/views/shared/_google_login.html.slim | 31 ++++++++++++++++--- web/config/routes.rb | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss b/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss index 3d6208565..b8f27aede 100644 --- a/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss +++ b/web/app/assets/stylesheets/dialogs/recordingFinishedDialog.css.scss @@ -42,7 +42,7 @@ } .google_login_button { - + vertical-align: middle; } .signed_in_to_google { 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/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 index 3402eb8b3..a190c6366 100644 --- a/web/app/views/shared/_google_login.html.slim +++ b/web/app/views/shared/_google_login.html.slim @@ -1,5 +1,26 @@ --google_auth = (current_user.nil?) ? nil : JamRuby::UserAuthorization.google_auth(current_user).first --if google_auth - span.signed_in_to_google="(Signed in)" --else - input.google_login_button 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" +-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'