changed to fixed number of images per load, rather than complicating with week/month/year retrieval
This commit is contained in:
38
files.py
38
files.py
@@ -103,38 +103,28 @@ def file_list():
|
||||
def files():
|
||||
noo="Oldest"
|
||||
grouping="Day"
|
||||
which="Week"
|
||||
how_many="50"
|
||||
|
||||
offset=0
|
||||
|
||||
if request.method=="POST":
|
||||
noo=request.form['noo']
|
||||
which=request.form['which']
|
||||
how_many=request.form['how_many']
|
||||
offset=int(request.form['offset'])
|
||||
grouping=request.form['grouping']
|
||||
|
||||
print( f"noo={noo}, which={which}, grouping={grouping}")
|
||||
if 'prev' in request.form:
|
||||
offset -= int(how_many)
|
||||
if offset < 0:
|
||||
offset=0
|
||||
if 'next' in request.form:
|
||||
offset += int(how_many)
|
||||
|
||||
entries=[]
|
||||
if noo == "Oldest":
|
||||
year=File.query.order_by(File.year).first()
|
||||
month=File.query.filter(File.year==year.year).order_by(File.month).first()
|
||||
woy=File.query.filter(File.year==year.year).order_by(File.woy).first()
|
||||
print( f"y={year}, m={month}, woy={woy}")
|
||||
if which == "Week":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name).all()
|
||||
elif which == "Month":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.month==month.month).order_by(Entry.name).all()
|
||||
elif which == "Year":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).order_by(Entry.name).all()
|
||||
entries=Entry.query.join(File).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
year=File.query.order_by(File.year.desc()).first()
|
||||
month=File.query.filter(File.year==year.year).order_by(File.month.desc()).first()
|
||||
woy=File.query.filter(File.year==year.year).order_by(File.woy.desc()).first()
|
||||
if which == "Week":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name).all()
|
||||
elif which == "Month":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.month==month.month).order_by(Entry.name).all()
|
||||
elif which == "Year":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).order_by(Entry.name).all()
|
||||
return render_template("files.html", page_title='View Files', entry_data=entries, grouping=grouping, which=which, form=request.form )
|
||||
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, grouping=grouping, how_many=how_many, offset=offset, form=request.form )
|
||||
|
||||
################################################################################
|
||||
# /search -> show thumbnail view of files from import_path(s)
|
||||
|
||||
@@ -1,135 +1,167 @@
|
||||
{% extends "base.html" %}
|
||||
{% block main_content %}
|
||||
<div class="container-fluid">
|
||||
<br>
|
||||
<div class="container-fluid">
|
||||
<form method="POST">
|
||||
<div class="form-row">
|
||||
<div class="input-group col px-0">
|
||||
<input type="submit">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-outline-info disabled" disabled="">Viewing:</button>
|
||||
<div class="row">
|
||||
<div class="input-group col-lg-5">
|
||||
<div class="input-group-prepend">
|
||||
<input id="viewing" type=submit class="btn btn-outline-info disabled" disabled value="Viewing:"></input>
|
||||
</div>
|
||||
<select name="noo" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control form-conrol-info" onChange="ChangeView()">
|
||||
{% if form['noo']=="Oldest" %}
|
||||
<option selected>Oldest</option>
|
||||
{% else %}
|
||||
<option>Oldest</option>
|
||||
{% endif %}
|
||||
{% if form['noo']=="Newest" %}
|
||||
<option selected>Newest</option>
|
||||
{% else %}
|
||||
<option>Newest</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
<select name="how_many" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control" onChange="ChangeView()">
|
||||
{% if form['how_many']=="50" %}
|
||||
<option selected>50</option>
|
||||
{% else %}
|
||||
<option>50</option>
|
||||
{% endif %}
|
||||
{% if form['how_many']=="100" %}
|
||||
<option selected>100</option>
|
||||
{% else %}
|
||||
<option>100</option>
|
||||
{% endif %}
|
||||
{% if form['how_many']=="200" %}
|
||||
<option selected>200</option>
|
||||
{% else %}
|
||||
<option>200</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-info disabled" disabled="">grouped by:</button>
|
||||
</div>
|
||||
<select name="grouping" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control" onChange="ChangeView()">
|
||||
{% if form['grouping']=="None" %}
|
||||
<option selected>None</option>
|
||||
{% else %}
|
||||
<option>None</option>
|
||||
{% endif %}
|
||||
{% if form['grouping']=="Day" %}
|
||||
<option selected>Day</option>
|
||||
{% else %}
|
||||
<option>Day</option>
|
||||
{% endif %}
|
||||
{% if form['grouping']=="Week" %}
|
||||
<option selected>Week</option>
|
||||
{% else %}
|
||||
<option>Week</option>
|
||||
{% endif %}
|
||||
{% if form['grouping']=="Month" %}
|
||||
<option selected>Month</option>
|
||||
{% else %}
|
||||
<option>Month</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div class="input-group">
|
||||
<div class="col h-100 my-auto">
|
||||
{% set fd=entry_data[0].file_details[0] %}
|
||||
<button id="prev" name="prev" class="btn btn-info"><i class="fas fa-arrow-alt-circle-left"></i></button>
|
||||
<span>{{form['how_many']}} files</span>
|
||||
<button id="next" name="next" class="btn btn-info"><i class="fas fa-arrow-alt-circle-right"></i></i></button>
|
||||
</div>
|
||||
<select name="noo" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control form-conrol-info">
|
||||
{% if form['noo']=="Oldest" %}
|
||||
<option selected>Oldest</option>
|
||||
{% else %}
|
||||
<option>Oldest</option>
|
||||
{% endif %}
|
||||
{% if form['noo']=="Newest" %}
|
||||
<option selected>Newest</option>
|
||||
{% else %}
|
||||
<option>Newest</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
<select name="which" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
{% if form['which']=="Week" %}
|
||||
<option selected>Week</option>
|
||||
{% else %}
|
||||
<option>Week</option>
|
||||
{% endif %}
|
||||
{% if form['which']=="Month" %}
|
||||
<option selected>Month</option>
|
||||
{% else %}
|
||||
<option>Month</option>
|
||||
{% endif %}
|
||||
{% if form['which']=="Year" %}
|
||||
<option selected>Year</option>
|
||||
{% else %}
|
||||
<option>Year</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-info disabled" disabled="">of images, grouped by:</button>
|
||||
</div>
|
||||
<select name="grouping" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
{% if form['grouping']=="Day" %}
|
||||
<option selected>Day</option>
|
||||
{% else %}
|
||||
<option>Day</option>
|
||||
{% endif %}
|
||||
{% if form['grouping']=="Week" %}
|
||||
<option selected>Week</option>
|
||||
{% else %}
|
||||
<option>Week</option>
|
||||
{% endif %}
|
||||
{% if form['grouping']=="Month" %}
|
||||
<option selected>Month</option>
|
||||
{% else %}
|
||||
<option>Month</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group offset-lg-2 col">
|
||||
<div class="input-group-prepend">
|
||||
<button style="width:98%" class="btn btn-outline-info disabled" disabled>Size:</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,64); return false;">XS</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,96); return false;">S</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-info" onClick="ChangeSize(this,128); return false;">M</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,192); return false;">L</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,256); return false;">XL</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group offset-lg-1 col">
|
||||
<div class="input-group-prepend">
|
||||
<button style="width:98%" class="btn btn-outline-info disabled" disabled>Size:</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,64); return false;">XS</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,96); return false;">S</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-info" onClick="ChangeSize(this,128); return false;">M</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,192); return false;">L</button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="sz-but btn btn-outline-info" onClick="ChangeSize(this,256); return false;">XL</button>
|
||||
</div>
|
||||
</div class="input-group">
|
||||
</div class="form-row">
|
||||
<input type="hidden" name="offset" value="{{offset}}">
|
||||
</form>
|
||||
<br>
|
||||
<div class="row">
|
||||
{% set last = namespace(printed=0) %}
|
||||
{% for obj in entry_data %}
|
||||
{% if which == "Week" %}
|
||||
{% if last.printed != obj.file_details[0].day %}
|
||||
</div><h6>Day: {{obj.file_details[0].day}} of {{obj.file_details[0].month}}/{{obj.file_details[0].year}}</h6></div><div class="row">
|
||||
{% set last.printed = obj.file_details[0].day %}
|
||||
{% endif %}
|
||||
{% elif which == "Month" %}
|
||||
{% if last.printed != obj.file_details[0].woy %}
|
||||
</div><h6>Week #: {{obj.file_details[0].woy}} of {{obj.file_details[0].year}}</h6></div><div class="row">
|
||||
{% set last.printed = obj.file_details[0].woy %}
|
||||
{% endif %}
|
||||
{% elif which == "Year" %}
|
||||
{% if last.printed != obj.file_details[0].month %}
|
||||
</div><h6>Month: {{obj.file_details[0].month}} of {{obj.file_details[0].year}}</h6></div><div class="row">
|
||||
{% set last.printed = obj.file_details[0].month %}
|
||||
|
||||
{% set last = namespace(printed=0) %}
|
||||
{% if grouping == "None" %}
|
||||
<div class="row pl-3">
|
||||
{% endif %}
|
||||
{% for obj in entry_data %}
|
||||
{% if grouping == "Day" %}
|
||||
{% if last.printed != obj.file_details[0].day %}
|
||||
{% if last.printed > 0 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row pl-3"><h6>Day: {{obj.file_details[0].day}} of {{obj.file_details[0].month}}/{{obj.file_details[0].year}}</h6></div>
|
||||
<div class="row pl-3">
|
||||
{% set last.printed = obj.file_details[0].day %}
|
||||
{% endif %}
|
||||
{% if obj.type.name != "Directory" %}
|
||||
<center>
|
||||
<figure class="figure px-2" font-size: 24px;>
|
||||
{% if obj.type.name=="Image" %}
|
||||
<a href="{{obj.in_dir[0].path_prefix}}/{{obj.name}}"><img class="thumb" height="128" src="data:image/jpeg;base64,{{obj.file_details[0].thumbnail}}"></img></a>
|
||||
{% elif obj.type.name == "Video" %}
|
||||
<div style="position:relative; width:100%">
|
||||
<a href="{{obj.in_dir[0].path_prefix}}/{{obj.name}}"><img class="thumb" style="display:block" height="128" src="data:image/jpeg;base64,{{obj.file_details[0].thumbnail}}"></img></a>
|
||||
<div style="position:absolute; top: 2; left: 2;">
|
||||
<i style="font-size:32;background-color:black;color:white" class="fas fa-film"></i>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<figcaption class="figure-caption text-center">{{obj.name}}</figcaption>
|
||||
</figure>
|
||||
</center>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div class="row">
|
||||
{% elif grouping == "Week" %}
|
||||
{% if last.printed != obj.file_details[0].woy %}
|
||||
{% if last.printed > 0 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row pl-3"><h6>Week #: {{obj.file_details[0].woy}} of {{obj.file_details[0].year}}</h6></div>
|
||||
<div class="row pl-3">
|
||||
{% set last.printed = obj.file_details[0].woy %}
|
||||
{% endif %}
|
||||
{% elif grouping == "Month" %}
|
||||
{% if last.printed != obj.file_details[0].month %}
|
||||
{% if last.printed > 0 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row pl-3"><h6>Month: {{obj.file_details[0].month}} of {{obj.file_details[0].year}}</h6></div>
|
||||
<div class="row pl-3">
|
||||
{% set last.printed = obj.file_details[0].month %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if obj.type.name != "Directory" %}
|
||||
<center>
|
||||
<figure class="figure px-1">
|
||||
{% if obj.type.name=="Image" %}
|
||||
<a href="{{obj.in_dir[0].path_prefix}}/{{obj.name}}"><img class="thumb" height="128" src="data:image/jpeg;base64,{{obj.file_details[0].thumbnail}}"></img></a>
|
||||
{% elif obj.type.name == "Video" %}
|
||||
<div style="position:relative; width:100%">
|
||||
<a href="{{obj.in_dir[0].path_prefix}}/{{obj.name}}"><img class="thumb" style="display:block" height="128" src="data:image/jpeg;base64,{{obj.file_details[0].thumbnail}}"></img></a>
|
||||
<div style="position:absolute; top: 2; left: 2;">
|
||||
<i style="font-size:32;background-color:black;color:white" class="fas fa-film"></i>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{# finding text distracting, <figcaption style="font-size:12px;" class="figure-caption text-center">{{obj.name}}</figcaption> #}
|
||||
</figure>
|
||||
</center>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if grouping == "None" %}
|
||||
</div class="row pl-3">
|
||||
{% endif %}
|
||||
</div class="container">
|
||||
{% endblock main_content %}
|
||||
{% block script_content %}
|
||||
<script>
|
||||
function ChangeSize(clicked_button,sz)
|
||||
{
|
||||
console.log(clicked_button)
|
||||
old_but=$('.sz-but.btn-info').removeClass('btn-info').addClass('btn-outline-info')
|
||||
$(clicked_button).addClass('btn-info').removeClass('btn-outline-info')
|
||||
$('.thumb').attr( {height: sz, style: 'font-size:'+sz } )
|
||||
}
|
||||
|
||||
function ChangeView()
|
||||
{
|
||||
$('#viewing').removeClass("disabled").removeClass("btn-outline-info").addClass("btn-info")
|
||||
$('#viewing').attr("disabled",false)
|
||||
$('#viewing').val("Change to:")
|
||||
}
|
||||
</script>
|
||||
{% endblock script_content %}
|
||||
|
||||
Reference in New Issue
Block a user