From 0838afe8b14e13c72d20b2b297b066ea25df2f3b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Apr 2024 14:05:05 +0200 Subject: [PATCH] #13059 fix bugs chose modules, chose agents, css, save and print data --- pandora_console/include/functions_html.php | 29 +++++++++++++++++-- .../include/javascript/pandora_dashboards.js | 4 +++ .../lib/Dashboard/Widgets/agent_module.php | 19 ++++++------ pandora_console/views/dashboard/cell.php | 1 + 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index cd326fd037..9d905b521e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -16,7 +16,7 @@ * @package Include * @subpackage HTML */ - +use PandoraFMS\Enterprise\Metaconsole\Node; if (!isset($config)) { $working_dir = getcwd(); $working_dir = str_replace('\\', '/', $working_dir); @@ -2078,7 +2078,7 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin explode(',', $data['mAgents']), !$commonModules, !is_metaconsole(), - (bool) $commonModules, + is_metaconsole(), false ); } else { @@ -2091,6 +2091,31 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin ',', $data['mModules'] ); + } else { + if (is_metaconsole()) { + foreach ($data['mModules'] as $row) { + $exp = explode('|', $row); + if (empty($exp[0]) === false) { + if (is_numeric($exp[1]) === false) { + if (is_metaconsole() === true) { + $node = new Node($exp[0]); + $node->connect(); + } + + $module = explode(' » ', $exp[1]); + $id_agente = db_get_sql(sprintf('SELECT id_agente FROM tagente WHERE nombre = "%s"', $module[1])); + $id_agente_modulo = db_get_sql(sprintf('SELECT id_agente_modulo FROM tagente_modulo WHERE nombre = "%s" AND id_agente = %s', $module[2], $id_agente)); + $array = [ + $exp[0].'|'.$id_agente_modulo => $exp[0].'|'.$id_agente_modulo, + ]; + $mModules = array_merge($mModules, $array); + if (is_metaconsole() === true) { + $node->disconnect(); + } + } + } + } + } } $result = []; diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 5378cca346..f7d84f2314 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -281,6 +281,8 @@ function initialiceLayout(data) { }); $("#configure-widget-" + id).click(function() { + widgetId = + widgetId === 0 ? $("#hidden-widget_id_" + id).val() : widgetId; getSizeModalConfiguration(id, widgetId); }); @@ -815,6 +817,8 @@ function initialiceLayout(data) { }); $("#configure-widget-" + cellId).click(function() { + widgetId = + widgetId === 0 ? $("#hidden-widget_id_" + cellId).val() : widgetId; getSizeModalConfiguration(cellId, widgetId); }); diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index 3ff5174b71..b9ff34129e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -179,7 +179,7 @@ class AgentModuleWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (isset($this->values['mModules']) === false) { + if (isset($this->values['mModules']) === false || (isset($this->values['mModules']) === true && empty($this->values['mModules'][0]) === true)) { $this->configurationRequired = true; } @@ -825,14 +825,15 @@ class AgentModuleWidget extends Widget } $key_name_module = $module->name(); - - if ($this->values['mTypeShow'] === '1') { - $mod = $module->toArray(); - $mod['datos'] = $module->lastValue(); - $module_last_value = modules_get_agentmodule_data_for_humans($mod); - $visualData[$agent_id]['modules'][$key_name_module] = $module_last_value; - } else { - $visualData[$agent_id]['modules'][$key_name_module] = $module->getStatus()->estado(); + if (array_key_exists($key_name_module, $allModules) === true) { + if ($this->values['mTypeShow'] === '1') { + $mod = $module->toArray(); + $mod['datos'] = $module->lastValue(); + $module_last_value = modules_get_agentmodule_data_for_humans($mod); + $visualData[$agent_id]['modules'][$key_name_module] = $module_last_value; + } else { + $visualData[$agent_id]['modules'][$key_name_module] = $module->getStatus()->estado(); + } } } diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index 910e7a114b..17be61a2b2 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -71,6 +71,7 @@ if ($manageDashboards !== 0 || $writeDashboards !== 0) { $output .= ''; $widget_description = db_get_value_sql('SELECT description FROM twidget WHERE id ='.$cellData['id_widget']); $output .= html_print_input_hidden('widget_name_'.$cellData['id'], $widget_description, true); + $output .= html_print_input_hidden('widget_id_'.$cellData['id'], $cellData['id_widget'], true); $output .= html_print_image( 'images/configuration@svg.svg', true,