From c0ebc5d283ecf485e239cecab458b7dfd7ac91cc Mon Sep 17 00:00:00 2001 From: Manuel Ceroni <46685230+manuelceroni@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:40:08 +0200 Subject: [PATCH] Reworked the Wazuh section in the asset details (#10289) --- http_src/utilities/table-utils.js | 53 +++++---- http_src/vue/page-asset-details.vue | 101 +++++++++++++++++- http_src/vue/page-assets.vue | 1 + http_src/vue/table-with-config.vue | 3 +- .../tables_config/wazuh_network_ifaces.json | 48 +++++++++ scripts/locales/en.lua | 19 +++- scripts/lua/modules/discover_utils.lua | 2 +- 7 files changed, 195 insertions(+), 32 deletions(-) create mode 100644 httpdocs/tables_config/wazuh_network_ifaces.json diff --git a/http_src/utilities/table-utils.js b/http_src/utilities/table-utils.js index 39a2c747fd..06db169571 100644 --- a/http_src/utilities/table-utils.js +++ b/http_src/utilities/table-utils.js @@ -9,7 +9,7 @@ import FormatterUtils from "./formatter-utils.js"; const _i18n = (t) => i18n(t); -async function build_table(http_prefix, table_id, f_map_columns, f_get_extra_params_obj, f_on_get_rows) { +async function build_table(http_prefix, table_id, f_map_columns, f_get_extra_params_obj, f_on_get_rows, rows_data = null) { let epoch_end = Number.parseInt(Date.now() / 1000); let table_def_url = `${http_prefix}/tables_config/${table_id}.json?epoch_end=${epoch_end}`; let table_def = await ntopng_utility.http_request(table_def_url, null, null, true); @@ -39,7 +39,7 @@ async function build_table(http_prefix, table_id, f_map_columns, f_get_extra_par const table_config = { id: table_id, columns: table_def.columns, - get_rows: get_rows_func(table_def, f_get_extra_params_obj, f_on_get_rows), + get_rows: get_rows_func(table_def, f_get_extra_params_obj, f_on_get_rows, rows_data), get_column_id: get_column_id_func(table_def), print_column_name: get_f_print_column_name(table_def), print_html_row: get_f_print_html_row(table_def), @@ -181,7 +181,7 @@ function get_f_print_v_node_buttons(list_or_array) { }; } -function get_rows_func(table_def, f_get_extra_params_obj, f_on_get_rows) { +function get_rows_func(table_def, f_get_extra_params_obj, f_on_get_rows, rows_data = null) { let f_get_column_id = get_column_id_func(table_def); return async (active_page, per_page, columns_wrap, map_search, first_get_rows) => { let sort_column = columns_wrap.find((c) => c.sort != 0); @@ -201,26 +201,35 @@ function get_rows_func(table_def, f_get_extra_params_obj, f_on_get_rows) { let extra_params = f_get_extra_params_obj(); params = { ...params, ...extra_params, }; } - const url_params = ntopng_url_manager.obj_to_url_params(params); - const url = `${http_prefix}/${table_def.data_url}?${url_params}`; - let res = await ntopng_utility.http_request(url, null, null, true); - if (f_on_get_rows != null) { - f_on_get_rows(params); + let rows, query_info, total_rows; + if (rows_data == null) { + const url_params = ntopng_url_manager.obj_to_url_params(params); + const url = `${http_prefix}/${table_def.data_url}?${url_params}`; + let res = await ntopng_utility.http_request(url, null, null, true); + if (f_on_get_rows != null) { + f_on_get_rows(params); + } + rows = res.rsp; + + if (table_def.rsp_records_field != null) { + rows = res.rsp[table_def.rsp_records_field]; + } + query_info = res.query_info; + if (table_def.rsp_query_info_field != null) { + query_info = res.rsp[table_def.rsp_query_info_field]; + } + // fix server rest bug + if (res.recordsFiltered > res.recordsTotal) { + res.recordsTotal = res.recordsFiltered; + } + total_rows = res.recordsTotal; } - let rows = res.rsp; - if (table_def.rsp_records_field != null) { - rows = res.rsp[table_def.rsp_records_field]; - } - let query_info = res.query_info; - if (table_def.rsp_query_info_field != null) { - query_info = res.rsp[table_def.rsp_query_info_field]; - } - // fix server rest bug - if (res.recordsFiltered > res.recordsTotal) { - res.recordsTotal = res.recordsFiltered; - } - return { total_rows: res.recordsTotal, rows, query_info }; - // return { total_rows: 1, rows: [rows[0]], query_info }; + else { + rows = rows_data; + query_info = null; + total_rows = rows_data.length; + } + return { total_rows, rows, query_info }; } } diff --git a/http_src/vue/page-asset-details.vue b/http_src/vue/page-asset-details.vue index b267191c4f..93711d3156 100644 --- a/http_src/vue/page-asset-details.vue +++ b/http_src/vue/page-asset-details.vue @@ -1,5 +1,5 @@ @@ -13,23 +13,69 @@ + + + + + + + {{ _i18n('asset_details.wazuh_asset_information') }} + + + + + + + + + + + + + + + + {{ _i18n('asset_details.wazuh_network_interfaces') }} + + + + + + + + + + + + + + +