From a6311b4f63376913b05909dd9f128aa605bb6d6a Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Tue, 19 Aug 2025 17:56:46 +0800 Subject: [PATCH] Commit for #355 --- .../configurationComponents/peerList.vue | 35 +++++++--- .../configurationComponents/peerSearch.vue | 4 +- .../configurationComponents/peerSearchBar.vue | 62 +++++++---------- .../peerSettingsDropdown.vue | 2 +- .../configurationComponents/peerTag.vue | 68 ++++++++++++++----- .../peerTagComponents/peerTagColorPicker.vue | 8 --- .../peerTagComponents/peerTagSetting.vue | 52 ++++++++++---- .../stores/WireguardConfigurationsStore.js | 6 +- 8 files changed, 148 insertions(+), 89 deletions(-) diff --git a/src/static/app/src/components/configurationComponents/peerList.vue b/src/static/app/src/components/configurationComponents/peerList.vue index cea058d1..a39f9ec5 100644 --- a/src/static/app/src/components/configurationComponents/peerList.vue +++ b/src/static/app/src/components/configurationComponents/peerList.vue @@ -76,7 +76,6 @@ const configurationModals = ref({ } }) const peerSearchBar = ref(false) - // Fetch Peer ===================================== const fetchPeerList = async () => { await fetchGet("/api/getWireguardConfigurationInfo", { @@ -110,6 +109,7 @@ setFetchPeerListInterval() onBeforeUnmount(() => { clearInterval(fetchPeerListInterval.value); fetchPeerListInterval.value = undefined; + wireguardConfigurationStore.Filter.HiddenTags = [] }) watch(() => { @@ -155,13 +155,28 @@ const configurationSummary = computed(() => { const showPeersCount = ref(10) const showPeersThreshold = 20; +const hiddenPeers = computed(() => { + return wireguardConfigurationStore.Filter.HiddenTags.map(tag => { + return configurationInfo.value.Info.PeerGroups[tag].Peers + }).flat() +}) +const taggedPeers = computed(() => { + return Object.values(configurationInfo.value.Info.PeerGroups).map(x => x.Peers).flat() +}) + const searchPeers = computed(() => { const result = wireguardConfigurationStore.searchString ? configurationPeers.value.filter(x => { - return x.name.includes(wireguardConfigurationStore.searchString) || + return (x.name.includes(wireguardConfigurationStore.searchString) || x.id.includes(wireguardConfigurationStore.searchString) || - x.allowed_ip.includes(wireguardConfigurationStore.searchString) - }) : configurationPeers.value; + x.allowed_ip.includes(wireguardConfigurationStore.searchString)) + && !hiddenPeers.value.includes(x.id) + && ( + wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id)) + ) + }) : configurationPeers.value.filter(x => !hiddenPeers.value.includes(x.id) && ( + wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id)) + )); if (dashboardStore.Configuration.Server.dashboard_sort === "restricted"){ return result.sort((a, b) => { @@ -201,6 +216,7 @@ watch(() => route.query.id, (newValue) => { }) +