From 43ef4a799ed1ff699279802216166fff7c08ca00 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 30 Mar 2026 13:48:40 +0700 Subject: [PATCH] Refactor user table display logic in users page - Updated the user table to conditionally render rows based on the presence of IP-server pairs, improving clarity in data presentation. - Simplified the rendering of user data when no pairs are available, ensuring a cleaner UI. - Enhanced the display of user links and metrics, maintaining consistent formatting across different scenarios. --- web/src/routes/users/+page.svelte | 130 ++++++++++++++++++------------ 1 file changed, 80 insertions(+), 50 deletions(-) diff --git a/web/src/routes/users/+page.svelte b/web/src/routes/users/+page.svelte index a6430df..4c55d8d 100644 --- a/web/src/routes/users/+page.svelte +++ b/web/src/routes/users/+page.svelte @@ -127,58 +127,88 @@ {@const username = row.username ?? ''} {@const pairs = ipServerPairsByUser[username] ?? []} - - - - {row.username} - - - -
- {#each row.links?.tls ?? [] as link (link)} - - {/each} - {#each row.links?.secure ?? [] as link (link)} - - {/each} -
-
- {formatMiB(row.total_megabytes ?? 0)} - - {#if (row.active_unique_ips ?? 0) > 0} - {row.active_unique_ips} - {#if row.max_unique_ips != null} - / {row.max_unique_ips} - {/if} - {:else} - — - {/if} - - - {row.data_quota_bytes != null ? formatBytes(row.data_quota_bytes) : '—'} - - - {row.expiration_rfc3339 - ? new Date(row.expiration_rfc3339).toLocaleString() - : '—'} - -
- - {#if pairs.length > 0} - {#each pairs as pair (pair.ip + '|' + pair.server)} + {#if pairs.length === 0} + + + + {row.username} + + + +
+ {#each row.links?.tls ?? [] as link (link)} + + {/each} + {#each row.links?.secure ?? [] as link (link)} + + {/each} +
+
+ {formatMiB(row.total_megabytes ?? 0)} + + + {row.data_quota_bytes != null ? formatBytes(row.data_quota_bytes) : '—'} + + + {row.expiration_rfc3339 ? new Date(row.expiration_rfc3339).toLocaleString() : '—'} + +
+ {:else} + {#each pairs as pair, idx (pair.ip + '|' + pair.server)} -   -   -   + + + {row.username} + + + + {#if idx === 0} +
+ {#each row.links?.tls ?? [] as link (link)} + + {/each} + {#each row.links?.secure ?? [] as link (link)} + + {/each} +
+ {:else} +   + {/if} +
+ + {#if idx === 0} + {formatMiB(row.total_megabytes ?? 0)} + {:else} +   + {/if} + {pair.ip} - {pair.server} -   -   + + {#if idx === 0} + {row.data_quota_bytes != null ? formatBytes(row.data_quota_bytes) : '—'} + {:else} +   + {/if} + + + {#if idx === 0} + {row.expiration_rfc3339 ? new Date(row.expiration_rfc3339).toLocaleString() : '—'} + {:else} +   + {/if} +
{/each} {/if}