all override add and remove now use new datastructures, close to be able to test / augment as per TODO

This commit is contained in:
2025-10-09 23:56:27 +11:00
parent 846bdc4e52
commit ee1c9b5494
6 changed files with 95 additions and 75 deletions

View File

@@ -117,10 +117,13 @@ function DrawImg()
context.lineWidth = 2
// this face has an override so diff colour
if( faces[i].override )
if( faces[i].fnmo.length || faces[i].ffmo.length )
{
context.strokeStyle = 'blue'
DrawLabelOnFace( faces[i].override.who )
if( faces[i].ffmo.length )
DrawLabelOnFace( faces[i].ffmo[0].person.tag )
else
DrawLabelOnFace( faces[i].fnmo[0].type.name )
}
else
{
@@ -234,10 +237,10 @@ $(document).ready( function()
if( x >= fx && x <= fx+fw && y >= fy && y <= fy+fh )
{
if( faces[i].override )
if( faces[i].ffmo.length || faces[i].fnmo.length )
{
item_list['remove_force_match_override']={ 'name': 'Remove override for this face', 'which_face': i, 'id': faces[i].id }
}
}
else if( faces[i].refimg )
{
item_list['match']={ 'name': faces[i].refimg.person.tag, 'which_face': i, 'id': faces[i].id }
@@ -250,7 +253,7 @@ $(document).ready( function()
item_list['no_match_new_person']={ 'name': 'Add as reference image to NEW person', 'which_face': i, 'id': faces[i].id }
item_list['no_match_new_refimg']={ 'name': 'Add as reference image to EXISTING person', 'which_face': i, 'id': faces[i].id }
for( var el in NMO ) {
item_list['NMO_'+el]={'type_id': NMO[el].type_id, 'name': 'Override: ' + NMO[el].name, 'which_face': i, 'id': faces[i].id }
item_list['NMO_'+el]={'type_id': NMO[el].id, 'name': 'Override: ' + NMO[el].name, 'which_face': i, 'id': faces[i].id }
}
}
delete item_list['not_a_face']
@@ -276,7 +279,7 @@ function OverrideForceMatch( person_id, key )
// we have type_id passed in, so dig the NMO out, and use that below (its really just for name, but in case we change that in the DB)
for( el in NMO )
{
if( NMO[el].type_id == item[key].type_id )
if( NMO[el].id == item[key].type_id )
{
fm_idx=el
break
@@ -284,12 +287,9 @@ function OverrideForceMatch( person_id, key )
}
ofm='&person_id='+person_id+'&face_id='+item[key].id
$.ajax({ type: 'POST', data: ofm, url: '/add_force_match_override', success: function(data) {
document.viewing.file_details.faces[item[key].which_face].override={}
document.viewing.file_details.faces[item[key].which_face].override.who=data.person_tag
document.viewing.file_details.faces[item[key].which_face].override.distance='N/A'
document.viewing.file_details.faces[item[key].which_face].override.type_id=NMO[fm_idx].id
document.viewing.file_details.faces[item[key].which_face].override.type_name=NMO[fm_idx].name
document.viewing.file_details.faces[item[key].which_face].ffmo=[]
document.viewing.file_details.faces[item[key].which_face].ffmo[0]={}
document.viewing.file_details.faces[item[key].which_face].ffmo[0].person=data.person
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
@@ -350,8 +350,7 @@ function SearchForPerson(content, key, face_id, face_pos, type_id)
for( var el in data ) {
content+='<div class="row">'
var person = data[el];
// NMO_1 is a non-match-override type_id==1 (or force match to existing person)
if( key == "NMO_1" )
if( item[key].name == "Override: Manual match to existing person" )
{
func='OverrideForceMatch('+person.id+',\''+key+'\' )'
content+= '<div class="col">' + person.tag + ' (' + person.firstname+' '+person.surname+ ') </div>'
@@ -376,15 +375,16 @@ function SearchForPerson(content, key, face_id, face_pos, type_id)
function RemoveOverrideForceMatch(face_pos)
{
if( document.viewing.file_details.faces[face_pos].override )
who=document.viewing.file_details.faces[face_pos].override.who
if( document.viewing.file_details.faces[face_pos].ffmo.length )
who=document.viewing.file_details.faces[face_pos].ffmo[0].person.tag
else
who=document.viewing.file_details.faces[face_pos].refimg.person.tag
d='&face_id='+document.viewing.file_details.faces[face_pos].id+'&person_tag='+document.viewing.file_details.faces[face_pos].refimg.person.tag+'&file_eid='+document.viewing.id
d='&face_id='+document.viewing.file_details.faces[face_pos].id+'&person_tag='+who+'&file_eid='+document.viewing.id
$.ajax({ type: 'POST', data: d, url: '/remove_force_match_override',
success: function(data) {
delete document.viewing.file_details.faces[face_pos].override
// force/delete the ffmo cleanly
document.viewing.file_details.faces[face_pos].ffmo.length=0
$('#dbox').modal('hide')
DrawImg()
CheckForJobs()
@@ -399,7 +399,7 @@ function RemoveOverrideNoMatch(face_pos, type_id)
d='&face_id='+document.viewing.file_details.faces[face_pos].id+'&type_id='+type_id
$.ajax({ type: 'POST', data: d, url: '/remove_no_match_override',
success: function(data) {
delete document.viewing.file_details.faces[face_pos].override
document.viewing.file_details.faces[face_pos].fnmo.length=0
$('#dbox').modal('hide')
DrawImg()
CheckForJobs()
@@ -414,11 +414,7 @@ function AddNoMatchOverride(type_id, face_id, face_pos, type_id)
d='&type_id='+type_id+'&face_id='+face_id
$.ajax({ type: 'POST', data: d, url: '/add_no_match_override',
success: function(data) {
document.viewing.file_details.faces[face_pos].override={}
document.viewing.file_details.faces[face_pos].override.who=NMO[type_id].name
document.viewing.file_details.faces[face_pos].override.distance='N/A'
document.viewing.file_details.faces[face_pos].override.type_id=type_id
document.viewing.file_details.faces[face_pos].override.type_name=NMO[type_id].name
document.viewing.file_details.faces[face_pos].fnmo[0]=data
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
@@ -466,17 +462,17 @@ function FaceDBox(key, item)
div+='</div><div class="col-6">'
if ( key == 'remove_force_match_override' )
{
if( document.viewing.file_details.faces[face_pos].override.type_name == 'Manual match to existing person' )
div+='<div class="row col-12">remove this override (force match to: ' + document.viewing.file_details.faces[face_pos].override.who + ')</div>'
if( document.viewing.file_details.faces[face_pos].ffmo.length )
div+='<div class="row col-12">remove this override (force match to: ' + document.viewing.file_details.faces[face_pos].ffmo[0].person.tag + ')</div>'
else
div+='<div class="row col-12">remove this override (no match)</div>'
div+='<div class="row col-12">remove this override (' + document.viewing.file_details.faces[face_pos].fnmo[0].type.name + ')</div>'
div+='<div class="row">'
div+='<button class="btn btn-outline-info col-6" type="button" onClick="$(\'#dbox\').modal(\'hide\'); return false">Cancel</button>'
div+='<button class="btn btn-outline-danger col-6" type="button" '
if( document.viewing.file_details.faces[face_pos].override.type_name == 'Manual match to existing person' )
if( document.viewing.file_details.faces[face_pos].ffmo.length )
div+='onClick="RemoveOverrideForceMatch(' +face_pos+ ')">Remove</button>'
else
div+='onClick="RemoveOverrideNoMatch(' +face_pos+','+document.viewing.file_details.faces[face_pos].override.type_id+ ')">Remove</button>'
div+='onClick="RemoveOverrideNoMatch(' +face_pos+','+document.viewing.file_details.faces[face_pos].fnmo[0].type.id+ ')">Remove</button>'
div+='</div>'
}
if ( key == 'no_match_new_person' )