From e66f33fd37fbe22e2ee243cda93b0033b21b501b Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 22 May 2020 12:14:01 +0200 Subject: [PATCH] WIP Cluster references updated --- .../godmode/agentes/modificar_agente.php | 45 +++++++++++++++---- .../include/class/NetworkMap.class.php | 14 ++++-- .../include/functions_treeview.php | 19 +++++--- pandora_console/include/lib/Agent.php | 11 ----- pandora_console/include/lib/Entity.php | 11 +++++ .../operation/agentes/estado_agente.php | 28 ++++++++++-- .../operation/agentes/estado_monitores.php | 6 ++- pandora_console/operation/users/user_edit.php | 2 +- 8 files changed, 100 insertions(+), 36 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 244e1d8618..94cbc63a1d 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -556,9 +556,18 @@ if ($agents !== false) { $agent['alias'] = $agent['nombre']; } - if ($agent['id_os'] == 100) { - $cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); - echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.$agent['alias'].'</a>'; + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=update&id='.$cluster->id() + ); + echo '<a href="'.$url.'">'.$agent['alias'].'</a>'; + } } else { echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente& sec2=godmode/agentes/configurar_agente&tab=$main_tab& @@ -594,10 +603,18 @@ if ($agents !== false) { echo '</span><div class="left actions" style="visibility: hidden; clear: left">'; if ($check_aw) { - if ($agent['id_os'] == 100) { - $cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); - echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>'; - echo ' | '; + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=update&id='.$cluster->id() + ); + echo '<a href="'.$url.'">'.__('Edit').'</a>'; + } } else { echo '<a href="index.php?sec=gagente& sec2=godmode/agentes/configurar_agente&tab=main& @@ -618,8 +635,18 @@ if ($agents !== false) { id_agente='.$agent['id_agente'].'">'.__('Alerts').'</a>'; echo ' | '; - if ($agent['id_os'] == 100) { - echo '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>'; + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=view&id='.$cluster->id() + ); + echo '<a href="'.$url.'">'.__('View').'</a>'; + } } else { echo '<a href="index.php?sec=estado &sec2=operation/agentes/ver_agente diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 1bacb108ad..e23b148c68 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -1537,14 +1537,15 @@ class NetworkMap /** * Returns target color to be used based on the status received. * - * @param integer $status Source information. + * @param integer $status Source information. + * @param boolean $force_module It's a module. * * @return string HTML tag for color. */ - public static function getColorByStatus($status) + public static function getColorByStatus($status, ?bool $force_module=false) { include_once __DIR__.'/../functions_modules.php'; - return modules_get_color_status($status); + return modules_get_color_status($status, $force_module); } @@ -1661,6 +1662,10 @@ class NetworkMap case NODE_MODULE: $item['id_module'] = $node['source_data']; + $item['color'] = self::getColorByStatus( + $source_data['status'], + true + ); break; case NODE_PANDORA: @@ -1687,7 +1692,8 @@ class NetworkMap $item['color'] = $source_data['color']; } else { $item['color'] = self::getColorByStatus( - $node['status'] + $node['status'], + (bool) $node['id_module'] ); } break; diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 32688a25ea..e067220eb0 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -667,13 +667,22 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) if ($user_access_node && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) { $go_to_agent = '<div style="text-align: right;">'; - if ($agent['id_os'] != 100) { + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=update&id='.$cluster->id() + ); + $go_to_agent .= '<a target="_blank" href="'.$url.'">'; + $go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true); + } + } else { $go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">'; $go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); - } else { - $cluster = db_get_row_sql('select id from tcluster where id_agent = '.$id_agente); - $go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1='.$id_agente.'">'; - $go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true); } $go_to_agent .= '</a>'; diff --git a/pandora_console/include/lib/Agent.php b/pandora_console/include/lib/Agent.php index b3b8c5a6cf..b599f6daed 100644 --- a/pandora_console/include/lib/Agent.php +++ b/pandora_console/include/lib/Agent.php @@ -88,17 +88,6 @@ class Agent extends Entity } - /** - * Returns current object as array. - * - * @return array Of fields. - */ - public function toArray() - { - return $this->fields; - } - - /** * Overrides Entity method. * diff --git a/pandora_console/include/lib/Entity.php b/pandora_console/include/lib/Entity.php index a82e47a2cd..3031a1336f 100644 --- a/pandora_console/include/lib/Entity.php +++ b/pandora_console/include/lib/Entity.php @@ -131,6 +131,17 @@ abstract class Entity } + /** + * Returns current object as array. + * + * @return array Of fields. + */ + public function toArray() + { + return $this->fields; + } + + /** * Saves current object definition to database. * diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index ba51431416..8b974881dd 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -791,8 +791,18 @@ foreach ($agents as $agent) { $data[0] .= '<div class="agentleft_'.$agent['id_agente'].'" style="visibility: hidden; clear: left;">'; - if ($agent['id_os'] == 100) { - $data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_view&id='.$cluster['id'].'">'.__('View').'</a>'; + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=view&id='.$cluster->id() + ); + echo '<a href="'.$url.'">'.__('View').'</a>'; + } } else { $data[0] .= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'">'.__('View').'</a>'; } @@ -800,8 +810,18 @@ foreach ($agents as $agent) { if (check_acl($config['id_user'], $agent['id_grupo'], 'AW')) { $data[0] .= ' | '; - if ($agent['id_os'] == 100) { - $data[0] .= '<a href="index.php?sec=reporting&sec2=enterprise/godmode/reporting/cluster_builder&id_cluster='.$cluster['id'].'&step=1&update=1">'.__('Edit').'</a>'; + if ($agent['id_os'] == CLUSTER_OS_ID) { + if (enterprise_installed()) { + $cluster = PandoraFMS\Enterprise\Cluster::loadFromAgentId( + $agent['id_agente'] + ); + $url = 'index.php?sec=reporting&sec2='.ENTERPRISE_DIR; + $url .= '/operation/cluster/cluster'; + $url = ui_get_full_url( + $url.'&op=update&id='.$cluster->id() + ); + echo '<a href="'.$url.'">'.__('Edit').'</a>'; + } } else { $data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$agent['id_agente'].'">'.__('Edit').'</a>'; } diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index d50ed3a0fb..37b23e622c 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -148,8 +148,10 @@ $sort = get_parameter('sort', 'up'); $modules_not_init = agents_monitor_notinit($id_agente); -if (!empty($modules_not_init)) { - $help_not_init = clippy_context_help('modules_not_init'); +if (empty($modules_not_init) === false) { + $help_not_init = ui_print_warning_message( + __('No initialized modules found.') + ); } else { $help_not_init = ''; } diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index d02b117720..50af55e637 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -463,7 +463,7 @@ $autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console'; $autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map'; $autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console'; $autorefresh_list_out['operation/events/events'] = 'Events'; -$autorefresh_list_out['enterprise/godmode/reporting/cluster_view'] = 'Cluster view'; +$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view'; if (enterprise_installed()) { $autorefresh_list_out['general/sap_view'] = 'SAP view'; }