diff --git a/admin/themes/default/js/maintenance.js b/admin/themes/default/js/maintenance.js index 107fd72e6..35ae16efb 100644 --- a/admin/themes/default/js/maintenance.js +++ b/admin/themes/default/js/maintenance.js @@ -1,4 +1,4 @@ -function displayResponse(domElem, values, mDivs, mValues) { +function displayResponse(domElem, values, mDivs, mValues, lastTimeCalc) { for (let index = 0; index < domElem.length; index++) { domElem[index].html(values[index]) @@ -6,8 +6,9 @@ function displayResponse(domElem, values, mDivs, mValues) { for (let index = 0; index < mDivs.length; index++) { mDivs[index].title = mValues[index] + "Mo"; - } + + $(".cache-lastCalculated-value").html(lastTimeCalc) } $(document).ready(function () { @@ -16,7 +17,7 @@ $(document).ready(function () { return new Promise((res, rej) => { jQuery.ajax({ - url: "ws.php?format=json&method=pwg.getInfos", + url: "ws.php?format=json&method=pwg.getCacheSize", type: "POST", data: { param : "test_param", @@ -29,13 +30,15 @@ $(document).ready(function () { console.log(data); + console.log(data.result.infos[1].value); + var domElemToRefresh = [$(".cache-size-value"), $(".multiple-pictures-sizes"), $(".multiple-compiledTemplate-sizes")]; - var domElemValues = [data.result.infos[12].value, 69, 42]; + var domElemValues = [data.result.infos[0].value, 69, 42]; var multipleSizes = $(".delete-check-container").children(".delete-size-check"); - var multipleSizesValues = [11, 10, 9, 8, 7, 6, 4, 3, 2, 1, 0] + var multipleSizesValues = data.result.infos[1].value; - displayResponse(domElemToRefresh , domElemValues, multipleSizes, multipleSizesValues); + displayResponse(domElemToRefresh , domElemValues, multipleSizes, multipleSizesValues, data.result.infos[2].value); $(".refresh-icon").addClass("icon-arrows-cw").removeClass("spin6"); diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index 7d970d0b8..cee577187 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -194,6 +194,47 @@ function ws_getInfos($params, &$service) return array('infos' => new PwgNamedArray($output, 'item')); } +/** + * API method + * Calculates and returns the size of the cache + * @param mixed[] $params + */ +function ws_getCacheSize($params, &$service) +{ + // Cache size + $infos['cache_size'] = 4444; + + + /* Multiples sizes */ + + $custom = 1; + $huge = 2; + $extra_large = 3; + $large = 4; + $medium = 5; + $small = 6; + $extra_small = 7; + $tiny = 8; + $thumbnail = 9; + $squarre = 10; + $all = $squarre + $thumbnail + $tiny + $extra_small + $small + $medium + $large + $extra_large + $huge + $custom; + + $infos['msizes'] = [$all, $squarre, $thumbnail, $tiny, $extra_small, $small, $medium, $large, $extra_large, $huge, $custom]; + + $infos['last_time_calc'] = "now"; + + foreach ($infos as $name => $value) + { + $output[] = array( + 'name' => $name, + 'value' => $value, + ); + } + + return array('infos' => new PwgNamedArray($output, 'item')); +} + + /** * API method * Adds images to the caddie diff --git a/ws.php b/ws.php index c6deb2533..430d83797 100644 --- a/ws.php +++ b/ws.php @@ -128,6 +128,15 @@ function ws_addDefaultMethods( $arr ) array('admin_only'=>true) ); + $service->addMethod( + 'pwg.getCacheSize', + 'ws_getCacheSize', + null, + 'Returns general informations.', + $ws_functions_root . 'pwg.php', + array('admin_only'=>true) + ); + $service->addMethod( 'pwg.activity.getList', 'ws_getActivityList',