From 1534fd9c40ea48c42367e14524ccd728ca4281fb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 5 Mar 2021 10:30:14 +0100 Subject: [PATCH] API module graph width --- pandora_console/include/chart_generator.php | 11 ++++++++--- pandora_console/include/functions_api.php | 8 +++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 50d81a87e9..8a49d52436 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -178,14 +178,19 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { $params_combined = json_decode($data_combined, true); $module_list = json_decode($data_module_list, true); - $type_graph_pdf = $type_graph_pdf; if (isset($params['vconsole']) === false || $params['vconsole'] === false) { - $params['width'] = (int) $viewport_width; + if ((int) $viewport_width > 0) { + $params['width'] = (int) $viewport_width; + } + if ((isset($params['width']) === false || ($params['width'] <= 0)) ) { - $params['width'] = 650; + if ((int) $params['width'] <= 0) { + $params['width'] = 650; + } + if ((int) $params['landscape'] === 1) { $params['width'] = 850; } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ef49a94ad9..dfc0fe1dc5 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13767,16 +13767,18 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) } if (is_array($other['data']) === true) { + // Parameters received by user call. $graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR; // 1 hour by default. - $graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0; + $graph_threshold = (!empty($other) && isset($other['data'][1]) && $other['data'][1]) ? $other['data'][1] : 0; // Graph height when send email by alert - $height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225; + $height = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 225; // Graph width (optional). - $width = (!empty($other) && isset($other['data'][4]) && $other['data'][4]) ? $other['data'][4] : 225; + $width = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : ''; } else { + // Fixed parameters for _modulegraph_nh_. $graph_seconds = $other['data']; $graph_threshold = 0; $other['data'][1] = 0;