mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Fix issues with select agents modules control
This commit is contained in:
parent
4f52e1192c
commit
9519e00992
@ -113,6 +113,7 @@ define('SECONDS_3YEARS', 94608000);
|
|||||||
// Separator constats.
|
// Separator constats.
|
||||||
define('SEPARATOR_COLUMN', ';');
|
define('SEPARATOR_COLUMN', ';');
|
||||||
define('SEPARATOR_ROW', chr(10));
|
define('SEPARATOR_ROW', chr(10));
|
||||||
|
define('SEPARATOR_META_MODULE', '|-|-|-|');
|
||||||
// Chr(10) is \n.
|
// Chr(10) is \n.
|
||||||
define('SEPARATOR_COLUMN_CSV', '#');
|
define('SEPARATOR_COLUMN_CSV', '#');
|
||||||
define('SEPARATOR_ROW_CSV', "@\n");
|
define('SEPARATOR_ROW_CSV', "@\n");
|
||||||
|
@ -1555,33 +1555,24 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($data['mAgents'] !== null) {
|
if ($data['mAgents'] !== null) {
|
||||||
$all_modules = select_modules_for_agent_group(
|
$all_modules = get_modules_agents(
|
||||||
$data['mModuleGroup'],
|
$data['mModuleGroup'],
|
||||||
explode(',', $data['mAgents']),
|
explode(',', $data['mAgents']),
|
||||||
$data['mShowCommonModules'],
|
$data['mShowCommonModules'],
|
||||||
false
|
false,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$all_modules = [];
|
$all_modules = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['mShowSelectedOtherGroups']) === true) {
|
|
||||||
$selected_modules_ids = explode(',', $data['mModules']);
|
|
||||||
foreach ($selected_modules_ids as $id) {
|
|
||||||
if (array_key_exists($id, $all_modules) === false) {
|
|
||||||
$module_data = modules_get_agentmodule($id);
|
|
||||||
$all_modules[$id] = $module_data['nombre'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$output .= html_print_input(
|
$output .= html_print_input(
|
||||||
[
|
[
|
||||||
'label' => __('Modules'),
|
'label' => __('Modules'),
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'fields' => $all_modules,
|
'fields' => $all_modules,
|
||||||
'name' => 'filtered-module-modules-'.$uniqId,
|
'name' => 'filtered-module-modules-'.$uniqId,
|
||||||
'selected' => explode(',', $data['mModules']),
|
'selected' => explode((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ',', $data['mModules']),
|
||||||
'return' => true,
|
'return' => true,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'style' => 'min-width: 200px;max-width:200px;',
|
'style' => 'min-width: 200px;max-width:200px;',
|
||||||
|
@ -3555,7 +3555,7 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true)
|
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false)
|
||||||
{
|
{
|
||||||
if ((bool) is_metaconsole() === true) {
|
if ((bool) is_metaconsole() === true) {
|
||||||
if ($select_mode === true) {
|
if ($select_mode === true) {
|
||||||
@ -3675,8 +3675,14 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
|
|||||||
|
|
||||||
$modules = array_reduce(
|
$modules = array_reduce(
|
||||||
$modules,
|
$modules,
|
||||||
function ($carry, $item) {
|
function ($carry, $item) use ($useName) {
|
||||||
$carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
|
// Only works in select mode.
|
||||||
|
if ($useName === true) {
|
||||||
|
$carry[io_safe_input($item['nombre'])] = io_safe_input($item['nombre']);
|
||||||
|
} else {
|
||||||
|
$carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
|
||||||
|
}
|
||||||
|
|
||||||
return $carry;
|
return $carry;
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
|
@ -388,7 +388,7 @@ function initialiceLayout(data) {
|
|||||||
dashboardId: data.dashboardId,
|
dashboardId: data.dashboardId,
|
||||||
widgetId: widgetId
|
widgetId: widgetId
|
||||||
},
|
},
|
||||||
width: widgetId == 14 || widgetId == 2 ? 750 : 450,
|
width: widgetId == 14 || widgetId == 2 || widgetId == 23 ? 750 : 450,
|
||||||
maxHeight: 600,
|
maxHeight: 600,
|
||||||
minHeight: 400
|
minHeight: 400
|
||||||
},
|
},
|
||||||
|
@ -35,7 +35,6 @@ use PandoraFMS\Module;
|
|||||||
*/
|
*/
|
||||||
class AgentModuleWidget extends Widget
|
class AgentModuleWidget extends Widget
|
||||||
{
|
{
|
||||||
const MODULE_SEPARATOR = '|-|-|-|';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name widget.
|
* Name widget.
|
||||||
@ -309,16 +308,12 @@ class AgentModuleWidget extends Widget
|
|||||||
|
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
$values['mModules'] = implode(
|
$values['mModules'] = implode(
|
||||||
self::MODULE_SEPARATOR,
|
SEPARATOR_META_MODULE,
|
||||||
array_reduce(
|
array_reduce(
|
||||||
$values['mModules'],
|
$values['mModules'],
|
||||||
function ($carry, $item) {
|
function ($carry, $item) {
|
||||||
$d = explode('|', $item);
|
$d = explode('|', $item);
|
||||||
if (isset($d[1]) === true) {
|
$carry[] = (isset($d[1]) === true) ? $d[1] : $item;
|
||||||
$carry[] = \io_safe_output($d[1]);
|
|
||||||
} else {
|
|
||||||
$carry[] = \io_safe_output($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $carry;
|
return $carry;
|
||||||
},
|
},
|
||||||
@ -639,7 +634,7 @@ class AgentModuleWidget extends Widget
|
|||||||
$target_modules = $this->values['mModules'];
|
$target_modules = $this->values['mModules'];
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
$target_modules = explode(
|
$target_modules = explode(
|
||||||
self::MODULE_SEPARATOR,
|
SEPARATOR_META_MODULE,
|
||||||
$this->values['mModules']
|
$this->values['mModules']
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -674,14 +669,7 @@ class AgentModuleWidget extends Widget
|
|||||||
if (is_object($item) === true) {
|
if (is_object($item) === true) {
|
||||||
$carry[$item->name()] = null;
|
$carry[$item->name()] = null;
|
||||||
} else {
|
} else {
|
||||||
if ((is_metaconsole() === true
|
$carry[io_safe_output($item)] = null;
|
||||||
&& $this->values['mShowCommonModules'] !== '1')
|
|
||||||
|| is_metaconsole() === false
|
|
||||||
) {
|
|
||||||
$carry[$item] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$carry[] = $item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $carry;
|
return $carry;
|
||||||
@ -721,8 +709,20 @@ class AgentModuleWidget extends Widget
|
|||||||
) {
|
) {
|
||||||
// MC should connect to nodes and retrieve information
|
// MC should connect to nodes and retrieve information
|
||||||
// from targets.
|
// from targets.
|
||||||
|
$reduceAllModules = [];
|
||||||
|
$tmpModules = array_reduce(
|
||||||
|
$target_modules,
|
||||||
|
function ($carry, $item) {
|
||||||
|
// In this case, the modules come with '» ' chain.
|
||||||
|
$tmpCarry = explode('» ', $item);
|
||||||
|
$carry[trim($tmpCarry[1])] = null;
|
||||||
|
|
||||||
|
return $carry;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$modules = $agent->searchModules(
|
$modules = $agent->searchModules(
|
||||||
['id_agente_modulo' => $target_modules]
|
['nombre' => array_keys($tmpModules)]
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user