From c5ec3ebb5597e5e1949cc5e54ff6caa115ddc18f Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 27 May 2014 14:31:53 +0000 Subject: [PATCH] 2014-05-27 Miguel de Dios * godmode/reporting/graph_builder.main.php, include/functions_graph.php, include/functions_visual_map.php, include/functions_custom_graphs.php, include/constants.php, operation/reporting/graph_viewer.php: killing unicorns and magic numbers for the kind of custom graphs. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10021 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 +++++++ .../godmode/reporting/graph_builder.main.php | 8 +++---- pandora_console/include/constants.php | 6 +++++ .../include/functions_custom_graphs.php | 8 ++++++- pandora_console/include/functions_graph.php | 13 ++++------- .../include/functions_visual_map.php | 4 ++-- .../operation/reporting/graph_viewer.php | 23 +++++++++++-------- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 15a0c3f6c0..6b6aa883ba 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2014-05-27 Miguel de Dios + + * godmode/reporting/graph_builder.main.php, + include/functions_graph.php, include/functions_visual_map.php, + include/functions_custom_graphs.php, include/constants.php, + operation/reporting/graph_viewer.php: killing unicorns and magic + numbers for the kind of custom graphs. + 2014-05-27 Sergio Martin * godmode/agentes/agent_wizard.snmp_explorer.php: Fix wrong diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index 235aa4e2ab..af41fb0012 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -140,10 +140,10 @@ echo ""; include_once($config["homedir"] . "/include/functions_graph.php"); $stackeds = array( - GRAPH_AREA => __('Area'), - GRAPH_STACKED_AREA => __('Stacked area'), - GRAPH_LINE => __('Line'), - GRAPH_STACKED_LINE => __('Stacked line')); + CUSTOM_GRAPH_AREA => __('Area'), + CUSTOM_GRAPH_STACKED_AREA => __('Stacked area'), + CUSTOM_GRAPH_LINE => __('Line'), + CUSTOM_GRAPH_STACKED_LINE => __('Stacked line')); html_print_select ($stackeds, 'stacked', $stacked); echo ""; diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 3edd84e6a2..1f701ba106 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -366,4 +366,10 @@ define("EVENTS_GOING_DOWN_NORMAL", 'going_down_normal'); define("EVENTS_GOING_DOWN_CRITICAL", 'going_down_critical'); define("EVENTS_GOING_UP_NORMAL", 'going_up_normal'); define("EVENTS_CONFIGURATION_CHANGE", 'configuration_change'); + +/* CUSTOM GRAPHS */ +define("CUSTOM_GRAPH_AREA", 0); +define("CUSTOM_GRAPH_STACKED_AREA", 1); +define("CUSTOM_GRAPH_LINE", 2); +define("CUSTOM_GRAPH_STACKED_LINE", 3); ?> diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 670ef9a1cc..8991ee19a3 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -93,9 +93,15 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr */ function custom_graphs_print($id_graph, $height, $width, $period, - $stacked, $return = false, $date = 0, $only_image = false) { + $stacked = null, $return = false, $date = 0, $only_image = false) { global $config; + $graph_conf = db_get_row('tgraph', 'id_graph', $id_graph); + + if ($stacked === null) { + $stacked = $graph_conf['stacked']; + } + $sources = db_get_all_rows_field_filter('tgraph_source', 'id_graph', $id_graph); $modules = array (); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index eac94da0e7..99f22fb929 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -20,11 +20,6 @@ include_once($config['homedir'] . "/include/functions_agents.php"); include_once($config['homedir'] . "/include/functions_modules.php"); include_once($config['homedir'] . "/include/functions_users.php"); -define("GRAPH_AREA", 0); -define("GRAPH_STACKED_AREA", 1); -define("GRAPH_LINE", 2); -define("GRAPH_STACKED_LINE", 3); - function get_graph_statistics ($chart_array) { /// IMPORTANT! @@ -1292,7 +1287,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, 'color' => COL_GRAPH13, 'alpha' => 50); switch ($stacked) { - case GRAPH_AREA: + case CUSTOM_GRAPH_AREA: return area_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), "", @@ -1300,21 +1295,21 @@ function graphic_combined_module ($module_list, $weight_list, $period, $fixed_font_size, "", $ttl); break; default: - case GRAPH_STACKED_AREA: + case CUSTOM_GRAPH_STACKED_AREA: return stacked_area_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), "", "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl); break; - case GRAPH_LINE: + case CUSTOM_GRAPH_LINE: return line_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), "", "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl); break; - case GRAPH_STACKED_LINE: + case CUSTOM_GRAPH_STACKED_LINE: return stacked_line_graph($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, ui_get_full_url("images/image_problem.opaque.png"), "", diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index cb94265323..dfa982a58e 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -219,7 +219,7 @@ function visual_map_print_item($layoutData) { if ($layoutData['id_custom_graph'] != 0) { $img = custom_graphs_print( $layoutData['id_custom_graph'], $height, $width, - $period, true, true, 0, true); + $period, null, true, 0, true); } else { $img = grafico_modulo_sparse($id_module, $period, 0, $width, @@ -1985,7 +1985,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line $layout_data['id_custom_graph'], $layout_data['height'], $layout_data['width'], - $layout_data['period'], true, false, 0, true); + $layout_data['period'], null, false, 0, true); } else { diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 7e6af465f3..4b9d8c9a28 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -151,33 +151,37 @@ if ($view_graph) { echo "
"; echo ""; echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; - echo ""; echo ""; + echo ""; echo "
"; echo "" . __('Date') . "" . " "; echo ""; echo html_print_input_text ('date', $date, '', 12, 10, true). ' '; echo ""; echo html_print_input_text ('time', $time, '', 7, 7, true). ' '; echo ""; echo "" . __('Time range') . ""; echo ""; - echo html_print_extended_select_for_time ('period', $period, '', '', '0', 10, true); - echo ""; $stackeds = array (); $stackeds[0] = __('Graph defined'); - $stackeds[0] = __('Area'); - $stackeds[1] = __('Stacked area'); - $stackeds[2] = __('Line'); - $stackeds[3] = __('Stacked line'); + $stackeds[CUSTOM_GRAPH_AREA] = __('Area'); + $stackeds[CUSTOM_GRAPH_STACKED_AREA] = __('Stacked area'); + $stackeds[CUSTOM_GRAPH_LINE] = __('Line'); + $stackeds[CUSTOM_GRAPH_STACKED_LINE] = __('Stacked line'); html_print_select ($stackeds, 'stacked', $stacked , '', '', -1, false, false); - echo ""; $zooms = array(); $zooms[0] = __('Graph defined'); @@ -185,11 +189,12 @@ if ($view_graph) { $zooms[2] = __('Zoom x2'); $zooms[3] = __('Zoom x3'); html_print_select ($zooms, 'zoom', $zoom , '', '', 0); + echo ""; - echo ""; + echo ""; echo "
"; echo "
";