diff --git a/package-lock.json b/package-lock.json index c036b4566..8aafa3f7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1352,6 +1352,18 @@ "node": ">=6" } }, + "node_modules/@nethesis/vue-components/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -6833,18 +6845,6 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/src/components/NeFilter.vue b/src/components/NeFilter.vue new file mode 100644 index 000000000..790fb3d6b --- /dev/null +++ b/src/components/NeFilter.vue @@ -0,0 +1,255 @@ + + + + + + + + {{ openMenuAriaLabel }} + + + + + + {{ label }} + + + + + + + + + + + + {{ clearFilterLabel }} + + + + + + + + + + + {{ option.label }} + + {{ option.description }} + + + + + + + + + + + + {{ option.label }} + + {{ option.description }} + + + + + + + + + + diff --git a/src/components/standalone/firewall/conntrack/ConntrackContent.vue b/src/components/standalone/firewall/conntrack/ConntrackContent.vue index d957e09d2..5646c8726 100644 --- a/src/components/standalone/firewall/conntrack/ConntrackContent.vue +++ b/src/components/standalone/firewall/conntrack/ConntrackContent.vue @@ -17,6 +17,8 @@ import { NeTextInput } from '@nethesis/vue-components' import { useNotificationsStore } from '@/stores/notifications' +import NeFilter, { type FilterOption } from '@/components/NeFilter.vue' + const notificationsStore = useNotificationsStore() import { getAxiosErrorMessage } from '@nethesis/vue-components' @@ -51,8 +53,36 @@ const error = ref({ notificationTitle: '' }) const filter = ref('') +const protocolFilter = ref([]) const showDeleteModal = ref(false) +const protocolFilterOptions: FilterOption[] = [ + { id: 'tcp', label: 'TCP' }, + { id: 'udp', label: 'UDP' }, + { id: 'icmp', label: 'ICMP' } + // { id: 'test1', label: 'Test 1' }, + // { id: 'test2', label: 'Test 2' }, + // { id: 'test3', label: 'Test 3' }, + // { id: 'test4', label: 'Test 4' }, + // { id: 'test5', label: 'Test 5' }, + // { id: 'test6', label: 'Test 6' }, + // { id: 'test7', label: 'Test 7' }, + // { id: 'test8', label: 'Test 8' }, + // { id: 'test9', label: 'Test 9' }, + // { id: 'test10', label: 'Test 10' }, + // { id: 'test11', label: 'Test 11' }, + // { id: 'test12', label: 'Test 12' }, + // { id: 'test13', label: 'Test 13' }, + // { id: 'test14', label: 'Test 14' }, + // { id: 'test15', label: 'Test 15' }, + // { id: 'test16', label: 'Test 16' }, + // { id: 'test17', label: 'Test 17' }, + // { id: 'test18', label: 'Test 18' }, + // { id: 'test19', label: 'Test 19' }, + // { id: 'test20', label: 'Test 20' }, + // { id: 'test99999999', label: 'Test 99999999999912345' } +] + onMounted(() => { fetchConntrack() }) @@ -72,9 +102,9 @@ async function fetchConntrack() { isLoading.value = false } } -function applyFilterToConntrackRecords(records: ConntrackRecord[], filter: string) { - const lowerCaseFilter = filter.toLowerCase() - return records.filter( +function applyFilterToConntrackRecords() { + const lowerCaseFilter = filter.value.toLowerCase() + const textFiltered = conntrackRecords.value.filter( (ConntrackRecord) => ConntrackRecord.source.toLowerCase().includes(lowerCaseFilter) || ConntrackRecord.destination.toLowerCase().includes(lowerCaseFilter) || @@ -83,6 +113,10 @@ function applyFilterToConntrackRecords(records: ConntrackRecord[], filter: strin (ConntrackRecord.source_port ?? '').toLowerCase().includes(lowerCaseFilter) || (ConntrackRecord.destination_port ?? '').toLowerCase().includes(lowerCaseFilter) ) + + return textFiltered.filter( + (record) => !protocolFilter.value.length || protocolFilter.value.includes(record.protocol) + ) } function deleteAll() { @@ -100,9 +134,7 @@ function closeDeleteModal() { } const filteredItems = computed(() => { - return filter.value === '' - ? conntrackRecords.value - : applyFilterToConntrackRecords(conntrackRecords.value, filter.value) + return applyFilterToConntrackRecords() }) function onRecordDeleted() { @@ -159,6 +191,14 @@ function onRecordDeleted() { + {{ t('common.clear_filter') }} diff --git a/src/views/standalone/ReportView.vue b/src/views/standalone/ReportView.vue index 1f80d5799..dc8b4fd6f 100644 --- a/src/views/standalone/ReportView.vue +++ b/src/views/standalone/ReportView.vue @@ -4,13 +4,14 @@ -->