diff --git a/http_src/vue/ntop_vue.js b/http_src/vue/ntop_vue.js index f5c77a255d..fd3d2fb383 100644 --- a/http_src/vue/ntop_vue.js +++ b/http_src/vue/ntop_vue.js @@ -60,6 +60,7 @@ import { default as PageHistoricalFlow } from "./page-historical-flow-details.vu import { default as PageSNMPQoS } from "./page-snmp-qos.vue" import { default as PageGeoMap } from "./hosts-geomap.vue" import { default as PageCountryStats } from "./page-country-stats.vue" +import { default as PageAsStats } from "./page-as-stats.vue" /* Config pages */ import { default as PageSNMPConfig } from "./page-snmp-config.vue" @@ -142,7 +143,8 @@ let ntopVue = { PageOpenPorts: PageOpenPorts, PageVulnerabilityScanReport: PageVulnerabilityScanReport, PageFlowsList: PageFlowsList, - + PageAsStats: PageAsStats, + /* SNMP */ PageSNMPDevices: PageSNMPDevices, PageSNMPQoS: PageSNMPQoS, diff --git a/http_src/vue/page-aggregated-live-flows.vue b/http_src/vue/page-aggregated-live-flows.vue index 819214191a..50b793f657 100644 --- a/http_src/vue/page-aggregated-live-flows.vue +++ b/http_src/vue/page-aggregated-live-flows.vue @@ -398,6 +398,7 @@ const map_table_def_columns = async (columns) => { return columns; } +/* FUNCTIONS TO FORMAT */ const format_client_name = function (data, rowData) { let alert_label = '' if (data.is_alerted) { diff --git a/http_src/vue/page-country-stats.vue b/http_src/vue/page-country-stats.vue index 9861b14fb7..103873c5c6 100644 --- a/http_src/vue/page-country-stats.vue +++ b/http_src/vue/page-country-stats.vue @@ -43,7 +43,7 @@ const map_table_def_columns = (columns) => { }, "seen_since": (value, row) => { // `seen_since` might require formatting, e.g., date formatting. - const formattedDate = new Date(value*1000).toLocaleDateString(); // Example date formatting + const formattedDate = NtopUtils.secondsToTime(Math.round(new Date().getTime() / 1000) - value) return formattedDate; }, "score": (value, row) => { diff --git a/http_src/vue/page-flows-list.vue b/http_src/vue/page-flows-list.vue index a881d32a7c..ac4d2e1a15 100644 --- a/http_src/vue/page-flows-list.vue +++ b/http_src/vue/page-flows-list.vue @@ -323,10 +323,11 @@ function set_filter_array_label() { el.basic_label = el.label; } - /* Getting the currently selected filter */ - const url_entry = ntopng_url_manager.get_url_entry(el.id) + /* Getting currently selected filter */ + let url_entry = ntopng_url_manager.get_url_entry(el.id) + el.options.forEach((option) => { - if (option.value.toString() === url_entry) { + if ('value' in option && option.value.toString() === url_entry) { el.current_option = option; } }) @@ -453,6 +454,11 @@ function columns_sorting(col, r0, r1) { } const get_extra_params_obj = () => { let extra_params = ntopng_url_manager.get_url_object(); + + if (extra_params.flowhosts_type !== undefined) { + extra_params.flowhosts_type = extra_params.flowhosts_type.slice(0, -2); + } + return extra_params; }; diff --git a/http_src/vue/page-hosts-list.vue b/http_src/vue/page-hosts-list.vue index ea1f113fcc..0e0d8684cd 100644 --- a/http_src/vue/page-hosts-list.vue +++ b/http_src/vue/page-hosts-list.vue @@ -35,6 +35,7 @@ const props = defineProps({ /* ************************************** */ const host_filters_key = ref(0); +const as_filters_key = ref(0); const table_id = props.context?.has_vlans ? ref('hosts_list_with_vlans') : ref('hosts_list'); const table_hosts_list = ref(null); const csrf = props.context.csrf; @@ -262,6 +263,8 @@ async function load_table_filters_array() { const url = `${http_prefix}/lua/rest/v2/get/host/host_filters.lua?${url_params}`; let res = await ntopng_utility.http_request(url); host_filters_key.value = host_filters_key.value + 1 + as_filters_key.value = as_filters_key.value + 1 + return res.map((t) => { const key_in_url = ntopng_url_manager.get_url_entry(t.name); if(dataUtils.isEmptyOrNull(key_in_url)) { diff --git a/httpdocs/inc/as_stats_id.inc b/httpdocs/inc/as_stats_id.inc deleted file mode 100644 index 197a0499bb..0000000000 --- a/httpdocs/inc/as_stats_id.inc +++ /dev/null @@ -1,76 +0,0 @@ - - -// ---------------- Automatic AS table update code ------------------------ - -function as_table_setID (row) { - var index = 0; - var as_key = row.find("td").eq(0).text(); - - // Set the row index to the AS key - row.attr('id', as_key); - - row.find("td").eq(index++).attr('id', as_key+"_key"); - - row.find("td").eq(index++).attr('id', as_key+"_asn"); - row.find("td").eq(index++).attr('id', as_key+"_chart"); - - row.find("td").eq(index++).attr('id', as_key+"_hosts"); - row.find("td").eq(index++).attr('id', as_key+"_score"); - row.find("td").eq(index++).attr('id', as_key+"_host_score_ratio"); - - row.find("td").eq(index++).attr('id', as_key+"_asname"); - - row.find("td").eq(index++).attr('id', as_key+"_since"); - row.find("td").eq(index++).attr('id', as_key+"_alerted_flows"); - row.find("td").eq(index++).attr('id', as_key+"_breakdown"); - row.find("td").eq(index++).attr('id', as_key+"_throughput"); - row.find("td").eq(index++).attr('id', as_key+"_traffic"); - - return row; - -} - -function as_row_update(as_key) { - var url = "@HTTP_PREFIX@/lua/get_as_data.lua?asn="+as_key; - - $.ajax({ - type: 'GET', - url: url, - cache: false, - success: function(content) { - var data = jQuery.parseJSON(content); - $("#"+as_key+'_asn').html(data.column_asn); - $("#"+as_key+'_chart').html(data.column_chart); - - $("#"+as_key+'_hosts').html(data.column_hosts); - $("#"+as_key+'_score').html(data.column_score); - $("#"+as_key+'_host_score_ratio').html(data.column_host_score_ratio); - - $("#"+as_key+'_asname').html(data.column_asname); - - $("#"+as_key+'_since').html(data.column_since); - $("#"+as_key+'_alerted_flows').html(data.column_alerted_flows); - $("#"+as_key+'_breakdown').html(data.column_breakdown); - $("#"+as_key+'_throughput').html(data.column_thpt); - $("#"+as_key+'_traffic').html(data.column_traffic); - }, - error: function(content) { - console.log("error"); - } - }); -} - -// Updating function -function as_table_update () { - var $dt = $("#table-as").data("datatable"); - var rows = $dt.rows; - - for (var row in rows){ - var as_key = rows[row][0].id; - as_row_update(as_key); - } -} - -// Refresh Interval (10 sec) -var as_table_interval = window.setInterval(as_table_update, 10000); -// ---------------- End automatic table update code ------------------------ diff --git a/httpdocs/inc/country_stats_id.inc b/httpdocs/inc/country_stats_id.inc deleted file mode 100644 index b2195e0685..0000000000 --- a/httpdocs/inc/country_stats_id.inc +++ /dev/null @@ -1,69 +0,0 @@ - - -// ---------------- Automatic Country table update code ------------------------ - -function country_table_setID (row) { - var index = 0; - var country_key = row.find("td").eq(0).text(); - - // Set the row index to the AS key - row.attr('id', country_key); - - row.find("td").eq(index++).attr('id', country_key+"_key"); - row.find("td").eq(index++).attr('id', country_key+"_number"); - // skip chart column - index++; - // country_stats_top - row.find("td").eq(index++).attr('id', country_key+"_hosts"); - row.find("td").eq(index++).attr('id', country_key+"_alerts"); - - row.find("td").eq(index++).attr('id', country_key+"_since"); - - // country_stats_bottom - row.find("td").eq(index++).attr('id', country_key+"_score"); - row.find("td").eq(index++).attr('id', country_key+"_breakdown"); - row.find("td").eq(index++).attr('id', country_key+"_throughput"); - row.find("td").eq(index++).attr('id', country_key+"_traffic"); - - return row; - -} - -function country_row_update(country_key) { - var url = "@HTTP_PREFIX@/lua/get_country_data.lua?country="+country_key; - - $.ajax({ - type: 'GET', - url: url, - cache: false, - success: function(content) { - var data = jQuery.parseJSON(content); - $("#"+country_key+'_hosts').html(data.column_hosts); - $("#"+country_key+'_alerts').html(data.column_alerts); - $("#"+country_key+'_since').html(data.column_since); - $("#"+country_key+'_score').html(data.column_score); - $("#"+country_key+'_breakdown').html(data.column_breakdown); - $("#"+country_key+'_throughput').html(data.column_thpt); - $("#"+country_key+'_traffic').html(data.column_traffic); - }, - error: function(content) { - console.log("error"); - } - }); -} - -// Updating function -function country_table_update () { - - var $dt = $("#table-country").data("datatable"); - var rows = $dt.rows; - - for (var row in rows){ - var country_key = rows[row][0].id; - country_row_update(country_key); - } -} - -// Refresh Interval (10 sec) -var country_table_interval = window.setInterval(country_table_update, 10000); -// ---------------- End automatic table update code ------------------------ diff --git a/httpdocs/tables_config/as_stats.json b/httpdocs/tables_config/as_stats.json new file mode 100644 index 0000000000..f0e9dbe9a6 --- /dev/null +++ b/httpdocs/tables_config/as_stats.json @@ -0,0 +1,110 @@ +{ + "id": "as_stats", + "data_url": "lua/rest/v2/get/asn/get_as_data.lua", + "use_current_page": false, + "enable_search": false, + "paging": false, + "display_empty_rows": false, + "columns": [ + { + "id": "as_number", + "title_i18n": "as_number", + "data_field": "asn", + "sortable": false, + "sticky": true, + "class": [ + "text-nowrap" + ] + }, + { + "id": "num_hosts", + "title_i18n": "hosts", + "data_field": "num_hosts", + "sortable": true, + "class": [ + "text-center", + "text-nowrap" + ] + }, + { + "id": "score", + "title_i18n": "score", + "data_field": "score", + "sortable": true, + "class": [ + "text-center", + "text-nowrap" + ] + }, + { + "id": "avg_host_score", + "title_i18n": "avg_host_score", + "data_field": "avg_host_score", + "sortable": true, + "class": [ + "text-center", + "text-nowrap" + ] + }, + { + "id": "name", + "title_i18n": "name", + "data_field": "asname", + "sortable": false, + "class": [ + "text-left", + "text-nowrap" + ] + }, + { + "id": "seen_since", + "title_i18n": "seen_since", + "data_field": "seen_since", + "sortable": true, + "class": [ + "text-center", + "text-nowrap" + ] + }, + { + "id": "alerted_flows", + "title_i18n": "flow_details.alerted_flows", + "data_field": "alerted_flows", + "sortable": true, + "class": [ + "text-nowrap", + "text-center" + ] + }, + { + "id": "breakdown", + "title_i18n": "breakdown", + "data_field": "breakdown", + "sortable": false, + "class": [ + "text-nowrap", + "text-center" + ] + }, + { + "id": "throughput", + "title_i18n": "throughput", + "data_field": "throughput", + "sortable": true, + "class": [ + "text-nowrap", + "text-right" + ] + }, + { + "id": "traffic", + "title_i18n": "traffic", + "data_field": "traffic", + "sortable": true, + "class": [ + "text-nowrap", + "text-right" + ] + } + ] +} \ No newline at end of file diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index a572d35909..7b6bf0b59d 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -1,5 +1,6 @@ local lang = { ["abort"] = "Abort", + ["avg_host_score"] = "Average Host Score", ["num_alerts"] = "Alerts Count", ["city"] = "City", ["acknowledge"] = "Acknowledge", diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua index c9b94c1250..ab79d833b1 100644 --- a/scripts/lua/admin/prefs.lua +++ b/scripts/lua/admin/prefs.lua @@ -2245,13 +2245,13 @@ if auth.has_capability(auth.capabilities.preferences) then return end - print('