From 1f07d8a022cec8988fdf148e5c4c35f447eb6fa0 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 17 Jan 2017 11:38:00 +0100 Subject: [PATCH] Added module value control to shows units in max, min and avg values. Ticket #159 --- .../godmode/setup/setup_visuals.php | 8 +++++ pandora_console/include/functions_config.php | 6 ++++ .../include/functions_reporting.php | 23 +++++++++++--- .../include/functions_visual_map.php | 30 ++++++++++++------- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 91f08ab175..21ddd9d8d8 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -334,6 +334,14 @@ $table_font->data[$row][1] = html_print_input_text('item_title_size_text', $config["item_title_size_text"], '', 3, 3, true); $row++; +$table_font->data[$row][0] = __('Show units in values report') . + ui_print_help_tip(__('This enabling this, max, min and avg values will be shown with units.'), true); +$table_font->data[$row][1] = __('Yes') . ' ' . + html_print_radio_button ('simple_module_value', 1, '', $config["simple_module_value"], true).'  '; +$table_font->data[$row][1] .= __('No') . ' ' . + html_print_radio_button ('simple_module_value', 0, '', $config["simple_module_value"], true); +$row++; + echo "
"; echo "" . __('Font and Text configuration') . ""; html_print_table ($table_font); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 277def1c08..ff69d159b0 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -494,6 +494,8 @@ function config_update_config () { $error_update[] = __('Item title size text'); if (!config_update_value ('gis_label', get_parameter ('gis_label'))) $error_update[] = __('GIS Labels'); + if (!config_update_value ('simple_module_value', get_parameter ('simple_module_value'))) + $error_update[] = __('Show units in values report'); if (!config_update_value ('gis_default_icon', get_parameter ('gis_default_icon'))) $error_update[] = __('Default icon in GIS'); if (!config_update_value ('autohidden_menu', get_parameter('autohidden_menu'))) @@ -1476,6 +1478,10 @@ function config_process_config () { if (!isset($config['item_title_size_text'])) { config_update_value ('item_title_size_text', 45); } + + if (!isset($config['simple_module_value'])) { + config_update_value ('simple_module_value', 1); + } if (!isset($config['gis_label'])) { config_update_value ('gis_label', 0); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 914e718033..54bd61c303 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3690,18 +3690,33 @@ function reporting_value($report, $content, $type) { break; case 'min': $value = reporting_get_agentmodule_data_min( - $content['id_agent_module'], $content['period'], $report["datetime"]); - $formated_value = format_for_graph($value, 2) . " " . $unit; + $content['id_agent_module'], $content['period'], $report["datetime"]); + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, 2) . " " . $unit; + } break; case 'avg': $value = reporting_get_agentmodule_data_average( $content['id_agent_module'], $content['period'], $report["datetime"]); - $formated_value = format_for_graph($value, 2) . " " . $unit; + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, 2) . " " . $unit; + } break; case 'sum': $value = reporting_get_agentmodule_data_sum( $content['id_agent_module'], $content['period'], $report["datetime"]); - $formated_value = format_for_graph($value, 2) . " " . $unit; + if (!$config['simple_module_value']) { + $formated_value = $value; + } + else { + $formated_value = format_for_graph($value, 2) . " " . $unit; + } break; case 'MTTR': $value = reporting_get_agentmodule_mttr( diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index cc8abea90e..5ee628472b 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1553,10 +1553,11 @@ function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) $value = __('Unknown'); } else { - if ( is_numeric($value) ) - $value = remove_right_zeros(number_format($value, $config['graph_precision'])); - //$value = format_for_graph($value, $config['graph_precision']); - + if ( is_numeric($value) ) { + if ($config['simple_module_value']) { + $value = remove_right_zeros(number_format($value, $config['graph_precision'])); + } + } if (!empty($unit_text)) { $value .= " " . $unit_text; } @@ -1573,8 +1574,11 @@ function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) $value = __('Unknown'); } else { - if ( is_numeric($value) ) - $value = format_for_graph($value, 2); + if ( is_numeric($value) ) { + if ($config['simple_module_value']) { + $value = format_for_graph($value, 2); + } + } if (!empty($unit_text)) $value .= " " . $unit_text; } @@ -1586,8 +1590,11 @@ function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) $value = __('Unknown'); } else { - if ( is_numeric($value) ) - $value = format_for_graph($value, 2); + if ( is_numeric($value) ) { + if ($config['simple_module_value']) { + $value = format_for_graph($value, 2); + } + } if (!empty($unit_text)) $value .= " " . $unit_text; } @@ -1599,8 +1606,11 @@ function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) $value = __('Unknown'); } else { - if ( is_numeric($value) ) - $value = format_for_graph($value, 2); + if ( is_numeric($value) ) { + if ($config['simple_module_value']) { + $value = format_for_graph($value, 2); + } + } if (!empty($unit_text)) $value .= " " . $unit_text; }