current, first_eid, last_eid now work for Flat view of Paths, folder view next
This commit is contained in:
1
TODO
1
TODO
@@ -20,6 +20,7 @@
|
|||||||
- [DONE] should really define the first/last of a GetEntries search and use definitive logic to show at start or end of entries (for next/prev buttons in viewer.html)
|
- [DONE] should really define the first/last of a GetEntries search and use definitive logic to show at start or end of entries (for next/prev buttons in viewer.html)
|
||||||
- [DONE] store "current", "first_eid", "last_eid" in pa_user_state
|
- [DONE] store "current", "first_eid", "last_eid" in pa_user_state
|
||||||
- use them on reload, e.g. if current set use it not view eid (should be okay with client-side skipping, and just make sure if it is viewlist we use next/prev logic not current
|
- use them on reload, e.g. if current set use it not view eid (should be okay with client-side skipping, and just make sure if it is viewlist we use next/prev logic not current
|
||||||
|
- need to set current/first_eid/last_eid on import/storage/bin as well as search
|
||||||
- can consider an optim-- new_view page makes calls to viewlist to ADD json data only, so only trigger a new "viewlist" if we dont have data for that part of the eids
|
- can consider an optim-- new_view page makes calls to viewlist to ADD json data only, so only trigger a new "viewlist" if we dont have data for that part of the eids
|
||||||
job.py:@app.route("/jobs", methods=["GET", "POST"])
|
job.py:@app.route("/jobs", methods=["GET", "POST"])
|
||||||
job.py:@app.route("/job/<id>", methods=["GET","POST"])
|
job.py:@app.route("/job/<id>", methods=["GET","POST"])
|
||||||
|
|||||||
50
files.py
50
files.py
@@ -182,14 +182,43 @@ def GetEntriesInFlatView( OPT, prefix ):
|
|||||||
|
|
||||||
if OPT.noo == "Oldest":
|
if OPT.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(OPT.offset).limit(OPT.how_many).all()
|
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(OPT.offset).limit(OPT.how_many).all()
|
||||||
|
last_entry=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.desc()).limit(1)
|
||||||
elif OPT.noo == "Newest":
|
elif OPT.noo == "Newest":
|
||||||
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(OPT.offset).limit(OPT.how_many).all()
|
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(OPT.offset).limit(OPT.how_many).all()
|
||||||
|
last_entry=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).limit(1)
|
||||||
elif OPT.noo == "Z to A":
|
elif OPT.noo == "Z to A":
|
||||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).offset(OPT.offset).limit(OPT.how_many).all()
|
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).offset(OPT.offset).limit(OPT.how_many).all()
|
||||||
|
last_entry=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).limit(1)
|
||||||
else:
|
else:
|
||||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
||||||
|
last_entry=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).limit(1)
|
||||||
|
print(f"GetEnt FLAT --> OPT={OPT}, len={len(entries)}")
|
||||||
|
if OPT.first_eid == 0 and OPT.offset == 0 and len(entries):
|
||||||
|
OPT.first_eid = entries[0].id
|
||||||
|
if OPT.last_eid == 0:
|
||||||
|
le=last_entry.all()
|
||||||
|
if len(le):
|
||||||
|
OPT.last_eid = le[0].id
|
||||||
|
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type).first()
|
||||||
|
UpdatePref( pref, OPT )
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# util function to just update the current/first/last positions needed for
|
||||||
|
# viewing / using pa_user_state DB table
|
||||||
|
################################################################################
|
||||||
|
def UpdatePref( pref, OPT ):
|
||||||
|
if OPT.current>0:
|
||||||
|
pref.current=OPT.current
|
||||||
|
if OPT.first_eid>0:
|
||||||
|
pref.first_eid=OPT.first_eid
|
||||||
|
if OPT.last_eid>0:
|
||||||
|
pref.last_eid=OPT.last_eid
|
||||||
|
print( f"UpdatePref: c={pref.current}, f={pref.first_eid}, l={pref.last_eid}" )
|
||||||
|
db.session.add(pref)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# GetEntriesInFolderView: func. to retrieve DB entries appropriate for folder view
|
# GetEntriesInFolderView: func. to retrieve DB entries appropriate for folder view
|
||||||
# read inline comments to deal with variations / ordering...
|
# read inline comments to deal with variations / ordering...
|
||||||
@@ -293,12 +322,7 @@ def GetEntries( OPT ):
|
|||||||
OPT.last_eid = l.id
|
OPT.last_eid = l.id
|
||||||
print( f"c={OPT.current}, f={OPT.first_eid}, l={OPT.last_eid} -- STORE THESE in pa_user_state" )
|
print( f"c={OPT.current}, f={OPT.first_eid}, l={OPT.last_eid} -- STORE THESE in pa_user_state" )
|
||||||
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.orig_search_term==search_term).first()
|
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.orig_search_term==search_term).first()
|
||||||
pref.current=OPT.current
|
UpdatePref( pref, OPT )
|
||||||
pref.first_eid=OPT.first_eid
|
|
||||||
pref.last_eid=OPT.last_eid
|
|
||||||
print( f"stored pref: {pref}" )
|
|
||||||
db.session.add(pref)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return all_entries
|
return all_entries
|
||||||
|
|
||||||
@@ -616,22 +640,20 @@ def viewlist():
|
|||||||
eids=eids.rstrip(",")
|
eids=eids.rstrip(",")
|
||||||
lst = eids.split(',')
|
lst = eids.split(',')
|
||||||
if 'next' in request.form:
|
if 'next' in request.form:
|
||||||
current = int(lst[0])
|
OPT.current = int(lst[0])
|
||||||
if 'prev' in request.form:
|
if 'prev' in request.form:
|
||||||
current = int(lst[-1])
|
OPT.current = int(lst[-1])
|
||||||
|
|
||||||
resp['current']=current
|
resp['current']=OPT.current
|
||||||
|
if OPT.first_eid>0:
|
||||||
resp['first_eid']=OPT.first_eid
|
resp['first_eid']=OPT.first_eid
|
||||||
resp['last_eid']=OPT.last_eid
|
resp['last_eid']=OPT.last_eid
|
||||||
resp['eids']=eids
|
resp['eids']=eids
|
||||||
resp['offset']=OPT.offset
|
resp['offset']=OPT.offset
|
||||||
print( "DDP: SAVE PREF HERE TO GET NEW CURRENT AND FIX back button WITH view/XXX when you next/prev to different page" )
|
print( "DDP: SAVE PREF HERE TO GET NEW CURRENT AND FIX back button WITH view/XXX when you next/prev to different page" )
|
||||||
|
|
||||||
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==OPT.path_type,PA_UserState.view_eid==OPT.view_eid).first()
|
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.view_eid==OPT.view_eid).first()
|
||||||
pref.current=current
|
UpdatePref( pref, OPT )
|
||||||
print( f"stored pref: {pref}" )
|
|
||||||
db.session.add(pref)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class States(PA):
|
|||||||
u=PAUser.query.filter(PAUser.dn==current_user.dn).one()
|
u=PAUser.query.filter(PAUser.dn==current_user.dn).one()
|
||||||
self.grouping=u.default_grouping
|
self.grouping=u.default_grouping
|
||||||
self.how_many=u.default_how_many
|
self.how_many=u.default_how_many
|
||||||
self.offset="0"
|
self.offset=0
|
||||||
self.size=u.default_size
|
self.size=u.default_size
|
||||||
if self.path_type == "View":
|
if self.path_type == "View":
|
||||||
self.root='static/' + self.orig_ptype
|
self.root='static/' + self.orig_ptype
|
||||||
|
|||||||
Reference in New Issue
Block a user