first cut of paths actually working with folder viewing - for now defaulting on for both Storage only

This commit is contained in:
2021-05-01 18:16:45 +10:00
parent b6b98ae5ca
commit 5e03650ed5
5 changed files with 65 additions and 38 deletions

View File

@@ -139,6 +139,9 @@ def ViewingOptions( request ):
else:
folders=False
cwd=None
# folders=True
# cwd='static/Import'
root=cwd
if request.method=="POST":
noo=request.form['noo']
@@ -160,7 +163,7 @@ def ViewingOptions( request ):
if 'next' in request.form:
offset += int(how_many)
return noo, grouping, how_many, offset, size, folders, cwd
return noo, grouping, how_many, offset, size, folders, cwd, root
################################################################################
# /file_list -> show detailed file list of files from import_path(s)
@@ -175,28 +178,30 @@ def file_list_ip():
@app.route("/files_ip", methods=["GET", "POST"])
def files_ip():
noo, grouping, how_many, offset, size, folders, cwd = ViewingOptions( request )
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request )
entries=[]
# per import path, add entries to view
settings=Settings.query.first()
paths = settings.import_path.split("#")
for path in paths:
prefix = SymlinkName(path,path+'/')
prefix = SymlinkName("Import",path,path+'/')
if noo == "Oldest":
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
else:
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).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 (Import Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd )
entries+=Entry.query.join(Dir).join(EntryDirLink).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
return render_template("files.html", page_title='View Files (Import Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
################################################################################
# /files -> show thumbnail view of files from storage_path
################################################################################
@app.route("/files_sp", methods=["GET", "POST"])
def files_sp():
noo, grouping, how_many, offset, size, folders, cwd = ViewingOptions( request )
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request )
entries=[]
print( f"cwd={cwd}" )
@@ -205,16 +210,15 @@ def files_sp():
settings=Settings.query.first()
paths = settings.storage_path.split("#")
for path in paths:
prefix = SymlinkName(path,path+'/')
prefix = SymlinkName("Storage",path,path+'/')
if noo == "Oldest":
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
entries+=Entry.query.join(Dir).join(EntryDirLink).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
else:
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
entries+=Entry.query.join(Dir).join(EntryDirLink).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
return render_template("files.html", page_title='View Files (Storage Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd )
entries+=Entry.query.join(Dir).join(EntryDirLink).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
return render_template("files.html", page_title='View Files (Storage Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
################################################################################
# /search -> show thumbnail view of files from import_path(s)
@@ -222,7 +226,7 @@ def files_sp():
@app.route("/search", methods=["GET","POST"])
def search():
noo, grouping, how_many, offset, size, folders, cwd = ViewingOptions( request )
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request )
# always show flat results for search to start with
folders=False
@@ -233,7 +237,7 @@ def search():
all_entries = file_data + dir_data + ai_data
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, folders=folders, cwd=cwd )
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, folders=folders, cwd=cwd, root=root )
################################################################################
# /files/scannow -> allows us to force a check for new files
@@ -336,6 +340,7 @@ def custom_static(filename):
################################################################################
@app.template_filter('TopLevelFolderOf')
def _jinja2_filter_toplevelfolderof(path, cwd):
print(f"path={path}, cwd={cwd}, dirname=={os.path.dirname(path)}")
if os.path.dirname(path) == cwd:
return True
else: