diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index e6e0bcb862..d50a5d8b55 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -1,29 +1,44 @@ "; - +$url = 'index.php?sec=reporting&sec2=godmode/reporting/graph_builder'; if ($edit_graph) { - echo "
'; +$output .= ''; +echo $output; +?> +'; + $("#checkbox-summatory_series").change(function() { + if( $("#checkbox-summatory_series").is(":checked") && + $("#checkbox-modules_series").is(":disabled") + ) { + $("#checkbox-modules_series").removeAttr("disabled"); + } else if(!$("#checkbox-average_series").is(":checked")) { + $("#checkbox-modules_series").attr("disabled", true); + $("#checkbox-modules_series").attr("checked", false); + } + }); + + $("#checkbox-average_series").change(function() { + if( $("#checkbox-average_series").is(":checked") && + $("#checkbox-modules_series").is(":disabled") + ) { + $("#checkbox-modules_series").removeAttr("disabled"); + } else if(!$("#checkbox-summatory_series").is(":checked")) { + $("#checkbox-modules_series").attr("disabled", true); + $("#checkbox-modules_series").attr("checked", false); + } + }); + }); + diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 23aa4b0771..f0262f6e5f 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -1,16 +1,31 @@ $config['id_user'], 'name' => $name, @@ -114,7 +131,7 @@ if ($add_graph) { if (trim($name) != '') { $id_graph = db_process_sql_insert('tgraph', $values); if ($id_graph !== false) { - db_pandora_audit('Report management', "Create graph #$id_graph"); + db_pandora_audit('Report management', 'Create graph #'.$id_graph); } else { db_pandora_audit('Report management', 'Fail try to create graph'); } @@ -166,9 +183,15 @@ if ($update_graph) { ['id_graph' => $id_graph] ); if ($success !== false) { - db_pandora_audit('Report management', "Update graph #$id_graph"); + db_pandora_audit( + 'Report management', + 'Update graph #'.$id_graph + ); } else { - db_pandora_audit('Report management', "Fail try to update graph #$id_graph"); + db_pandora_audit( + 'Report management', + 'Fail try to update graph #'.$id_graph + ); } } else { $success = false; @@ -188,12 +211,12 @@ if ($add_module) { $id_agents = get_parameter('id_agents'); $weight = get_parameter('weight'); - // Id modules has double entities conversion - // Safe output remove all entities + // Id modules has double entities conversion. + // Safe output remove all entities. io_safe_output_array($id_modules, ''); // We need to put the entities again - // to browse in db + // to browse in db. io_safe_input_array($id_modules); $id_agent_modules = db_get_all_rows_sql( @@ -304,23 +327,39 @@ switch ($tab) { } if ($add_graph) { - ui_print_result_message($id_graph, __('Graph stored successfully'), __('There was a problem storing Graph')); + ui_print_result_message( + $id_graph, + __('Graph stored successfully'), + __('There was a problem storing Graph') + ); } if ($add_module) { - ui_print_result_message($result, __('Module added successfully'), __('There was a problem adding Module')); + ui_print_result_message( + $result, + __('Module added successfully'), + __('There was a problem adding Module') + ); } if ($update_graph) { - ui_print_result_message($success, __('Update the graph'), __('Bad update the graph')); + ui_print_result_message( + $success, + __('Update the graph'), + __('Bad update the graph') + ); } if ($delete_module) { - ui_print_result_message($result, __('Graph deleted successfully'), __('There was a problem deleting Graph')); + ui_print_result_message( + $result, + __('Graph deleted successfully'), + __('There was a problem deleting Graph') + ); } -// Parse CHUNK information into showable information -// Split id to get all parameters +// Parse CHUNK information into showable information. +// Split id to get all parameters. if (!$delete_module) { if (isset($_POST['period'])) { $period = $_POST['period']; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index e21c3b6e55..8c07381452 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -917,6 +917,15 @@ $row++; ); $row++; + $table_chars->data[$row][0] = __('Chart fit to content'); + $table_chars->data[$row][1] = html_print_checkbox_switch( + 'maximum_y_axis', + 1, + $config['maximum_y_axis'], + true + ); + $row++; + $table_chars->data[$row][0] = __('Type of module charts'); $table_chars->data[$row][1] = __('Area').' '.html_print_radio_button( 'type_module_charts', diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 3922e0ddf4..ea94b3a7da 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -925,6 +925,10 @@ function config_update_config() $error_update[] = __('Use round corners'); } + if (!config_update_value('maximum_y_axis', (bool) get_parameter('maximum_y_axis'))) { + $error_update[] = __('Chart fit to content'); + } + if (!config_update_value('show_qr_code_header', (bool) get_parameter('show_qr_code_header'))) { $error_update[] = __('Show QR code header'); } @@ -1772,6 +1776,10 @@ function config_process_config() config_update_value('round_corner', false); } + if (isset($config['maximum_y_axis']) === false) { + config_update_value('maximum_y_axis', false); + } + if (!isset($config['show_qr_code_header'])) { config_update_value('show_qr_code_header', false); } diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index a7e5545d55..212098e23f 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -56,7 +56,17 @@ function forecast_projection_graph( 'projection' => true, ]; - $module_data = grafico_modulo_sparse($params, $server_name); + if (is_metaconsole()) { + $id_meta = metaconsole_get_id_server($server_name); + $server = metaconsole_get_connection_by_id($id_meta); + metaconsole_connect($server); + } + + $module_data = grafico_modulo_sparse($params); + + if (is_metaconsole()) { + metaconsole_restore_db(); + } if (empty($module_data)) { return []; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 9747cb1033..b4505df1a0 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -629,172 +629,177 @@ function grafico_modulo_sparse_data( * 'graph_render' => 0, * 'zoom' => 1, * 'server_id' => null, - * 'stacked' => 0. + * 'stacked' => 0 + * 'maximum_y_axis' => 0. * * @return string html Content graphs. */ -function grafico_modulo_sparse($params, $server_name='') +function grafico_modulo_sparse($params) { global $config; - if (!isset($params) || !is_array($params)) { + if (isset($params) === false || is_array($params) === false) { return false; } - if (!isset($params['period'])) { + if (isset($params['period']) === false) { return false; } - if (!isset($params['show_events'])) { + if (isset($params['show_events']) === false) { $params['show_events'] = false; } - if (!isset($params['width'])) { + if (isset($params['width']) === false) { $params['width'] = '90%'; } - if (!isset($params['height'])) { + if (isset($params['height']) === false) { $params['height'] = 450; } - if (!isset($params['title'])) { + if (isset($params['title']) === false) { $params['title'] = ''; } - if (!isset($params['unit_name'])) { + if (isset($params['unit_name']) === false) { $params['unit_name'] = null; } - if (!isset($params['show_alerts'])) { + if (isset($params['show_alerts']) === false) { $params['show_alerts'] = false; } - if (!isset($params['date']) || !$params['date']) { + if (isset($params['date']) === false || !$params['date']) { $params['date'] = get_system_time(); } - if (!isset($params['unit'])) { + if (isset($params['unit']) === false) { $params['unit'] = ''; } - if (!isset($params['baseline'])) { + if (isset($params['baseline']) === false) { $params['baseline'] = 0; } - if (!isset($params['return_data'])) { + if (isset($params['return_data']) === false) { $params['return_data'] = 0; } - if (!isset($params['show_title'])) { + if (isset($params['show_title']) === false) { $show_title = true; } - if (!isset($params['only_image'])) { + if (isset($params['only_image']) === false) { $params['only_image'] = false; } - if (!isset($params['homeurl'])) { + if (isset($params['homeurl']) === false) { $params['homeurl'] = $config['homeurl']; } - if (!isset($params['ttl'])) { + if (isset($params['ttl']) === false) { $params['ttl'] = 1; } - if (!isset($params['adapt_key'])) { + if (isset($params['adapt_key']) === false) { $params['adapt_key'] = ''; } - if (!isset($params['compare'])) { + if (isset($params['compare']) === false) { $params['compare'] = false; } - if (!isset($params['show_unknown'])) { + if (isset($params['show_unknown']) === false) { $params['show_unknown'] = false; } - if (!isset($params['menu'])) { + if (isset($params['menu']) === false) { $params['menu'] = true; } - if (!isset($params['show_legend'])) { + if (isset($params['show_legend']) === false) { $params['show_legend'] = true; } - if (!isset($params['show_overview'])) { + if (isset($params['show_overview']) === false) { $params['show_overview'] = true; } - if (!isset($params['show_export_csv'])) { + if (isset($params['show_export_csv']) === false) { $params['show_export_csv'] = true; } - if (!isset($params['backgroundColor'])) { + if (isset($params['backgroundColor']) === false) { $params['backgroundColor'] = 'white'; } - if (!isset($params['percentil'])) { + if (isset($params['percentil']) === false) { $params['percentil'] = null; } - if (!isset($params['dashboard'])) { + if (isset($params['dashboard']) === false) { $params['dashboard'] = false; } - if (!isset($params['vconsole']) || $params['vconsole'] == false) { + if (isset($params['vconsole']) === false || $params['vconsole'] == false) { $params['vconsole'] = false; } else { $params['menu'] = false; } - if (!isset($params['type_graph'])) { + if (isset($params['type_graph']) === false) { $params['type_graph'] = $config['type_module_charts']; } - if (!isset($params['fullscale'])) { + if (isset($params['fullscale']) === false) { $params['fullscale'] = false; } - if (!isset($params['id_widget_dashboard'])) { + if (isset($params['id_widget_dashboard']) === false) { $params['id_widget_dashboard'] = false; } - if (!isset($params['force_interval'])) { + if (isset($params['force_interval']) === false) { $params['force_interval'] = ''; } - if (!isset($params['time_interval'])) { + if (isset($params['time_interval']) === false) { $params['time_interval'] = 300; } - if (!isset($params['array_data_create'])) { + if (isset($params['array_data_create']) === false) { $params['array_data_create'] = 0; } - if (!isset($params['return_img_base_64'])) { + if (isset($params['return_img_base_64']) === false) { $params['return_img_base_64'] = false; } - if (!isset($params['image_treshold'])) { + if (isset($params['image_treshold']) === false) { $params['image_treshold'] = false; } - if (!isset($params['graph_combined'])) { + if (isset($params['graph_combined']) === false) { $params['graph_combined'] = false; } - if (!isset($params['zoom'])) { + if (isset($params['zoom']) === false) { $params['zoom'] = ($config['zoom_graph']) ? $config['zoom_graph'] : 1; } - if (!isset($params['type_mode_graph'])) { + if (isset($params['type_mode_graph']) === false) { $params['type_mode_graph'] = $config['type_mode_graph']; if (isset($params['graph_render']) === true) { $params['type_mode_graph'] = $params['graph_render']; } } - if (!isset($params['projection'])) { + if (isset($params['maximum_y_axis']) === false) { + $params['maximum_y_axis'] = $config['maximum_y_axis']; + } + + if (isset($params['projection']) === false) { $params['projection'] = false; } @@ -802,7 +807,7 @@ function grafico_modulo_sparse($params, $server_name='') $params['pdf'] = false; } - if (!isset($params['agent_module_id'])) { + if (isset($params['agent_module_id']) === false) { return graph_nodata_image( $params['width'], $params['height'], @@ -815,14 +820,12 @@ function grafico_modulo_sparse($params, $server_name='') $agent_module_id = $params['agent_module_id']; } - if (!isset($params['stacked'])) { + if (isset($params['stacked']) === false) { $params['stacked'] = 0; } - // TODO: Configurable. $params['grid_color'] = '#C1C1C1'; $params['legend_color'] = '#636363'; - $params['font'] = $config['fontpath']; $params['font_size'] = $config['font_size']; $params['short_data'] = $config['short_module_graph_data']; @@ -880,14 +883,14 @@ function grafico_modulo_sparse($params, $server_name='') } // Format of the graph. - if (empty($params['unit'])) { + if (empty($params['unit']) === true) { $params['unit'] = $module_data['unit']; if (modules_is_unit_macro($params['unit'])) { $params['unit'] = ''; } } - if (empty($params['divisor'])) { + if (empty($params['divisor']) === true) { $params['divisor'] = get_data_multiplier($params['unit']); } @@ -986,7 +989,7 @@ function grafico_modulo_sparse($params, $server_name='') // Check available data. if ($params['compare'] === 'separated') { - if (!empty($array_data)) { + if (empty($array_data) === false) { $return = area_graph( $agent_module_id, $array_data, @@ -1011,7 +1014,7 @@ function grafico_modulo_sparse($params, $server_name='') } $return .= '