changing options on files_*, search, also next/prev all now use POST->redirect model, so should allow back/forward browser buttons to work - commit so we can test in PROD

This commit is contained in:
2022-01-22 21:36:58 +11:00
parent 491663f1c9
commit 0f4632e240
14 changed files with 264 additions and 77 deletions

View File

@@ -109,8 +109,6 @@
<input type="hidden" id="search_how_many" name="how_many" value="">
<input type="hidden" id="search_offset" name="offset" value="">
<input type="hidden" id="search_size" name="size" value="">
<input type="hidden" id="search_folders" name="folders" value="">
<input type="hidden" id="search_cwd" name="cwd" value="">
<input id="search_term" class="form-control" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="search_term">
<button class="btn btn-outline-success" onClick="javascript:st=$('#search_term').val(); document.location.href='/search/'+st" type="button">Search</button>
</form>
@@ -119,7 +117,7 @@
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#user"/></svg>
</a>
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
<div><a class="dropdown-item" href="{{url_for('states')}}">{{current_user|Username}}</a></div>
<div><a class="dropdown-item" href="{{url_for('states')}}">{{current_user.dn|Username}}</a></div>
<div><a class="dropdown-item" href="{{url_for('logout')}}">Logout</a></div>
</div>
</div>

View File

@@ -18,17 +18,17 @@
fig_{{f.id}}=$('#fig_{{f.id}}')
// store this stuff in an javascript Object to use when document is ready event is triggered
var orig_face_{{f.id}}=new Object;
orig_face_{{f.id}}.x = (({{f.locn[0][1]}}*1.05 - {{f.locn[0][3]}}*.95) - {{f.w}}) / 2
orig_face_{{f.id}}.y = (({{f.locn[0][2]}}*1.05 - {{f.locn[0][0]}}*.95) - {{f.h}}) / 2
orig_face_{{f.id}}.x = (({{f.locn[1]}}*1.05 - {{f.locn[3]}}*.95) - {{f.w}}) / 2
orig_face_{{f.id}}.y = (({{f.locn[2]}}*1.05 - {{f.locn[0]}}*.95) - {{f.h}}) / 2
orig_face_{{f.id}}.w = {{f.w}}
orig_face_{{f.id}}.h = {{f.h}}
orig_face_{{f.id}}.orig_w = {{f.locn[0][1]}}*1.05 - {{f.locn[0][3]}}*.95
orig_face_{{f.id}}.orig_h = {{f.locn[0][2]}}*1.05 - {{f.locn[0][0]}}*.95
orig_face_{{f.id}}.orig_w = {{f.locn[1]}}*1.05 - {{f.locn[3]}}*.95
orig_face_{{f.id}}.orig_h = {{f.locn[2]}}*1.05 - {{f.locn[0]}}*.95
console.log( orig_face_{{f.id}} )
// when the document is ready, then DrawRefimg
$(function() { DrawRefimg( fig_{{f.id}}, im_{{f.id}}, c_{{f.id}}, orig_face_{{f.id}} ) });
$(function() { DrawUnmatchedFace( fig_{{f.id}}, im_{{f.id}}, c_{{f.id}}, orig_face_{{f.id}} ) });
</script>
<figcaption>Face #{{f.id}}</figcation>
</div>

View File

