From be09c1c64daca59bdc48f07041f96526a760c689 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 23 Jun 2021 14:24:16 +0200 Subject: [PATCH] Some changes, multibox fixes for metaconsole --- pandora_console/include/functions_html.php | 2 +- pandora_console/include/styles/alert.css | 1 + .../operation/agentes/ver_agente.php | 68 +++++++++++++++---- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 8429ba64d4..6eabde142f 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1441,7 +1441,7 @@ function html_print_select_multiple_modules_filtered(array $data):string // Force_serialized. false, // Meta_fields. - $data['mMetaFields'] + ($data['mMetaFields'] ?? is_metaconsole()) ); if ((empty($agents)) === true || $agents == -1) { diff --git a/pandora_console/include/styles/alert.css b/pandora_console/include/styles/alert.css index 92bcc5d2df..a5f505c81d 100644 --- a/pandora_console/include/styles/alert.css +++ b/pandora_console/include/styles/alert.css @@ -133,6 +133,7 @@ div.target { display: flex; flex-direction: column; width: 100%; + box-sizing: border-box; } div.target.flex { border: 2px dashed #ddd; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 5a6c0e8a04..7ba2c28782 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -275,20 +275,38 @@ if (is_ajax()) { } } else { // All modules. - $modules = array_reduce( - $modules[$tserver], - function ($carry, $item) use ($tserver) { - $t = []; - foreach ($item as $k => $v) { - $t[$k] = $v; - } + $return = []; + $nodes = []; + foreach ($agents as $tserver => $id_agents) { + try { + $nodes[$tserver] = new Node($tserver); + } catch (Exception $e) { + hd($e); + } - $t['id_node'] = $tserver; - $carry[] = $t; - return $carry; - }, - [] - ); + $return = array_reduce( + $modules[$tserver], + function ($carry, $item) use ($tserver, $nodes) { + $t = []; + foreach ($item as $k => $v) { + $t[$k] = $v; + } + + $t['id_node'] = $tserver; + if ($nodes[$tserver] !== null) { + $t['nombre'] = io_safe_output( + $nodes[$tserver]->server_name().' » '.$t['nombre'] + ); + } + + $carry[] = $t; + return $carry; + }, + $return + ); + } + + $modules = $return; } echo json_encode($modules); @@ -301,12 +319,27 @@ if (is_ajax()) { $modules = (array) get_parameter('modules', []); $existing_modules = []; + $avoid_duplicates = []; foreach ($modules as $def) { $data = explode('|', $def); if (is_metaconsole() === true) { $id_node = (int) $data[0]; - $id_agent = (int) $data[1]; - $module_name = $data[2]; + $id_agent = db_get_value( + 'id_tagente', + 'tmetaconsole_agent', + 'id_agente', + (int) $data[1] + ); + + if ($id_agent === false) { + continue; + } + + $mod = explode(' » ', $data[2]); + $module_name = $mod[1]; + if (empty($module_name) === true) { + $module_name = $data[2]; + } } else { $id_agent = $data[0]; $module_name = $data[1]; @@ -337,6 +370,11 @@ if (is_ajax()) { $text .= $module->agent()->alias().' » '.$module->nombre(); $id .= $module->id_agente_modulo(); + if ($avoid_duplicates[$id] === 1) { + continue; + } + + $avoid_duplicates[$id] = 1; $existing_modules[] = [ 'id' => $id, 'text' => io_safe_output($text),