first pass of rotation sub-menu on images. It only posts on Image. For each selection it turns thumbnail gray, overlays a centered color spinning wheel, posts to the f/e to create a rotation job, gets the job id back, keeps checking the f/e to see when the job id is done, and when it is (for now) undoes the spinning wheel/grayscale - will return new thumb once done and pa_job_mgr has no code to handle job as yet

This commit is contained in:
2021-07-16 21:08:16 +10:00
parent d42ac8c8b5
commit 3ac6f143f4
2 changed files with 79 additions and 6 deletions

View File

@@ -482,6 +482,40 @@ def view_img(id):
eids=''
return render_template("viewer.html", obj=obj, eids=eids)
# 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
# specific rotation job is finished (/checkrotatejob) which will be called (say) every 1 sec. from f/e
# with a spinning wheel, then when pa_job_mgr has finished it will return the rotated thumb
@app.route("/rotate", methods=["POST"])
@login_required
def rotate():
id = request.form['id']
amt = request.form['amt']
print( f"rotate called with id={id}, amt={amt}")
jex=[]
for el in request.form:
jex.append( JobExtra( name=f"{el}", value=request.form[el] ) )
job=NewJob( "rotate_image", 0, None, jex )
resp={}
resp['job_id']=job.id
# TODO: make this return data with the job number, then the f/e can poll checkrotatejob
return resp
@app.route("/checkrotatejob", methods=["POST"])
@login_required
def checkrotatejob():
job_id = request.form['job_id']
job = Job.query.get(job_id)
resp={}
resp['finished']=False
if job.pa_job_state == 'Completed':
resp['finished']=True
return resp
################################################################################
# /static -> returns the contents of any file referenced inside /static.
# we create/use symlinks in static/ to reference the images to show