From 30f60e4ec3e0a1a3dd95a81f5e08d0f3fb3cdf72 Mon Sep 17 00:00:00 2001 From: Raelon Masters Date: Tue, 4 Aug 2020 13:18:44 -0400 Subject: [PATCH] buttons for importBooks, and logout. --- src/interface/static/js/pyshelf_ux.js | 43 +++++++++++++++++++++++---- src/interface/views.py | 2 ++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/interface/static/js/pyshelf_ux.js b/src/interface/static/js/pyshelf_ux.js index 008cf3b..33e4116 100755 --- a/src/interface/static/js/pyshelf_ux.js +++ b/src/interface/static/js/pyshelf_ux.js @@ -88,11 +88,7 @@ $(document).ready(function(){ window.location.href="/flip_sort/"+$("#_order").val(); }); $('#search_string').html(" "+$('#_search').val().substr(0,15)+""); - $('#pop_over_0').dialog({ autoOpen: false }); - resize_search(); - $(window).resize(resize_search(win_width)); - $('#pop_over_0').on('click', 'div.collection', function(){ window.location.href = '/show_collection/'+$(this).attr('data'); }); @@ -102,7 +98,6 @@ $(document).ready(function(){ $('#pop_over_0').dialog("close"); return; } - customlog(['Login Clicked']); $.ajax({ type: "GET", url: "/live", data: {hook: 'register'}, success: function (response) { @@ -135,8 +130,42 @@ $(document).ready(function(){ }); }); $('#btn_logout').on('click', function() { - window.location.href = '/logout'; + //window.location.href = '/logout'; + var isopen = $('#pop_over_0').dialog("isOpen"); + if (isopen) { + $('#pop_over_0').dialog("close"); + return; + } + $('#pop_over_0').dialog({ + title: "User Controls", + maxHeight: (win_height - 100), + minWidth: $("#horiz_nav_main").width(), + hide: {effect: "blind", duration: 1000}, + show: {effect: "blind", duration: 1000}, + position: { + my: "top", at: "bottom", of: $("#horiz_nav_main") + } + }); + // clear and create a new container + $('#pop_over_0').html('
'); + // Populate the container from response.data + $('#usercp').append('
'); + $('#usercp-inner').append( + '
' + + '' + + '
' + + '
' + + '' + + '
' + ); + $('#usercp-inner').append('
'); + $('#usercp').append('
'); + // Close the container + $('#pop_over').append(''); + // Now open this dialog + $('#pop_over_0').dialog("open"); }); + $('.logout-btn').on('click', function(){window.location.href = '/logout'}); $('#coll_button').on('click', function(){ var isopen = $('#pop_over_0').dialog("isOpen"); if (isopen){ @@ -215,6 +244,8 @@ $(document).ready(function(){ } }); }); + resize_search(); + $(window).resize(resize_search(win_width)); }); function resize_search(win_width){ if (win_width <= 1025){ diff --git a/src/interface/views.py b/src/interface/views.py index 030c70d..4fa3183 100755 --- a/src/interface/views.py +++ b/src/interface/views.py @@ -402,6 +402,8 @@ def live(request, **kwargs): html = render_to_string('signup.html', {'form': SignUpForm}, request) html += render_to_string('login.html', {'form': UserLoginForm}, request) return JsonResponse({"data": html}) + elif hook == "update_books": + print("Update Books") else: return JsonResponse(err_txt, status=404) return JsonResponse({"data": "Response sent"}, status=200)