From b89bd7b632ad9dc1de713266907b76a795e9eb64 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 30 Mar 2026 14:10:26 +0700 Subject: [PATCH] Add unique IP count by user in the user traffic table - Introduced a derived state to calculate the count of unique IPs associated with each user, enhancing the data presented in the user traffic table. - Replaced the previous unordered list with a structured table format for better readability and organization of user traffic and IP data. - Updated the user interface to display the number of unique IPs alongside user traffic metrics, improving the overall user experience and data clarity. --- web/src/routes/+page.svelte | 46 ++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 8c3b4ba..a00234d 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -160,6 +160,20 @@ return set.size; }); + let uniqueIpCountByUser = $derived.by((): Record => { + const byUser: Record = {}; + for (const row of uniqueIps ?? []) { + const username = row.username ?? ''; + if (!username) continue; + const set = new Set(); + for (const ip of row.ips ?? []) { + if (ip.ip) set.add(ip.ip); + } + byUser[username] = set.size; + } + return byUser; + }); + let readOnlyNodes = $derived.by(() => { let n = 0; for (const s of fleet?.servers ?? []) { @@ -459,14 +473,30 @@ Топ пользователей по трафику -
    - {#each summary.top_users.slice(0, 10) as t (t.username)} -
  • - {t.username} - {formatMiB(t.total_megabytes)} -
  • - {/each} -
+ + + + Пользователь + Трафик + Замеченные IP + + + + {#each summary.top_users.slice(0, 10) as t (t.username)} + + + + {t.username} + + + {formatMiB(t.total_megabytes)} + + {uniqueIpCountByUser[t.username] ?? 0} + + + {/each} + +
{/if}