From dec86ad222e9ef0c45c3f808e153ab1ff27a6dfe Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Nov 2026 12:01:12 +0100 Subject: [PATCH] Add traffic sorting to the WG user page (#1409) * Initial plan * Add peer traffic sorting Co-authored-by: DaanSelen <80752476+DaanSelen@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaanSelen <80752476+DaanSelen@users.noreply.github.com> --- .../app/src/components/configurationComponents/peerList.vue | 6 ++++++ .../src/components/configurationComponents/peerSearch.vue | 1 + 2 files changed, 7 insertions(+) diff --git a/src/static/app/src/components/configurationComponents/peerList.vue b/src/static/app/src/components/configurationComponents/peerList.vue index 85ea6651..f7d5e478 100644 --- a/src/static/app/src/components/configurationComponents/peerList.vue +++ b/src/static/app/src/components/configurationComponents/peerList.vue @@ -191,6 +191,12 @@ const searchPeers = computed(() => { wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id)) )); + if (dashboardStore.Configuration.Server.dashboard_sort === "traffic"){ + return result.sort((a, b) => { + return (b.total_data + b.cumu_data) - (a.total_data + a.cumu_data) + }).slice(0, showPeersCount.value); + } + if (dashboardStore.Configuration.Server.dashboard_sort === "restricted"){ return result.sort((a, b) => { if ( a[dashboardStore.Configuration.Server.dashboard_sort] diff --git a/src/static/app/src/components/configurationComponents/peerSearch.vue b/src/static/app/src/components/configurationComponents/peerSearch.vue index 45dcd8a9..ef77960f 100644 --- a/src/static/app/src/components/configurationComponents/peerSearch.vue +++ b/src/static/app/src/components/configurationComponents/peerSearch.vue @@ -24,6 +24,7 @@ export default { status: GetLocale("Status"), name: GetLocale("Name"), allowed_ip: GetLocale("Allowed IPs"), + traffic: GetLocale("Total Usage"), restricted: GetLocale("Restricted") }, interval: {