@@ -16,7 +16,7 @@
</script>
<div class="container-fluid">
<form id="main_form" method="POST">
<form id="main_form" method="POST" action="/ChangeFileOpts">
<input type="hidden" name="cwd" id="cwd" value="{{OPT.cwd}}">
{% if search_term is defined %}
<input type="hidden" name="search_term" id="view_term" value="{{search_term}}">
@@ -83,36 +83,36 @@
</div>
<div class="d-flex col col-auto justify-content-end">
<div class="btn-group">
{% if OPT.size == "64" %}
{% if OPT.size == 64 %}
{% set bt="btn-info text-white" %}
{% else %}
{% set bt="btn-outline-info" %}
{% endif %}
<button aria-label="extra small" id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,64); return false;">XS</button>
{% if OPT.size == "96" %}
<button aria-label="extra small" id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="$('#size').val(64)">XS</button>
{% if OPT.size == 96 %}
{% set bt="btn-info text-white" %}
{% else %}
{% set bt="btn-outline-info" %}
{% endif %}
<button aria-label="small" id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,96); return false;">S</button>
{% if OPT.size == "128" %}
<button aria-label="small" id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="$('#size').val(96)">S</button>
{% if OPT.size == 128 %}
{% set bt="btn-info text-white" %}
{% else %}
{% set bt="btn-outline-info" %}
{% endif %}
<button aria-label="medium" id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,128); return false;">M</button>
{% if OPT.size == "192" %}
<button aria-label="medium" id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="$('#size').val(128)">M</button>
{% if OPT.size == 192 %}
{% set bt="btn-info text-white" %}
{% else %}
{% set bt="btn-outline-info" %}
{% endif %}
<button aria-label="large" id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,192); return false;">L</button>
{% if OPT.size == "256" %}
<button aria-label="large" id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="$('#size').val(192)">L</button>
{% if OPT.size == 256 %}
{% set bt="btn-info text-white" %}
{% else %}
{% set bt="btn-outline-info" %}
{% endif %}
<button aria-label="extra large" id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,256); return false;">XL</button>
<button aria-label="extra large" id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="$('#size').val(256)">XL</button>
</div class="btn-group">
</div class="col">
<input id="offset" type="hidden" name="offset" value="{{OPT.offset}}">
@@ -250,7 +250,7 @@
</div>
<div class="container-fluid">
<form id="nav_form" method="POST"">
<form id="nav_form" method="POST" action="/ChangeFileOpts">
<input type="hidden" name="cwd" id="cwd" value="{{OPT.cwd}}">
<div class="row">
<div class="col my-auto d-flex justify-content-center">
@@ -282,15 +282,12 @@ function CallViewRoute(id)
{
s='<form id="_fm" method="POST" action="/view/' + id + '">'
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
s+='<input type="hidden" name="noo" value="{{OPT.noo}}">'
s+='<input type="hidden" name="cwd" value="{{OPT.cwd}}">'
s+='<input type="hidden" name="root" value="{{OPT.root}}">'
s+='<input type="hidden" name="size" value="{{OPT.size}}">'
s+='<input type="hidden" name="grouping" value="{{OPT.grouping}}">'
s+='<input type="hidden" name="offset" value="{{OPT.offset}}">'
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
s+='<input type="hidden" name="view_eid" value="'+id+'">'
{% if search_term is defined %}
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
{% endif %}

View File

@@ -1,12 +1,54 @@
{% extends "base.html" %}
{% block main_content %}
<h3>PA User state page</h3>
<div class="container-fluid">
<div class="row">
<alert class="alert alert-warning">The following values are based on navigating the application and are not set by hand. This page is for checking/debugging only.</alert>
<h3>Defaults for {{user.dn|Username}}</h3>
<div class="col-6">
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">When viewing show in fullscreen:</label>
{{CreateSelect( "size", user.default_size, ["XS", "S", "M", "L", "XL"], "ChangeDefault();return false", "col-2 rounded-end", { 0:64, 1:96, 2:128, 3:192, 4:256 } )|safe }}
</div>
</div class="row">
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">Ordered by:</label>
{{CreateSelect( "noo", user.default_noo, ["Oldest", "Newest","A to Z", "Z to A"], "ChangeDefault();return false", "col-2 rounded-end")|safe }}
</div class="input-group">
</div>
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">How many thumbnails to show at once:</label>
{{CreateSelect( "how_many", user.default_how_many, [10, 25, 50, 75, 100, 150, 200, 500], "ChangeDefault();return false", "col-2 rounded-end")|safe }}
</div class="input-group">
</div>
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">Group by:</label>
{{CreateSelect( "grouping", user.default_grouping, ["None", "Day", "Week", "Month"], "ChangeDefault();return false", "col-2 rounded-end")|safe }}
</div class="input-group">
</div>
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">Folders or Flat view of thumbnails:</label>
{{CreateSelect( "folders", user.default_folders, ["In Folder", "Flat View"], "ChangeDefault();return false", "col-2 rounded-end", { 0:true, 1:false } )|safe }}
</div>
</div>
<div class="row">
<div class="input-group">
<label class="py-1 input-group-text col-6 justify-content-end">When viewing show in fullscreen:</label>
{{CreateSelect( "fullscreen", user.default_fullscreen, [True,False], "ChangeDefault();return false", "col-2 rounded-end")|safe }}
</div>
</div>
</div class="col-6">
<div class="row pt-5">
<alert class="alert alert-warning">The following values are based on the defaults above and subsequent changes as you navigate the application and are not set by hand. The following content is for checking/debugging only.</alert>
</div class="row">
<div class="row">
<table id="pa_user_state_tbl" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead>
@@ -43,3 +85,19 @@
</div class="row">
</div class="container-fluid">
{% endblock main_content %}
{% block script_content %}
<script>
function ChangeDefault()
{
data="dn={{user.dn}}"
data+="&default_size="+$('#size').val()
data+="&default_noo="+$('#noo').val()
data+="&default_how_many="+$('#how_many').val()
data+="&default_grouping="+$('#grouping').val()
data+="&default_folders="+$('#folders').val()
data+="&default_fullscreen="+$('#fullscreen').val()
console.log("Changing Default:"+data )
$.ajax({ type: 'POST', data: data, url: '/changedefaults', success: function(data){ window.location='/states'; return false; } })
}
</script>
{% endblock script_content %}

View File

@@ -86,6 +86,7 @@
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
s+='<input type="hidden" name="orig_url" value="{{OPT.orig_url}}">'
s+='<input type="hidden" name="view_eid" value="{{OPT.view_eid}}">'
s+='<input type="hidden" name="fullscreen" value="' + fullscreen + '">'
s+='<input type="hidden" name="' + dir + '" value="1">'
{% if search_term is defined %}