complete rewrite of viewer, videos need to be fixed. Otherwise, viewer now loads entry data for all "how_many" images on the screen, and allows prev/next movement between images without a DB load for the current page of images, then as required, it will retrieve the prev/next "how_many" from the database via /viewlist route, and go back into view/<id> of the appropriate new image of the new list. Also prevents going below 0 and beyond end of DB for the first time.

This commit is contained in:
2021-08-27 23:38:31 +10:00
parent 652a89161d
commit 1d3caf17de
6 changed files with 419 additions and 357 deletions

12
TODO
View File

@@ -1,12 +1,10 @@
## GENERAL ## GENERAL
* viewer: * viewer:
buttons need tootltips - buttons need tootltips to show shortcut key
can we make it preload next/prev images, and only reload the image div when we jump? to make arrow-based nav much faster - if DrawImg runs into a video, deal with it :)
im_next = new Image()
im_next.src="..." * files.py cleanup:
few things though: class Option for dot-notation, or namespace???
- have to remember the details of not just the src fname, but also face* details
- onload event, what if we use it and use say arrow keys to load/change image, will one beat the other, but if we arrow next too fast, the img wont be loaded?
* remove dirs after the duplicate cleanup removes all its content * remove dirs after the duplicate cleanup removes all its content

354
files.py
View File

