From 1ccd792f23102063c5cfdcebb4d42b4602e191d2 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 29 Jan 2013 10:22:59 +0000 Subject: [PATCH] 2013-01-29 Sergio Martin * include/functions_treeview.php operation/tree.php: Added module info table to the tree view and fix the hash of instances when is in metaconsole mode git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7539 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 + .../include/functions_treeview.php | 149 ++++++++++++++++-- pandora_console/operation/tree.php | 46 ++++-- 3 files changed, 181 insertions(+), 21 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5cbfdcb55f..26c125dabf 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-01-29 Sergio Martin + + * include/functions_treeview.php + operation/tree.php: Added module info table to the + tree view and fix the hash of instances when is in + metaconsole mode + 2013-01-29 Miguel de Dios * godmode/modules/manage_network_components_form.php, diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index cd5d629737..68b2ae7395 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -14,9 +14,120 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function treeview_printAlertsTable($id_module, $console_url = '') { +function treeview_printModuleTable($id_module, $server_data = false) { + global $config; + + if(empty($server_data)) { + $server_name = ''; + $server_id = ''; + $url_hash = ''; + $console_url = ''; + } + else { + $server_name = $server_data['server_name']; + $server_id = $server_data['id']; + $console_url = $server_data['server_url'] . '/'; + $url_hash = metaconsole_get_servers_url_hash($server_data); + } + + require_once ($config["homedir"] . "/include/functions_agents.php"); + require_once ($config["homedir"] . "/include/functions_graph.php"); + include_graphs_dependencies($config['homedir'].'/'); + require_once ($config['homedir'] . "/include/functions_groups.php"); + require_once ($config['homedir'] . "/include/functions_servers.php"); + enterprise_include_once ('meta/include/functions_modules_meta.php'); + enterprise_include_once ('meta/include/functions_ui_meta.php'); + enterprise_include_once ('meta/include/functions_metaconsole.php'); + + $filter["id_agente_modulo"] = $id_module; + + $module = db_get_row_filter ("tagente_modulo", $filter); + + if ($module === false) { + echo ui_print_error_message(__('There was a problem loading module')); + return; + } + + if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) { + db_pandora_audit("ACL Violation", + "Trying to access Module Information"); + require_once ("general/noaccess.php"); + return; + } + + echo '
'; + echo ''; + //Agent name + echo ''; + + if ($module["disabled"]) + $cellName = "" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; + else + $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); + + echo ''; + + // Server + echo ''; + echo ''; + + // Parent + echo ''; + echo ''; + + echo ''; + echo ''; + + // Group icon + echo ''; + echo ''; + + //End of table + echo '
'.__('Module name').''.$cellName.'
'.__('Server').''; + echo $server_data['server_name']; + echo '
'.__('Module group').''; + $module_group = modules_get_modulegroup_name($module['id_module_group']); + + if ($module_group === false) + echo __('Not assigned'); + else + echo __("$module_group"); + echo '
'.__('Module type').''; + echo servers_show_type ($module['id_modulo']); + echo '
'.__('Description').''. ui_print_truncate_text ($module['descripcion'], GENERIC_SIZE_TEXT, true, true, true, '[…]') .'
'; + echo "
"; + + $id_group = agents_get_agent_group($module['id_agente']); + $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); + $agent_name = db_get_value('nombre', 'tagente', 'id_agente', $module['id_agente']); + + // Actions table + echo ''; + echo ''; + echo ''; + echo '
'; + html_print_submit_button (__('Go to modules detail'), 'upd_button', false, 'class="sub search"'); + echo '
'; + + return; +} + +function treeview_printAlertsTable($id_module, $server_data = array()) { global $config; + if(empty($server_data)) { + $server_name = ''; + $server_id = ''; + $url_hash = ''; + $console_url = ''; + } + else { + $server_name = $server_data['server_name']; + $server_id = $server_data['id']; + $console_url = $server_data['server_url'] . '/'; + $url_hash = metaconsole_get_servers_url_hash($server_data); + } + $module_alerts = alerts_get_alerts_agent_module($id_module); $module_name = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_module); $agent_id = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_module); @@ -56,16 +167,31 @@ function treeview_printAlertsTable($id_module, $console_url = '') { } echo ''; - echo '
'; - echo '
'; + // Actions table + echo ''; + echo ''; + echo ''; + echo '
'; html_print_submit_button (__('Go to alerts detail'), 'upd_button', false, 'class="sub search"'); - echo ''; - echo ''; + echo '
'; } -function treeview_printTable($id_agente, $console_url = '') { +function treeview_printTable($id_agente, $server_data = array()) { global $config; + if(empty($server_data)) { + $server_name = ''; + $server_id = ''; + $url_hash = ''; + $console_url = ''; + } + else { + $server_name = $server_data['server_name']; + $server_id = $server_data['id']; + $console_url = $server_data['server_url'] . '/'; + $url_hash = metaconsole_get_servers_url_hash($server_data); + } + require_once ("include/functions_agents.php"); require_once ($config["homedir"] . '/include/functions_graph.php'); include_graphs_dependencies(); @@ -227,12 +353,15 @@ function treeview_printTable($id_agente, $console_url = '') { echo '
'; + echo ''; - echo ''; - echo '
'; + // If user has access to normal console + echo '
'; + echo ''; + + echo '
'; html_print_submit_button (__('Go to agent detail'), 'upd_button', false, 'class="sub search"'); - echo ''; - echo ''; + echo '
'; return; } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index d7620b8e8e..ad2a73e1d7 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -54,19 +54,17 @@ if (is_ajax ()) $search_free = get_parameter('search_free', ''); $printTable = get_parameter('printTable', 0); $printAlertsTable = get_parameter('printAlertsTable', 0); + $printModuleTable = get_parameter('printModuleTable', 0); $server_name = get_parameter('server_name', ''); + $server = array(); if ($printTable) { $id_agente = get_parameter('id_agente'); if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); metaconsole_connect($server); - $console_url = $server['server_url'] . '/'; - } - else { - $console_url = ''; } - treeview_printTable($id_agente, $console_url); + treeview_printTable($id_agente, $server); if (defined ('METACONSOLE')) { metaconsole_restore_db(); @@ -78,14 +76,25 @@ if (is_ajax ()) if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); metaconsole_connect($server); - $console_url = $server['server_url'] . '/'; - } - else { - $console_url = ''; } - treeview_printAlertsTable($id_module, $console_url); + treeview_printAlertsTable($id_module, $server); + if (defined ('METACONSOLE')) { + metaconsole_restore_db(); + } + } + if ($printModuleTable) { + $id_module = get_parameter('id_module'); + + if (defined ('METACONSOLE')) { + $server = metaconsole_get_connection ($server_name); + metaconsole_connect($server); + } + + treeview_printModuleTable($id_module, $server); + + if (defined ('METACONSOLE')) { metaconsole_restore_db(); } @@ -435,12 +444,16 @@ if (is_ajax ()) $nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"])); if($nmodule_alerts > 0) { - echo "" . html_print_image ("images/bell.png", true, array ("style" => 'vertical-align: middle;', "border" => "0", "title" => __('Module alerts') )) . ""; + echo ""; + echo html_print_image ("images/bell.png", true, array ("style" => 'vertical-align: middle;', "border" => "0", "title" => __('Module alerts') )); + echo ""; echo " "; } + echo ""; echo io_safe_output($row['nombre']); + echo ""; if ($row['quiet']) { echo " "; html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); @@ -770,4 +783,15 @@ treeview_printTree($activeTab); } }); } + + function loadModuleTable(id_module, server_name) { + $.ajax({ + type: "POST", + url: , + data: "page=&printModuleTable=1&id_module=" + id_module + "&server_name=" + server_name, + success: function(data){ + $('#cont').html(data); + } + }); + }