Files
photoassistant/internal/js/files_transform.js

56 lines
2.3 KiB
JavaScript

// 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 )
{
console.log( 'removing amendment for: ' + id )
document.amendments=document.amendments.filter(obj => obj.eid !== id)
}
// If Transform job has finished then reset relevant document.entries
// with updated from DB, remove the amendment and redraw image
function handleTransformImageJobCompleted(job, entry)
{
removeAmendment( entry.id )
// update viewer and files* views, in case we view/go up without a new page load
// force reload with timestamped version of im.src
im.src=im.src + '?t=' + new Date().getTime();
DrawImg()
idx = entryList.indexOf(entry.id)
// replace data for this entry now its been transformed
document.entries[idx]=entry
// redraw into figure html in dom
html = createFigureHtml( entry )
$('#'+entry.id).replaceWith( html )
}
// for each highlighted image, POST the transform with amt (90, 180, 270,
// fliph, flipv) which will let the job manager know what to do to this file.
// we also grayscale the thumbnail out, remove the entry class for now, show
// the spinning wheel, and finally kick of the checking for the transform job
// to finish
function Transform(amt)
{
// we are in the viewer with 1 image only...
if( $('#viewer_div').length && ! $('#viewer_div').hasClass('d-none') )
{
post_data = '&amt='+amt+'&id='+document.viewing.id
// 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) {
processAmendments(data.job.amendments)
checkForAmendmentJobToComplete(data.job.id)
} })
}
else
{
$('.highlight').each(function( cnt, e ) {
post_data = '&amt='+amt+'&id='+e.id
// 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){
processAmendments(data.job.amendments)
checkForAmendmentJobToComplete(data.job.id)
} })
} )
}
}