related to #1316 method cache size added, data fetched from php not js

Real data need to be created now
This commit is contained in:
Matthieu Leproux
2021-06-24 17:12:09 +02:00
parent c0f69bcdba
commit 932439b94c
3 changed files with 59 additions and 6 deletions

View File

@@ -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");

View File

@@ -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

9
ws.php
View File

@@ -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',