made basic newest/oldest week/month/year part of gui actually retreive what we want, and have a title per grouping, but the grouping title is hard-coded for now, will need more data to do a better test, also hacky submit button for now until I decide how to enact the gui change requested
This commit is contained in:
43
files.py
43
files.py
@@ -70,7 +70,6 @@ class File(db.Model):
|
||||
__tablename__ = "file"
|
||||
eid = db.Column(db.Integer, db.ForeignKey("entry.id"), primary_key=True )
|
||||
size_mb = db.Column(db.Integer, unique=False, nullable=False)
|
||||
hash = db.Column(db.Integer, unique=True, nullable=True)
|
||||
thumbnail = db.Column(db.String, unique=False, nullable=True)
|
||||
hash = db.Column(db.Integer)
|
||||
year = db.Column(db.Integer)
|
||||
@@ -79,7 +78,7 @@ class File(db.Model):
|
||||
woy = db.Column(db.Integer)
|
||||
|
||||
def __repr__(self):
|
||||
return "<eid: {}, size_mb={}, hash={}>".format(self.eid, self.size_mb, self.hash )
|
||||
return f"<eid: {self.eid}, size_mb={self.size_mb}, hash={self.hash}, year={self.year}, month={self.month}, day={self.day}, woy={self.woy}>"
|
||||
|
||||
class FileType(db.Model):
|
||||
__tablename__ = "file_type"
|
||||
@@ -100,19 +99,41 @@ def file_list():
|
||||
################################################################################
|
||||
# /files -> show thumbnail view of files from import_path(s)
|
||||
################################################################################
|
||||
@app.route("/files", methods=["GET"])
|
||||
@app.route("/files", methods=["GET", "POST"])
|
||||
def files():
|
||||
order_by="asc"
|
||||
grouping="day"
|
||||
which="week"
|
||||
if which == "week":
|
||||
noo="Oldest"
|
||||
grouping="Day"
|
||||
which="Week"
|
||||
|
||||
if request.method=="POST":
|
||||
noo=request.form['noo']
|
||||
which=request.form['which']
|
||||
grouping=request.form['grouping']
|
||||
|
||||
print( f"noo={noo}, which={which}, grouping={grouping}")
|
||||
|
||||
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()
|
||||
if order_by == "desc":
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name.desc()).all()
|
||||
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()
|
||||
else:
|
||||
entries=Entry.query.join(File).filter(File.year==year.year).filter(File.woy==woy.woy).order_by(Entry.name.desc()).all()
|
||||
return render_template("files.html", page_title='View Files', entry_data=entries )
|
||||
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 )
|
||||
|
||||
################################################################################
|
||||
# /search -> show thumbnail view of files from import_path(s)
|
||||
|
||||
@@ -260,9 +260,9 @@ def ProcessImportDirs(parent_job=None):
|
||||
job2.extra.append(jex2)
|
||||
session.add(job2)
|
||||
session.commit()
|
||||
"""
|
||||
if parent_job:
|
||||
AddLogForJob(parent_job, "adding <a href='/job/{}'>job id={} {}</a> (wait for: {})".format( job2.id, job2.id, job2.name, job2.wait_for ) )
|
||||
"""
|
||||
jex3=JobExtra( name="path", value=path )
|
||||
job3=Job(start_time=now, last_update=now, name="processai", state="New", wait_for=job2.id, pa_job_state="New", current_file_num=0 )
|
||||
job3.extra.append(jex3)
|
||||
|
||||
@@ -2,16 +2,18 @@
|
||||
{% block main_content %}
|
||||
<div class="container-fluid">
|
||||
<br>
|
||||
<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>
|
||||
<select style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control form-conrol-info">
|
||||
<select name="noo" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control form-conrol-info">
|
||||
<option>Oldest</option>
|
||||
<option>Newest</option>
|
||||
</select>
|
||||
<select style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
<select name="which" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
<option>Week</option>
|
||||
<option>Month</option>
|
||||
<option>Year</option>
|
||||
@@ -19,7 +21,7 @@
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-info disabled" disabled="">of images, grouped by:</button>
|
||||
</div>
|
||||
<select style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
<select name="grouping" style="color:#5bc0de;border:1px solid #5bc0de;" class="form-control">
|
||||
<option>Day</option>
|
||||
<option>Week</option>
|
||||
<option>Month</option>
|
||||
@@ -46,9 +48,27 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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 %}
|
||||
<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 %}
|
||||
<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 %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if obj.type.name != "Directory" %}
|
||||
<center>
|
||||
<figure class="figure px-2" font-size: 24px;>
|
||||
|
||||
Reference in New Issue
Block a user