Compare commits

...

2 Commits

5 changed files with 27 additions and 23 deletions

3
TODO
View File

@@ -3,9 +3,6 @@
# consider how to better version jscript - across all html files, consistently
# mtime, didnt work anyway, my phone still wont pick up the change, it was adding any ?v= changed this (once)
#
# 4 TEST everything (don't forget keybindings,e.g. delete)
# going up from folder view shows different order?
#
# 5 think I killed pa_job_manager without passing an eid to a transform job, shouldn't crash
# SHOULD JUST get AI to help clean-up and write defensive code here...
###

View File

@@ -313,28 +313,31 @@ def process_ids():
################################################################################
# /get_dir_entries -> show thumbnail view of files from import_path(s)
# /get_dir_entries -> FIXME:
################################################################################
@app.route("/get_dir_entries", methods=["POST"])
@app.route("/get_dir_eids", 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
noo = data.get('noo', "A to Z") # Extract noo ordering
# if we are going back, find the parent id and use that instead
if back:
# find current dir
stmt=( select(EntryDirLink.dir_eid).filter(EntryDirLink.entry_id==dir_id) )
dir_id = db.session.execute(stmt).scalars().all() [0]
dir_id = db.session.execute(stmt).scalars().one_or_none()
# get parent of this dir, to go back
stmt=( select(EntryDirLink.dir_eid).filter(EntryDirLink.entry_id==dir_id) )
dir_id = db.session.execute(stmt).scalars().one_or_none()
# get content of dir_id
stmt=( select(Entry.id).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir_id) )
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))
stmt=stmt.order_by(*order_map.get(noo) )
return jsonify( entry_list=db.session.execute(stmt).scalars().all() )
# get Face overrid details
# get Face override details
def getFOT():
stmt = select(FaceOverrideType)
fot=db.session.execute(stmt).scalars().all()

View File

@@ -440,21 +440,19 @@ function getDirEntries(dir_id, back)
data={}
data.dir_id=dir_id
data.back=back
data.noo=OPT.noo
$.ajax({
type: 'POST',
url: '/get_dir_entries',
url: '/get_dir_eids',
data: JSON.stringify(data),
contentType: 'application/json',
dataType: 'json',
success: function(res) {
document.entries=res
// rebuild entryList/pageList as each dir comes with new entries
entryList=res.map(obj => obj.id);
entryList=res.entry_list
pageList=entryList.slice(0, OPT.how_many)
if( back )
document.back_id = res[0].in_dir.eid
drawPageOfFigures()
// now go get actual data/entries
getPage(1,getPageFigures)
},
error: function(xhr, status, error) {
console.error("Error:", error);
@@ -472,7 +470,8 @@ function drawPageOfFigures()
if( OPT.folders )
{
if( (document.entries.length && document.entries[0].in_dir.rel_path == '' ) || OPT.root_eid == 0 )
// it root_eid is 0, then no entries in this path - cant go up
if( OPT.root_eid == 0 || (document.entries.length && document.entries[0].in_dir.eid == OPT.root_eid ) )
{
gray="_gray"
back=""
@@ -485,8 +484,10 @@ function drawPageOfFigures()
cl="back"
}
// back button, if gray/back decide if we see grayed out folder and/or the name of the folder we go back to
// with clas "back" this gets a different click handler which flags server to return data by 'going back/up' in dir tree
// we give the server the id of the first item on the page so it can work out how to go back
html=`<div class="col col-auto g-0 m-1">
<figure id="${document.back_id}" ecnt="0" class="${cl} entry m-1" type="Directory">
<figure id="${document.entries[0].id}" ecnt="0" class="${cl} entry m-1" type="Directory">
<svg class="svg" width="${OPT.size-22}" height="${OPT.size-22}">
<use xlink:href="internal/icons.svg#folder_back${gray}"/>
</svg>
@@ -630,7 +631,7 @@ function nextPage(successCallback)
// should never happen / just return pageList unchanged
if ( currentPage === -1 || isLastPage( currentPage ) )
{
console.error( "WARNING: seems first on pg=" + firstEntryOnPage + " of how many=" + OPT.how_many + " gives currentPage=" + currentPage + " and we cant go next page?" )
console.error( "WARNING: seems first on pg=" + pageList[0] + " of how many=" + OPT.how_many + " gives currentPage=" + currentPage + " and we cant go next page?" )
return
}
getPage( currentPage+1, successCallback )
@@ -645,7 +646,7 @@ function prevPage(successCallback)
// should never happen / just return pageList unchanged
if (currentPage === 1 || currentPage === -1 )
{
console.error( "WARNING: seems first on pg=" + firstEntryOnPage + " of how many=" + OPT.how_many + " gives currentPage=" + currentPage + " and we cant go prev page?" )
console.error( "WARNING: seems first on pg=" + pageList[0] + " of how many=" + OPT.how_many + " gives currentPage=" + currentPage + " and we cant go prev page?" )
return
}
getPage( currentPage-1, successCallback )
@@ -694,7 +695,6 @@ function changeOPT(successCallback) {
OPT.folders=( OPT.folders == 'True' )
OPT.how_many=parseInt(OPT.how_many)
$('.how_many_text').html( `&nbsp;${OPT.how_many} files&nbsp;` )
OPT.root_eid=parseInt(OPT.root_eid)
OPT.size=parseInt(OPT.size)
getPage(1,successCallback)
}

View File

@@ -40,6 +40,8 @@
// this is the list of entry ids for the images for ALL matches for this query
var entryList={{query_data.entry_list}}
var OPT = {{ OPT.to_dict()|tojson }};
// set from query data and stored in OPT for convenience. It can be 0 -
// this implies no content in the Path at all
OPT.root_eid = {{ query_data.root_eid }};
// pageList is just those entries shown on this page from the full entryList

View File

@@ -247,6 +247,8 @@
document.viewing=null;
var OPT = {{ OPT.to_dict()|tojson }};
// set from query data and stored in OPT for convenience. It can be 0 -
// this implies no content in the Path at all
OPT.root_eid = {{ query_data.root_eid }};
// get items out of query_data into convenience javascript vars...