From ffad6bb505134a796a0a9d02e023e51277760a23 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 30 Apr 2012 12:44:26 +0000 Subject: [PATCH] 2012-04-30 Miguel de Dios * godmode/reporting/visual_console_builder.php: fixed when the module have a spaces or other entities in the name when try to create a items with the wizzard. * godmode/reporting/visual_console_builder.wizard.php: changed the style of form to show more horizontality. Fixes: #3521724 * include/functions_reporting.php: fixed the "Top-N". Fixes: #3521724 * include/functions_agents.php: cleaned source code style. * operation/agentes/ver_agente.php: return more data in the ajax request for the modules. MERGED FROM 4.0.2 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 24 +++++++ .../reporting/visual_console_builder.php | 16 +++-- .../visual_console_builder.wizard.php | 14 ++-- pandora_console/include/functions_agents.php | 2 +- .../include/functions_reporting.php | 72 ++++++++----------- .../operation/agentes/ver_agente.php | 39 +++++----- 6 files changed, 93 insertions(+), 74 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f2f9011e22..b1cda231de 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,27 @@ +2012-04-30 Miguel de Dios + + * godmode/reporting/visual_console_builder.php: fixed when the + module have a spaces or other entities in the name when try to + create a items with the wizzard. + + * godmode/reporting/visual_console_builder.wizard.php: changed the + style of form to show more horizontality. + + Fixes: #3521724 + + + + * include/functions_reporting.php: fixed the "Top-N". + + Fixes: #3521724 + + * include/functions_agents.php: cleaned source code style. + + * operation/agentes/ver_agente.php: return more data in the ajax + request for the modules. + + MERGED FROM 4.0.2 + 2012-04-30 Vanessa Gil * pandoradb.php diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 57af3170d4..10de390517 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -208,13 +208,15 @@ switch ($activeTab) { } else { $id_modules = array(); - foreach($name_modules as $mod){ - foreach($id_agents as $ag){ - $sql = "SELECT id_agente_modulo - FROM tagente_modulo - WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'"; - $result = db_get_row_sql ($sql); - $id_modules[] = $result['id_agente_modulo']; + foreach ($name_modules as $mod) { + foreach ($id_agents as $ag) { + $id_module = agents_get_modules($ag, + array('id_agente_modulo'), + array('nombre' => io_safe_input($mod))); + if (empty($id_module)) + continue; + + $id_modules[] = $id_module; } } $message .= visual_map_process_wizard_add_modules($id_modules, diff --git a/pandora_console/godmode/reporting/visual_console_builder.wizard.php b/pandora_console/godmode/reporting/visual_console_builder.wizard.php index c5352fbb39..1a7d093daa 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.wizard.php +++ b/pandora_console/godmode/reporting/visual_console_builder.wizard.php @@ -32,8 +32,8 @@ $table->id = 'wizard_table'; $table->width = '98%'; $table->data = array (); $table->style = array (); -$table->style[0] = 'font-weight: bold; vertical-align:top'; -$table->style[2] = 'font-weight: bold'; +$table->style[0] = 'font-weight: bold; vertical-align: text-top;'; +$table->style[1] = 'font-weight: bold; vertical-align: top;'; $table->size = array (); $table->data = array (); @@ -72,7 +72,7 @@ $table->data["all_1"][1] = html_print_input_text ('range', 50, '', 5, 5, true); $table->rowstyle["staticgraph_modulegraph"] = 'display: none;'; $table->data["staticgraph_modulegraph"][0] = __('Size (px)'); $table->data["staticgraph_modulegraph"][1] = __('Width').': '.html_print_input_text ('width', 0, '', 5, 5, true); -$table->data["staticgraph_modulegraph"][1] .= '
'.__('Height').': '.html_print_input_text ('height', 0, '', 5, 5, true); +$table->data["staticgraph_modulegraph"][1] .= ' ' . __('Height').': '.html_print_input_text ('height', 0, '', 5, 5, true); $table->rowstyle["modulegraph"] = 'display: none;'; $table->data["modulegraph"][0] = __('Period'); @@ -111,11 +111,9 @@ $table->data["all_2"][1] = html_print_select_groups($config['id_user'], "AR", tr $table->rowstyle["all_3"] = 'display: none;'; $table->data["all_3"][0] = __('Agents'); $table->data["all_3"][1] = html_print_select (agents_get_group_agents (0, false, "none", false, true), - 'id_agents[]', 0, false, '', '', true, true); - -$table->rowstyle["all_4"] = 'display: none;'; -$table->data["all_4"][0] = __('Modules'); -$table->data["all_4"][1] = html_print_select (array (), 'module[]', 0, false, __('None'), -1, true, true); + 'id_agents[]', 0, false, '', '', true, true) . + ' ' . __('Modules') . '' . + html_print_select (array (), 'module[]', 0, false, __('None'), -1, true, true); $table->rowstyle["all_5"] = 'display: none;'; $table->data["all_5"][0] = __('Label'); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8d50dcfe3a..278618585a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1075,7 +1075,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false if($id_agent == false) { $id_agent = array(); } - + $temp = array(); foreach ($id_agent as $item) { $temp[] = $item['id_agente']; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 69b688bcb7..8367c41f1c 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2312,8 +2312,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f // Important parameter, this tell to graphic_combined_module function that is a projection graph $output_projection, $content['top_n_value'] - ); - array_push ($table->data, $data); + ); + array_push ($table->data, $data); break; case 'prediction_date': reporting_header_content($mini, $content, $report, $table, __('Prediction date'), @@ -2322,7 +2322,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f //RUNNING $table->colspan[1][0] = 4; - set_time_limit(500); + set_time_limit(500); // Put description at the end of the module (if exists) $table->colspan[2][0] = 4; @@ -2585,20 +2585,20 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f metaconsole_restore_db(); } } - + // SLA items sorted descending () if ($content['top_n'] == 2){ usort($table1->data, "sla_value_desc_cmp"); } // SLA items sorted ascending else if ($content['top_n'] == 1){ - usort($table1->data, "sla_value_asc_cmp"); + usort($table1->data, "sla_value_asc_cmp"); } // Delete temporary column used to sort SLA data for ($i=0; $i < count($table1->data); $i++) { - unset($table1->data[$i][6]); - } + unset($table1->data[$i][6]); + } $table->colspan[2][0] = 3; if ($show_graph == 0 || $show_graph == 1) { @@ -2606,14 +2606,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table1, true); array_push ($table->data, $data); } - + $table->colspan[3][0] = 2; $data = array(); $data_pie_graph = json_encode ($data_graph); if (($show_graph == 1 || $show_graph == 2) && !empty($slas)) { $data[0] = pie3d_graph(false, $data_graph, 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); + + $config['fontpath'], $config['font_size']); //Print resume @@ -3401,7 +3402,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f else { $data[3] = format_for_graph($d, 2) . " " . $units[$i]; } - array_push ($table1->data, $data); $i++; } @@ -3458,6 +3458,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f continue; } } + $ag_name = modules_get_agentmodule_agent_name ($general ['id_agent_module']); if (!in_array ($ag_name, $agent_list)) { array_push ($agent_list, $ag_name); @@ -3503,6 +3504,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f continue; } } + $agent_name = modules_get_agentmodule_agent_name ($g['id_agent_module']); $module_name = modules_get_agentmodule_name ($g['id_agent_module']); $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $g['id_agent_module']); @@ -3712,6 +3714,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table1->style[2] = 'text-align: left'; } + //Get data of all agents (before to slide to N values) $data_top = array(); foreach ($tops as $key => $row) { @@ -3760,42 +3763,16 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f metaconsole_restore_db(); } } - if(empty($data_top)) { + + if (empty($data_top)) { $data = array (); $table->colspan[2][0] = 3; $data[0] = __('Insuficient data'); array_push ($table->data, $data); break; } - switch ($top_n) { - //Max - case 1: - array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); - break; - //Min - case 2: - array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); - break; - //By agent name or without selection - case 0: - case 3: - array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); - break; - } - - $data_top_values = array (); - $data_top_values['data_top'] = $data_top; - $data_top_values['agent_name'] = $agent_name; - $data_top_values['module_name'] = $module_name; - $data_top_values['id_agent_module'] = $id_agent_module; - $data_top_values['units'] = $units; - - array_splice ($data_top, $top_n_value); - array_splice ($agent_name, $top_n_value); - array_splice ($module_name, $top_n_value); - array_splice ($id_agent_module, $top_n_value); - array_splice ($units, $top_n_value); + //Order to show. switch ($order_uptodown) { //Descending case 1: @@ -3812,6 +3789,19 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f break; } + array_splice ($data_top, $top_n_value); + array_splice ($agent_name, $top_n_value); + array_splice ($module_name, $top_n_value); + array_splice ($id_agent_module, $top_n_value); + array_splice ($units, $top_n_value); + + $data_top_values = array (); + $data_top_values['data_top'] = $data_top; + $data_top_values['agent_name'] = $agent_name; + $data_top_values['module_name'] = $module_name; + $data_top_values['id_agent_module'] = $id_agent_module; + $data_top_values['units'] = $units; + // Define truncate size depends the graph width $truncate_size = $sizgraph_w / (4 * ($config['font_size']))-1; @@ -3874,7 +3864,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table1, true); array_push ($table->data, $data); } - + $table->colspan[3][0] = 3; $data = array(); if ($show_graph == 1 || $show_graph == 2) { @@ -3925,7 +3915,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table_summary->data[0][0] = format_for_graph($min, 2); $table_summary->data[0][1] = format_for_graph($avg, 2); $table_summary->data[0][2] = format_for_graph($max, 2); - + $table->colspan[5][0] = 3; array_push ($table->data, array(''.__('Summary').'')); $table->colspan[6][0] = 3; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 57badb9dfe..c221e22cf4 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -42,11 +42,11 @@ if (is_ajax ()) { $get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip"); $get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip"); $get_agent_id = (bool) get_parameter ("get_agent_id"); - + if ($get_agents_group_json) { $id_group = (int) get_parameter('id_group'); $recursion = (int) get_parameter ('recursion', 0); - + if($id_group > 0) { $groups = array($id_group); if ($recursion) { @@ -55,17 +55,17 @@ if (is_ajax ()) { } else { $groups_orig = users_get_groups(); - + $groups = array_keys($groups_orig); } - + $filter = " WHERE id_grupo IN (". implode(',', $groups) .")"; $agents = db_get_all_rows_sql("SELECT id_agente, nombre FROM tagente". $filter); - + echo json_encode($agents); return; } - + if ($get_agent_json) { $id_agent = (int) get_parameter ('id_agent'); @@ -78,10 +78,15 @@ if (is_ajax ()) { if ($get_agent_modules_json_for_multiple_agents_id) { $idAgents = get_parameter('id_agent'); - $nameModules = db_get_all_rows_sql('SELECT nombre, id_agente_modulo + $modules = db_get_all_rows_sql('SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')'); - echo json_encode($nameModules); + $return = array(); + foreach ($modules as $module) { + $return[$module['id_agente_modulo']] = $module['nombre']; + } + + echo json_encode($return); return; } @@ -93,7 +98,7 @@ if (is_ajax ()) { FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')'; - + if($selection_mode == 'common') { $sql .= 'AND ( SELECT count(t3.nombre) @@ -103,10 +108,10 @@ if (is_ajax ()) { } $sql .= ' ORDER BY t1.nombre'; - + $nameAgents = db_get_all_rows_sql($sql); - foreach($nameAgents as $nameAgent) { + foreach ($nameAgents as $nameAgent) { $names[] = $nameAgent['name']; } @@ -169,13 +174,13 @@ if (is_ajax ()) { $enabled = 'disabled = 0'; break; } - + if ($config ['metaconsole'] == 1) { $result = array(); $nameModules = array(); $temp = array(); $first = true; - + foreach ($idAgents as $idA) { $row = explode ('|', $idA); $server_name = $row[0]; @@ -230,13 +235,13 @@ if (is_ajax ()) { } $sql .= ' ORDER BY nombre'; - + $nameModules = db_get_all_rows_sql($sql); - + if ($nameModules == false) { $nameModules = array(); } - + $result = array(); foreach($nameModules as $nameModule) { $result[] = io_safe_output($nameModule['nombre']); @@ -246,7 +251,7 @@ if (is_ajax ()) { echo json_encode($result); return; } - + if ($get_agent_modules_json) { $id_agent = (int) get_parameter ('id_agent'); $filter = io_safe_output((string) get_parameter ('filter'));