From 8345131eb5f09dcb6d7d35ba0eb140bc14f03faf Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 13 Mar 2012 13:14:28 +0000 Subject: [PATCH] 2012-03-13 Miguel de Dios * include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php: fixed the show value in the item simple value, now show formated and with units. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5755 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++ .../ajax/visual_console_builder.ajax.php | 21 +++++- .../include/functions_visual_map.php | 67 ++++++++++++++----- 3 files changed, 74 insertions(+), 20 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9fe5d86267..4cd6de8631 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-03-13 Miguel de Dios + + * include/functions_visual_map.php, + include/ajax/visual_console_builder.ajax.php: fixed the show value in the + item simple value, now show formated and with units. + 2012-03-13 Juan Manuel Ramon * include/functions_graph.php: Removed legend in diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 8778a707f8..e98960953b 100644 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -90,30 +90,45 @@ switch ($action) { $layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element)); switch ($layoutData['type']) { case SIMPLE_VALUE_MAX: + $unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); + $unit = trim(io_safe_output($unit)); + $value = reporting_get_agentmodule_data_max ($layoutData['id_agente_modulo'], 86400, 0); if ($value === false) { $returnValue = __('Unknown'); } else { - $returnValue = format_numeric ($value); + $returnValue = format_for_graph($returnValue, 2); + if (!empty($unit_text)) + $returnValue .= " " . $unit_text; } break; case SIMPLE_VALUE_MIN: + $unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); + $unit = trim(io_safe_output($unit)); + $value = reporting_get_agentmodule_data_min ($layoutData['id_agente_modulo'], 86400, 0); if ($value === false) { $returnValue = __('Unknown'); } else { - $returnValue = format_numeric ($value); + $returnValue = format_for_graph($returnValue, 2); + if (!empty($unit_text)) + $returnValue .= " " . $unit_text; } break; case SIMPLE_VALUE_AVG: + $unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); + $unit = trim(io_safe_output($unit)); + $value = reporting_get_agentmodule_data_average ($layoutData['id_agente_modulo'], 86400, 0); if ($value === false) { $returnValue = __('Unknown'); } else { - $returnValue = format_numeric ($value); + $returnValue = format_for_graph($returnValue, 2); + if (!empty($unit_text)) + $returnValue .= " " . $unit_text; } break; case PERCENTILE_BAR: diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 0d051b4d11..398134e00d 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -234,27 +234,41 @@ function visual_map_print_item($layoutData) { case SIMPLE_VALUE_MAX: case SIMPLE_VALUE_MIN: case SIMPLE_VALUE_AVG: + $unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); + echo '
'; echo $text; switch ($type){ case SIMPLE_VALUE: - echo ' ' . db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module) . ''; + $value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module); + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; + echo ' ' . $value . ''; break; case SIMPLE_VALUE_MAX: $value = reporting_get_agentmodule_data_max ($id_module, 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); - } + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; + } + echo ' ' . $value . ''; break; case SIMPLE_VALUE_MIN: $value = reporting_get_agentmodule_data_min ($id_module, 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; } echo ' ' . $value . ''; break; @@ -262,8 +276,11 @@ function visual_map_print_item($layoutData) { $value = reporting_get_agentmodule_data_average ($id_module, 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; } echo ' ' . $value . ''; break; @@ -964,6 +981,9 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line // **************************************************************** // SIMPLE DATA VALUE (type = 2) // **************************************************************** + $unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module); + $unit_text = trim(io_safe_output($unit_text)); + if ($resizedMap) echo '
'; else @@ -1000,14 +1020,21 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line //TODO: change interface to add a period parameter, now is set to 1 day switch ($layout_data['type']){ case 2: - echo db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']); + $value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']); + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; + echo $value; break; case 6: $value = reporting_get_agentmodule_data_max ($layout_data['id_agente_modulo'], 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; } echo $value; break; @@ -1015,18 +1042,24 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line $value = reporting_get_agentmodule_data_min ($layout_data['id_agente_modulo'], 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); - } + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; + } echo $value; break; case 8: $value = reporting_get_agentmodule_data_average($layout_data['id_agente_modulo'], 86400, 0); if ($value === false) { $value = __('Unknown'); - } else { - $value = format_numeric ($value); - } + } + else { + $value = format_for_graph($value, 2); + if (!empty($unit_text)) + $value .= " " . $unit_text; + } echo $value; break; }