From 7e2494884e71195228e6f4e37058b720040dbc92 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 6 Jun 2021 14:09:11 +1000 Subject: [PATCH] can now toggle between folder or flat view, its a bit ugly, but it works --- TODO | 2 -- main.py | 5 +++-- pa_job_manager.py | 3 +++ shared.py | 14 ++++++++++++++ templates/files.html | 36 ++++++++++++++++++++++++------------ 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 1f2e66d..a51beb5 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ ## GENERAL - * storage_path viewing needs to be by folder / not a big grab bag of files (by default - DONE) - -> EITHER view by folders (and hide the oldest 50 by Day section), or view flat and show it * need a way for search results to show we found something in import_path or storage_path: - now we can use the in_path, then have a series of icons, e.g. disk for storage, ? for import, and bin for recycling -- only show these on the thumbs *IF* we search (where it may not be obvious where it came from) diff --git a/main.py b/main.py index e74de73..6151e9a 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ from flask_bootstrap import Bootstrap from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerField, TextAreaField, validators from flask_wtf import FlaskForm from status import st, Status -from shared import CreateSelect, DB_URL +from shared import CreateSelect, CreateFoldersSelect, DB_URL import re import socket @@ -44,6 +44,7 @@ app.jinja_env.globals['GetNumActiveJobs'] = GetNumActiveJobs app.jinja_env.globals['GetJM_Message'] = GetJM_Message app.jinja_env.globals['ClearJM_Message'] = ClearJM_Message app.jinja_env.globals['CreateSelect'] = CreateSelect +app.jinja_env.globals['CreateFoldersSelect'] = CreateFoldersSelect # default page, just the navbar @app.route("/", methods=["GET"]) @@ -54,4 +55,4 @@ if __name__ == "__main__": if hostname == PROD_HOST: app.run(ssl_context=('/etc/letsencrypt/live/book.depaoli.id.au/cert.pem', '/etc/letsencrypt/live/book.depaoli.id.au/privkey.pem'), host="0.0.0.0", debug=False) else: - app.run(host="0.0.0.0", debug=True) \ No newline at end of file + app.run(host="0.0.0.0", debug=True) diff --git a/pa_job_manager.py b/pa_job_manager.py index bc7766a..c2e2edf 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -1129,6 +1129,9 @@ def ValidateSettingsPaths(): if not ip_exists: print("ERROR: None of the import paths in the settings exist - Please fix now"); paths = settings.import_path.split("#") + if not rbp_exists or not sp_exists or not ip_exists: + print("ERROR: Existing until above errors are fixed by paths being created or settings being updated to valid paths" ) + exit(-1) return diff --git a/shared.py b/shared.py index dcbdcc3..54cd0aa 100644 --- a/shared.py +++ b/shared.py @@ -29,6 +29,20 @@ def CreateSelect(name, selected, list, js=""): str += '' return str +def CreateFoldersSelect(selected): + str = f'' + return str + + def SymlinkName(ptype, path, file): sig_bit=file.replace(path, "") last_dir=os.path.basename(path[0:-1]) diff --git a/templates/files.html b/templates/files.html index bb66c00..406bdd3 100644 --- a/templates/files.html +++ b/templates/files.html @@ -10,29 +10,38 @@
- {% if search_term is defined %} {% endif %}
- {% if "files_ip" in request.url %} - I - {% elif "files_sp" in request.url %} - S - {% else %} - R - {% endif %} {% if folders %} -
- In: {{cwd}} +
+ + {% if "files_ip" in request.url %} + + {% set tmp_path=cwd | replace( "static/Import", "" ) + "/" %} + {% elif "files_sp" in request.url %} + + {% set tmp_path=cwd | replace( "static/Storage", "" ) + "/" %} + {% else %} + + {% set tmp_path=cwd | replace( "static/Bin", "" ) + "/" %} + {% endif %} + In: {{tmp_path}}
{% endif %}
{{CreateSelect( "noo", noo, ["Oldest", "Newest"], "$('#offset').val(0)")|safe }} {{CreateSelect( "how_many", how_many, ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }} - grouped by: - {{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"])|safe }} + {% if folders %} + + {{CreateFoldersSelect( folders )|safe }} + {% else %} + {{CreateFoldersSelect( folders )|safe }} + grouped by: + {{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"])|safe }} + {% endif %}
{% if search_term is defined %}
@@ -114,6 +123,9 @@ {% endif %} {% endif %} + {% if not folders and obj.type.name == "Directory" %} + {% continue %} + {% endif %} {% if grouping == "Day" %} {% if last.printed != obj.file_details.day %} {% if last.printed > 0 %}