@@ -78,6 +78,7 @@ class Dir(db.Model):
# {dir|file}_etails are convenience data for the relevant details from the Dir # {dir|file}_etails are convenience data for the relevant details from the Dir
# or File class - not in DB # or File class - not in DB
# in_dir - is the Dir that this entry is located in (convenience for class only) # in_dir - is the Dir that this entry is located in (convenience for class only)
# FullPathOnFS(): method to get path on the FS for this Entry
################################################################################ ################################################################################
class Entry(db.Model): class Entry(db.Model):
__tablename__ = "entry" __tablename__ = "entry"
@@ -89,6 +90,17 @@ class Entry(db.Model):
file_details = db.relationship( "File", uselist=False ) file_details = db.relationship( "File", uselist=False )
in_dir = db.relationship ("Dir", secondary="entry_dir_link", uselist=False ) in_dir = db.relationship ("Dir", secondary="entry_dir_link", uselist=False )
def FullPathOnFS(self):
if self.in_dir:
s=self.in_dir.in_path.path_prefix + '/'
if len(self.in_dir.rel_path) > 0:
s += self.in_dir.rel_path + '/'
# this occurs when we have a dir that is the root of a path
else:
s=self.dir_details.in_path.path_prefix+'/'
s += self.name
return s
def __repr__(self): def __repr__(self):
return f"<id: {self.id}, name: {self.name}, type={self.type}, dir_details={self.dir_details}, file_details={self.file_details}, in_dir={self.in_dir}" return f"<id: {self.id}, name: {self.name}, type={self.type}, dir_details={self.dir_details}, file_details={self.file_details}, in_dir={self.in_dir}"
@@ -159,79 +171,94 @@ def ClearJM_Message(id):
return return
################################################################################ ################################################################################
# ViewingOptions: defines set of default values for viewing (order/size, etc.) # SetViewingOptions: defines set of default values for viewing (order/size, etc.)
# and if a request object (from a POST) is passed in, it returns those instead # and if a request object (from a POST) is passed in, it returns those instead
# it also handles the cwd appropriately # it also handles the cwd appropriately
################################################################################ ################################################################################
def ViewingOptions( request ): def SetViewingOptions( request ):
noo="Oldest" OPT={}
grouping="None" OPT['noo']="Oldest"
how_many="50" OPT['grouping']="None"
offset="0" OPT['how_many']="50"
size="128" OPT['offset']="0"
if 'files_sp' in request.path: OPT['size']="128"
noo="A to Z" settings=Settings.query.first()
folders=True if 'orig_url' in request.form:
cwd='static/Storage' print("okay, this has come from a viewer.html and needs next/prev how_many, recreate orig critiera...")
elif 'files_rbp' in request.path: url = request.form['orig_url']
folders=True
cwd='static/Bin'
else: else:
folders=False url = request.path
cwd='static/Import' if 'files_sp' in url:
root=cwd OPT['noo']="A to Z"
OPT['folders']=True
OPT['path_type'] = 'Storage'
OPT['cwd']='static/Storage'
OPT['paths'] = settings.storage_path.split("#")
elif 'files_rbp' in url:
OPT['folders']=True
OPT['path_type'] = 'Bin'
OPT['cwd']='static/Bin'
OPT['paths'] = settings.recycle_bin_path.split("#")
else:
OPT['folders']=False
OPT['path_type'] = 'Import'
OPT['cwd']='static/Import'
OPT['paths'] = settings.import_path.split("#")
OPT['root']=OPT['cwd']
# the above are defaults, if we are here, then we have current values, use them instead # the above are defaults, if we are here, then we have current values, use them instead
if request.method=="POST": if request.method=="POST":
noo=request.form['noo'] OPT['noo']=request.form['noo']
how_many=request.form['how_many'] OPT['how_many']=request.form['how_many']
offset=int(request.form['offset']) OPT['offset']=int(request.form['offset'])
grouping=request.form['grouping'] OPT['grouping']=request.form['grouping']
size = request.form['size'] OPT['size'] = request.form['size']
# seems html cant do boolean, but uses strings so convert # seems html cant do boolean, but uses strings so convert
if request.form['folders'] == "False": if request.form['folders'] == "False":
folders=False OPT['folders']=False
if request.form['folders'] == "True": if request.form['folders'] == "True":
folders=True OPT['folders']=True
# have to force grouping to None if we flick to folders from a flat # have to force grouping to None if we flick to folders from a flat
# view with grouping (otherwise we print out group headings for # view with grouping (otherwise we print out group headings for
# child content that is not in the CWD) # child content that is not in the CWD)
grouping=None OPT['grouping']=None
cwd = request.form['cwd'] OPT['cwd'] = request.form['cwd']
if 'fullscreen' in request.form:
OPT['fullscreen']=request.form['fullscreen']
if 'prev' in request.form: if 'prev' in request.form:
offset -= int(how_many) OPT['offset'] -= int(OPT['how_many'])
if offset < 0: if OPT['offset'] < 0:
offset=0 OPT['offset']=0
if 'next' in request.form: if 'next' in request.form:
offset += int(how_many) OPT['offset'] += int(OPT['how_many'])
return noo, grouping, how_many, offset, size, folders, cwd, root return OPT
################################################################################ ################################################################################
# GetEntriesInFlatView: func. to retrieve DB entries appropriate for flat view # GetEntriesInFlatView: func. to retrieve DB entries appropriate for flat view
################################################################################ ################################################################################
def GetEntriesInFlatView( cwd, prefix, noo, offset, how_many ): def GetEntriesInFlatView( OPT, prefix ):
entries=[] entries=[]
if 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(offset).limit(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()
elif 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(offset).limit(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()
elif 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(offset).limit(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()
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(offset).limit(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()
return entries return entries
################################################################################ ################################################################################
# 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...
################################################################################ ################################################################################
def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ): def GetEntriesInFolderView( OPT, prefix ):
entries=[] entries=[]
# okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path='' # okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path=''
if os.path.dirname(cwd) == 'static': if os.path.dirname(OPT['cwd']) == 'static':
dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path=='').filter(Path.path_prefix==prefix).order_by(Entry.name).first() dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path=='').filter(Path.path_prefix==prefix).order_by(Entry.name).first()
# this can occur if the path in settings does not exist as it wont be in # the DB # this can occur if the path in settings does not exist as it wont be in # the DB
if not dir: if not dir:
@@ -239,7 +266,7 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ):
# although this is 1 entry, needs to come back via all() to be iterable # although this is 1 entry, needs to come back via all() to be iterable
entries+= Entry.query.filter(Entry.id==dir.id).all() entries+= Entry.query.filter(Entry.id==dir.id).all()
else: else:
rp = cwd.replace( prefix, '' ) rp = OPT['cwd'].replace( prefix, '' )
# when in subdirs, replacing prefix will leave the first char as /, get rid of it # when in subdirs, replacing prefix will leave the first char as /, get rid of it
if len(rp) and rp[0] == '/': if len(rp) and rp[0] == '/':
rp=rp[1:] rp=rp[1:]
@@ -247,22 +274,51 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ):
# this can occur if the path in settings does not exist as it wont be in # the DB # this can occur if the path in settings does not exist as it wont be in # the DB
if not dir: if not dir:
return entries return entries
if noo == "Z to A" or "Newest": if OPT['noo'] == "Z to A" or "Newest":
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all() entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all()
# just do A to Z / Oldest by default or if no valid option # just do A to Z / Oldest by default or if no valid option
else: else:
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name).all() entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name).all()
# add any files at the current CWD (based on dir_eid in DB) # add any files at the current CWD (based on dir_eid in DB)
if noo == "Oldest": if OPT['noo'] == "Oldest":
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all() entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
elif noo == "Newest": elif OPT['noo'] == "Newest":
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all() entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
elif noo == "Z to A": elif OPT['noo'] == "Z to A":
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(offset).limit(how_many).all() entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(OPT['offset']).limit(OPT['how_many']).all()
# just do A to Z by default or if no valid option # just do A to Z by default or if no valid option
else: else:
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(offset).limit(how_many).all() entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
return entries
################################################################################
# /GetEntries -> helper function that Gets Entries for required files to show
# for several routes (files_ip, files_sp, files_rbp, search, viewlist)
################################################################################
def GetEntries( OPT ):
entries=[]
if 'search_term' in request.form:
search_term=request.form['search_term']
if 'AI:' in search_term:
search_term = search_term.replace('AI:','')
all_entries = Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
else:
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
dir_data=Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
ai_data=Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{search_term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(OPT['offset']).limit(OPT['how_many']).all()
all_entries = file_data + dir_data + ai_data
return all_entries
for path in OPT['paths']:
if not os.path.exists(path):
continue
prefix = SymlinkName(OPT['path_type'],path,path+'/')
if OPT['folders']:
entries+=GetEntriesInFolderView( OPT, prefix )
else:
entries+=GetEntriesInFlatView( OPT, prefix )
return entries return entries
################################################################################ ################################################################################
@@ -271,15 +327,9 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ):
@app.route("/file_list_ip", methods=["GET","POST"]) @app.route("/file_list_ip", methods=["GET","POST"])
@login_required @login_required
def file_list_ip(): def file_list_ip():
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request ) OPT=SetViewingOptions( request )
entries=[] entries=GetEntries( OPT )
return render_template("file_list.html", page_title='View File Details (Import Path)', entry_data=entries, OPT=OPT )
settings=Settings.query.first()
paths = settings.import_path.split("#")
for path in paths:
prefix = SymlinkName("Import",path,path+'/')
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
return render_template("file_list.html", page_title='View File Details (Import Path)', entry_data=entries, noo=noo, how_many=how_many, offset=offset )
################################################################################ ################################################################################
# /files -> show thumbnail view of files from import_path(s) # /files -> show thumbnail view of files from import_path(s)
@@ -287,26 +337,10 @@ def file_list_ip():
@app.route("/files_ip", methods=["GET", "POST"]) @app.route("/files_ip", methods=["GET", "POST"])
@login_required @login_required
def files_ip(): def files_ip():
OPT=SetViewingOptions( request )
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request ) entries=GetEntries( OPT )
entries=[]
people = Person.query.all() people = Person.query.all()
return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT, people=people )
# per import path, add entries to view
settings=Settings.query.first()
paths = settings.import_path.split("#")
for path in paths:
if not os.path.exists(path):
continue
prefix = SymlinkName("Import",path,path+'/')
if folders:
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
else:
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
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, people=people )
################################################################################ ################################################################################
# /files -> show thumbnail view of files from storage_path # /files -> show thumbnail view of files from storage_path
@@ -314,24 +348,10 @@ def files_ip():
@app.route("/files_sp", methods=["GET", "POST"]) @app.route("/files_sp", methods=["GET", "POST"])
@login_required @login_required
def files_sp(): def files_sp():
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request ) OPT=SetViewingOptions( request )
entries=[] entries=GetEntries( OPT )
people = Person.query.all() people = Person.query.all()
return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT, people=people )
# per storage path, add entries to view
settings=Settings.query.first()
paths = settings.storage_path.split("#")
for path in paths:
if not os.path.exists(path):
continue
prefix = SymlinkName("Storage",path,path+'/')
if folders:
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
else:
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
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, people=people )
################################################################################ ################################################################################
@@ -340,22 +360,10 @@ def files_sp():
@app.route("/files_rbp", methods=["GET", "POST"]) @app.route("/files_rbp", methods=["GET", "POST"])
@login_required @login_required
def files_rbp(): def files_rbp():
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request ) OPT=SetViewingOptions( request )
entries=[] entries=GetEntries( OPT )
people = Person.query.all()
# per recyle bin path, add entries to view return render_template("files.html", page_title=f"View Files ({OPT['path_type']} Path)", entry_data=entries, OPT=OPT )
settings=Settings.query.first()
paths = settings.recycle_bin_path.split("#")
for path in paths:
if not os.path.exists(path):
continue
prefix = SymlinkName("Bin",path,path+'/')
if folders:
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
else:
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
return render_template("files.html", page_title='View Files (Bin Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
################################################################################ ################################################################################
@@ -364,22 +372,11 @@ def files_rbp():
@app.route("/search", methods=["GET","POST"]) @app.route("/search", methods=["GET","POST"])
@login_required @login_required
def search(): def search():
OPT=SetViewingOptions( request )
noo, grouping, how_many, offset, size, folders, cwd, root = ViewingOptions( request )
# always show flat results for search to start with # always show flat results for search to start with
folders=False OPT['folders']=False
entries=GetEntries( OPT )
term=request.form['term'] return render_template("files.html", page_title='View Files', search_term=request.form['search_term'], entry_data=entries, OPT=OPT )
if 'AI:' in term:
term = term.replace('AI:','')
all_entries = Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{term}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
else:
file_data=Entry.query.join(File).filter(Entry.name.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
dir_data=Entry.query.join(File).join(EntryDirLink).join(Dir).filter(Dir.rel_path.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
ai_data=Entry.query.join(File).join(FaceFileLink).join(Face).join(FaceRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(Person.tag.ilike(f"%{request.form['term']}%")).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
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, root=root )
################################################################################ ################################################################################
# /files/scannow -> allows us to force a check for new files # /files/scannow -> allows us to force a check for new files
@@ -520,73 +517,62 @@ def move_files():
return render_template("base.html") return render_template("base.html")
################################################################################ ################################################################################
# /viewnext -> moves to the next entry and grabs data from DB and views it # /viewlist -> get new set of eids and set current to new img to view
################################################################################ ################################################################################
@app.route("/viewnext", methods=["GET","POST"]) @app.route("/viewlist", methods=["POST"])
@login_required @login_required
def viewnext(): def viewlist():
sels={} OPT=SetViewingOptions( request )
sels['fname']='true' # Get next/prev set of data - e.g. if next set, then it will use orig_url
sels['faces']='true' # to go forward how_many from offset and then use viewer.html to show that
sels['distance']='true' # first obj of the new list of entries
if request.method=="POST": entries=GetEntries( OPT )
id = request.form['current'] # this occurs when we went from the last image on a page (with how_many on
eids=request.form['eids'] # it) and it just happened to also be the last in the DB...
sels['fname']=request.form['fname'] if not entries:
sels['faces']=request.form['faces'] # undo the skip by how_many and getentries again
sels['distance']=request.form['distance'] OPT['offset'] -= int(OPT['how_many'])
lst = eids.split(',') entries=GetEntries( OPT )
new_id = lst[lst.index(id)+1] # now flag we are at the last in db, to reset current below
obj = Entry.query.join(File).filter(Entry.id==new_id).first() OPT['last_entry_in_db']=1
objs = {}
eids=""
for e in entries:
objs[e.id]=e
# get new eids for viewer.html
eids=eids+f"{e.id},"
# put locn data back into array format # put locn data back into array format
for face in obj.file_details.faces: for face in e.file_details.faces:
face.locn = json.loads(face.locn) face.locn = json.loads(face.locn)
return render_template("viewer.html", obj=obj, eids=eids, sels=sels ) eids=eids.rstrip(",")
lst = eids.split(',')
################################################################################ if 'next' in request.form:
# /viewprev -> moves to the prev entry and grabs data from DB and views it current = int(lst[0])
################################################################################ if 'prev' in request.form:
@app.route("/viewprev", methods=["GET","POST"]) current = int(lst[-1])
@login_required if 'last_entry_in_db' in OPT:
def viewprev(): # force this back to the last image of the last page - its the last in the DB, so set OPT for it
sels={} current = int(lst[-1])
sels['fname']='true' OPT['last_entry_in_db']=current
sels['faces']='true'
sels['distance']='true'
if request.method=="POST":
id = request.form['current']
eids=request.form['eids']
sels['fname']=request.form['fname']
sels['faces']=request.form['faces']
sels['distance']=request.form['distance']
lst = eids.split(',')
new_id = lst[lst.index(id)-1]
obj = Entry.query.join(File).filter(Entry.id==new_id).first()
# put locn data back into array format
for face in obj.file_details.faces:
face.locn = json.loads(face.locn)
return render_template("viewer.html", obj=obj, eids=eids, sels=sels )
return render_template("viewer.html", current=current, eids=eids, objs=objs, OPT=OPT )
################################################################################ ################################################################################
# /view/id -> grabs data from DB and views it # /view/id -> grabs data from DB and views it
################################################################################ ################################################################################
@app.route("/view/<id>", methods=["GET","POST"]) @app.route("/view/<id>", methods=["POST"])
@login_required @login_required
def view_img(id): def view_img(id):
obj = Entry.query.join(File).filter(Entry.id==id).first() OPT=SetViewingOptions( request )
# put locn data back into array format eids=request.form['eids'].rstrip(',')
for face in obj.file_details.faces: objs = {}
face.locn = json.loads(face.locn) lst = eids.split(',')
for e in Entry.query.join(File).filter(Entry.id.in_(lst)).all():
if request.method=="POST": objs[e.id]=e
eids=request.form['eids'] # put locn data back into array format
else: for face in e.file_details.faces:
eids='' face.locn = json.loads(face.locn)
sels={} return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT )
sels['fname']='true'
sels['faces']='true'
sels['distance']='true'
return render_template("viewer.html", obj=obj, eids=eids, sels=sels )
# route called from front/end - if multiple images are being rotated, each rotation == a separate call # route called from front/end - if multiple images are being rotated, each rotation == a separate call
# to this route (and therefore a separate rotate job. Each reponse allows the f/e to check the # to this route (and therefore a separate rotate job. Each reponse allows the f/e to check the
@@ -652,7 +638,7 @@ def custom_static(filename):
############################################################################### ###############################################################################
# This func creates a new filter in jinja2 to test to see if the Dir being # This func creates a new filter in jinja2 to test to see if the Dir being
# checked, is a top-level folder of 'cwd' # checked, is a top-level folder of 'OPT['cwd']'
################################################################################ ################################################################################
@app.template_filter('TopLevelFolderOf') @app.template_filter('TopLevelFolderOf')
def _jinja2_filter_toplevelfolderof(path, cwd): def _jinja2_filter_toplevelfolderof(path, cwd):

View File

@@ -107,7 +107,7 @@
<input type="hidden" id="search_size" name="size" value=""> <input type="hidden" id="search_size" name="size" value="">
<input type="hidden" id="search_folders" name="folders" value=""> <input type="hidden" id="search_folders" name="folders" value="">
<input type="hidden" id="search_cwd" name="cwd" value=""> <input type="hidden" id="search_cwd" name="cwd" value="">
<input id="term" class="form-control" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="term"> <input class="form-control" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="search_term">
<button class="btn btn-outline-success" type="submit">Search</button> <button class="btn btn-outline-success" type="submit">Search</button>
</form> </form>
</div class="navbar-nav"> </div class="navbar-nav">

View File

@@ -2,26 +2,26 @@
<div class="container-fluid"> <div class="container-fluid">
<h3 class="offset-2">{{page_title}}</h3> <h3 class="offset-2">{{page_title}}</h3>
<form id="main_form" method="POST"> <form id="main_form" method="POST">
<input id="offset" type="hidden" name="offset" value="{{offset}}"> <input id="offset" type="hidden" name="offset" value="{{OPT['offset']}}">
<input id="grouping" type="hidden" name="grouping" value=""> <input id="grouping" type="hidden" name="grouping" value="">
<input id="size" type="hidden" name="size" value=""> <input id="size" type="hidden" name="size" value="">
<input id="cwd" type="hidden" name="cwd" value=""> <input id="cwd" type="hidden" name="cwd" value="">
<input id="folders" type="hidden" name="folders" value="False"> <input id="folders" type="hidden" name="folders" value="False">
<div class="col col-auto"> <div class="col col-auto">
<div class="input-group"> <div class="input-group">
{{CreateSelect( "noo", noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-1 my-1")|safe }} {{CreateSelect( "noo", OPT['noo'], ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-1 my-1")|safe }}
{{CreateSelect( "how_many", how_many, ["10", "25", "50", "75", "100", "150", "200", "500"], "", "rounded-end py-1 my-1" )|safe }} {{CreateSelect( "how_many", OPT['how_many'], ["10", "25", "50", "75", "100", "150", "200", "500"], "", "rounded-end py-1 my-1" )|safe }}
<div class="mb-1 col my-auto d-flex justify-content-center"> <div class="mb-1 col my-auto d-flex justify-content-center">
{% set prv_disabled="" %} {% set prv_disabled="" %}
{% if offset|int == 0 %} {% if OPT['offset']|int == 0 %}
{% set prv_disabled="disabled" %} {% set prv_disabled="disabled" %}
{% endif %} {% endif %}
<button id="prev" {{prv_disabled}} name="prev" class="prev sm-txt btn btn-outline-secondary"> <button id="prev" {{prv_disabled}} name="prev" class="prev sm-txt btn btn-outline-secondary">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
</button> </button>
<span class="sm-txt my-auto">&nbsp;{{how_many}} files&nbsp;</span> <span class="sm-txt my-auto">&nbsp;{{OPT['how_many']}} files&nbsp;</span>
{% set nxt_disabled="" %} {% set nxt_disabled="" %}
{% if entry_data|length < how_many|int %} {% if entry_data|length < OPT['how_many']|int %}
{% set nxt_disabled="disabled" %} {% set nxt_disabled="disabled" %}
{% endif %} {% endif %}
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary"> <button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">

View File

@@ -6,38 +6,38 @@
<div class="container-fluid"> <div class="container-fluid">
<form id="main_form" method="POST"> <form id="main_form" method="POST">
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}"> <input type="hidden" name="cwd" id="cwd" value="{{OPT['cwd']}}">
{% if search_term is defined %} {% if search_term is defined %}
<input type="hidden" name="term" id="view_term" value="{{search_term}}"> <input type="hidden" name="search_term" id="view_term" value="{{search_term}}">
{% endif %} {% endif %}
<div class="d-flex row mb-2"> <div class="d-flex row mb-2">
{% if folders %} {% if OPT['folders'] %}
<div class="my-auto col col-auto"> <div class="my-auto col col-auto">
<span class="alert alert-primary py-2"> <span class="alert alert-primary py-2">
{% if "files_ip" in request.url %} {% if "files_ip" in request.url %}
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#import"/></svg> <svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#import"/></svg>
{% set tmp_path=cwd | replace( "static/Import", "" ) + "/" %} {% set tmp_path=OPT['cwd'] | replace( "static/Import", "" ) + "/" %}
{% elif "files_sp" in request.url %} {% elif "files_sp" in request.url %}
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#db"/></svg> <svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#db"/></svg>
{% set tmp_path=cwd | replace( "static/Storage", "" ) + "/" %} {% set tmp_path=OPT['cwd'] | replace( "static/Storage", "" ) + "/" %}
{% elif "files_rbp" in request.url %} {% elif "files_rbp" in request.url %}
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg> <svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#trash"/></svg>
{% set tmp_path=cwd | replace( "static/Bin", "" ) + "/" %} {% set tmp_path=OPT['cwd'] | replace( "static/Bin", "" ) + "/" %}
{% endif %} {% endif %}
{{tmp_path}}</span> {{tmp_path}}</span>
</div class="col my-auto"> </div class="col my-auto">
{% endif %} {% endif %}
<div class="col col-auto"> <div class="col col-auto">
<div class="input-group"> <div class="input-group">
{{CreateSelect( "noo", noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }} {{CreateSelect( "noo", OPT['noo'], ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)", "rounded-start py-2")|safe }}
{{CreateSelect( "how_many", how_many, ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }} {{CreateSelect( "how_many", OPT['how_many'], ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
{% if folders %} {% if OPT['folders'] %}
<input type="hidden" name="grouping" id="grouping" value="{{grouping}}"> <input type="hidden" name="grouping" id="grouping" value="{{OPT['grouping']}}">
{{CreateFoldersSelect( folders, "rounded-end" )|safe }} {{CreateFoldersSelect( OPT['folders'], "rounded-end" )|safe }}
{% else %} {% else %}
{{CreateFoldersSelect( folders )|safe }} {{CreateFoldersSelect( OPT['folders'] )|safe }}
<span class="sm-txt my-auto btn btn-outline-info disabled border-top border-bottom">grouped by:</span> <span class="sm-txt my-auto btn btn-outline-info disabled border-top border-bottom">grouped by:</span>
{{CreateSelect( "grouping", grouping, ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }} {{CreateSelect( "grouping", OPT['grouping'], ["None", "Day", "Week", "Month"], "", "rounded-end")|safe }}
{% endif %} {% endif %}
</div class="input-group"> </div class="input-group">
</div class="col"> </div class="col">
@@ -50,9 +50,9 @@
<button id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary"> <button id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
</button> </button>
<span class="sm-txt my-auto">&nbsp;{{how_many}} files&nbsp;</span> <span class="sm-txt my-auto">&nbsp;{{OPT['how_many']}} files&nbsp;</span>
{% set nxt_disabled="" %} {% set nxt_disabled="" %}
{% if entry_data|length < how_many|int %} {% if entry_data|length < OPT['how_many']|int %}
{% set nxt_disabled="disabled" %} {% set nxt_disabled="disabled" %}
{% endif %} {% endif %}
<button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary"> <button id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
@@ -72,31 +72,31 @@
</div> </div>
<div class="d-flex col col-auto justify-content-end"> <div class="d-flex col col-auto justify-content-end">
<div class="btn-group"> <div class="btn-group">
{% if size == "64" %} {% if OPT['size'] == "64" %}
{% set bt="btn-info text-white" %} {% set bt="btn-info text-white" %}
{% else %} {% else %}
{% set bt="btn-outline-info" %} {% set bt="btn-outline-info" %}
{% endif %} {% endif %}
<button id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,64); return false;">XS</button> <button id="64" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,64); return false;">XS</button>
{% if size == "96" %} {% if OPT['size'] == "96" %}
{% set bt="btn-info text-white" %} {% set bt="btn-info text-white" %}
{% else %} {% else %}
{% set bt="btn-outline-info" %} {% set bt="btn-outline-info" %}
{% endif %} {% endif %}
<button id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,96); return false;">S</button> <button id="96" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,96); return false;">S</button>
{% if size == "128" %} {% if OPT['size'] == "128" %}
{% set bt="btn-info text-white" %} {% set bt="btn-info text-white" %}
{% else %} {% else %}
{% set bt="btn-outline-info" %} {% set bt="btn-outline-info" %}
{% endif %} {% endif %}
<button id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,128); return false;">M</button> <button id="128" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,128); return false;">M</button>
{% if size == "192" %} {% if OPT['size'] == "192" %}
{% set bt="btn-info text-white" %} {% set bt="btn-info text-white" %}
{% else %} {% else %}
{% set bt="btn-outline-info" %} {% set bt="btn-outline-info" %}
{% endif %} {% endif %}
<button id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,192); return false;">L</button> <button id="192" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,192); return false;">L</button>
{% if size == "256" %} {% if OPT['size'] == "256" %}
{% set bt="btn-info text-white" %} {% set bt="btn-info text-white" %}
{% else %} {% else %}
{% set bt="btn-outline-info" %} {% set bt="btn-outline-info" %}
@@ -104,8 +104,8 @@
<button id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,256); return false;">XL</button> <button id="256" class="px-2 sm-txt sz-but btn {{bt}}" onClick="ChangeSize(this,256); return false;">XL</button>
</div class="btn-group"> </div class="btn-group">
</div class="col"> </div class="col">
<input id="offset" type="hidden" name="offset" value="{{offset}}"> <input id="offset" type="hidden" name="offset" value="{{OPT['offset']}}">
<input id="size" type="hidden" name="size" value="{{size}}"> <input id="size" type="hidden" name="size" value="{{OPT['size']}}">
</div class="form-row"> </div class="form-row">
{% set eids=namespace( str="" ) %} {% set eids=namespace( str="" ) %}
{# gather all the file eids and collect them in case we go gallery mode #} {# gather all the file eids and collect them in case we go gallery mode #}
@@ -120,59 +120,59 @@
<div class="row ms-2"> <div class="row ms-2">
{% set last = namespace(printed=0) %} {% set last = namespace(printed=0) %}
{# rare event of empty folder, still need to show back button #} {# rare event of empty folder, still need to show back button #}
{% if folders and entry_data|length == 0 %} {% if OPT['folders'] and entry_data|length == 0 %}
{% if cwd != root %} {% if OPT['cwd'] != OPT['root'] %}
<figure id="_back" class="dir entry m-1" ecnt="1" dir="{{cwd|ParentPath}}" type="Directory"> <figure id="_back" class="dir entry m-1" ecnt="1" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg> <svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
<figcaption class="figure-caption text-center">Back</figcaption> <figcaption class="figure-caption text-center">Back</figcaption>
</figure class="figure"> </figure class="figure">
<script>f=$('#_back'); w=f.find('svg').width(); f.find('figcaption').width(w);</script> <script>f=$('#_back'); w=f.find('svg').width(); f.find('figcaption').width(w);</script>
{% else %} {% else %}
<div class="col col-auto g-0 m-1"> <div class="col col-auto g-0 m-1">
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg> <svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% for obj in entry_data %} {% for obj in entry_data %}
{% if loop.index==1 and folders %} {% if loop.index==1 and OPT['folders'] %}
{% if cwd != root %} {% if OPT['cwd'] != OPT['root'] %}
<figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{cwd|ParentPath}}" type="Directory"> <figure class="col col-auto g-0 dir entry m-1" ecnt="{{loop.index}}" dir="{{OPT['cwd']|ParentPath}}" type="Directory">
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}" fill="currentColor"> <svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}" fill="currentColor">
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg> <use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back"/></svg>
<figcaption class="svg_cap figure-caption text-center">Back</figcaption> <figcaption class="svg_cap figure-caption text-center">Back</figcaption>
</figure class="figure"> </figure class="figure">
{% else %} {% else %}
{# create an even lighter-grey, unclickable back button - so folders dont jump around when you go into them #} {# create an even lighter-grey, unclickable back button - so folders dont jump around when you go into them #}
<div class="col col-auto g-0 m-1"> <div class="col col-auto g-0 m-1">
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg> <svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#folder_back_gray"/></svg>
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if not folders and obj.type.name == "Directory" %} {% if not OPT['folders'] and obj.type.name == "Directory" %}
{% continue %} {% continue %}
{% endif %} {% endif %}
{% if grouping == "Day" %} {% if OPT['grouping'] == "Day" %}
{% if last.printed != obj.file_details.day %} {% if last.printed != obj.file_details.day %}
<div class="row ps-3"><h6>Day: {{obj.file_details.day}} of {{obj.file_details.month}}/{{obj.file_details.year}}</h6></div> <div class="row ps-3"><h6>Day: {{obj.file_details.day}} of {{obj.file_details.month}}/{{obj.file_details.year}}</h6></div>
{% set last.printed = obj.file_details.day %} {% set last.printed = obj.file_details.day %}
{% endif %} {% endif %}
{% elif grouping == "Week" %} {% elif OPT['grouping'] == "Week" %}
{% if last.printed != obj.file_details.woy %} {% if last.printed != obj.file_details.woy %}
<div class="row ps-3"><h6>Week #: {{obj.file_details.woy}} of {{obj.file_details.year}}</h6></div> <div class="row ps-3"><h6>Week #: {{obj.file_details.woy}} of {{obj.file_details.year}}</h6></div>
{% set last.printed = obj.file_details.woy %} {% set last.printed = obj.file_details.woy %}
{% endif %} {% endif %}
{% elif grouping == "Month" %} {% elif OPT['grouping'] == "Month" %}
{% if last.printed != obj.file_details.month %} {% if last.printed != obj.file_details.month %}
<div class="row ps-3"><h6>Month: {{obj.file_details.month}} of {{obj.file_details.year}}</h6></div> <div class="row ps-3"><h6>Month: {{obj.file_details.month}} of {{obj.file_details.year}}</h6></div>
{% set last.printed = obj.file_details.month %} {% set last.printed = obj.file_details.month %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if obj.type.name != "Directory" %} {% if obj.type.name != "Directory" %}
{% if (not folders) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(cwd)) %} {% if (not OPT['folders']) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(OPT['cwd'])) %}
<figure id="{{obj.id}}" ecnt="{{loop.index}}" class="col col-auto g-0 figure entry m-1" path_type="{{obj.in_dir.in_path.type.name}}" size="{{obj.file_details.size_mb}}" hash="{{obj.file_details.hash}}" in_dir="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" pretty_date="{{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}}" type="{{obj.type.name}}"> <figure id="{{obj.id}}" ecnt="{{loop.index}}" class="col col-auto g-0 figure entry m-1" path_type="{{obj.in_dir.in_path.type.name}}" size="{{obj.file_details.size_mb}}" hash="{{obj.file_details.hash}}" in_dir="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" pretty_date="{{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}}" type="{{obj.type.name}}">
{% if obj.type.name=="Image" %} {% if obj.type.name=="Image" %}
<div style="position:relative; width:100%"> <div style="position:relative; width:100%">
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a> <a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{OPT['size']}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
{% if search_term is defined %} {% if search_term is defined %}
<div style="position:absolute; bottom: 0px; left: 2px;"> <div style="position:absolute; bottom: 0px; left: 2px;">
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#{{LocationIcon(obj)}}"/></svg> <svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#{{LocationIcon(obj)}}"/></svg>
@@ -184,7 +184,7 @@
</div> </div>
{% elif obj.type.name == "Video" %} {% elif obj.type.name == "Video" %}
<div style="position:relative; width:100%"> <div style="position:relative; width:100%">
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a> <a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" style="display:block" height="{{OPT['size']}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
<div style="position:absolute; top: 0px; left: 2px;"> <div style="position:absolute; top: 0px; left: 2px;">
<svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#film"/></svg> <svg width="16" height="16" fill="white"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#film"/></svg>
</div> </div>
@@ -198,16 +198,16 @@
</figure> </figure>
{% endif %} {% endif %}
{% else %} {% else %}
{% if folders %} {% if OPT['folders'] %}
{% if obj.dir_details.rel_path | length %} {% if obj.dir_details.rel_path | length %}
{% set dirname=obj.dir_details.in_path.path_prefix+'/'+obj.dir_details.rel_path %} {% set dirname=obj.dir_details.in_path.path_prefix+'/'+obj.dir_details.rel_path %}
{% else %} {% else %}
{% set dirname=obj.dir_details.in_path.path_prefix %} {% set dirname=obj.dir_details.in_path.path_prefix %}
{% endif %} {% endif %}
{# if this dir is the toplevel of the cwd, show the folder icon #} {# if this dir is the toplevel of the cwd, show the folder icon #}
{% if dirname| TopLevelFolderOf(cwd) %} {% if dirname| TopLevelFolderOf(OPT['cwd']) %}
<figure class="col col-auto g-0 figure dir entry m-1" id={{obj.id}} ecnt={{loop.index}} dir="{{dirname}}" type="Directory"> <figure class="col col-auto g-0 figure dir entry m-1" id={{obj.id}} ecnt={{loop.index}} dir="{{dirname}}" type="Directory">
<svg class="svg" width="{{size|int-22}}" height="{{size|int-22}}" fill="currentColor"> <svg class="svg" width="{{OPT['size']|int-22}}" height="{{OPT['size']|int-22}}" fill="currentColor">
<use xlink:href="{{url_for('internal', filename='icons.svg')}}#Directory"/></svg> <use xlink:href="{{url_for('internal', filename='icons.svg')}}#Directory"/></svg>
<figcaption class="svg_cap figure-caption text-center text-wrap text-break">{{obj.name}}</figcaption> <figcaption class="svg_cap figure-caption text-center text-wrap text-break">{{obj.name}}</figcaption>
</figure class="figure"> </figure class="figure">
@@ -220,13 +220,13 @@
</div> </div>
<div class="container-fluid"> <div class="container-fluid">
<form id="nav_form" method="POST""> <form id="nav_form" method="POST"">
<input type="hidden" name="cwd" id="cwd" value="{{cwd}}"> <input type="hidden" name="cwd" id="cwd" value="{{OPT['cwd']}}">
<div class="row"> <div class="row">
<div class="col my-auto d-flex justify-content-center"> <div class="col my-auto d-flex justify-content-center">
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); })" id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary"> <button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); })" id="prev" name="prev" class="prev sm-txt btn btn-outline-secondary">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
</button> </button>
<span class="sm-txt my-auto">&nbsp;{{how_many}} files&nbsp;</span> <span class="sm-txt my-auto">&nbsp;{{OPT['how_many']}} files&nbsp;</span>
<button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); });" id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary"> <button onClick="$.each( $('#main_form').serializeArray() , function( index, value ) { $('#nav_form').append( '<input type=hidden name=' + value['name'] +' value='+value['value'] + '>' ); });" id="next" {{nxt_disabled}} name="next" class="next sm-txt btn btn-outline-secondary">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
</button> </button>
@@ -242,13 +242,32 @@
$('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; }); $('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; });
$(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() }); $(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() });
$('.figure').dblclick( function CallViewRouteWrapper()
function() { {
s='<form id="_fm" method="POST" action="/view/' + $(this).attr("id"); CallViewRoute( $(this).attr("id") )
s+='"><input type="hidden" name="eids" value="'+$("#eids").val() + '"></form>' }
$(s).appendTo('body').submit(); }
);
function CallViewRoute(id)
{
s='<form id="_fm" method="POST" action="/view/' + id + '">'
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
s+='<input type="hidden" name="noo" value="{{OPT['noo']}}">'
s+='<input type="hidden" name="cwd" value="{{OPT['cwd']}}">'
s+='<input type="hidden" name="root" value="{{OPT['root']}}">'
s+='<input type="hidden" name="size" value="{{OPT['size']}}">'
s+='<input type="hidden" name="grouping" value="{{OPT['grouping']}}">'
s+='<input type="hidden" name="offset" value="{{OPT['offset']}}">'
s+='<input type="hidden" name="folders" value="{{OPT['folders']}}">'
s+='<input type="hidden" name="how_many" value="{{OPT['how_many']}}">'
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
{% if search_term is defined %}
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
{% endif %}
s+='</form>'
$(s).appendTo('body').submit();
}
$('.figure').dblclick( CallViewRouteWrapper )
// different context menu on files // different context menu on files
$.contextMenu({ $.contextMenu({
@@ -307,11 +326,7 @@ $.contextMenu({
return { return {
callback: function( key, options) { callback: function( key, options) {
if( key == "details" ) { DetailsDBox() } if( key == "details" ) { DetailsDBox() }
if( key == "view" ) { if( key == "view" ) { CallViewRoute( $(this).attr('id') ) }
s='<form id="_fm" method="POST" action="/view/' + $(this).attr("id");
s+='"><input type="hidden" name="eids" value="'+$("#eids").val() + '"></form>'
$(s).appendTo('body').submit();
}
if( key == "move" ) { MoveDBox() } if( key == "move" ) { MoveDBox() }
if( key == "del" ) { DelDBox('Delete') } if( key == "del" ) { DelDBox('Delete') }
if( key == "undel") { DelDBox('Restore') } if( key == "undel") { DelDBox('Restore') }
@@ -329,7 +344,7 @@ $.contextMenu({
$(document).ready(function() { $(document).ready(function() {
if( {{offset}} == 0 ) if( {{OPT['offset']}} == 0 )
{ {
$('.prev').addClass('disabled') $('.prev').addClass('disabled')
$('.prev').prop('disabled', true) $('.prev').prop('disabled', true)

View File

@@ -21,6 +21,33 @@
var grayscale=0 var grayscale=0
var throbber=0 var throbber=0
var objs=[]
var current={{current}}
var eids="{{eids}}"
var eid_lst=eids.split(",")
{% for id in objs %}
e=new Object()
e.name = "{{objs[id].name}}"
e.url = "{{objs[id].FullPathOnFS()}}"
{% if objs[id].file_details.faces %}
e.face_model="{{objs[id].file_details.faces[0].facefile_lnk.model_used}}"
{% endif %}
e.faces=[]
{% for face in objs[id].file_details.faces %}
data = {
'x': '{{face.locn[3]}}', 'y': '{{face.locn[0]}}',
'w': '{{face.locn[1]-face.locn[3]}}', 'h':'{{face.locn[2]-face.locn[0]}}'
}
{% if face.refimg %}
data['who']='{{face.refimg.person.tag}}'
data['distance']="{{face.refimg_lnk.face_distance|round(2)}}"
{% endif %}
e.faces.push( data )
{% endfor %}
objs[{{id}}]=e
{% endfor %}
function NewWidth() function NewWidth()
{ {
w_r=im.width/(window.innerWidth*gap) w_r=im.width/(window.innerWidth*gap)
@@ -61,20 +88,48 @@
else else
$('#throbber').hide(); $('#throbber').hide();
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
if( $('#fname_toggle').prop('checked' ) )
{
$('.figcaption').attr('style', 'display:show' )
// reset fname for new image (if navigated left/right to get here)
$('#fname').html(objs[current].name)
}
else
$('.figcaption').attr('style', 'display:none' )
// if we have faces, the enable the toggles, otherwise disable them
// and reset model select too
if( objs[current].faces.length )
{
$('#faces').attr('disabled', false)
$('#distance').attr('disabled', false)
$('#model').val( Number(objs[current].face_model) )
}
else
{
$('#faces').attr('disabled', true)
$('#distance').attr('disabled', true)
// if no faces, then model is N/A (always 1st element - or 0 in select)
$('#model').val(0)
}
// okay, we want faces drawn so lets do it
if( $('#faces').prop('checked') ) if( $('#faces').prop('checked') )
{ {
// draw rect on each face // draw rect on each face
for( i=0; i<faces.length; i++ ) for( i=0; i<objs[current].faces.length; i++ )
{ {
x = faces[i].x / ( im.width/canvas.width ) x = objs[current].faces[i].x / ( im.width/canvas.width )
y = faces[i].y / ( im.height/canvas.height ) y = objs[current].faces[i].y / ( im.height/canvas.height )
w = faces[i].w / ( im.width/canvas.width ) w = objs[current].faces[i].w / ( im.width/canvas.width )
h = faces[i].h / ( im.height/canvas.height ) h = objs[current].faces[i].h / ( im.height/canvas.height )
context.beginPath() context.beginPath()
context.rect( x, y, w, h ) context.rect( x, y, w, h )
context.lineWidth = 2 context.lineWidth = 2
context.strokeStyle = 'green' context.strokeStyle = 'green'
if( faces[i].who ) if( objs[current].faces[i].who )
{ {
// finish face box, need to clear out new settings for // finish face box, need to clear out new settings for
// transparent backed-name tag // transparent backed-name tag
@@ -83,9 +138,9 @@
context.lineWidth = 0.1 context.lineWidth = 0.1
context.font = "30px Arial" context.font = "30px Arial"
context.globalAlpha = 0.6 context.globalAlpha = 0.6
str=faces[i].who str=objs[current].faces[i].who
if( $('#distance').prop('checked') ) if( $('#distance').prop('checked') )
str += "("+faces[i].distance+")" str += "("+objs[current].faces[i].distance+")"
bbox = context.measureText(str); bbox = context.measureText(str);
f_h=bbox.fontBoundingBoxAscent f_h=bbox.fontBoundingBoxAscent
@@ -109,8 +164,8 @@
context.font = "14px Arial" context.font = "14px Arial"
context.textAlign = "center" context.textAlign = "center"
context.fillStyle = "black" context.fillStyle = "black"
context.fillText( 'x=' + faces[i].x + ', y=' + faces[i].y, x+w/2, y-2) context.fillText( 'x=' + objs[current].faces[i].x + ', y=' + objs[current].faces[i].y, x+w/2, y-2)
context.fillText( 'x=' + faces[i].x + ', y=' + faces[i].y, x+w/2, y-2) context.fillText( 'x=' + objs[current].faces[i].x + ', y=' + objs[current].faces[i].y, x+w/2, y-2)
} }
*/ */
context.stroke(); context.stroke();
@@ -129,128 +184,133 @@
DrawImg() DrawImg()
} }
function CallViewListRoute(dir)
{
s='<form id="_fmv" method="POST" action="/viewlist">'
s+='<input type="hidden" name="eids" value="'+$("#eids").val() + '">'
s+='<input type="hidden" name="noo" value="{{OPT['noo']}}">'
s+='<input type="hidden" name="cwd" value="{{OPT['cwd']}}">'
s+='<input type="hidden" name="root" value="{{OPT['root']}}">'
s+='<input type="hidden" name="size" value="{{OPT['size']}}">'
s+='<input type="hidden" name="grouping" value="{{OPT['grouping']}}">'
s+='<input type="hidden" name="offset" value="{{OPT['offset']}}">'
s+='<input type="hidden" name="folders" value="{{OPT['folders']}}">'
s+='<input type="hidden" name="how_many" value="{{OPT['how_many']}}">'
s+='<input type="hidden" name="orig_url" value="{{request.path}}">'
s+='<input type="hidden" name="' + dir + '" value="1">'
{% if search_term is defined %}
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
{% endif %}
s+='</form>'
$(s).appendTo('body')
$('#_fmv').submit();
}
</script> </script>
<div id="viewer" class="container-fluid"> <div id="viewer" class="container-fluid">
{% set max=eids.split(',')|length %} {% set max=eids.split(',')|length %}
<input type="hidden" name="eids" value={{eids}}> <input type="hidden" name="eids" value={{eids}}>
<div class="row"> <div class="row">
{% if eids.find(obj.id|string) > 0 %} <button title="Show previous image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="la"
<form id="prev" class="col col-auto" action="/viewprev" method="POST">
<input id="current" type="hidden" name="current" value="{{obj.id}}">
<input type="hidden" name="eids" value="{{eids}}">
<input id="prev_fname" type="hidden" name="fname" value="">
<input id="prev_faces" type="hidden" name="faces" value="">
<input id="prev_distance" type="hidden" name="distance" value="">
<button title="Show previous image" class="btn btn-outline-info h-75" id="la"
onClick=" onClick="
$('#prev_fname').val($('#fname').prop('checked')) cidx = eid_lst.indexOf(current.toString())
$('#prev_faces').val($('#faces').prop('checked')) prev=cidx-1
$('#prev_distance').val($('#distance').prop('checked')) if( prev < 0 )
{
if( {{OPT['offset']}} )
{
CallViewListRoute('prev')
return
}
else
{
$('#la').attr('disabled', true )
prev=0
}
}
$('#ra').attr('disabled', false )
current=eid_lst[prev]
im.src='http://mara.ddp.net:5000/' + objs[current].url
"> ">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#prev"/></svg>
</button> </button>
</form id="prev"> {% if objs[current].type.name == "Image" %}
{% endif %} <figure class="col col-auto border border-info rounded m-0 p-1" id="figure">
{% if obj.type.name == "Image" %} <canvas id="canvas"></canvas>
<figure class="col col-auto border border-info rounded m-0 p-1" id="figure"> <img id="throbber" src="{{url_for('internal', filename='throbber.gif')}}" style="display:none;">
<canvas id="canvas"></canvas> <script>
<img id="throbber" src="{{url_for('internal', filename='throbber.gif')}}" style="display:none;"> var im=new Image();
im.onload=DrawImg
im.src="http://mara.ddp.net:5000/" + objs[current].url
var context = canvas.getContext('2d')
window.addEventListener('resize', DrawImg, false);
</script>
<figcaption class="figure-caption text-center text-wrap text-break"><span id="fname">{{objs[current].name}}</span></figcaption>
</figure>
{% elif objs[current].type.name == "Video" %}
<video id="_v" controls>
<source src="http://mara.ddp.net:5000/{{objs[current].FullPathOnFS()}}" type="video/mp4">
Your browser does not support the video tag.
</video>
<script> <script>
var im=new Image(); window.addEventListener('resize', ResizeVideo, false);
im.onload=DrawImg ResizeVideo()
im.src="/{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"
var faces=[]
{% for face in obj.file_details.faces %}
data = {
'x': '{{face.locn[3]}}', 'y': '{{face.locn[0]}}',
'w': '{{face.locn[1]-face.locn[3]}}', 'h':'{{face.locn[2]-face.locn[0]}}'
}
{% if face.refimg %}
data['who']='{{face.refimg.person.tag}}'
data['distance']="{{face.refimg_lnk.face_distance|round(2)}}"
data['model']="{{face.facefile_lnk.model_used}}"
{% endif %}
faces.push( data )
{% endfor %}
var context = canvas.getContext('2d')
window.addEventListener('resize', DrawImg, false);
</script> </script>
<figcaption class="figure-caption text-center text-wrap text-break"
{% if sels['fname']=='false' %}
style="display:none"
{% endif %}
>{{obj.name}}
</figcaption>
</figure>
{% elif obj.type.name == "Video" %}
<video id="_v" controls>
<source src="/{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}" type="video/mp4">
Your browser does not support the video tag.
</video>
<script>
window.addEventListener('resize', ResizeVideo, false);
ResizeVideo()
</script>
{% endif %}
{% for eid in eids.split(',') %}
{% if loop.index == max-1 %}
{% if eid|int != obj.id %}
<form id="next" class="col col-auto" action="/viewnext" method="POST">
<input type="hidden" name="current" value="{{obj.id}}">
<input type="hidden" name="eids" value="{{eids}}">
<input id="next_fname" type="hidden" name="fname" value="">
<input id="next_faces" type="hidden" name="faces" value="">
<input id="next_distance" type="hidden" name="distance" value="">
<button title="Show next image" class="col col-auto btn btn-outline-info h-75" id="ra"
onClick="
$('#next_fname').val($('#fname').prop('checked'))
$('#next_faces').val($('#faces').prop('checked'))
$('#next_distance').val($('#distance').prop('checked'))
">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
</button>
</form id="next">
{% endif %}
{% endif %} {% endif %}
{% endfor %}
<button title="Show next image" class="col-auto btn btn-outline-info px-2" style="padding: 10%" id="ra"
onClick="
{% if 'last_entry_in_db' in OPT %}
if( current == {{OPT['last_entry_in_db']}} )
{
$('#ra').attr('disabled', true )
return
}
{% endif %}
cidx = eid_lst.indexOf(current.toString())
if( cidx < eid_lst.length-1 )
{
current=eid_lst[cidx+1]
im.src='http://mara.ddp.net:5000/' + objs[current].url
$('#la').attr('disabled', false )
}
else
{
{# only go next route if list contains as many elements as we asked to display... can be more than how_many on any page in reality, as its really how_many per dir? #}
if( eid_lst.length >= {{OPT['how_many']}} )
CallViewListRoute('next')
}
">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
</button>
</div id="/form-row"> </div id="/form-row">
{# use this for color of toggles: https://www.codeply.com/p/4sL9uhevwJ #} {# use this for color of toggles: https://www.codeply.com/p/4sL9uhevwJ #}
<div class="row"> <div class="row">
{# this whole div, just takes up the same space as the left button and is hidden for alignment only #} {# this whole div, just takes up the same space as the left button and is hidden for alignment only #}
<div class="col col-auto"> <div class="col-auto px-0">
<button class="btn btn-outline-info" disabled style="visibility:hidden"> <button class="btn btn-outline-info px-2" disabled style="visibility:hidden">
<svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg> <svg width="16" height="16" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#next"/></svg>
</button> </button>
</div> </div>
<span class="col col-auto my-auto">Show:</span> <span class="col-auto my-auto">Show:</span>
<div title="Toggle showing filename" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5"> <div title="Toggle showing filename" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5">
<input class="form-check-input" type="checkbox" id="fname" onChange="$('.figure-caption').toggle()" <input class="form-check-input" type="checkbox" id="fname_toggle" onChange="$('.figure-caption').toggle()" checked>
{% if sels['fname']=='true' %} checked {% endif %} > <label class="form-check-label ps-1" for="fname_toggle">Filename</label>
<label class="form-check-label ps-1" for="fname">Filename</label>
</div> </div>
<div title="Toggle showing matched faces" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5"> <div title="Toggle showing matched faces" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5">
<input class="form-check-input" type="checkbox" onChange="FaceToggle()" id="faces" <input class="form-check-input" type="checkbox" onChange="FaceToggle()" id="faces">
{% if not obj.file_details.faces %} disabled {% endif %}
{% if sels['faces']=='true' %} checked {% endif %}
>
<label class="form-check-label ps-1" for="faces">Faces</label> <label class="form-check-label ps-1" for="faces">Faces</label>
</div> </div>
<div title="Toggle showing 'distance' on matched faces" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5"> <div title="Toggle showing 'distance' on matched faces" class="d-flex form-check form-switch border border-info rounded col col-auto my-auto py-1 justify-content-center ps-5">
<input class="form-check-input" type="checkbox" onChange="DrawImg()" id="distance" <input class="form-check-input" type="checkbox" onChange="DrawImg()" id="distance">
{% if not obj.file_details.faces or sels['faces']=='false' %} disabled {% endif %}
{% if sels['distance']=='true' %} checked {% endif %}
>
<label class="form-check-label ps-1" for="distance">Distance</label> <label class="form-check-label ps-1" for="distance">Distance</label>
</div> </div>
<div title="Change the model used to detect faces" class="col col-auto my-auto"> <div title="Change the model used to detect faces" class="col col-auto my-auto">
AI Model: AI Model:
{% if not obj.file_details.faces %} {# can use 0 as default, it will be (re)set correctly in DrawImg() anyway #}
{{CreateSelect( "model", 0, ["N/A", "normal", "slow/accurate"], "", "rounded norm-txt", [0,1,2])|safe }} {{CreateSelect( "model", 0, ["N/A", "normal", "slow/accurate"], "", "rounded norm-txt", [0,1,2])|safe }}
{% else %}
{{CreateSelect( "model", obj.file_details.faces[0].facefile_lnk.model_used, ["normal", "slow/accurate"], "", "rounded norm-txt", [1,2])|safe }}
{% endif %}
</div> </div>
<div class="col col-auto pt-1"> <div class="col col-auto pt-1">
<button class="btn btn-outline-info p-1" title="Rotate by 90 degrees" onClick="Transform(90)"> <button class="btn btn-outline-info p-1" title="Rotate by 90 degrees" onClick="Transform(90)">
@@ -268,7 +328,7 @@
<button class="btn btn-outline-info p-1" title="Flip vertically" onClick="Transform('flipv')"> <button class="btn btn-outline-info p-1" title="Flip vertically" onClick="Transform('flipv')">
<svg width="28" height="28" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#flip_v"/></svg> <svg width="28" height="28" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#flip_v"/></svg>
</button> </button>
<button class="btn btn-outline-info p-1" title="View in Fullscreen mode" onClick="document.getElementById('canvas').requestFullscreen()"> <button class="btn btn-outline-info p-1" title="View in Fullscreen mode" onClick="$('#prev_fullscreen').val('true'); $('#next_fullscreen').val('true'); document.getElementById('canvas').requestFullscreen()">
<svg width="28" height="28" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#fullscreen"/></svg> <svg width="28" height="28" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#fullscreen"/></svg>
</button> </button>
</div> </div>
@@ -300,5 +360,8 @@ $( document ).keydown(function(event) {
return; // Quit when this doesn't handle the key event. return; // Quit when this doesn't handle the key event.
} }
}); });
{% if OPT['fullscreen']=='true' %}
$( document ).ready ( function() { document.getElementById('canvas').requestFullscreen() } )
{% endif %}
</script> </script>
{% endblock script_content %} {% endblock script_content %}