renamed pa_pref to better named pa_user_state, changed code to adapt and made new_view and viewlist work with newer Options/pa_user_state - still more work but it should be functional again
This commit is contained in:
14
TODO
14
TODO
@@ -1,12 +1,20 @@
|
|||||||
## GENERAL
|
## GENERAL
|
||||||
|
* for below.. make Options( request )
|
||||||
|
- know that a view is a "path", dont rely on orig_url
|
||||||
|
- remove all "Options()" that are not set by a user-choice in the F/E and just make sure new "OPtions" sets all defaults as needed
|
||||||
|
-- viewlist can work out new view_eids server side, and pass them back as json data
|
||||||
|
- 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
|
||||||
|
|
||||||
* going forward into search page (and probably all POSTs) does not work
|
* going forward into search page (and probably all POSTs) does not work
|
||||||
don't render_template instead do a redirect to a GET of the new, or list? for del...
|
don't render_template instead do a redirect to a GET of the new, or list? for del...
|
||||||
files.py:@app.route("/view/<id>", methods=["POST"])
|
files.py:@app.route("/view/<id>", methods=["POST"])
|
||||||
job.py:@app.route("/jobs", methods=["GET", "POST"])
|
- first pass -- fails on storage in prod (view_eids was NONE, but prefs had content, odd... ALSO in dev, it did have a list but the img we were viewing was not in the list!
|
||||||
job.py:@app.route("/job/<id>", methods=["GET","POST"])
|
|
||||||
files.py:@app.route("/fix_dups", methods=["POST"])
|
|
||||||
files.py:@app.route("/viewlist", methods=["POST"])
|
files.py:@app.route("/viewlist", methods=["POST"])
|
||||||
-- this will need a total rewrite for viewer to handle fullscreen across offset/size boundaries so fix that instead
|
-- this will need a total rewrite for viewer to handle fullscreen across offset/size boundaries so fix that instead
|
||||||
|
job.py:@app.route("/jobs", methods=["GET", "POST"])
|
||||||
|
job.py:@app.route("/job/<id>", methods=["GET","POST"])
|
||||||
|
-- these ned to store 'job prefs' somewhere...
|
||||||
|
files.py:@app.route("/fix_dups", methods=["POST"])
|
||||||
|
|
||||||
* optim to not run_ai_on_* for scan, needs to make sure last run_ai_on actually ran/worked - might have failed (or in my case was marked stale and I cancelled it)
|
* optim to not run_ai_on_* for scan, needs to make sure last run_ai_on actually ran/worked - might have failed (or in my case was marked stale and I cancelled it)
|
||||||
-- also the case for get file details though, need to make sure last one was completed
|
-- also the case for get file details though, need to make sure last one was completed
|
||||||
|
|||||||
33
files.py
33
files.py
@@ -20,7 +20,7 @@ import re
|
|||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from options import Options
|
from states import Options
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Local Class imports
|
# Local Class imports
|
||||||
@@ -526,6 +526,9 @@ def viewlist():
|
|||||||
objs = {}
|
objs = {}
|
||||||
eids=""
|
eids=""
|
||||||
for e in entries:
|
for e in entries:
|
||||||
|
if not e.file_details:
|
||||||
|
print( f"seems {e.name} is not a file? -- {e.type}" )
|
||||||
|
continue
|
||||||
objs[e.id]=e
|
objs[e.id]=e
|
||||||
# get new eids for viewer.html
|
# get new eids for viewer.html
|
||||||
eids=eids+f"{e.id},"
|
eids=eids+f"{e.id},"
|
||||||
@@ -550,14 +553,22 @@ def viewlist():
|
|||||||
def newview_img(id):
|
def newview_img(id):
|
||||||
OPT=Options( request )
|
OPT=Options( request )
|
||||||
objs = {}
|
objs = {}
|
||||||
lst = OPT.view_eids.split(',')
|
print( OPT )
|
||||||
print( f"lst={lst}" )
|
entries=GetEntries( OPT )
|
||||||
for e in Entry.query.join(File).filter(Entry.id.in_(lst)).all():
|
eids=""
|
||||||
|
for e in entries:
|
||||||
|
print( f"in loop deal with: {e.id}")
|
||||||
objs[e.id]=e
|
objs[e.id]=e
|
||||||
|
eids += f"{e.id},"
|
||||||
|
if not e.file_details:
|
||||||
|
print( f"seems {e.name} is not a file? -- {e.type}" )
|
||||||
|
continue
|
||||||
# put locn data back into array format
|
# put locn data back into array format
|
||||||
for face in e.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", current=int(id), eids=OPT.view_eids, objs=objs, OPT=OPT )
|
print("now render the viewer" )
|
||||||
|
eids=eids.rstrip(",")
|
||||||
|
return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT )
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# /view/id -> grabs data from DB and views it
|
# /view/id -> grabs data from DB and views it
|
||||||
@@ -566,17 +577,7 @@ def newview_img(id):
|
|||||||
@login_required
|
@login_required
|
||||||
def view_img(id):
|
def view_img(id):
|
||||||
OPT=Options( request )
|
OPT=Options( request )
|
||||||
# return redirect( "/new_view/" + id );
|
return redirect( "/new_view/" + id );
|
||||||
objs = {}
|
|
||||||
OPT.view_eids = request.form['eids'].rstrip(',')
|
|
||||||
lst = OPT.view_eids.split(',')
|
|
||||||
print( f"lst={lst}" )
|
|
||||||
for e in Entry.query.join(File).filter(Entry.id.in_(lst)).all():
|
|
||||||
objs[e.id]=e
|
|
||||||
# put locn data back into array format
|
|
||||||
for face in e.file_details.faces:
|
|
||||||
face.locn = json.loads(face.locn)
|
|
||||||
return render_template("viewer.html", current=int(id), eids=OPT.view_eids, objs=objs, OPT=OPT )
|
|
||||||
|
|
||||||
# route called from front/end - if multiple images are being transformed, each transorm == a separate call
|
# route called from front/end - if multiple images are being transformed, each transorm == a separate call
|
||||||
# to this route (and therefore a separate transorm job. Each reponse allows the f/e to check the
|
# to this route (and therefore a separate transorm job. Each reponse allows the f/e to check the
|
||||||
|
|||||||
173
options.py
173
options.py
@@ -1,173 +0,0 @@
|
|||||||
from settings import Settings, SettingsRBPath, SettingsIPath, SettingsSPath
|
|
||||||
from flask import request, render_template, redirect, url_for
|
|
||||||
from flask_login import login_required, current_user
|
|
||||||
from main import db, app, ma
|
|
||||||
from shared import PA
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# PA_PREF: preference data for a given user / path_type combo, so a given user
|
|
||||||
# and their prefs for say the import path(s) and storage path(s) etc, each
|
|
||||||
# path_type has different defaults, and keeping those works better
|
|
||||||
################################################################################
|
|
||||||
class PA_PREF(db.Model):
|
|
||||||
__tablename__ = "pa_pref"
|
|
||||||
pa_user_dn = db.Column(db.String, db.ForeignKey('pa_user.dn'), primary_key=True )
|
|
||||||
path_type = db.Column(db.String, primary_key=True, unique=False, nullable=False )
|
|
||||||
noo = db.Column(db.String, unique=False, nullable=False )
|
|
||||||
grouping = db.Column(db.String, unique=False, nullable=False )
|
|
||||||
how_many = db.Column(db.Integer, unique=False, nullable=False )
|
|
||||||
st_offset = db.Column(db.Integer, unique=False, nullable=False )
|
|
||||||
size = db.Column(db.Integer, unique=False, nullable=False )
|
|
||||||
folders = db.Column(db.Boolean, unique=False, nullable=False )
|
|
||||||
fullscreen = db.Column(db.Boolean, unique=False, nullable=False )
|
|
||||||
root = db.Column(db.String, unique=False, nullable=False )
|
|
||||||
cwd = db.Column(db.String, unique=False, nullable=False )
|
|
||||||
view_eids = db.Column(db.String, unique=False, nullable=False )
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f"<pa_user_dn: {self.pa_user_dn}, path_type: {self.path_type}, noo: {self.noo}, grouping: {self.grouping}, how_many: {self.how_many}, st_offset: {self.st_offset}, size: {self.size}, folders: {self.folders}, root: {self.root}, cwd: {self.cwd}, view_eids: {self.view_eids}>"
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Options: class to store set of default values for viewing (order/size, etc.)
|
|
||||||
# and if a request object (from a POST) is passed in, it returns those instead
|
|
||||||
# it also handles the cwd appropriately, paths, fullscreen, search, etc.
|
|
||||||
################################################################################
|
|
||||||
class Options(PA):
|
|
||||||
def __init__(self, request):
|
|
||||||
if 'orig_url' in request.form:
|
|
||||||
url = request.form['orig_url']
|
|
||||||
if 'eids' in request.form:
|
|
||||||
print( "setting view_eids due to form" )
|
|
||||||
self.view_eids = request.form['eids'].rstrip(',')
|
|
||||||
else:
|
|
||||||
url = request.path
|
|
||||||
print( "setting view_eids due to null (for now)" )
|
|
||||||
self.view_eids=""
|
|
||||||
self.orig_url=url
|
|
||||||
if 'files_sp' in url:
|
|
||||||
self.path_type = 'Storage'
|
|
||||||
self.paths = SettingsSPath()
|
|
||||||
pref=PA_PREF.query.filter(PA_PREF.pa_user_dn==current_user.dn,PA_PREF.path_type==self.path_type).first()
|
|
||||||
if pref:
|
|
||||||
self.folders=pref.folders
|
|
||||||
self.noo=pref.noo
|
|
||||||
else:
|
|
||||||
self.folders=True
|
|
||||||
self.noo="A to Z"
|
|
||||||
elif 'files_rbp' in url:
|
|
||||||
self.path_type = 'Bin'
|
|
||||||
self.paths = []
|
|
||||||
self.paths.append(SettingsRBPath())
|
|
||||||
pref=PA_PREF.query.filter(PA_PREF.pa_user_dn==current_user.dn,PA_PREF.path_type==self.path_type).first()
|
|
||||||
if pref:
|
|
||||||
self.folders=pref.folders
|
|
||||||
self.noo=pref.noo
|
|
||||||
else:
|
|
||||||
self.folders=True
|
|
||||||
self.noo="A to Z"
|
|
||||||
elif 'search' in url:
|
|
||||||
self.path_type = 'Search'
|
|
||||||
self.paths = None
|
|
||||||
pref=PA_PREF.query.filter(PA_PREF.pa_user_dn==current_user.dn,PA_PREF.path_type==self.path_type).first()
|
|
||||||
if pref:
|
|
||||||
self.folders=pref.folders
|
|
||||||
self.noo=pref.noo
|
|
||||||
else:
|
|
||||||
self.folders=False
|
|
||||||
self.noo="Oldest"
|
|
||||||
else:
|
|
||||||
self.path_type = 'Import'
|
|
||||||
self.paths = SettingsIPath()
|
|
||||||
pref=PA_PREF.query.filter(PA_PREF.pa_user_dn==current_user.dn,PA_PREF.path_type==self.path_type).first()
|
|
||||||
if pref:
|
|
||||||
self.folders=pref.folders
|
|
||||||
self.noo=pref.noo
|
|
||||||
self.view_eids=pref.view_eids
|
|
||||||
else:
|
|
||||||
self.folders=False
|
|
||||||
self.noo="Oldest"
|
|
||||||
|
|
||||||
if pref:
|
|
||||||
self.grouping=pref.grouping
|
|
||||||
self.how_many=pref.how_many
|
|
||||||
self.offset=pref.st_offset
|
|
||||||
self.size=pref.size
|
|
||||||
self.root=pref.root
|
|
||||||
self.cwd=pref.cwd
|
|
||||||
else:
|
|
||||||
self.grouping="None"
|
|
||||||
self.how_many="50"
|
|
||||||
self.offset="0"
|
|
||||||
self.size="128"
|
|
||||||
self.root='static/' + self.path_type
|
|
||||||
self.cwd=self.root
|
|
||||||
|
|
||||||
|
|
||||||
# the above are defaults, if we are here, then we have current values, use them instead if they are set -- AI: searches dont set them so then we use those in the DB first
|
|
||||||
if request.method=="POST":
|
|
||||||
if 'noo' in request.form:
|
|
||||||
self.noo=request.form['noo']
|
|
||||||
if 'how_many' in request.form:
|
|
||||||
self.how_many=request.form['how_many']
|
|
||||||
if 'offset' in request.form:
|
|
||||||
self.offset=int(request.form['offset'])
|
|
||||||
if 'grouping' in request.form:
|
|
||||||
self.grouping=request.form['grouping']
|
|
||||||
# this can be null if we come from view by details
|
|
||||||
if 'size' in request.form:
|
|
||||||
self.size = request.form['size']
|
|
||||||
# seems html cant do boolean, but uses strings so convert
|
|
||||||
if 'folders' not in request.form or request.form['folders'] == "False":
|
|
||||||
self.folders=False
|
|
||||||
elif request.form['folders'] == "True":
|
|
||||||
self.folders=True
|
|
||||||
# have to force grouping to None if we flick to folders from a flat
|
|
||||||
# view with grouping (otherwise we print out group headings for
|
|
||||||
# child content that is not in the CWD)
|
|
||||||
self.grouping=None
|
|
||||||
|
|
||||||
# possible to not be set for an AI: search
|
|
||||||
if 'cwd' in request.form:
|
|
||||||
self.cwd = request.form['cwd']
|
|
||||||
if 'fullscreen' in request.form:
|
|
||||||
self.fullscreen=request.form['fullscreen']
|
|
||||||
else:
|
|
||||||
self.fullscreen=False
|
|
||||||
if 'prev' in request.form:
|
|
||||||
self.offset -= int(self.how_many)
|
|
||||||
if self.offset < 0:
|
|
||||||
self.offset=0
|
|
||||||
if 'next' in request.form:
|
|
||||||
self.offset += int(self.how_many)
|
|
||||||
|
|
||||||
pref=PA_PREF.query.filter(PA_PREF.pa_user_dn==current_user.dn,PA_PREF.path_type==self.path_type).first()
|
|
||||||
if not pref:
|
|
||||||
pref=PA_PREF( pa_user_dn=current_user.dn, path_type=self.path_type, noo=self.noo, grouping=self.grouping, how_many=self.how_many,
|
|
||||||
st_offset=self.offset, size=self.size, folders=self.folders, root=self.root, cwd=self.cwd, view_eids=self.view_eids)
|
|
||||||
else:
|
|
||||||
pref.noo=self.noo
|
|
||||||
pref.grouping=self.grouping
|
|
||||||
pref.how_many=self.how_many
|
|
||||||
pref.st_offset=self.offset
|
|
||||||
pref.size=self.size
|
|
||||||
pref.folders=self.folders
|
|
||||||
pref.root = self.root
|
|
||||||
pref.cwd = self.cwd
|
|
||||||
pref.view_eids = self.view_eids
|
|
||||||
|
|
||||||
db.session.add(pref)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# /prefs -> GET only -> prints out list of all prefs (simple for now)
|
|
||||||
################################################################################
|
|
||||||
@app.route("/prefs", methods=["GET"])
|
|
||||||
@login_required
|
|
||||||
def prefs():
|
|
||||||
prefs = PA_PREF.query.filter( PA_PREF.pa_user_dn==current_user.dn ).all()
|
|
||||||
return render_template("prefs.html", prefs=prefs )
|
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ create table SETTINGS(
|
|||||||
constraint FK_DEFAULT_REFIMG_MODEL foreign key (DEFAULT_REFIMG_MODEL) references AI_MODEL(ID),
|
constraint FK_DEFAULT_REFIMG_MODEL foreign key (DEFAULT_REFIMG_MODEL) references AI_MODEL(ID),
|
||||||
constraint FK_DEFAULT_SCAN_MODEL foreign key (DEFAULT_SCAN_MODEL) references AI_MODEL(ID) );
|
constraint FK_DEFAULT_SCAN_MODEL foreign key (DEFAULT_SCAN_MODEL) references AI_MODEL(ID) );
|
||||||
|
|
||||||
create table PA_PREF ( PA_USER_DN varchar(128), PATH_TYPE varchar(16), NOO varchar(16), GROUPING varchar(16), HOW_MANY integer, ST_OFFSET integer, SIZE integer, FOLDERS Boolean, FULLSCREEN Boolean, ROOT varchar, CWD varchar, VIEW_EIDS varchar, VIEW_EIDS varchar,
|
create table PA_USER_STATES ( PA_USER_DN varchar(128), PATH_TYPE varchar(16), NOO varchar(16), GROUPING varchar(16), HOW_MANY integer, ST_OFFSET integer, SIZE integer, FOLDERS Boolean, FULLSCREEN Boolean, ROOT varchar, CWD varchar, VIEW_EIDS varchar, VIEW_EIDS varchar,
|
||||||
constraint PK_PA_USER_DN_PATH_TYPE primary key(PA_USER_DN, PATH_TYPE ) );
|
constraint PK_PA_USER_STATES_DN_PATH_TYPE primary key(PA_USER_DN, PATH_TYPE ) );
|
||||||
|
|
||||||
create table PA_USER( ID integer, dn varchar,
|
create table PA_USER( ID integer, dn varchar,
|
||||||
constraint PK_PA_USER_ID primary key(ID) );
|
constraint PK_PA_USER_ID primary key(ID) );
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#user"/></svg>
|
<svg width="20" height="20" fill="currentColor"><use xlink:href="{{url_for('internal', filename='icons.svg')}}#user"/></svg>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
|
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
|
||||||
<div><a class="dropdown-item" href="{{url_for('prefs')}}">{{current_user|Username}}</a></div>
|
<div><a class="dropdown-item" href="{{url_for('states')}}">{{current_user|Username}}</a></div>
|
||||||
<div><a class="dropdown-item" href="{{url_for('logout')}}">Logout</a></div>
|
<div><a class="dropdown-item" href="{{url_for('logout')}}">Logout</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block main_content %}
|
|
||||||
<h3>Simple Pref page</h3>
|
|
||||||
|
|
||||||
<table id="prefs_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
|
||||||
<thead>
|
|
||||||
<tr class="table-primary"><th>Path</th><th>New or Oldest</th><th>How Many</th><th>Folders?</th><th>Group by</th><th>Thumb size</th><th>Fullscreen</th><th>DB retrieve offset</th><th>Root</th><th>cwd</th><th>View eids</th></tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for pref in prefs %}
|
|
||||||
<tr>
|
|
||||||
<td>{{pref.path_type}}</td>
|
|
||||||
<td>{{pref.noo}}</td>
|
|
||||||
<td>{{pref.how_many}}</td>
|
|
||||||
<td>{{pref.folders}}</td>
|
|
||||||
<td>{{pref.grouping}}</td>
|
|
||||||
<td>{{pref.size}}</td>
|
|
||||||
<td>{{pref.fullscreen}}</td>
|
|
||||||
<td>{{pref.st_offset}}</td>
|
|
||||||
<td>{{pref.root}}</td>
|
|
||||||
<td>{{pref.cwd}}</td>
|
|
||||||
<td>{{pref.view_eids}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endblock main_content %}
|
|
||||||
Reference in New Issue
Block a user