another large clean up of code, all POSTs are now using make_response() and returning json OR are for a form that flask handles with rendering direct html. Where there is a POST with json response, the jscript now calls CheckForJobs() to show it in the F/E. Removed several debugs. Fixed up undocumented BUG where import datetime was wrong, and prefix/suffix also to offer directories near the date of an image. Removed unused routes for clearing messages

This commit is contained in:
2023-01-12 16:47:43 +11:00
parent 8d9cf5279e
commit ef9f26189a
12 changed files with 45 additions and 58 deletions

View File

@@ -21,14 +21,15 @@ function GetSelnAsData()
return to_del
}
// use an ajax POST to force an AI scan on the selected images
// use an ajax POST to force an AI scan on the selected image(s)
function RunAIOnSeln(person)
{
post_data = GetSelnAsData()
post_data += '&person='+person.replace('ai-','')
$.ajax({ type: 'POST', data: post_data, url: '/run_ai_on', success: function(data){ window.location='/'; return false; } })
$.ajax({ type: 'POST', data: post_data, url: '/run_ai_on', success: function(data){ CheckForJobs() } })
}
// code to change the associated image/icon when the move to selection box (import or storage paths) is changed
function change_rp_sel()
{
icon_url = $('option:selected', '#rp_sel').attr('icon_url')
@@ -37,6 +38,8 @@ function change_rp_sel()
$('#move_path_type').val( $('option:selected', '#rp_sel').attr('path_type') )
}
// POST to see if there are any other existing directories named around this date
// (if so display them as options for a move)
function GetExistingDirsAsDiv( dt, divname )
{
$.ajax({
@@ -46,7 +49,7 @@ function GetExistingDirsAsDiv( dt, divname )
dirs = JSON.parse(data)
s=''
dirs.forEach( function(item, index) {
s+= '<button class="btn btn-outline-primary" type="button" onClick="$(\'#prefix\').val(\''+item.prefix+'\'); $(\'#suffix\').val(\''+item.suffix+'\');return false;">'+item.prefix+'/'+item.suffix+'</button>'
s+= '<button class="btn btn-outline-primary" type="button" onClick="$(\'#prefix\').val(\''+item.prefix+'\'); $(\'#suffix\').val(\''+item.suffix+'\');return false;">'+item.prefix+item.suffix+'</button>'
} )
if( s == '' )
$('#existing').html('')
@@ -59,12 +62,12 @@ function GetExistingDirsAsDiv( dt, divname )
// 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
// 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 highlighting can work
// 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(); return false; } })
$.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
@@ -134,13 +137,13 @@ function DelDBox(del_or_undel)
if( del_or_undel == "Delete" )
div+=`
'/delete_files',
success: function(data){ window.location='/'; return false; } })" class="btn btn-outline-danger col-2">Ok</button>
success: function(data){ window.location='/'; CheckForJobs() } })" class="btn btn-outline-danger col-2">Ok</button>
</div>
`
else
div+=`
'/restore_files',
success: function(data){ window.location='/'; return false; } })" class="btn btn-outline-success col-2">Ok</button>
success: function(data){ window.location='/'; CheckForJobs() } })" class="btn btn-outline-success col-2">Ok</button>
</div>
`
$('#dbox-content').html(div)

View File

@@ -287,6 +287,7 @@ function OverrideForceMatch( person_id, key )
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
CheckForJobs()
}
} )
}
@@ -320,6 +321,7 @@ function AddRefimgTo( person_id, key, search )
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
CheckForJobs()
}
})
}
@@ -374,6 +376,7 @@ function RemoveOverrideForceMatch(face_pos)
delete objs[current].faces[face_pos].override
$('#dbox').modal('hide')
DrawImg()
CheckForJobs()
return false
}
} )
@@ -388,6 +391,7 @@ function RemoveOverrideNoMatch(face_pos, type_id)
delete objs[current].faces[face_pos].override
$('#dbox').modal('hide')
DrawImg()
CheckForJobs()
return false
}
} )
@@ -407,6 +411,7 @@ function AddNoMatchOverride(type_id, face_id, face_pos, type_id)
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
CheckForJobs()
}
} )
}