Fix issue with modules

This commit is contained in:
Jose Gonzalez 2022-01-06 16:23:13 +01:00
parent 68e63bd5fb
commit 8cdf1acd42
2 changed files with 20 additions and 15 deletions

View File

@ -1480,7 +1480,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'return' => true, 'return' => true,
'nothing' => __('All'), 'nothing' => __('All'),
'nothing_value' => 0, 'nothing_value' => 0,
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
$output .= '</div>'; $output .= '</div>';
@ -1533,7 +1533,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'return' => true, 'return' => true,
'multiple' => true, 'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;', 'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
@ -1550,7 +1550,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'name' => 'filtered-module-show-common-modules-'.$uniqId, 'name' => 'filtered-module-show-common-modules-'.$uniqId,
'selected' => $data['mShowCommonModules'], 'selected' => $data['mShowCommonModules'],
'return' => true, 'return' => true,
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
@ -1565,11 +1565,10 @@ function html_print_select_multiple_modules_filtered(array $data):string
$all_modules = []; $all_modules = [];
} }
if ($data['mShowSelectedOtherGroups']) { if (isset($data['mShowSelectedOtherGroups']) === true) {
$selected_modules_ids = explode(',', $data['mModules']); $selected_modules_ids = explode(',', $data['mModules']);
foreach ($selected_modules_ids as $id) { foreach ($selected_modules_ids as $id) {
if (!array_key_exists($id, $all_modules)) { if (array_key_exists($id, $all_modules) === false) {
$module_data = modules_get_agentmodule($id); $module_data = modules_get_agentmodule($id);
$all_modules[$id] = $module_data['nombre']; $all_modules[$id] = $module_data['nombre'];
} }

View File

@ -211,7 +211,7 @@ function fmAgentChange(uniqId) {
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function fmModuleChange(uniqId) { function fmModuleChange(uniqId, isMeta) {
var idModuleGroup = $("#filtered-module-module-group-" + uniqId).val(); var idModuleGroup = $("#filtered-module-module-group-" + uniqId).val();
var idAgents = $("#filtered-module-agents-" + uniqId).val(); var idAgents = $("#filtered-module-agents-" + uniqId).val();
var showCommonModules = $( var showCommonModules = $(
@ -230,7 +230,9 @@ function fmModuleChange(uniqId) {
$("#filtered-module-modules-" + uniqId).html(""); $("#filtered-module-modules-" + uniqId).html("");
if (data) { if (data) {
jQuery.each(data, function(id, value) { jQuery.each(data, function(id, value) {
var option = $("<option></option>") var option = $("<option></option>");
if (isMeta === true) {
option
.attr( .attr(
"value", "value",
value["id_node"] value["id_node"]
@ -238,6 +240,10 @@ function fmModuleChange(uniqId) {
: value["id_agente_modulo"] : value["id_agente_modulo"]
) )
.html(value["nombre"]); .html(value["nombre"]);
} else {
option.attr("value", value).html(value);
}
$("#filtered-module-modules-" + uniqId).append(option); $("#filtered-module-modules-" + uniqId).append(option);
}); });
} }