diff --git a/admin-web/src/features/dashboard/DashboardPage.tsx b/admin-web/src/features/dashboard/DashboardPage.tsx index 9b19189..e4377d0 100644 --- a/admin-web/src/features/dashboard/DashboardPage.tsx +++ b/admin-web/src/features/dashboard/DashboardPage.tsx @@ -5,6 +5,7 @@ import { ArrowUpRight, FileClock, Network, + TrendingUp, Shield, Users } from "lucide-react"; @@ -94,6 +95,10 @@ export function DashboardPage() { .sort((left, right) => (right.rx_bytes + right.tx_bytes) - (left.rx_bytes + left.tx_bytes)) .slice(0, 5); + const busiestDeviceTotal = topDevices.length + ? Math.max(...topDevices.map((device) => (device.rx_bytes ?? 0) + (device.tx_bytes ?? 0))) + : 0; + const recentAudit = [...auditEvents] .sort((left, right) => new Date(right.created_at).getTime() - new Date(left.created_at).getTime()) .slice(0, 6); @@ -112,6 +117,7 @@ export function DashboardPage() { totalRX, totalTX, topDevices, + busiestDeviceTotal, recentAudit }; }, [auditQuery.data, devicesQuery.data, gatewaysQuery.data, policiesQuery.data, servicesQuery.data, usersQuery.data]); @@ -192,6 +198,56 @@ export function DashboardPage() {
Traffic overview
+Loading traffic overview...
: null} + {!isLoading && summary.topDevices.length === 0 ?No tunnel traffic has been recorded yet.
: null} + {summary.topDevices.map((device) => { + const total = (device.rx_bytes ?? 0) + (device.tx_bytes ?? 0); + const width = summary.busiestDeviceTotal > 0 ? `${Math.max(8, Math.round((total / summary.busiestDeviceTotal) * 100))}%` : "0%"; + + return ( +