implemented inventory widget

This commit is contained in:
alejandro.campos@artica.es 2023-08-01 09:57:49 +02:00
parent 84f61c9022
commit 78e76e1ad3
4 changed files with 1422 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -412,6 +412,10 @@ class Widget
$className .= '\WuxWidget'; $className .= '\WuxWidget';
break; break;
case 'inventory':
$className .= '\InventoryWidget';
break;
case 'os_quick_report': case 'os_quick_report':
$className .= '\OsQuickReportWidget'; $className .= '\OsQuickReportWidget';
break; break;

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,7 @@ if (is_ajax()) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$pendingdelete = (bool) get_parameter('pendingdelete'); $pendingdelete = (bool) get_parameter('pendingdelete');
$get_node_agent = (bool) get_parameter('get_node_agent', false); $get_node_agent = (bool) get_parameter('get_node_agent', false);
$get_agent_inventory_modules = (bool) get_parameter('get_agent_inventory_modules', false);
$refresh_contact = get_parameter('refresh_contact', 0); $refresh_contact = get_parameter('refresh_contact', 0);
@ -1327,6 +1328,86 @@ if (is_ajax()) {
} }
} }
if ($get_agent_inventory_modules) {
$inventory_id_agent = get_parameter('id_agent');
$id_node = (int) get_parameter('id_node');
$sql = 'SELECT `name`
FROM tmodule_inventory, tagent_module_inventory
WHERE tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory';
if ($inventory_id_agent > 0) {
$sql .= ' AND id_agente = '.$inventory_id_agent;
}
$fields = [];
// Get results from all nodes if id_node equals to 0.
if ($id_node === 0 && is_metaconsole() === true) {
$result = [];
$nodes_connection = metaconsole_get_connections();
foreach ($nodes_connection as $key => $server) {
$id_node = $server['id'];
try {
if (is_metaconsole() === true) {
$node = new Node($id_node);
$node->connect();
}
$node_result = db_get_all_rows_sql($sql);
if ($node_result === false) {
continue;
}
$result = array_merge(
$result,
$node_result
);
if (is_metaconsole() === true) {
$node->disconnect();
}
} catch (Exception $e) {
if ($node !== null) {
$node->disconnect();
}
return;
}
}
} else {
try {
if (is_metaconsole() === true) {
$node = new Node($id_node);
$node->connect();
}
$result = db_get_all_rows_sql($sql);
if (is_metaconsole() === true) {
$node->disconnect();
}
} catch (Exception $e) {
if ($node !== null) {
$node->disconnect();
}
return;
}
}
if ($result === false) {
$result = [];
}
echo json_encode($result);
return;
}
return; return;
} }