Skip to content

Commit

Permalink
Fixes icons incorrectly shown on probes page (#8814)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Nov 13, 2024
1 parent 3d5a351 commit b14991c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
53 changes: 30 additions & 23 deletions http_src/vue/page-exporters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TableWithConfig ref="table_probes" :table_id="table_id" :csrf="csrf" :f_map_columns="map_table_def_columns"
:f_sort_rows="columns_sorting" :get_extra_params_obj="get_extra_params_obj">
</TableWithConfig>

<NoteList :note_list="note_list"> </NoteList>
</div>
</template>
Expand All @@ -35,8 +35,8 @@ import { default as SelectSearch } from "./select-search.vue";
import { default as sortingFunctions } from "../utilities/sorting-utils.js";
import { default as TableWithConfig } from "./table-with-config.vue";
import { default as NoteList } from "./note-list.vue";
import { default as formatterUtils} from "../utilities/formatter-utils";
import { default as dataUtils} from "../utilities/data-utils.js";
import { default as formatterUtils } from "../utilities/formatter-utils";
import { default as dataUtils } from "../utilities/data-utils.js";
const props = defineProps({
context: Object,
Expand Down Expand Up @@ -91,7 +91,7 @@ onMounted(() => {
first_open.value = false;
table_probes.value.refresh_table()
update_sankey_data()
}, 10000 /* 10 sec refresh */)
}, 10000 /* 10 sec refresh */)
})
/* ************************************** */
Expand Down Expand Up @@ -152,19 +152,26 @@ const get_extra_params_obj = () => {
const map_table_def_columns = (columns) => {
let map_columns = {
"ip": (value, row) => {
let returnValue = value;
let exporter_ip = value;
// Add interface name if defined
if (!dataUtils.isEmptyOrNull(row['interface_name'])) {
returnValue = `${returnValue} ${row['interface_name']}`;
exporter_ip = `${exporter_ip} ${row['interface_name']}`;
}
let timeseries_link = ""
// Add timeseries icon if timeseries are enabled
if (row['timeseries_enabled']) {
let timeseriesUrl = `${chart_url}ip=${value}&page=historical&ifid=${row['ifid']}`;
returnValue += `&nbsp;<a href="${timeseriesUrl}"><i class="fas fa-chart-area fa-lg"></i></a>`;
timeseries_link = ` <a href="${timeseriesUrl}"><i class="fas fa-chart-area fa-lg"></i></a>`;
}
let host_link = ""
if (row.is_in_memory) {
const host_details_url = `${http_prefix}/lua/host_details.lua?`
host_link = ` <a href=${host_details_url}host=${value}><i class="fas fa-laptop"></i></a>`
}
return `<a href="${host_url}ip=${value}&exporter_uuid=${row.exporter_uuid}&probe_uuid=${row.probe_uuid}">${returnValue}</a>`;
return `<a href="${host_url}ip=${value}&exporter_uuid=${row.exporter_uuid}&probe_uuid=${row.probe_uuid}">${exporter_ip}</a>${host_link}${timeseries_link}`;
},
"probe_ip": (value, row) => {
return value;
Expand All @@ -183,24 +190,24 @@ const map_table_def_columns = (columns) => {
}
},
"time_last_used": (value, row) => {
if (!value)
return '';
else
return (NtopUtils.secondsToTime((Math.round(new Date().getTime() / 1000)) - value) + " ago");
if (!value)
return '';
else
return (NtopUtils.secondsToTime((Math.round(new Date().getTime() / 1000)) - value) + " ago");
},
"exported_flows": (value, row) => {
let diff_value = value
if(!first_open.value) {
if (!first_open.value) {
const old_value = localStorage.getItem("exporter_exported_flows." + row.exporter_uuid + row.ip)
diff_value = (value - Number(old_value)) / 10
}
localStorage.setItem("exporter_exported_flows." + row.exporter_uuid + row.ip, value)
if (!value)
return '';
let formatted_value = formatterUtils.formatAccounting(value)
if(!first_open.value) {
if (!first_open.value) {
let updated_counter = ''
if(diff_value > 0 ) {
if (diff_value > 0) {
updated_counter = '<i class="fas fa-arrow-up"></i>'
} else {
updated_counter = "<i class='fas fa-minus'></i>"
Expand All @@ -211,17 +218,17 @@ const map_table_def_columns = (columns) => {
},
"dropped_flows": (value, row) => {
let diff_value = value
if(!first_open.value) {
if (!first_open.value) {
const old_value = localStorage.getItem("exporter_dropped_flows." + row.exporter_uuid + row.ip)
diff_value = (value - Number(old_value)) / 10
}
localStorage.setItem("exporter_dropped_flows." + row.exporter_uuid + row.ip, value)
if (!value)
return '';
let formatted_value = formatterUtils.formatAccounting(Math.abs(value))
if(!first_open.value) {
if (!first_open.value) {
let updated_counter = ''
if(diff_value > 0 ) {
if (diff_value > 0) {
updated_counter = '<i class="fas fa-arrow-up"></i>'
} else {
updated_counter = "<i class='fas fa-minus'></i>"
Expand All @@ -232,17 +239,17 @@ const map_table_def_columns = (columns) => {
},
"dropped_packets": (value, row) => {
let diff_value = value
if(!first_open.value) {
if (!first_open.value) {
const old_value = localStorage.getItem("exporter_dropped_packets." + row.exporter_uuid + row.ip)
diff_value = (value - Number(old_value)) / 10
}
localStorage.setItem("exporter_dropped_packets." + row.exporter_uuid + row.ip, value)
if (!value)
return '';
let formatted_value = formatterUtils.formatAccounting(Math.abs(value))
if(!first_open.value) {
if (!first_open.value) {
let updated_counter = ''
if(diff_value > 0 ) {
if (diff_value > 0) {
updated_counter = '<i class="fas fa-arrow-up"></i>'
} else {
updated_counter = "<i class='fas fa-minus'></i>"
Expand All @@ -255,7 +262,7 @@ const map_table_def_columns = (columns) => {
if (!value) {
return '';
} else {
return `<a href="${exporter_url}&ifid=${row.ifid}&ip=${row.probe_ip}"><i class="fas fa-file-export"></i> ${formatterUtils.formatAccounting(value)}</a>`
return `<a href="${exporter_url}&ifid=${row.ifid}&ip=${row.probe_ip}"><i class="fas fa-file-export"></i> ${formatterUtils.formatAccounting(value)}</a>`
}
}
};
Expand All @@ -273,7 +280,7 @@ function columns_sorting(col, r0, r1) {
return sortingFunctions.sortByIP(r0.ip, r1.ip, col.sort);
} else if (col.id == "name") {
return sortingFunctions.sortByName(r0.name, r1.name, col.sort);
} else if (col.id == "ntopng_interface") {
} else if (col.id == "ntopng_interface") {
return sortingFunctions.sortByIP(r0.ntopng_interface, r1.ntopng_interface, col.sort);
} else if (col.id == "probe_ip") {
return sortingFunctions.sortByIP(r0.probe_ip, r1.probe_ip, col.sort);
Expand Down
6 changes: 5 additions & 1 deletion http_src/vue/page-probes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ const get_extra_params_obj = () => {
const map_table_def_columns = (columns) => {
let map_columns = {
"probe_ip": (value, row) => {
return `<a href=${exporter_url}probe_uuid=${row.probe_uuid_num}>${value}</a><a href=${host_url}host=${value}> <i class="fas fa-laptop"></i></a>`
let host_link = ""
if (row.is_in_memory) {
host_link = ` <a href=${host_url}host=${value}> <i class="fas fa-laptop"></i></a>`
}
return `<a href=${exporter_url}probe_uuid=${row.probe_uuid_num}>${value}</a>${host_link}`
},
"probe_public_ip": (value, row) => {
return value
Expand Down
2 changes: 1 addition & 1 deletion httpdocs/dist
Submodule dist updated 1 files
+2 −2 ntopng.js
6 changes: 6 additions & 0 deletions scripts/lua/rest/v2/get/interface/nprobes/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ for interface_id, probes_list in pairs(ifstats.probes or {}) do
local probe_interface
local num_ports = 0
local flow_exporters_num = table.len(probe_info.exporters)
local is_probe_in_memory = false

if probe_info["probe.mode"] == "packet_collection" then
flow_exporters_num = 1 -- Packet exporter
Expand All @@ -64,6 +65,10 @@ for interface_id, probes_list in pairs(ifstats.probes or {}) do
end
probe_interface = i18n("if_stats_overview.remote_probe_collector_mode")
end

if interface.getHostInfo(probe_info["probe.ip"]) then
is_probe_in_memory = true
end

res[#res + 1] = {
probe_interface = probe_interface,
Expand All @@ -79,6 +84,7 @@ for interface_id, probes_list in pairs(ifstats.probes or {}) do
flow_exporters = flow_exporters_num,
exporters_interfaces = num_ports,
dropped_flows = flow_drops,
is_in_memory = is_probe_in_memory,
captured_packets = (probe_info["packets.total"] or 0),
dropped_packets = (probe_info["packets.drops"] or 0),
exported_flows = exported_flows,
Expand Down

0 comments on commit b14991c

Please sign in to comment.