From d0a04177c0fa7dc523255f6168222b16e8a3a046 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Wed, 18 May 2022 17:17:31 +0200 Subject: [PATCH] add treshold pdf pandora_enterprise#1419 --- .../reporting_builder.item_editor.php | 21 +++++++++++++++ .../godmode/reporting/reporting_builder.php | 6 +++++ .../include/ajax/custom_fields.php | 2 +- .../include/class/AgentWizard.class.php | 2 +- pandora_console/include/functions_api.php | 2 +- pandora_console/include/functions_graph.php | 10 +++---- .../include/functions_reporting.php | 6 +++++ .../include/graphs/flot/pandora.flot.js | 26 +++++++++---------- 8 files changed, 54 insertions(+), 21 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 724d695f6a..eff8d41220 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -135,6 +135,7 @@ $current_month = true; // Only avg is selected by default for the simple graphs. $fullscale = false; $percentil = false; +$image_threshold = false; $time_compare_overlapped = false; // Added for events items. @@ -307,6 +308,7 @@ switch ($action) { case 'simple_graph': $fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0; $percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0; + $image_threshold = (isset($style['image_threshold']) === true) ? (bool) $style['image_threshold'] : false; $graph_render = $item['graph_render']; // The break hasn't be forgotten. case 'simple_baseline_graph': @@ -2501,6 +2503,23 @@ $class = 'databox filters'; + + + + + + + + + head = []; $table_modules->head[0] = __('Module name'); $table_modules->head[1] = __('Data'); - $table_modules->head[2] = __('Treshold'); + $table_modules->head[2] = __('Threshold'); $table_modules->head[3] = __('Current interval'); $table_modules->head[4] = __('Timestamp'); $table_modules->head[5] = __('Status'); diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index 1600aab4b6..36c5d36c75 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -1181,7 +1181,7 @@ class AgentWizard extends HTML $table->head[1] = ''.__('Server').''; $table->head[2] = ''.__('Type').''; $table->head[3] = ''.__('Description').''; - $table->head[4] = ''.__('Treshold').''; + $table->head[4] = ''.__('Threshold').''; $table->data = []; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 71128946c5..8155e22415 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -14855,7 +14855,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) 'type_graph' => $config['type_module_charts'], 'fullscale' => false, 'return_img_base_64' => true, - 'image_treshold' => $graph_threshold, + 'image_threshold' => $graph_threshold, 'graph_font_size' => $graph_font_size, ]; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index d9493a99b2..df7440754b 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -626,7 +626,7 @@ function grafico_modulo_sparse_data( * 'show_legend' => true, * 'show_overview' => true, * 'return_img_base_64' => false, - * 'image_treshold' => false, + * 'image_threshold' => false, * 'graph_combined' => false, * 'graph_render' => 0, * 'zoom' => 1, @@ -782,8 +782,8 @@ function grafico_modulo_sparse($params) $params['return_img_base_64'] = false; } - if (isset($params['image_treshold']) === false) { - $params['image_treshold'] = false; + if (isset($params['image_threshold']) === false) { + $params['image_threshold'] = false; } if (isset($params['graph_combined']) === false) { @@ -1305,8 +1305,8 @@ function graphic_combined_module( $params['return_img_base_64'] = false; } - if (isset($params['image_treshold']) === false) { - $params['image_treshold'] = false; + if (isset($params['image_threshold']) === false) { + $params['image_threshold'] = false; } if (isset($params['show_unknown']) === false) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6bf29c1235..12ff161603 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -10157,6 +10157,11 @@ function reporting_simple_graph( $fullscale = (bool) $content['style']['fullscale']; } + $image_threshold = false; + if (isset($content['style']['image_threshold'])) { + $image_threshold = (bool) $content['style']['image_threshold']; + } + $return['chart'] = ''; // Get chart. @@ -10211,6 +10216,7 @@ function reporting_simple_graph( 'backgroundColor' => 'transparent', 'return_img_base_64' => true, 'graph_render' => $content['graph_render'], + 'image_threshold' => $image_threshold, ]; if ($only_image === false) { diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index bdd3aa3038..b30d9e487b 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1003,7 +1003,7 @@ function pandoraFlotArea( var max_x = date_array["final_date"] * 1000; var type = parseInt(params.stacked); var show_legend = params.show_legend; - var image_treshold = params.image_treshold; + var image_threshold = params.image_threshold; var short_data = params.short_data != "" ? params.short_data : 3; var grid_color = params.grid_color; var background_color = params.backgroundColor; @@ -2198,7 +2198,7 @@ function pandoraFlotArea( } if (thresholded) { - var data_base_treshold = add_threshold( + var data_base_threshold = add_threshold( data_base, threshold_data, ranges.yaxis.from, @@ -2211,7 +2211,7 @@ function pandoraFlotArea( plot = $.plot( $("#" + graph_id), - data_base_treshold, + data_base_threshold, $.extend(true, {}, options, { grid: { borderWidth: 1, @@ -2597,7 +2597,7 @@ function pandoraFlotArea( $("#overview_" + graph_id).bind("mouseout", resetInteractivity); } - if (image_treshold) { + if (image_threshold) { var y_recal = plot.getAxes().yaxis.max; if (!thresholded) { // Recalculate the y axis @@ -2611,7 +2611,7 @@ function pandoraFlotArea( ); } - var datas_treshold = add_threshold( + var datas_threshold = add_threshold( data_base, threshold_data, plot.getAxes().yaxis.min, @@ -2624,7 +2624,7 @@ function pandoraFlotArea( plot = $.plot( $("#" + graph_id), - datas_treshold, + datas_threshold, $.extend(true, {}, options, { yaxis: { max: y_recal.max @@ -2758,7 +2758,7 @@ function pandoraFlotArea( ); } - datas_treshold = add_threshold( + datas_threshold = add_threshold( data_base, threshold_data, plot.getAxes().yaxis.min, @@ -2771,7 +2771,7 @@ function pandoraFlotArea( plot = $.plot( $("#" + graph_id), - datas_treshold, + datas_threshold, $.extend(true, {}, options, { yaxis: { min: max_draw["min"], @@ -3115,7 +3115,7 @@ function axis_thresholded( return y; } -//add treshold +//add threshold function add_threshold( data_base, threshold_data, @@ -3235,13 +3235,13 @@ function add_threshold( } }); - var extreme_treshold_array = []; + var extreme_threshold_array = []; var i = 0; var flag = true; $.each(threshold_array, function(index, value) { flag = true; - extreme_treshold_array[i] = { + extreme_threshold_array[i] = { below: value["max"], color: value["color"] }; @@ -3252,7 +3252,7 @@ function add_threshold( } }); if (flag) { - extreme_treshold_array[i] = { + extreme_threshold_array[i] = { below: value["min"], color: datas[0].color }; @@ -3260,7 +3260,7 @@ function add_threshold( } }); - datas[0].threshold = extreme_treshold_array; + datas[0].threshold = extreme_threshold_array; return datas; }