From 697b240b5cc91159d7e498da35740854b8d3fa2a Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Wed, 3 Aug 2022 16:33:43 +0200 Subject: [PATCH] related to #1703 added params in ws.php and pagination works but filters don't --- admin/themes/default/js/history.js | 6 ++--- include/ws_functions/pwg.php | 13 ++++++---- ws.php | 38 +++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/admin/themes/default/js/history.js b/admin/themes/default/js/history.js index 7ad23d3a4..edfa09181 100644 --- a/admin/themes/default/js/history.js +++ b/admin/themes/default/js/history.js @@ -195,13 +195,13 @@ function fillHistoryResult(ajaxParam) { $(".tab").empty(); }, success: function (raw_data) { - + console.log(raw_data); + data = raw_data.result["lines"]; imageDisplay = raw_data.result["params"].display_thumbnail; maxPage = raw_data.result["maxPage"]; summary = raw_data.result["summary"]; - // console.log(raw_data); - + //clear lines before refill if (data.length > 0) { diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index fe9a9ebd6..5d2aff97d 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -607,6 +607,10 @@ function ws_history_search($param, &$service) $page['start'] = 0; } + $page['start'] = $param['pageNumber']; + // print_r("page start :"); + // print_r($page['start']); + $types = array_merge(array('none'), get_enums(HISTORY_TABLE, 'image_type')); $display_thumbnails = array('no_display_thumbnail' => l10n('No display'), @@ -838,8 +842,8 @@ SELECT } } - $i = 0; - $first_line = $page['start'] + 1; + $i = $page['start']; + $first_line = $page['start']; $last_line = $page['start'] + $conf['nb_logs_page']; $summary['total_filesize'] = 0; @@ -867,7 +871,7 @@ SELECT $i++; - if ($i < $first_line or $i > $last_line) + if ($i >= $first_line and $i <= $last_line) { continue; } @@ -972,7 +976,8 @@ SELECT ); } - $max_page = ceil(count($result)/300); + // print_r(count($result)); + $max_page = ceil($page['nb_lines']/300); $result = array_reverse($result, true); $result = array_slice($result, $param['pageNumber']*300, 300); diff --git a/ws.php b/ws.php index b3d9d507e..caa3dec1e 100644 --- a/ws.php +++ b/ws.php @@ -1296,7 +1296,43 @@ enabled_high, registration_date, registration_date_string, registration_date_sin $service->addMethod( 'pwg.history.search', 'ws_history_search', - null, + array( + 'start' => array( + 'default' => null + ), + 'end' => array( + 'default' => null + ), + 'types' => array( + 'flags'=>WS_PARAM_FORCE_ARRAY, + 'default' => array( + 'none', + 'picture', + 'high', + 'other', + ) + ), + 'user' => array( + 'default' => -1, + ), + 'image_id' => array( + 'default' => null, + 'type' => WS_TYPE_ID, + ), + 'filename' => array( + 'default' => null + ), + 'ip' => array( + 'default' => null + ), + 'display_thumbnail' => array( + 'default' => 'display_thumbnail_classic' + ), + 'pageNumber' => array( + 'default' => null, + 'type' => WS_TYPE_INT|WS_TYPE_POSITIVE, + ), + ), 'Gives an history of who has visited the galery and the actions done in it. Receives parameter.', $ws_functions_root . 'pwg.php' );