From 77b280341bb9e5688b6173198b4db35401e210dc Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sat, 14 Mar 2026 21:21:53 +0100 Subject: [PATCH] fix: use official bunnycdn logo, redesign traffic distribution with map and country grid --- app/sites/[id]/cdn/page.tsx | 91 +++++++++++++++++--------------- app/sites/[id]/settings/page.tsx | 48 +++++++++++++---- 2 files changed, 86 insertions(+), 53 deletions(-) diff --git a/app/sites/[id]/cdn/page.tsx b/app/sites/[id]/cdn/page.tsx index dbfa207..d44f9ab 100644 --- a/app/sites/[id]/cdn/page.tsx +++ b/app/sites/[id]/cdn/page.tsx @@ -24,6 +24,15 @@ import { SkeletonLine, StatCardSkeleton, useMinimumLoading, useSkeletonFade } fr // ─── Helpers ──────────────────────────────────────────────────── +function getCountryName(code: string): string { + try { + const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) + return regionNames.of(code) || code + } catch { + return code + } +} + function formatBytes(bytes: number): string { if (bytes === 0) return '0 B' const units = ['B', 'KB', 'MB', 'GB', 'TB'] @@ -152,7 +161,7 @@ export default function CDNPage() { const daily = dailyStats?.daily_stats ?? [] const countries = topCountries?.countries ?? [] - const maxCountryBandwidth = countries.length > 0 ? countries[0].bandwidth : 1 + const totalBandwidth = countries.reduce((sum, row) => sum + row.bandwidth, 0) return (
@@ -409,56 +418,52 @@ export default function CDNPage() {
- {/* Traffic Distribution Map */} -
+ {/* Traffic Distribution */} +

Traffic Distribution

{countries.length > 0 ? ( -
- ({ - country: row.country_code, - pageviews: row.bandwidth, - }))} - /> -
+ <> +
+ ({ + country: row.country_code, + pageviews: row.bandwidth, + }))} + /> +
+
+ {countries.map((row) => { + const pct = totalBandwidth > 0 ? (row.bandwidth / totalBandwidth) * 100 : 0 + return ( +
+
+ + {getCountryName(row.country_code)} + + + {formatBytes(row.bandwidth)} + +
+
+
+
+
+ {pct.toFixed(1)}% of total traffic +
+
+ ) + })} +
+ ) : (
No geographic data for this period.
)}
- - {/* Bandwidth by Country */} -
-

Bandwidth by Country

- {countries.length > 0 ? ( -
- {countries.map((row) => ( -
- - {row.country_code} - -
-
-
- - {formatBytes(row.bandwidth)} - - - {formatNumber(row.requests)} req - -
- ))} -
- ) : ( -

- No geographic data for this period. -

- )} -
) } diff --git a/app/sites/[id]/settings/page.tsx b/app/sites/[id]/settings/page.tsx index f45423c..7c3fb16 100644 --- a/app/sites/[id]/settings/page.tsx +++ b/app/sites/[id]/settings/page.tsx @@ -1616,11 +1616,25 @@ export default function SiteSettingsPage() {
- - - - - + + + + + + + + + + + + + + + + + + +
@@ -1733,11 +1747,25 @@ export default function SiteSettingsPage() {
- - - - - + + + + + + + + + + + + + + + + + + +