From 1a58501af91638e64cff511781ba5bf4450765e3 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 4 Apr 2024 18:21:10 +0200 Subject: [PATCH] #13059 fix bugs dashboard agent module view --- pandora_console/include/functions_html.php | 79 ++++++++++--------- .../javascript/multiselect_filtered.js | 4 +- .../include/javascript/pandora_dashboards.js | 15 +++- .../lib/Dashboard/Widgets/agent_module.php | 6 +- pandora_console/include/styles/pandora.css | 4 + 5 files changed, 69 insertions(+), 39 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 61793193af..9dd4b4a30e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1926,7 +1926,7 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin ] ); $output .= ''; - $output .= '
'; + $output .= '
'; // Recursion. $output .= html_print_input( @@ -2037,33 +2037,35 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin if (is_metaconsole() === true) { $output .= html_print_input( [ - 'label' => __('Agents'), - 'label_class' => 'font-title-font', - 'type' => 'select', - 'fields' => $agents, - 'name' => 'filtered-module-agents-'.$uniqId, - 'selected' => explode(',', $data['mAgents']), - 'return' => true, - 'multiple' => true, - 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - 'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '', + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select', + 'fields' => $agents, + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + 'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '', + 'truncate_size' => 300, ] ); } else { $output .= html_print_input( [ - 'label' => __('Agents'), - 'label_class' => 'font-title-font', - 'type' => 'select_from_sql', - 'sql' => 'SELECT `id_agente`,`alias` FROM tagente', - 'name' => 'filtered-module-agents-'.$uniqId, - 'selected' => explode(',', $data['mAgents']), - 'return' => true, - 'multiple' => true, - 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - 'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '', + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select_from_sql', + 'sql' => 'SELECT `id_agente`,`alias` FROM tagente', + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + 'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '', + 'truncate_size' => 300, ] ); } @@ -2075,8 +2077,9 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin $data['mModuleGroup'], explode(',', $data['mAgents']), !$commonModules, - false, - true + true, + (bool) $commonModules, + false ); } else { $all_modules = []; @@ -2098,16 +2101,17 @@ function html_print_select_multiple_modules_filtered_formated(array $data):strin $output .= html_print_input( [ - 'label' => __('Modules'), - 'label_class' => 'font-title-font', - 'type' => 'select', - 'fields' => $all_modules, - 'name' => 'filtered-module-modules-'.$uniqId, - 'selected' => $result, - 'return' => true, - 'multiple' => true, - 'style' => 'max-width:98%;', - 'input_class' => 'flex-colum-center-important', + 'label' => __('Modules'), + 'label_class' => 'font-title-font', + 'type' => 'select', + 'fields' => $all_modules, + 'name' => 'filtered-module-modules-'.$uniqId, + 'selected' => $result, + 'return' => true, + 'multiple' => true, + 'style' => 'max-width:98%;', + 'input_class' => 'flex-colum-center-important', + 'truncate_size' => 300, ] ); @@ -2162,6 +2166,7 @@ function html_print_select_from_sql( $class='', $required=false, $placeholder='', + $title=false, ) { global $config; @@ -2209,7 +2214,8 @@ function html_print_select_from_sql( '', false, null, - $placeholder + $placeholder, + $title ); } @@ -5989,6 +5995,7 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['class']) === true) ? $data['class'] : ''), ((isset($data['required']) === true) ? $data['required'] : false), ((isset($data['placeholder']) === true) ? $data['placeholder'] : null), + ((isset($data['title']) === true) ? $data['title'] : false), ); break; diff --git a/pandora_console/include/javascript/multiselect_filtered.js b/pandora_console/include/javascript/multiselect_filtered.js index 7bdeba4baf..fd2ab9fe46 100644 --- a/pandora_console/include/javascript/multiselect_filtered.js +++ b/pandora_console/include/javascript/multiselect_filtered.js @@ -218,6 +218,7 @@ function fmModuleChange(uniqId, isMeta) { "#filtered-module-show-common-modules-" + uniqId ).attr("type"); + var select_mode = isMeta === 1 ? 0 : 1; var showCommonModules = +( $("#filtered-module-show-common-modules-" + uniqId).prop("checked") == false ); @@ -229,7 +230,8 @@ function fmModuleChange(uniqId, isMeta) { get_modules_group_json: 1, id_module_group: idModuleGroup, id_agents: idAgents, - selection: showCommonModules + selection: showCommonModules, + select_mode: select_mode }, function(data) { $("#filtered-module-modules-" + uniqId).html(""); diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 2bb7faa773..5378cca346 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -330,7 +330,20 @@ function initialiceLayout(data) { }, dataType: "json", success: function(data) { - addCell(data.cellId, 0, 0, 4, 4, true, 0, 2000, 0, 2000, 0, true); + addCell( + data.cellId, + 0, + 0, + 4, + 4, + true, + 0, + 2000, + 0, + 2000, + original_widgetId, + true + ); }, error: function(xhr, textStatus, errorMessage) { console.log("ERROR" + errorMessage + textStatus + xhr); diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index 7fa4a04fa1..9269956051 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -297,7 +297,7 @@ class AgentModuleWidget extends Widget } $inputs[] = [ - 'class' => 'flex flex-column', + 'class' => 'flex-colum-center-important', 'id' => 'select_multiple_modules_filtered_formated', 'arguments' => [ 'type' => 'select_multiple_modules_filtered_formated', @@ -514,6 +514,10 @@ class AgentModuleWidget extends Widget $array_names = []; foreach ($allModules as $module_name) { + if (is_numeric($module_name)) { + $module_name = modules_get_agentmodule_name($module_name); + } + $file_name = ui_print_truncate_text( \io_safe_output($module_name), 'module_small', diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 824a6c363a..a508eacfca 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -7187,6 +7187,10 @@ div.graph div.legend table { margin-left: 20px; } +.mrgn_lft_20px_important { + margin-left: 20px !important; +} + .mrgn_lft_23px { margin-left: 23px; }