updated BUGs in general to remove older / fixed BUGs relating to the confusion of current/eids, etc.
update amendments in tables.sql to include job_id in entry_ammendment added amend.py to move amendment-related code into its own file when we create a job (NewJob) and that job matches an amendmentType (via job_name or job_name:amt <- where amt relates to how we do a transform_image), then we enter a new EntryAmendment pa_job_mgr knows when a Transform job ends, and removes relevant EntryAmendment files*.js use EntryAmendment data to render thumbnails with relevant AmendmentType if a normal page load (like /files_ip), and there is an EntryAmendment, mark up the thumb, run the check jobs to look for completion of the job, removeal of the EntryAmendment and update the entry based on 'transformed' image OVERALL: this is a functioning version that uses EntryAmendments and can handle loading a new page with outstanding amendments and 'deals' with it. This is a good base, but does not cater for remove_files or move_files
This commit is contained in:
@@ -1,11 +1,31 @@
|
||||
// This function will remove the matching amendment for this entry (id)
|
||||
// can only have 1 ammendment per image, its grayed out for other changes
|
||||
function removeAmendment( id )
|
||||
{
|
||||
document.amendments=document.amendments.filter(obj => obj.eid !== id)
|
||||
}
|
||||
|
||||
// POST to a check URL, that will tell us if the transformation has completed,
|
||||
// if not, try again in 1 second... If it has finished then reset the thumbnail
|
||||
// to full colour, put it back to being an entry and reset the thumbnail to the
|
||||
// newly created one that was sent back in the response to the POST
|
||||
function handleTransformFiles(data,id,job_id)
|
||||
{
|
||||
if( data.finished )
|
||||
{
|
||||
$('#s'+id).hide()
|
||||
$('#'+id).find('img.thumb').attr('style', 'filter: color(100%);' );
|
||||
$('#'+id).addClass('entry')
|
||||
$('#'+id).find('.thumb').attr('src', 'data:image/jpeg;base64,'+data.thumbnail)
|
||||
id=parseInt(id)
|
||||
idx = entryList.indexOf(id)
|
||||
// replace data for this entry now its been transformed
|
||||
document.entries[idx]=data.entry
|
||||
// update cache too
|
||||
// document.page[getPageNumberForId(id)][howFarIntoPageCache(id)]=data.entry
|
||||
// FIXME: for now just invalidate whole cache
|
||||
document.page.length=0
|
||||
removeAmendment( id )
|
||||
// redraw into figure html in dom
|
||||
last={ 'printed': 'not required' }
|
||||
html = createFigureHtml( data.entry, last, 9999 )
|
||||
$('#'+id).replaceWith( html )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -15,17 +35,15 @@ function handleTransformFiles(data,id,job_id)
|
||||
}
|
||||
|
||||
// POST to a check URL, that will tell us if the transformation has completed,
|
||||
// if not, try again in 1 second... If it has finished then reset the thumbnail
|
||||
// to full colour, put it back to being an entry and reset the thumbnail to the
|
||||
// newly created one that was sent back in the response to the POST
|
||||
// if not, try again in 1 second... If it has finished then reset the image
|
||||
// to full colour
|
||||
function handleTransformViewing(data,id,job_id)
|
||||
{
|
||||
if( data.finished )
|
||||
{
|
||||
// stop throbber, remove grayscale & then force reload with timestamped version of im.src
|
||||
grayscale=0
|
||||
throbber=0
|
||||
im.src=im.src + '?t=' + new Date().getTime();
|
||||
removeAmendment( id )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -41,7 +59,18 @@ function handleTransformViewing(data,id,job_id)
|
||||
function CheckTransformJob(id,job_id,successCallback)
|
||||
{
|
||||
CheckForJobs()
|
||||
$.ajax( { type: 'POST', data: '&job_id='+job_id, url: '/check_transform_job', success: function(res) { successCallback(res,id,job_id); } } )
|
||||
$.ajax( { type: 'POST', data: '&job_id='+job_id, url: '/check_transform_job',
|
||||
success: function(res) { successCallback(res,id,job_id); } } )
|
||||
}
|
||||
|
||||
// function to add data for document.amendment based on id and amt
|
||||
// used when we transform several images in files_*, or single image in viewer
|
||||
function addTransformAmendment(id,amt)
|
||||
{
|
||||
am={}
|
||||
am.eid=parseInt(id)
|
||||
am.type = document.amendTypes.filter(obj => obj.job_name === 'transform_image:'+amt )[0]
|
||||
document.amendments.push(am)
|
||||
}
|
||||
|
||||
// for each highlighted image, POST the transform with amt (90, 180, 270,
|
||||
@@ -55,16 +84,28 @@ function Transform(amt)
|
||||
if( document.viewing )
|
||||
{
|
||||
post_data = '&amt='+amt+'&id='+document.viewing.id
|
||||
// send /transform for this image, grayscale the thumbmail, add color spinning wheel overlay, and start checking for job end
|
||||
$.ajax({ type: 'POST', data: post_data, url: '/transform', success: function(data) { grayscale=1; throbber=1; DrawImg(); CheckTransformJob(document.viewing.id,data.job_id,handleTransformViewing); return false; } })
|
||||
// POST /transform for image, grayscale the image, add throbber, & start checking for end of job
|
||||
$.ajax({ type: 'POST', data: post_data, url: '/transform', success: function(data) {
|
||||
addTransformAmendment(document.viewing.id, amt)
|
||||
DrawImg();
|
||||
CheckTransformJob(document.viewing.id,data.job_id,handleTransformViewing);
|
||||
return false;
|
||||
} })
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.highlight').each(function( id, e ) {
|
||||
$('.highlight').each(function( cnt, e ) {
|
||||
post_data = '&amt='+amt+'&id='+e.id
|
||||
// send /transform for this image, grayscale the thumbmail, add color spinning wheel overlay, and start checking for job end
|
||||
$.ajax({ type: 'POST', data: post_data, url: '/transform', success: function(data){ $('#'+e.id).find('img.thumb').attr('style', 'filter: grayscale(100%);' ); $('#'+e.id).removeClass('entry'); $('#s'+e.id).show(); CheckTransformJob(e.id,data.job_id,handleTransformFiles); return false; } })
|
||||
// POST /transform for image, grayscale the thumbnail, add throbber, & start checking for end of job
|
||||
$.ajax({ type: 'POST', data: post_data, url: '/transform', success: function(data){
|
||||
addTransformAmendment(e.id, amt)
|
||||
last={ 'printed': 'not required' }
|
||||
idx = pageList.indexOf(parseInt(e.id))
|
||||
html = createFigureHtml( document.entries[idx], last, 9999 )
|
||||
$('#'+e.id).replaceWith( html )
|
||||
CheckTransformJob(e.id,data.job_id,handleTransformFiles);
|
||||
return false;
|
||||
} })
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user