now allow files_sp paths to work (and support folders). Highlighting with folders is broken (likely dodgy ecnt). viewing still broken, but basic navigations is finally working with folders now
This commit is contained in:
79
files.py
79
files.py
@@ -179,6 +179,7 @@ class FileSchema(ma.SQLAlchemyAutoSchema):
|
||||
class DirSchema(ma.SQLAlchemyAutoSchema):
|
||||
class Meta: model = Dir
|
||||
load_instance = True
|
||||
eid = ma.auto_field() # Explicitly include eid
|
||||
in_path = ma.Nested(PathSchema)
|
||||
|
||||
################################################################################
|
||||
@@ -404,39 +405,70 @@ def process_ids():
|
||||
# return entries as json
|
||||
return jsonify(entries_schema.dump(entries))
|
||||
|
||||
###
|
||||
# query_data = { 'entry_lst': entry_lst, 'query_id': query_id, ... }
|
||||
###
|
||||
|
||||
################################################################################
|
||||
# /get_dir_entries -> show thumbnail view of files from import_path(s)
|
||||
################################################################################
|
||||
@app.route("/get_dir_entries", methods=["POST"])
|
||||
@login_required
|
||||
def get_dir_entries():
|
||||
data = request.get_json() # Parse JSON body
|
||||
dir_id = data.get('dir_id', []) # Extract list of ids
|
||||
back = data.get('back', False) # Extract back boolean
|
||||
|
||||
# if we are going back, find the parent id and use that instead
|
||||
if back:
|
||||
stmt=( select(EntryDirLink.dir_eid).filter(EntryDirLink.entry_id==dir_id) )
|
||||
dir_id = db.session.execute(stmt).scalars().all() [0]
|
||||
|
||||
# get content of dir_id
|
||||
stmt=( select(Entry.id).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir_id) )
|
||||
# FIXME: what do we do with ordering anyway???
|
||||
#stmt=stmt.order_by(*order_map.get(OPT.noo) )
|
||||
ids=db.session.execute(stmt).scalars().all()
|
||||
entries_schema = EntrySchema(many=True)
|
||||
entries = Entry.query.filter(Entry.id.in_(ids)).all()
|
||||
return jsonify(entries_schema.dump(entries))
|
||||
|
||||
################################################################################
|
||||
# Call this ONCE on first menu choice of View files, or search box submission
|
||||
# create the list of entry ids that matcht the required viewing/list
|
||||
################################################################################
|
||||
def GetQueryData( OPT ):
|
||||
query_data = {}
|
||||
query_data={}
|
||||
query_data['query_id']=None
|
||||
query_data['entry_list']=None
|
||||
|
||||
# set up the sql order strings (back in OPT) based on value of noo
|
||||
# FIXME: remove this for all last/first eid usage AND use order_map
|
||||
SetOrderStrings( OPT )
|
||||
|
||||
if OPT.path_type == 'Search':
|
||||
print ("NOT YET")
|
||||
return query_data
|
||||
|
||||
# always get the top of the (OPT.prefix) Path's eid and keep it for OPT.folders toggling/use
|
||||
dir_stmt=( select(Entry.id).join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path == '').filter(Path.path_prefix==OPT.prefix) )
|
||||
# this should return the 1 Dir (that we want to see the content of) - and with only 1, no need to worry about order
|
||||
dir_arr=db.session.execute(dir_stmt).scalars().all()
|
||||
dir_id=dir_arr[0]
|
||||
query_data['root_eid']=dir_id
|
||||
|
||||
if OPT.folders:
|
||||
entries, tmp_num_ents = GetEntriesInFolderView( OPT, prefix )
|
||||
# start folder view with only the root folder
|
||||
stmt=( select(Entry.id).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir_id) )
|
||||
query_data['entry_list']=db.session.execute(stmt).scalars().all()
|
||||
else:
|
||||
stmt = ( select(Entry.id).join(File).join(EntryDirLink).join(Dir).join(PathDirLink).
|
||||
join(Path).filter(Path.path_prefix == OPT.prefix) )
|
||||
stmt = stmt.order_by(*order_map.get(OPT.noo) )
|
||||
# get every File that is in the OPT.prefix Path
|
||||
stmt=( select(Entry.id).join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix == OPT.prefix) )
|
||||
stmt=stmt.order_by(*order_map.get(OPT.noo) )
|
||||
query_data['entry_list']= db.session.execute(stmt).scalars().all()
|
||||
|
||||
# first time we get the data q_offset is 0, current=first one, search never gets here, so search_term=''
|
||||
# FIXME: Doubt we need cwd -- I only need originals to either invalidate this list, or recreate it... need to think about that a lot more
|
||||
query = Query( path_type=OPT.path_type, noo=OPT.noo, q_offset=0, folder=OPT.folders, grouping=OPT.grouping, root=OPT.root, cwd=OPT.cwd, search_term='',
|
||||
entry_list=query_data['entry_list'], current=query_data['entry_list'][0], created=datetime.now(pytz.utc) )
|
||||
db.session.add(query)
|
||||
db.session.commit()
|
||||
|
||||
query_data['query_id']=query.id
|
||||
# not sure I need this in hindsight - any value at all???
|
||||
# # first time we get the data q_offset is 0, current=first one, search never gets here, so search_term=''
|
||||
# # FIXME: Doubt we need cwd -- I only need originals to either invalidate this list, or recreate it... need to think about that a lot more
|
||||
# query = Query( path_type=OPT.path_type, noo=OPT.noo, q_offset=0, folder=OPT.folders, grouping=OPT.grouping, root=OPT.root, cwd=OPT.cwd, search_term='',
|
||||
# entry_list=query_data['entry_list'], current=query_data['entry_list'][0], created=datetime.now(pytz.utc) )
|
||||
# db.session.add(query)
|
||||
# db.session.commit()
|
||||
#
|
||||
# query_data['query_id']=query.id
|
||||
return query_data
|
||||
|
||||
################################################################################
|
||||
@@ -519,11 +551,10 @@ def files_ip():
|
||||
# now we have reset the offset, etc. into the prefs, we can use a GET and this will be back/forward browser button safe
|
||||
if request.method=='POST':
|
||||
redirect("/files_ip")
|
||||
entries=GetEntries( OPT )
|
||||
people = Person.query.all()
|
||||
move_paths = MovePathDetails()
|
||||
query_data = GetQueryData( OPT )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", entry_data=entries, OPT=OPT, people=people, move_paths=move_paths, query_data=query_data )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", OPT=OPT, people=people, move_paths=move_paths, query_data=query_data )
|
||||
|
||||
################################################################################
|
||||
# /files -> show thumbnail view of files from storage_path
|
||||
@@ -535,10 +566,10 @@ def files_sp():
|
||||
# now we have reset the offset, etc. into the prefs, we can use a GET and this will be back/forward browser button safe
|
||||
if request.method=='POST':
|
||||
redirect("/files_sp")
|
||||
entries=GetEntries( OPT )
|
||||
people = Person.query.all()
|
||||
move_paths = MovePathDetails()
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", entry_data=entries, OPT=OPT, people=people, move_paths=move_paths )
|
||||
query_data = GetQueryData( OPT )
|
||||
return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", OPT=OPT, people=people, move_paths=move_paths, query_data=query_data )
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user