From 4110c7c954d85e905c2c958c0fe4d3248388b7b9 Mon Sep 17 00:00:00 2001 From: ramonn Date: Tue, 27 Nov 2012 19:11:55 +0000 Subject: [PATCH] 2012-11-27 Ramon Novoa * include/functions_treeview.php, operation/tree.php: Added support for agent and module navigation from the metaconsole. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7193 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++ .../include/functions_treeview.php | 8 +- pandora_console/operation/tree.php | 73 +++++++++++-------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 234752e364..cc96111775 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-11-27 Ramon Novoa + + * include/functions_treeview.php, + operation/tree.php: Added support for agent and module navigation + from the metaconsole. + 2012-11-27 Dario Rodriguez * operation/agentes/status_monitor.php: Added title for metaconsole. diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 18479d3057..c428c714c0 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -14,7 +14,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function treeview_printTable($id_agente) { +function treeview_printTable($id_agente, $console_url = '') { global $config; require_once ("include/functions_agents.php"); @@ -99,7 +99,7 @@ function treeview_printTable($id_agente) { echo __('There is no GIS data.'); } else { - echo ''; + echo ''; if ($dataPositionAgent['description'] != "") echo $dataPositionAgent['description']; else @@ -179,7 +179,7 @@ function treeview_printTable($id_agente) { echo ''; - echo '
'; + echo ''; echo '
'; html_print_submit_button (__('Go to agent detail'), 'upd_button', false, 'class="sub upd"'); echo '
'; @@ -259,7 +259,7 @@ function treeview_printTree($type) { } echo "
  • "; - echo ""; + echo ""; echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('. ''.''.$item['_num_ok_'].''.''. diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 476ddd9e0a..d004357308 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -52,10 +52,22 @@ if (is_ajax ()) $statusSel = get_parameter('status'); $search_free = get_parameter('search_free', ''); $printTable = get_parameter('printTable', 0); - + $server_name = get_parameter('server_name', ''); if ($printTable) { $id_agente = get_parameter('id_agente'); - treeview_printTable($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); + + if (defined ('METACONSOLE')) { + metaconsole_restore_db(); + } } /* * It's a binary for branch (0 show - 1 hide) @@ -101,6 +113,10 @@ if (is_ajax ()) $server_rows = array (); } } + // Add the server name + foreach ($server_rows as $key => $row) { + $server_rows[$key]['server_name'] = $server['server_name']; + } $rows = array_merge($rows, $server_rows); } @@ -169,7 +185,7 @@ if (is_ajax ()) } echo "
  • "; echo ""; + href='javascript: loadSubTree(\"agent_" . $type . "\"," . $row["id_agente"] . ", " . $less . ", \"" . $id . "\", \"" . $row["server_name"] . "\")'>"; if ($lessBranchs == 1) html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); @@ -187,7 +203,7 @@ if (is_ajax ()) str_replace('img', 'img style="vertical-align: middle;"', $agent_info["alert_img"]) ); echo ""; + href='javascript: loadTable(\"agent_" . $type . "\"," . $row["id_agente"] . ", " . $less . ", \"" . $id . "\", \"" . $row['server_name'] . "\")'>"; echo " "; echo $row["nombre"]; @@ -229,26 +245,19 @@ if (is_ajax ()) case 'agent_tag': $fatherType = str_replace('agent_', '', $type); - if (! defined ('METACONSOLE')) { - $sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father); - $rows = db_get_all_rows_sql($sql); - } else { - $rows = array (); - foreach ($servers as $server) { - if (metaconsole_connect($server) != NOERR) { - continue; - } - $sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father); - $server_rows = db_get_all_rows_sql($sql); - if ($server_rows === false) { - $server_rows = array (); - } - $rows = array_merge($rows, $server_rows); + if (defined ('METACONSOLE')) { + $server = metaconsole_get_connection ($server_name); + if (metaconsole_connect($server) != NOERR) { + continue; } - + } + + $sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father); + $rows = db_get_all_rows_sql($sql); + $countRows = count ($rows); + if (defined ('METACONSOLE')) { metaconsole_restore_db(); } - $countRows = count ($rows); if ($countRows === 0) { echo "