fixed BUGs 22 and 23 - both relate to the HTML forms being different for the search and viewing data, so changing one when the other was set, did not pass the values through, e.g. search term not there when you change a viewing option, or after searching, it did not know the grouping options. Fixed from the search side by showing a label of what you are searching for and storing it statically in the viewing form. Sorted by jscript onSubmit func to take 5 viewing options and store the last value in hidden inputs in the search form

This commit is contained in:
2021-02-21 15:40:47 +11:00
parent e13f44810d
commit 7fd6a2eddb
4 changed files with 70 additions and 25 deletions

6
BUGs
View File

@@ -1,6 +1,2 @@
### Next: 22 ### Next: 25
BUG-22: search for (say) 0000, and the thumbnail sizes are a mess?
- div class row is missing (grouping is not set -- might be BUG-23 kickin in),
the right-click context is also missing, the size of thumbs is wrong too?
BUg-23: search for anything, then change view on search (eg group by, or num per page) and 'term' is not known
BUg-24: duplicates of one type, but template shows both, so get odd choices between blank buttons (my test photo area, with no duplicates in 2 dirs only) BUg-24: duplicates of one type, but template shows both, so get odd choices between blank buttons (my test photo area, with no duplicates in 2 dirs only)

View File

@@ -88,19 +88,7 @@ class FileType(db.Model):
def __repr__(self): def __repr__(self):
return "<id: {}, name={}>".format(self.id, self.name ) return "<id: {}, name={}>".format(self.id, self.name )
def ViewingOptions( request ):
################################################################################
# /file_list -> show detailed file list of files from import_path(s)
################################################################################
@app.route("/file_list", methods=["GET"])
def file_list():
return render_template("file_list.html", page_title='View Files (details)', entry_data=Entry.query.order_by(Entry.name).all())
################################################################################
# /files -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/files", methods=["GET", "POST"])
def files():
noo="Oldest" noo="Oldest"
grouping="Day" grouping="Day"
how_many="50" how_many="50"
@@ -120,6 +108,22 @@ def files():
if 'next' in request.form: if 'next' in request.form:
offset += int(how_many) offset += int(how_many)
return noo, grouping, how_many, offset, size
################################################################################
# /file_list -> show detailed file list of files from import_path(s)
################################################################################
@app.route("/file_list", methods=["GET"])
def file_list():
return render_template("file_list.html", page_title='View Files (details)', entry_data=Entry.query.order_by(Entry.name).all())
################################################################################
# /files -> show thumbnail view of files from import_path(s)
################################################################################
@app.route("/files", methods=["GET", "POST"])
def files():
noo, grouping, how_many, offset, size = ViewingOptions( request )
entries=[] entries=[]
if noo == "Oldest": if noo == "Oldest":
entries=Entry.query.join(File).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all() entries=Entry.query.join(File).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
@@ -127,17 +131,21 @@ def files():
entries=Entry.query.join(File).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all() entries=Entry.query.join(File).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
return render_template("files.html", page_title='View Files', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size ) return render_template("files.html", page_title='View Files', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size )
################################################################################ ################################################################################
# /search -> show thumbnail view of files from import_path(s) # /search -> show thumbnail view of files from import_path(s)
################################################################################ ################################################################################
@app.route("/search", methods=["GET","POST"]) @app.route("/search", methods=["GET","POST"])
def search(): def search():
file_data=Entry.query.filter(Entry.name.ilike(f"%{request.form['term']}%")).all() noo, grouping, how_many, offset, size = ViewingOptions( request )
ai_data=Entry.query.join(File).join(FileRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(FileRefimgLink.matched==True).filter(Person.tag.ilike(f"%{request.form['term']}%")).all()
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
ai_data=Entry.query.join(File).join(FileRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(FileRefimgLink.matched==True).filter(Person.tag.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
all_entries = file_data + ai_data all_entries = file_data + ai_data
return render_template("files.html", page_title='View Files', entry_data=all_entries)
return render_template("files.html", page_title='View Files', search_term=request.form['term'], entry_data=all_entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size )
################################################################################ ################################################################################
# /files/scannow -> allows us to force a check for new files # /files/scannow -> allows us to force a check for new files

View File

@@ -94,8 +94,13 @@
</div class="nav-item"> </div class="nav-item">
</div class="navbar-nav"> </div class="navbar-nav">
<form class="form-inline my-2 my-lg-0" method="POST" action="/search"> <form class="form-inline my-2 my-lg-0" method="POST" onSubmit="SetViewingOptionsForSearchForm()" action="/search">
<input class="form-control mr-sm-2" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="term"> <input type="hidden" id="search_noo" name="noo" value="">
<input type="hidden" id="search_grouping" name="grouping" value="">
<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 id="term" class="form-control mr-sm-2" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="term">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form> </form>
</div class="collapse navbar-collapse"> </div class="collapse navbar-collapse">
@@ -133,6 +138,35 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script> <script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
<script>
function SetViewingOptionsForSearchForm()
{
if( $('#noo').length )
$('#search_noo').val( $('#noo').val() )
else
$('#search_noo').val("Oldest")
if( $('#grouping').length )
$('#search_grouping').val( $('#grouping').val() )
else
$('#search_grouping').val("Day")
if( $('#how_many').length )
$('#search_how_many').val( $('#how_many').val() )
else
$('#search_how_many').val("10")
if( $('#offset').length )
$('#search_offset').val( $('#offset').val() )
else
$('#search_offset').val(0)
if( $('#size').length )
$('#search_size').val( $('#size').val() )
else
$('#search_size').val(128)
}
</script>
{%block script_content %}{% endblock script_content %} {%block script_content %}{% endblock script_content %}
</body> </body>
</html> </html>

View File

@@ -9,7 +9,10 @@
</div> </div>
<div class="container-fluid"> <div class="container-fluid">
<form method="POST"> <form method="POST"">
{% if search_term is defined %}
<input type="hidden" name="term" id="view_term" value="{{search_term}}">
{% endif %}
<div class="row"> <div class="row">
<div class="input-group col-lg-4"> <div class="input-group col-lg-4">
{{CreateSelect( "noo", noo, ["Oldest", "Newest"], "$('#offset').val(0)")|safe }} {{CreateSelect( "noo", noo, ["Oldest", "Newest"], "$('#offset').val(0)")|safe }}
@@ -17,8 +20,12 @@
<span style="border:0" class="sm-txt my-auto h-100 btn btn-outline-info disabled">grouped by:</span> <span style="border:0" class="sm-txt my-auto h-100 btn btn-outline-info disabled">grouped by:</span>
{{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"])|safe }} {{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"])|safe }}
</div class="input-group"> </div class="input-group">
{% if search_term is defined %}
<div class="col my-auto">
<span class="alert alert-primary">Searched for: '{{search_term}}'</span>
</div class="col my-auto">
{% endif %}
<div class="col my-auto d-flex justify-content-end"> <div class="col my-auto d-flex justify-content-end">
{% set fd=entry_data[0].file_details[0] %}
<button id="prev" name="prev" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-left"></i></button> <button id="prev" name="prev" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-left"></i></button>
<span class="sm-txt h-100 my-auto">&nbsp;{{how_many}} files&nbsp;</span> <span class="sm-txt h-100 my-auto">&nbsp;{{how_many}} files&nbsp;</span>
<button id="next" name="next" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-right"></i></button> <button id="next" name="next" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-right"></i></button>