Some changes, multibox fixes for metaconsole

This commit is contained in:
fbsanchez 2021-06-23 14:24:16 +02:00
parent de03486134
commit be09c1c64d
3 changed files with 55 additions and 16 deletions

View File

@ -1441,7 +1441,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
// Force_serialized.
false,
// Meta_fields.
$data['mMetaFields']
($data['mMetaFields'] ?? is_metaconsole())
);
if ((empty($agents)) === true || $agents == -1) {

View File

@ -133,6 +133,7 @@ div.target {
display: flex;
flex-direction: column;
width: 100%;
box-sizing: border-box;
}
div.target.flex {
border: 2px dashed #ddd;

View File

@ -275,20 +275,38 @@ if (is_ajax()) {
}
} else {
// All modules.
$modules = array_reduce(
$modules[$tserver],
function ($carry, $item) use ($tserver) {
$t = [];
foreach ($item as $k => $v) {
$t[$k] = $v;
}
$return = [];
$nodes = [];
foreach ($agents as $tserver => $id_agents) {
try {
$nodes[$tserver] = new Node($tserver);
} catch (Exception $e) {
hd($e);
}
$t['id_node'] = $tserver;
$carry[] = $t;
return $carry;
},
[]
);
$return = array_reduce(
$modules[$tserver],
function ($carry, $item) use ($tserver, $nodes) {
$t = [];
foreach ($item as $k => $v) {
$t[$k] = $v;
}
$t['id_node'] = $tserver;
if ($nodes[$tserver] !== null) {
$t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' » '.$t['nombre']
);
}
$carry[] = $t;
return $carry;
},
$return
);
}
$modules = $return;
}
echo json_encode($modules);
@ -301,12 +319,27 @@ if (is_ajax()) {
$modules = (array) get_parameter('modules', []);
$existing_modules = [];
$avoid_duplicates = [];
foreach ($modules as $def) {
$data = explode('|', $def);
if (is_metaconsole() === true) {
$id_node = (int) $data[0];
$id_agent = (int) $data[1];
$module_name = $data[2];
$id_agent = db_get_value(
'id_tagente',
'tmetaconsole_agent',
'id_agente',
(int) $data[1]
);
if ($id_agent === false) {
continue;
}
$mod = explode(' » ', $data[2]);
$module_name = $mod[1];
if (empty($module_name) === true) {
$module_name = $data[2];
}
} else {
$id_agent = $data[0];
$module_name = $data[1];
@ -337,6 +370,11 @@ if (is_ajax()) {
$text .= $module->agent()->alias().' » '.$module->nombre();
$id .= $module->id_agente_modulo();
if ($avoid_duplicates[$id] === 1) {
continue;
}
$avoid_duplicates[$id] = 1;
$existing_modules[] = [
'id' => $id,
'text' => io_safe_output($text),