diff --git a/files.py b/files.py index 8db2878..7aa7484 100644 --- a/files.py +++ b/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) diff --git a/templates/files.html b/templates/files.html index 91088d2..08e4f21 100644 --- a/templates/files.html +++ b/templates/files.html @@ -1,135 +1,167 @@ {% extends "base.html" %} {% block main_content %} -
-
+
-
-
- -
- +
+
+
+ +
+ + +
+ +
+ +
+
+ {% set fd=entry_data[0].file_details[0] %} + + {{form['how_many']}} files +
- - -
- -
- -
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ -
-
- {% set last = namespace(printed=0) %} - {% for obj in entry_data %} - {% if which == "Week" %} - {% if last.printed != obj.file_details[0].day %} -
Day: {{obj.file_details[0].day}} of {{obj.file_details[0].month}}/{{obj.file_details[0].year}}
- {% set last.printed = obj.file_details[0].day %} - {% endif %} - {% elif which == "Month" %} - {% if last.printed != obj.file_details[0].woy %} -
Week #: {{obj.file_details[0].woy}} of {{obj.file_details[0].year}}
- {% set last.printed = obj.file_details[0].woy %} - {% endif %} - {% elif which == "Year" %} - {% if last.printed != obj.file_details[0].month %} -
Month: {{obj.file_details[0].month}} of {{obj.file_details[0].year}}
- {% set last.printed = obj.file_details[0].month %} + + {% set last = namespace(printed=0) %} + {% if grouping == "None" %} +
+ {% endif %} + {% for obj in entry_data %} + {% if grouping == "Day" %} + {% if last.printed != obj.file_details[0].day %} + {% if last.printed > 0 %} +
{% endif %} +
Day: {{obj.file_details[0].day}} of {{obj.file_details[0].month}}/{{obj.file_details[0].year}}
+
+ {% set last.printed = obj.file_details[0].day %} {% endif %} - {% if obj.type.name != "Directory" %} -
-
- {% if obj.type.name=="Image" %} - - {% elif obj.type.name == "Video" %} -
- -
- -
-
- {% endif %} -
{{obj.name}}
-
-
- {% endif %} - {% endfor %} -
+ {% elif grouping == "Week" %} + {% if last.printed != obj.file_details[0].woy %} + {% if last.printed > 0 %} +
+ {% endif %} +
Week #: {{obj.file_details[0].woy}} of {{obj.file_details[0].year}}
+
+ {% set last.printed = obj.file_details[0].woy %} + {% endif %} + {% elif grouping == "Month" %} + {% if last.printed != obj.file_details[0].month %} + {% if last.printed > 0 %} +
+ {% endif %} +
Month: {{obj.file_details[0].month}} of {{obj.file_details[0].year}}
+
+ {% set last.printed = obj.file_details[0].month %} + {% endif %} + {% endif %} + {% if obj.type.name != "Directory" %} +
+
+ {% if obj.type.name=="Image" %} + + {% elif obj.type.name == "Video" %} +
+ +
+ +
+
+ {% endif %} + {# finding text distracting,
{{obj.name}}
#} +
+
+ {% endif %} + {% endfor %} + {% if grouping == "None" %} +
+ {% endif %} {% endblock main_content %} {% block script_content %} {% endblock script_content %}