Ported AS table to new table (#8475)

* Fixes parsing error while pasing XML strings with comments

* Ported host countries table to new vue table

* Added country filter when redirected to hosts list page

* Ported network discovery table to TableWithConfig vue component

* FIxed indentation

* Added documentation for VueJS, Lua and cpp used in ntopng

* Fixed error

* Added Netbox pref entry for default site, customizable input box size. To implement cpp side for netbox default site

* Removed tprint

* Ported AS table to new table

* Started fixing live flow IP filter

* Fixed date formatter

* Removed debug code

* Removed tprint

* Removed unused import

---------

Co-authored-by: DGabri <gabriele.deri@gmail.com>
Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
This commit is contained in:
GabrieleDeri 2024-06-26 15:22:55 +02:00 committed by GitHub
parent d6965f24b7
commit 43dcd76e2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 247 additions and 413 deletions

View file

@ -5,164 +5,33 @@
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
local template_utils = require("template_utils")
local page_utils = require "page_utils"
local json = require "dkjson"
require "lua_utils"
local asn = _GET["asn"]
local page_utils = require("page_utils")
sendHTTPContentTypeHeader('text/html')
page_utils.print_header_and_set_active_menu_entry(page_utils.menu_entries.autonomous_systems)
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
page_utils.print_page_title(i18n("as_stats.autonomous_systems"))
page_utils.print_navbar(i18n("as_stats.autonomous_systems"), ntop.getHttpPrefix() .. "lua/as_stats.lua", {{
active = page == "overview" or not page,
page_name = "overview",
label = "<i class=\"fas fa-lg fa-home\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" title=\"" ..
i18n("as_stats.autonomous_systems") .. "\"></i>"
}})
local url = ntop.getHttpPrefix() .. "/lua/get_ases_data.lua?"
if not isEmptyString(asn) then
url = url .. "asn=" .. asn
end
local context = {
ifid = interface.getId()
}
print [[
<div id="table-as"></div>
<script>
var url_update = "]] print (url) print [[";]]
local json_context = json.encode(context)
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/as_stats_id.inc")
print [[
$("#table-as").datatable({
title: "AS List",
url: url_update ,
]]
print('title: "",\n')
print ('rowCallback: function ( row ) { return as_table_setID(row); },')
-- Set the preference table
preference = tablePreferences("rows_number",_GET["perPage"])
if (preference ~= "") then print ('perPage: '..preference.. ",\n") end
-- Automatic default sorted. NB: the column must exist.
print ('sort: [ ["' .. getDefaultTableSort("asn") ..'","' .. getDefaultTableSortOrder("asn").. '"] ],')
print [[
showPagination: true,
columns: [
{
title: "Key",
field: "key",
hidden: true,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("as_number")) print[[",
field: "column_asn",
sortable: true,
css: {
textAlign: 'left'
}
},
{
title: "]] print(i18n("chart")) print[[",
field: "column_chart",
hidden: ]] print(ternary(areASTimeseriesEnabled(interface.getId()), "false", "true")) print[[,
sortable: false,
css: {
textAlign: 'center'
}
},
]]
print [[
{
title: "]] print(i18n("hosts_stats.hosts")) print[[",
field: "column_hosts",
sortable: true,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("score")) print[[",
field: "column_score",
sortable: true,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("host_score_ratio")) print[[",
field: "column_host_score_ratio",
sortable: false,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("name")) print[[",
field: "column_asname",
sortable: true,
css: {
textAlign: 'left'
}
},
{
title: "]] print(i18n("seen_since")) print[[",
field: "column_since",
sortable: true,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("flow_details.alerted_flows")) print[[",
field: "column_alerted_flows",
sortable: true,
css: {
textAlign: 'center'
},
},
]]
print [[
{
title: "]] print(i18n("breakdown")) print[[",
field: "column_breakdown",
sortable: false,
css: {
textAlign: 'center'
}
},
{
title: "]] print(i18n("throughput")) print[[",
field: "column_thpt",
sortable: true,
css: {
textAlign: 'right'
}
},
{
title: "]] print(i18n("traffic")) print[[",
field: "column_traffic",
sortable: true,
css: {
textAlign: 'right'
}
}
]
});
</script>
]]
template_utils.render("pages/vue_page.template", {
vue_page_name = "PageAsStats",
page_context = json_context
})
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")