From 972eac5b5b679e38a4e9d623bcd933d6c3ef498e Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 3 Jan 2023 15:48:13 +1100 Subject: [PATCH] first pass of move_files not redirecting to / and staying put for an other move_files, works, but needs success/toast --- TODO | 1 + files.py | 5 +++-- internal/js/files_support.js | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 4193f98..8fd904b 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ ### GENERAL * after move, instead of back to home page, go to an ammended view of the thumbs to keep moving + - works in DEV, should explore bootstrap5 toast? (or a better 'status' update on POSTs, and get it to also increase/descrease the job counter as appropriate) * ignore face should ignore ALL matching faces (re: Declan) diff --git a/files.py b/files.py index bfe653f..003d737 100644 --- a/files.py +++ b/files.py @@ -1,6 +1,6 @@ from wtforms import SubmitField, StringField, HiddenField, validators, Form from flask_wtf import FlaskForm -from flask import request, render_template, redirect, send_from_directory, url_for +from flask import request, render_template, redirect, send_from_directory, url_for, jsonify, make_response from main import db, app, ma from sqlalchemy import Sequence from sqlalchemy.exc import SQLAlchemyError @@ -623,7 +623,8 @@ def move_files(): jex.append( JobExtra( name=f"{el}", value=request.form[el] ) ) job=NewJob( "move_files", 0, None, jex ) st.SetMessage( f"Created Job #{job.id} to move selected file(s)") - return redirect("/jobs") +# return redirect("/jobs") + return make_response( jsonify( job_id=job.id, status="success" ) ) @login_required @app.route("/viewlist", methods=["POST"]) diff --git a/internal/js/files_support.js b/internal/js/files_support.js index d859a26..29f2dbc 100644 --- a/internal/js/files_support.js +++ b/internal/js/files_support.js @@ -55,6 +55,16 @@ function GetExistingDirsAsDiv( dt, divname ) } ) } +// wrapper to do some clean up before POST to /move_files +// used to remove the highlighted item(s) -- effectively removing them from view/selection so continued 'Moves' can occur +function MoveSubmit() +{ + // remove the images being moved + $("[name^=eid-]").each( function() { $('#'+$(this).attr('value')).remove() } ) + $('#dbox').modal('hide') + $.ajax({ type: 'POST', data: $('#mv_fm').serialize(), url: '/move_files', success: function(data){ console.log(data); return false; } }) +} + // show the DBox for a move file, includes all thumbnails of selected files to move // and a pre-populated folder to move them into, with text field to add a suffix function MoveDBox(path_details, db_url) @@ -64,7 +74,7 @@ function MoveDBox(path_details, db_url)

Moving the following files?

-
+ ' @@ -95,7 +105,7 @@ function MoveDBox(path_details, db_url)
- +
`