diff --git a/TODO b/TODO index 54c4fce..1ca2bbd 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,20 @@ ### # get override data into view -# think view_transform might need to be included? # should start with an empty DB and test - definitely no dirs in storage_sp gives: # dir_id=dir_arr[0] # IndexError: list index out of range +# TEST this, code in files will work, but now passes root_eid=0 for +# this - so need GUI to work - may even be good to put an alert up - its so odd to hvae not root dir ONLY happens when no data # empty directories are sometimes showing "No matches for: 'undefined'" <- should only comes up for search in URL??? -# transforms in files_* also fails (old js in *transform uses current) +# think I killed pa_job_manager without passing an eid to a transform job, shouldn't crash +# SHOULD JUST get AI to help clean-up and write defensive code here... # also all the add ref img/add override, etc are non-functional - FIX the override* stuff first to get table/naming consistency as that is half the problem # delete button also uses current? (eid is empty anyway) +# move as much jscript into *_support, as possible (if there are no more {{ - # then move it) +# convert move_paths to a json setup +# ALSO revisit this move_paths to be as safe as possible ultimately, triple-check there are no leading / or .. 's +# TEST everything (don't forget keybindings) +# transforms -> should consider removing the pull logic to see if a job is finished (have job-mgr push data back? while more rest, not sure b/e EVER sends data to F/E at moment) ### ### major fix - go to everywhere I call GetEntries(), and redo the logic totally... diff --git a/internal/js/files_transform.js b/internal/js/files_transform.js index 4525efc..0d17b16 100644 --- a/internal/js/files_transform.js +++ b/internal/js/files_transform.js @@ -1,27 +1,47 @@ +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) + return false; + } + else + { + setTimeout( function() { CheckTransformJob(id,job_id,handleTransformFiles) }, 1000,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 -function CheckTransformJob(id,job_id) +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(); + return false; + } + else + { + setTimeout( function() { CheckTransformJob(id,job_id,handleTransformViewing) }, 1000,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 +function CheckTransformJob(id,job_id,successCallback) { CheckForJobs() - $.ajax( - { - type: 'POST', data: '&job_id='+job_id, url: '/check_transform_job', success: function(data) { - 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) - return false; - } - else - { - setTimeout( function() { CheckTransformJob(id,job_id) }, 1000,id, job_id ); - } - }, - } ) + $.ajax( { type: 'POST', data: '&job_id='+job_id, url: '/check_transform_job', success: function(res) { successCallback(res,id,job_id); } } ) } // for each highlighted image, POST the transform with amt (90, 180, 270, @@ -31,9 +51,20 @@ function CheckTransformJob(id,job_id) // to finish function Transform(amt) { - $('.highlight').each(function( id, e ) { - post_data = '&amt='+amt+'&id='+e.id + // we are in the viewer with 1 image only... + 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){ $('#'+e.id).find('img.thumb').attr('style', 'filter: grayscale(100%);' ); $('#'+e.id).removeClass('entry'); $('#s'+e.id).show(); CheckTransformJob(e.id,data.job_id); return false; } }) - } ) + $.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; } }) + } + else + { + $('.highlight').each(function( id, 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; } }) + } ) + } } +