From a12153dd6ec31d7e9b53c6433207d740561dd46b Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Thu, 13 Nov 2014 20:04:08 +0100 Subject: [PATCH] Now the only average value of the simple graphs can be deactivated --- .../reporting/reporting_builder.item_editor.php | 14 +++++++++++++- .../godmode/reporting/reporting_builder.php | 10 ++++++++++ pandora_console/include/functions_reporting.php | 16 ++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 47be14041e..d83caf6b31 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -85,6 +85,8 @@ $sla_sorted_by = 0; $id_agents = ''; $inventory_modules = array(); $date = null; +// Only avg is selected by default for the simple graphs +$only_avg = true; //Added for events items $filter_event_validated = false; @@ -171,8 +173,10 @@ switch ($action) { $idAgentModule = $item['id_agent_module']; $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); break; - case 'simple_baseline_graph': case 'simple_graph': + $only_avg = isset($style['only_avg']) ? (bool) $style['only_avg'] : true; + // The break hasn't be forgotten. + case 'simple_baseline_graph': case 'projection_graph': $description = $item['description']; $idAgentModule = $item['id_agent_module']; @@ -1001,6 +1005,10 @@ html_print_input_hidden('id_item', $idItem); ?> + + + + @@ -1873,6 +1881,7 @@ function chooseType() { $("#row_show_resume").hide(); $("#row_show_graph").hide(); $("#row_max_min_avg").hide(); + $("#row_only_avg").hide(); $("#row_quantity").hide(); $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); @@ -1915,6 +1924,9 @@ function chooseType() { $("#row_event_graphs").show(); break; case 'simple_graph': + $("#row_only_avg").show(); + // The break hasn't be forgotten, this element + // only should be shown on the simple graphs. case 'simple_baseline_graph': $("#row_description").show(); $("#row_agent").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 33d5cc2a24..5e1ae7e08a 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -971,6 +971,11 @@ switch ($action) { $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; break; + case 'simple_graph': + // Warning. We are using this column to hold this value to avoid + // the modification of the database for compatibility reasons. + $style['only_avg'] = (int) get_parameter('only_avg'); + break; } $values['style'] = io_safe_input(json_encode($style)); @@ -1180,6 +1185,11 @@ switch ($action) { $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; break; + case 'simple_graph': + // Warning. We are using this column to hold this value to avoid + // the modification of the database for compatibility reasons. + $style['only_avg'] = (int) get_parameter('only_avg'); + break; } $values['style'] = io_safe_input(json_encode($style)); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index fda41cc284..bf1fcd1597 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3471,13 +3471,25 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $moduletype_name = modules_get_moduletype_name( modules_get_agentmodule_type( $content['id_agent_module'])); + + $only_avg = true; + // Due to database compatibility problems, the 'only_avg' value + // is stored into the json contained into the 'style' column. + if (isset($content['style'])) { + $style_json = io_safe_output($content['style']); + $style = json_decode($style_json, true); + + if (isset($style['only_avg'])) { + $only_avg = (bool) $style['only_avg']; + } + } if (preg_match ("/string/", $moduletype_name)) { $urlImage = ui_get_full_url(false, false, false, false); $data[0] = grafico_modulo_string ($content['id_agent_module'], $content['period'], - false, $sizgraph_w, $sizgraph_h, '', '', false, 1, false, + false, $sizgraph_w, $sizgraph_h, '', '', false, $only_avg, false, $report["datetime"], $only_image, $urlImage); } @@ -3492,7 +3504,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f '', '', false, - true, + $only_avg, true, $report["datetime"], '',