Permalink
Browse files

feature #593, simplify detailed output for pwg.images.delete

1 parent edff754 commit 743bbb61f4a09e23bf55e2d363284401210b255e @plegall plegall committed Jan 9, 2017
Showing with 10 additions and 14 deletions.
  1. +8 −5 admin/themes/default/js/batchManagerGlobal.js
  2. +2 −9 include/ws_functions/pwg.images.php
@@ -288,8 +288,14 @@ jQuery('#applyAction').click(function(e) {
image_id: image_ids.join(',')
},
dataType: 'json',
- success: ( function(data) { todo += data.result.details.nb_processed; progressDelete(todo, progressBar_max, data.result.success) }),
- error: ( function(data) { todo += data.result.details.nb_processed; progressDelete(todo, progressBar_max, false) })
+ success: ( function(data) {
+ todo += data.result.nb_processed;
+ progressDelete(todo, progressBar_max, true)
+ }),
+ error: ( function(data) {
+ todo += deleteBlockSize; // TODO: might be not exact, if last query
@plegall
plegall Jan 9, 2017 Member

@modus75 at this very step I would like to get image_ids.length, but I can't :-/ I don't know how I can get this info, required to make the progress bar accurate and got to the end of the progress. Can you help?

@modus75
modus75 Jan 9, 2017 Contributor

I would say that

  • first you need to test data.stat=="ok" before assuming real success (you are not using the PwgWS function that does that)
  • than I think that if you just return a number from the ws function, you could just test data.results.

You cannot use image_ids because you change the object before the callback is run ... You would need to enclose it in another function e.g. (no tested)..
function enqueueBlockDeleteRequest(image_ids) {
var ids_len = image_ids.length;
...
success: function(data) {
.... use ids_len
}
}

@plegall
plegall Jan 10, 2017 Member

thank you for your tips :-)

For now, I haven't been able to make that work. I have merged the branch on master. We will improve that later.

I don't see how I can use a function like enqueueBlockDeleteRequest :-( I don't understand how Piwigo could return the number of images it was supposed to delete, if an error like "session expired" occurs (well, this very error should not occur)

+ progressDelete(todo, progressBar_max, false)
+ })
});
image_ids = Array();
@@ -304,9 +310,6 @@ function progressDelete(val, max, success) {
boxImage: 'themes/default/images/progressbar.gif',
barImage: 'themes/default/images/progressbg_orange.gif'
});
- type = success ? 'regenerateSuccess': 'regenerateError'
- s = jQuery('[name="'+type+'"]').val();
- jQuery('[name="'+type+'"]').val(++s);
if (val == max) {
jQuery('#applyAction').click();
@@ -1743,15 +1743,8 @@ function ws_images_delete($params, $service)
if ($params['return_details'])
{
return array(
- 'success' => true,
- 'details' => array(
- 'nb_processed' => count($image_ids),
- ),
- );
- }
- else
- {
- return true;
+ 'nb_processed' => count($image_ids),
+ );
}
}

0 comments on commit 743bbb6

Please sign in to comment.