From ca6a24b13c0eced0732fa76549dce4bd457506b1 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Wed, 7 Oct 2015 21:57:01 -0400 Subject: Add signin button. --- photos.cabal | 1 + web/index.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/photos.cabal b/photos.cabal index e548c6f..2dd843e 100644 --- a/photos.cabal +++ b/photos.cabal @@ -31,3 +31,4 @@ executable photos , transformers , filepath , either + , http-conduit diff --git a/web/index.html b/web/index.html index b4dcd7b..f5ee27c 100644 --- a/web/index.html +++ b/web/index.html @@ -2,6 +2,9 @@ + + + @@ -21,10 +24,17 @@ var position = input[0].value.length; input[0].setSelectionRange(position, position); }, 0); + $(input).keypress(function(e) { + if (e.which == 13) { + $(input).replaceWith($('renaming...')); + renamePending(albumName, input[0].value); + } + }); $(this).replaceWith(input); }); $('#pending-container').append(element); } + function addPermanentAlbum(albumName) { function makeElement(name) { return $('
  • ' + name + '
  • '); @@ -57,26 +67,59 @@ } }); } - $(document).ready(function() { - fetchAlbums(); + function showError(error) { + $('#generic-error').html( + '

    ' + error + '

    '); + } + + function renamePending(oldName, newName) { var request = { - from: { name: 'x', pending: true }, - to: { name: 'y', pending: false } - }; - console.log('rename request: ', request); + from: { name: oldName, pending: true }, + to: { name: newName, pending: false } + }; $.ajax({ url: '/api/rename', type: 'POST', contentType: 'application/json', data: JSON.stringify(request), - success: function(data) { console.log('Rename succes: ', data); }, - error: function(unused, unusedStatus, error) { console.log('Rename failure: ' + error); } + success: function(data) { + if ('Left' in data) { + showError('Error renaming ' + oldName + ' to ' + newName + ': ' + + data.Left); + } + fetchAlbums(); + } }); + } + + function onSignIn(googleUser) { + // Useful data for your client-side scripts: + var profile = googleUser.getBasicProfile(); + console.log("ID: " + profile.getId()); // Don't send this directly to your server! + console.log("Name: " + profile.getName()); + console.log("Image URL: " + profile.getImageUrl()); + console.log("Email: " + profile.getEmail()); + + // The ID token you need to pass to your backend: + var id_token = googleUser.getAuthResponse().id_token; + console.log("ID Token: " + id_token); + $('.g-signin2').remove(); + }; + + $(document).ready(function() { + fetchAlbums(); + var request = { + from: { name: 'x', pending: true }, + to: { name: 'y', pending: false } + }; }); +
    + +

    Pending Photos

    -- cgit v1.2.3