From f1c43906abdba6748cee1c44587279873ca3e64e Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 15 Jan 2023 13:32:25 +1100 Subject: [PATCH] delete & restore files now clean up UI and dont reload page by default. For all moves/deletes/restores that start on a search view, they now reload the page instead of just cleaning up the UI as searching by name will cause the UI to need complex redrawing, easier to live with the reload for now --- TODO | 6 ++---- internal/js/files_support.js | 22 ++++++++++++++-------- main.py | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index da871d4..26088f2 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,12 @@ ### GENERAL - * delete files should behave like /move_files (stay on same page) as well as the status messages above - * all routes should be consistent naming conventions (with or without _ ) - * change the rotation code to use that jpeg util to reduce/remove compression loss? - * get build process to create a random string for secret for PROD, otherwise use builtin for dev * think about security - in job_mgr anywhere I can os.replace/remove NEED to protect, etc + * change the rotation code to use that jpeg util to reduce/remove compression loss? + * read this: https://flask.palletsprojects.com/en/2.2.x/testing/#faking-resources-and-context * could get better AI optim, by keeping track of just new files since scan (even if we did this from the DB), diff --git a/internal/js/files_support.js b/internal/js/files_support.js index 9c43b34..d6c0ae3 100644 --- a/internal/js/files_support.js +++ b/internal/js/files_support.js @@ -74,18 +74,18 @@ function GetExistingDirsAsDiv( dt, divname, ptype ) } ) } -// 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() +// wrapper to do some clean up before POST to /move_files or /delete_files +// used to remove the highlighted item(s) && reset the numbering so highlighting continues to work +function MoveOrDelCleanUpUI() { // remove the images being moved (so UI immediately 'sees' the move) $("[name^=eid-]").each( function() { $('#'+$(this).attr('value')).remove() } ) // reorder the images via ecnt again, so future highlighting can work document.mf_id=0; $('.figure').each( function() { $(this).attr('ecnt', document.mf_id ); document.mf_id++ } ) $('#dbox').modal('hide') - $.ajax({ type: 'POST', data: $('#mv_fm').serialize(), url: '/move_files', success: function(data) { CheckForJobs() } }) } + // 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) @@ -126,10 +126,12 @@ function MoveDBox(path_details, db_url)
- +
` + $('#dbox-content').html(div) $('#dbox').modal('show') $("#prefix").keypress(function (e) { if (e.which == 13) { $("#move_submit").click(); return false; } } ) @@ -148,18 +150,22 @@ function DelDBox(del_or_undel) ` div+=` - + success: function(data){ + if( $(location).attr('pathname').match('search') !== null ) { window.location='/' }; CheckForJobs() } }); return false" class="btn btn-outline-danger col-2">Ok ` else + // just force page reload to / for now if restoring files from a search path -- a search (by name) + // would match the deleted/restored file, so it would be complex to clean up the UI (and can't reload, as DB won't be changed yet) div+=` '/restore_files', - success: function(data){ window.location='/'; CheckForJobs() } })" class="btn btn-outline-success col-2">Ok + success: function(data){ + if( $(location).attr('pathname').match('search') !== null ) { window.location='/' }; CheckForJobs() } }); return false" class="btn btn-outline-success col-2">Ok ` $('#dbox-content').html(div) diff --git a/main.py b/main.py index 0e3a2ca..7faf47d 100644 --- a/main.py +++ b/main.py @@ -87,7 +87,7 @@ def save_user(dn, username, data, memberships): # if we already have a valid user/session, and say the web has restarted, just re-use it, dont make more users if pau: return pau - pau=PAUser(dn=dn, default_import_noo="Oldest", default_storage_noo="A to Z", default_search_noo="Newest", default_grouping="None", default_how_many=50, default_size=128, default_import_folders=False, default_storage_folders=True ) + pau=PAUser(dn=dn, default_import_noo="Newest", default_storage_noo="A to Z", default_search_noo="Newest", default_grouping="None", default_how_many=50, default_size=128, default_import_folders=False, default_storage_folders=True ) db.session.add(pau) db.session.commit() return pau