From 8e7f0947fbbbf8677a5598a52e057cb1965b16fc Mon Sep 17 00:00:00 2001 From: zasbu <136494048+zasbu@users.noreply.github.com> Date: Sat, 7 Nov 2026 02:24:12 +1100 Subject: [PATCH 01/12] Fold the servers chart and list into one board, like the activity page --- web/src/app/servers/page.tsx | 3 +- web/src/features/servers/ServerActivity.tsx | 99 +++++++++++---------- web/src/features/servers/ServerList.tsx | 36 +++++--- web/src/features/servers/ServerRow.tsx | 5 +- web/src/features/servers/ServerRows.tsx | 67 +++++++------- 5 files changed, 116 insertions(+), 94 deletions(-) diff --git a/web/src/app/servers/page.tsx b/web/src/app/servers/page.tsx index c703778..b6891b7 100644 --- a/web/src/app/servers/page.tsx +++ b/web/src/app/servers/page.tsx @@ -10,8 +10,7 @@ export const metadata: Metadata = { export default function ServersPage() { return ( - -

Servers

+ ); diff --git a/web/src/features/servers/ServerActivity.tsx b/web/src/features/servers/ServerActivity.tsx index 61b2468..6b48a15 100644 --- a/web/src/features/servers/ServerActivity.tsx +++ b/web/src/features/servers/ServerActivity.tsx @@ -1,10 +1,9 @@ "use client"; -// Players online across listed servers over the last day, week, month or year. Hovering, tapping or arrow -// keys read a point: players and servers at that time. Every range arrives with the page, so switching is -// instant. +// The top of the Servers board: its title and players online across listed servers over the last day, week, +// month or year. Hovering, tapping or arrow keys read a point: players and servers at that time. Every range +// arrives with the page, so switching is instant. import { type ReactNode, useState } from "react"; import type { Schemas } from "@/api/client"; -import { Card } from "@/ui/Card"; import { classNames } from "@/ui/classNames"; import { LineChart } from "@/ui/LineChart"; import { Segmented } from "@/ui/Segmented"; @@ -36,8 +35,11 @@ const date = new Intl.DateTimeFormat("en", { }); export function ServerActivity({ + heading, activity, }: { + /** Sits in the chart's top row, so the page doesn't spend a line on its own title. */ + heading: string; activity: Partial>; }) { const [range, setRange] = useState("day"); @@ -47,48 +49,54 @@ export function ServerActivity({ // The longer ranges' buckets are averages, so "now" always comes from the day's. const now = activity.day?.points.at(-1) ?? points.at(-1); const hovered = active === null ? undefined : points[active]; - if (!current || !now || points.length < 2) return null; + const title =

{heading}

; + // Without a chart to draw, the board still opens with its title. + if (!current || !now || points.length < 2) + return
{title}
; const peak = Math.max(...points.map((point) => point.players)); return ( - -
-

- {hovered ? ( - <> - - {hovered.players === 1 ? "player" : "players"} - {range !== "day" && " on average"} - - - - {hovered.servers === 1 ? "server" : "servers"} - - - - {when(hovered.at, current.bucket_minutes)} - - - ) : ( - <> - 0 ? "text-success" : "text-danger"} - > - online now - - - - {now.servers === 1 ? "server" : "servers"} - - - peak in {rangeLabel(range)} - - )} -

+
+
+
+ {title} +

+ {hovered ? ( + <> + + {hovered.players === 1 ? "player" : "players"} + {range !== "day" && " on average"} + + + + {hovered.servers === 1 ? "server" : "servers"} + + + + {when(hovered.at, current.bucket_minutes)} + + + ) : ( + <> + 0 ? "text-success" : "text-danger"} + > + online now + + + + {now.servers === 1 ? "server" : "servers"} + + + peak in {rangeLabel(range)} + + )} +

+
-
+ {/* Darker than the board, so the trace reads as a screen rather than more flat fill. */} +
{edge(points.at(-1)?.at, range)}
- +
); } diff --git a/web/src/features/servers/ServerList.tsx b/web/src/features/servers/ServerList.tsx index bd03a94..03b20f8 100644 --- a/web/src/features/servers/ServerList.tsx +++ b/web/src/features/servers/ServerList.tsx @@ -1,5 +1,6 @@ -// The Servers page: activity over time, then the listed servers running the SourceJump plugin, online ones -// first. Staff with manage_servers also see unlisted servers there, and list or unlist them in place. +// The Servers page as one board: its title and activity over time, then the listed servers running the +// SourceJump plugin, online ones first. Staff with manage_servers also see unlisted servers there, and list or +// unlist them in place. import { api } from "@/api/client"; import { ServerActivity } from "./ServerActivity"; import { ServerRows } from "./ServerRows"; @@ -14,22 +15,29 @@ export async function ServerList() { ), ]); const servers = result?.data?.servers; - if (!servers) { - return

Servers couldn't be loaded. Try again in a moment.

; - } - if (servers.length === 0) return ; return ( -
+
0 + ? { + day: day?.data, + week: week?.data, + month: month?.data, + year: year?.data, + } + : {} + } /> - + {servers ? ( + + ) : ( +

+ Servers couldn't be loaded. Try again in a moment. +

+ )}
); } diff --git a/web/src/features/servers/ServerRow.tsx b/web/src/features/servers/ServerRow.tsx index 390f762..f556729 100644 --- a/web/src/features/servers/ServerRow.tsx +++ b/web/src/features/servers/ServerRow.tsx @@ -244,8 +244,9 @@ export function ServerRowFrame({ return (
diff --git a/web/src/features/servers/ServerRows.tsx b/web/src/features/servers/ServerRows.tsx index 5221bbe..ab01ecd 100644 --- a/web/src/features/servers/ServerRows.tsx +++ b/web/src/features/servers/ServerRows.tsx @@ -8,7 +8,6 @@ import type { CSSProperties, ReactNode } from "react"; import type { Schemas } from "@/api/client"; import { StaffServerRow } from "@/features/staff/servers/StaffServerRow"; import { useStaffServers } from "@/features/staff/servers/useStaffServers"; -import { Card } from "@/ui/Card"; import { ChoiceBar } from "@/ui/ChoiceBar"; import { classNames } from "@/ui/classNames"; import { LinkTabs } from "@/ui/LinkTabs"; @@ -24,11 +23,7 @@ export function ServerRows({ if (staff) { if (staff.servers.length === 0) { - return ( - - No server has sent a heartbeat or been listed yet. - - ); + return No server has sent a heartbeat or been listed yet.; } // A server listed before it was ever heard from has no mark to read, so it stays under Public. const marked = (server: Schemas["StaffServer"]) => @@ -50,11 +45,7 @@ export function ServerRows({ } if (servers.length === 0) { - return ( - - No listed server has been online in the last day. - - ); + return No listed server has been online in the last day.; } const shown = servers.filter((server) => server.whitelist === whitelist); return ( @@ -86,31 +77,33 @@ function View({ rows: { address: string; row: ReactNode }[]; }) { return ( -
+
{(hasWhitelist || whitelist) && ( - - - +
+ + + +
)} {rows.length > 0 ? ( ) : ( - + {whitelist ? "No whitelist server has been online in the last day." : "No public server has been online in the last day."} - + )}
); @@ -125,17 +118,21 @@ function Rows({ pairs: boolean; }) { return ( -
+
+ {/* Each cell draws the line below it; pulled down a pixel so the last row's line sits on the board's edge. */}