feat(admin): dashboard home, telemetry section, enrollment ops screen
- mission-control dashboard: now strip, tournament quick actions, usage sparklines, error feed, live activity, tools list - /admin/telemetry with functions/events/errors/players/usage child routes, hand-rolled svg chart primitives, decomposed activities table - error browser with grouping and mark-resolved - consolidated per-tournament enrollment screen; hub simplified with run tournament promoted - /admin/activities redirects to /admin/telemetry/functions
This commit is contained in:
@@ -1,52 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { Tabs } from "@mantine/core";
|
||||
import { Suspense, useState } from "react";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/activities")({
|
||||
component: Stats,
|
||||
beforeLoad: ({ context }) => {
|
||||
const queryClient = context.queryClient;
|
||||
prefetchServerQuery(queryClient, activityQueries.search());
|
||||
prefetchServerQuery(queryClient, playerQueries.activity());
|
||||
beforeLoad: () => {
|
||||
throw redirect({ to: "/admin/telemetry/functions" });
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
header: {
|
||||
title: msg`Activities`,
|
||||
withBackButton: true,
|
||||
},
|
||||
refresh: [activityQueries.search().queryKey, playerQueries.activity().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function Stats() {
|
||||
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
||||
|
||||
return (
|
||||
<Tabs value={activeTab} onChange={setActiveTab}>
|
||||
<Tabs.List mb='md'>
|
||||
<Tabs.Tab value="server-functions"><Trans>Server Functions</Trans></Tabs.Tab>
|
||||
<Tabs.Tab value="player-activity"><Trans>Player Activity</Trans></Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="server-functions">
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSearch withSubtitle withTrailing="text" />}>
|
||||
<ActivitiesTable />
|
||||
</Suspense>
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="player-activity">
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSubtitle withTrailing="text" />}>
|
||||
<PlayersActivityTable />
|
||||
</Suspense>
|
||||
</Tabs.Panel>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { AdminPage } from "@/features/admin";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { AdminDashboard } from "@/features/admin";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import { telemetryQueries } from "@/features/telemetry/queries";
|
||||
import { lastNDays } from "@/features/telemetry/range";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/")({
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, tournamentQueries.current());
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.runtimeStatus());
|
||||
const month = lastNDays(30);
|
||||
prefetchServerQuery(
|
||||
context.queryClient,
|
||||
telemetryQueries.errorGroups({ from: month.from, to: month.to })
|
||||
);
|
||||
},
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
@@ -10,5 +23,5 @@ export const Route = createFileRoute("/_authed/admin/")({
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
component: () => <AdminPage />,
|
||||
component: () => <AdminDashboard />,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Outlet, createFileRoute, useNavigate, useRouterState } from "@tanstack/react-router";
|
||||
import { Tabs } from "@mantine/core";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
const TAB_ROUTES = {
|
||||
functions: "/admin/telemetry/functions",
|
||||
events: "/admin/telemetry/events",
|
||||
errors: "/admin/telemetry/errors",
|
||||
players: "/admin/telemetry/players",
|
||||
usage: "/admin/telemetry/usage",
|
||||
} as const;
|
||||
|
||||
type TabValue = keyof typeof TAB_ROUTES;
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry")({
|
||||
component: TelemetryLayout,
|
||||
loader: () => ({
|
||||
header: {
|
||||
title: msg`Telemetry`,
|
||||
withBackButton: true,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
function TelemetryLayout() {
|
||||
const navigate = useNavigate();
|
||||
const pathname = useRouterState({ select: (s) => s.location.pathname });
|
||||
const activeTab =
|
||||
(Object.keys(TAB_ROUTES) as TabValue[]).find((tab) =>
|
||||
pathname.endsWith(`/${tab}`)
|
||||
) ?? "functions";
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
value={activeTab}
|
||||
onChange={(value) => {
|
||||
if (value && value in TAB_ROUTES) {
|
||||
navigate({ to: TAB_ROUTES[value as TabValue] });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Tabs.List mb="md" style={{ flexWrap: "nowrap", overflowX: "auto", overflowY: "hidden" }}>
|
||||
<Tabs.Tab value="functions">
|
||||
<Trans>Functions</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="events">
|
||||
<Trans>Events</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="errors">
|
||||
<Trans>Errors</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="players">
|
||||
<Trans>Players</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="usage">
|
||||
<Trans>Usage</Trans>
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Outlet />
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, lastNDays, ErrorBrowser } from "@/features/telemetry";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
const errorGroupParams = () => ({ ...lastNDays(30), includeResolved: false });
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/errors")({
|
||||
component: ErrorsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.errorGroups(errorGroupParams()));
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [telemetryQueries.errorGroups(errorGroupParams()).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function ErrorsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={6} withSubtitle />}>
|
||||
<ErrorBrowser />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, defaultClientEventParams, ClientEventsTable } from "@/features/telemetry";
|
||||
import { playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/events")({
|
||||
component: EventsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
const queryClient = context.queryClient;
|
||||
prefetchServerQuery(queryClient, telemetryQueries.events(defaultClientEventParams));
|
||||
prefetchServerQuery(queryClient, playerQueries.list());
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [telemetryQueries.events(defaultClientEventParams).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function EventsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSearch withSubtitle withTrailing="text" />}>
|
||||
<ClientEventsTable />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||
import { playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/functions")({
|
||||
component: FunctionsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
const queryClient = context.queryClient;
|
||||
prefetchServerQuery(queryClient, activityQueries.search());
|
||||
prefetchServerQuery(queryClient, playerQueries.list());
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [activityQueries.search().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function FunctionsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSearch withSubtitle withTrailing="text" />}>
|
||||
<ActivitiesTable />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/")({
|
||||
beforeLoad: () => {
|
||||
throw redirect({ to: "/admin/telemetry/functions" });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/players")({
|
||||
component: PlayersTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, playerQueries.activity());
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [playerQueries.activity().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function PlayersTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSubtitle withTrailing="text" />}>
|
||||
<PlayersActivityTable />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, lastNDays, USAGE_METRICS, UsageScreen } from "@/features/telemetry";
|
||||
|
||||
const defaultUsageParams = () => ({ metrics: USAGE_METRICS, ...lastNDays(7) });
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/usage")({
|
||||
component: UsageTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.rollups(defaultUsageParams()));
|
||||
},
|
||||
loader: () => ({
|
||||
refresh: [telemetryQueries.rollups(defaultUsageParams()).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function UsageTab() {
|
||||
return <UsageScreen />;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import Enrollment from "@/features/tournaments/components/enrollment";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { ListSkeleton, StatTileSkeleton } from "@/components/skeletons";
|
||||
import { Skeleton, Stack } from "@mantine/core";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/enrollment")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
const { queryClient } = context;
|
||||
const tournament = await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.details(params.id)
|
||||
);
|
||||
if (!tournament) throw redirect({ to: "/admin/tournaments" });
|
||||
if (tournament.regional) {
|
||||
await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.free_agents(params.id)
|
||||
);
|
||||
} else {
|
||||
await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.unenrolled(params.id)
|
||||
);
|
||||
}
|
||||
return { tournament };
|
||||
},
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: msg`Enrollment`,
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
pendingComponent: EnrollmentPending,
|
||||
});
|
||||
|
||||
function EnrollmentPending() {
|
||||
return (
|
||||
<Stack gap="lg">
|
||||
<StatTileSkeleton align="row" />
|
||||
<Stack gap="xs">
|
||||
<Skeleton height={14} width={80} radius="sm" />
|
||||
<Skeleton height={42} radius="sm" />
|
||||
</Stack>
|
||||
<ListSkeleton rows={6} withAvatar avatarSize={32} withTrailing padding="xs" />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function RouteComponent() {
|
||||
const { tournament } = Route.useRouteContext();
|
||||
return <Enrollment tournament={tournament} />;
|
||||
}
|
||||
Reference in New Issue
Block a user