diff --git a/pandora_console/general/first_task/service_list.php b/pandora_console/general/first_task/service_list.php index 94f1003b6f..f3b816c006 100755 --- a/pandora_console/general/first_task/service_list.php +++ b/pandora_console/general/first_task/service_list.php @@ -12,20 +12,19 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. global $config; -global $agent_w; check_login(); ui_require_css_file('first_task'); ?> true, 'message' => __('There are no services defined yet.') ]); ?> - - +
+
-
- + diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 5edb500e73..1132abbacc 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1552,9 +1552,14 @@ function enterprise_hook($function_name, $parameters=false) /** - * TODO: Document enterprise functions + * Include an enterprise file. + * + * @param string $filename Enterprise file to be included. + * @param array $variables Variables to be exported, as [varname => value]. + * + * @return mixed */ -function enterprise_include($filename) +function enterprise_include($filename, $variables=[]) { global $config; @@ -1576,6 +1581,10 @@ function enterprise_include($filename) } if (file_exists($filepath)) { + if (is_array($variables) === true) { + extract($variables); + } + include $filepath; return true; } @@ -1587,11 +1596,12 @@ function enterprise_include($filename) /** * Includes a file from enterprise section. * - * @param string $filename Target file. + * @param string $filename Enterprise file to be included. + * @param array $variables Variables to be exported, as [varname => value]. * * @return mixed Result code. */ -function enterprise_include_once($filename) +function enterprise_include_once($filename, $variables=[]) { global $config; @@ -1613,6 +1623,10 @@ function enterprise_include_once($filename) } if (file_exists($filepath)) { + if (is_array($variables) === true) { + extract($variables); + } + include_once $filepath; return true; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 02fa0c5154..8429ba64d4 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1488,12 +1488,16 @@ function html_print_select_multiple_modules_filtered(array $data):string ] ); - $all_modules = select_modules_for_agent_group( - $data['mModuleGroup'], - explode(',', $data['mAgents']), - $data['mShowCommonModules'], - false - ); + if ($data['mAgents'] !== null) { + $all_modules = select_modules_for_agent_group( + $data['mModuleGroup'], + explode(',', $data['mAgents']), + $data['mShowCommonModules'], + false + ); + } else { + $all_modules = []; + } if ($data['mShowSelectedOtherGroups']) { $selected_modules_ids = explode(',', $data['mModules']); diff --git a/pandora_console/include/javascript/multiselect_filtered.js b/pandora_console/include/javascript/multiselect_filtered.js index 7976158740..358dadcd68 100644 --- a/pandora_console/include/javascript/multiselect_filtered.js +++ b/pandora_console/include/javascript/multiselect_filtered.js @@ -217,7 +217,12 @@ function fmModuleChange(uniqId) { if (data) { jQuery.each(data, function(id, value) { var option = $("") - .attr("value", value["id_agente_modulo"]) + .attr( + "value", + value["id_node"] + ? value["id_node"] + "|" + value["id_agente_modulo"] + : value["id_agente_modulo"] + ) .html(value["nombre"]); $("#filtered-module-modules-" + uniqId).append(option); }); diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 0b370deab7..542ce10a2b 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -388,7 +388,7 @@ function initialiceLayout(data) { dashboardId: data.dashboardId, widgetId: widgetId }, - width: widgetId == 14 ? 750 : 450, + width: widgetId == 14 || widgetId == 2 ? 750 : 450, maxHeight: 600, minHeight: 400 }, diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index a06a730141..7a072fa168 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -299,10 +299,28 @@ class AgentModuleWidget extends Widget $values['mShowCommonModules'] = \get_parameter( 'filtered-module-show-common-modules-'.$this->cellId ); - $values['mModules'] = \get_parameter( - 'filtered-module-modules-'.$this->cellId + $values['mModules'] = explode( + ',', + \get_parameter( + 'filtered-module-modules-'.$this->cellId + ) ); + if (is_metaconsole() === true) { + $values['mModules'] = implode( + ',', + array_reduce( + $values['mModules'], + function ($carry, $item) { + $d = explode('|', $item); + $carry[] = $d[1]; + return $carry; + }, + [] + ) + ); + } + return $values; } @@ -620,6 +638,10 @@ class AgentModuleWidget extends Widget $reduceAllModules = array_reduce( $all_modules, function ($carry, $item) { + if ($item === null) { + return $carry; + } + $carry[$item->name()] = null; return $carry; } @@ -659,6 +681,10 @@ class AgentModuleWidget extends Widget $visualData[$agent_id]['modules'] = $reduceAllModules; foreach ($modules as $module) { + if ($module === null) { + continue; + } + if ((bool) is_metaconsole() === true) { $reduceAllModules[$module->name()] = null; } diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index 9bb770c3bf..d2a5956e8c 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -161,13 +161,24 @@ class Module extends Entity $obj->{$k}($v); } - if ($obj->nombre() === 'delete_pending') { + if ($obj->nombre() === 'delete_pending' + || $obj->nombre() === 'pendingdelete' + ) { return null; } // Customize certain fields. - $obj->status = new ModuleStatus($obj->id_agente_modulo()); - $obj->moduleType = new ModuleType($obj->id_tipo_modulo()); + try { + $obj->status = new ModuleStatus($obj->id_agente_modulo()); + } catch (\Exception $e) { + $obj->status = null; + } + + try { + $obj->moduleType = new ModuleType($obj->id_tipo_modulo()); + } catch (\Exception $e) { + $obj->moduleType = null; + } // Include some enterprise dependencies. enterprise_include_once('include/functions_config_agents.php'); diff --git a/pandora_console/include/styles/meta_dashboards.css b/pandora_console/include/styles/meta_dashboards.css index b42a9b47b6..f7d19020f3 100644 --- a/pandora_console/include/styles/meta_dashboards.css +++ b/pandora_console/include/styles/meta_dashboards.css @@ -1,8 +1,10 @@ div#page { width: auto; +} +li#select_multiple_modules_filtered { + width: 650px; margin: 0 auto; } - .networkconsole { height: 100%; } diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index 0e85defc80..e47bc9d2ca 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -31,12 +31,20 @@ ul.wizard.inline li { margin-bottom: 0; } -ul.wizard li > label:not(.p-switch) { +ul.wizard li > label:not(.p-switch):first-of-type { width: 250px; vertical-align: top; display: inline-block; } +ul.wizard li > label:not(.p-switch):not(:first-of-type) { + margin-left: 1em; +} + +.select2.select2-container { + min-width: 200px; +} + ul.wizard li > textarea { width: 600px; height: 15em; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index b39830610f..0fc78d9a00 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -27,6 +27,8 @@ * ============================================================================ */ +use PandoraFMS\Enterprise\Metaconsole\Node; + global $config; require_once 'include/functions_gis.php'; @@ -192,9 +194,14 @@ if (is_ajax()) { if ($get_modules_group_json) { $id_group = (int) get_parameter('id_module_group', 0); - $id_agents = get_parameter('id_agents'); + $id_agents = get_parameter('id_agents', null); $selection = get_parameter('selection'); + if ($id_agents === null) { + echo '[]'; + return; + } + if ((bool) is_metaconsole() === true) { if (count($id_agents) > 0) { $rows = db_get_all_rows_sql( @@ -270,8 +277,14 @@ if (is_ajax()) { // All modules. $modules = array_reduce( $modules[$tserver], - function ($carry, $item) { - $carry[] = $item; + function ($carry, $item) use ($tserver) { + $t = []; + foreach ($item as $k => $v) { + $t[$k] = $v; + } + + $t['id_node'] = $tserver; + $carry[] = $t; return $carry; }, [] @@ -290,10 +303,21 @@ if (is_ajax()) { foreach ($modules as $def) { $data = explode('|', $def); - $id_agent = $data[0]; - $module_name = $data[1]; + if (is_metaconsole() === true) { + $id_node = (int) $data[0]; + $id_agent = (int) $data[1]; + $module_name = $data[2]; + } else { + $id_agent = $data[0]; + $module_name = $data[1]; + } try { + if (is_metaconsole() === true) { + $node = new Node($id_node); + $node->connect(); + } + $module = PandoraFMS\Module::search( [ 'id_agente' => $id_agent, @@ -303,14 +327,30 @@ if (is_ajax()) { ); if ($module !== null) { + $text = ''; + if ($node !== null) { + $text = $node->server_name().' » '; + $id = $node->id().'|'; + } + + $text .= $module->agent()->alias().' » '.$module->nombre(); + + $id .= $module->id_agente_modulo(); $existing_modules[] = [ - 'id' => $module->id_agente_modulo(), - 'text' => io_safe_output( - $module->agent()->alias().' » '.$module->nombre() - ), + 'id' => $id, + 'text' => io_safe_output($text), ]; } + + + if (is_metaconsole() === true) { + $node->disconnect(); + } } catch (Exception $e) { + if ($node !== null) { + $node->disconnect(); + } + continue; } }