feat(dashboard-v2): scaffold Astryx app with system status slice
This commit is contained in:
1 parent
90b2b89bac
commit
56f1aecb63
15 files changed
+727
No files matched your search
@@ -26,6 +26,10 @@ config.production.toml
|
||||
/ui/.vite/
|
||||
/ui/*.tsbuildinfo
|
||||
# ui/dist IS committed: the Go build must not need a Node toolchain.
|
||||
/dashboard-v2/node_modules/
|
||||
/dashboard-v2/.vite/
|
||||
/dashboard-v2/*.tsbuildinfo
|
||||
/dashboard-v2/dist/
|
||||
|
||||
# air live-reload
|
||||
/.air/
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# AGENTS.md
|
||||
|
||||
Project-specific guidance for AI coding agents.
|
||||
|
||||
<!-- ASTRYX:START -->
|
||||
Astryx v0.7.4 · 173 components
|
||||
CLI: run every command as `pnpm dlx @astryxdesign/cli@0.7.4 <cmd>` (shown below as `astryx ...`).
|
||||
|
||||
SETUP (once, in app entry e.g. main.tsx) — without these, components render unstyled:
|
||||
import "@astryxdesign/core/reset.css";
|
||||
import "@astryxdesign/core/astryx.css";
|
||||
|
||||
WORKFLOW — start every page from a template, never from scratch:
|
||||
1. `astryx build "<idea>"` — names the template to scaffold from and the parts it lacks.
|
||||
2. `astryx template <name> <path>` — scaffold it; keep its frame, gap and padding; replace the content.
|
||||
3. `astryx template <Block>` for parts it lacks; `astryx component <Name>` to read props before using one.
|
||||
Changing an existing page? Keep it: skip step 2 and add blocks/components inside its sections.
|
||||
|
||||
RULES:
|
||||
- No <div> — components handle all layout and spacing.
|
||||
- Read `astryx docs layout` before changing a template's frame.
|
||||
- Dense data = rows (Table, List/Item), not Card-wrapped lists. Badge = counts only.
|
||||
- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes directly. Some templates use StyleX and need a compiler plugin; see `astryx docs styling-overview`.
|
||||
- Palettes and custom colors go through the theme, never :root overrides. Run `astryx theme add <slug>` to import; `theme eject <slug>` only forks source. See `astryx docs theme`.
|
||||
- SELF-CHECK: re-read the file; replace any raw <div>/<span>, imported .css/@apply, or hardcoded #hex/px with the component or a token.
|
||||
|
||||
`astryx help` lists every command. Key ones beyond the workflow:
|
||||
search "<query>" find any component / hook / doc / template
|
||||
discover <words> integrations you could add
|
||||
docs <topic> getting-started, principles, tokens, theme … (`astryx docs` lists all)
|
||||
docs cli commands and API reference
|
||||
docs authoring build an integration package, and every field it holds
|
||||
upgrade --from <old version> --apply run after a dependency bump
|
||||
<!-- ASTRYX:END -->
|
||||
@@ -0,0 +1,3 @@
|
||||
<!-- ASTRYX:START -->
|
||||
@./AGENTS.md
|
||||
<!-- ASTRYX:END -->
|
||||
@@ -0,0 +1,28 @@
|
||||
# dashboard-v2
|
||||
|
||||
React plus Astryx replacement for the Vue dashboard (`ui/`), growing by
|
||||
strangler: new pages land here, served beside the Vue app until v2 covers
|
||||
everything. The server owns every contract; this app presents them.
|
||||
|
||||
First slice: System status (service health plus component versions), a
|
||||
read-only mirror of the Vue status page.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
cd dashboard-v2
|
||||
pnpm install
|
||||
astryx theme add neutral # regenerates src/astryx-themes.ts
|
||||
pnpm run dev # http://localhost:5174
|
||||
```
|
||||
|
||||
Open http://localhost:5174 in a browser after starting it. `/api` proxies
|
||||
to a locally running archie-ui on 127.0.0.1:8484, same as the Vue dev
|
||||
server. Port 5174 keeps v2 beside the Vue app on 5173.
|
||||
|
||||
`pnpm run build` typechecks and builds to `dist/`, which is not committed:
|
||||
serving v2 (embed vs separate deploy) is still an open decision.
|
||||
|
||||
Dependency versions were chosen offline to match Astryx CLI 0.7.4
|
||||
(`@astryxdesign/*` 0.7.4, React 19, Vite 8); if `pnpm install` reports peer
|
||||
conflicts, follow its resolution and commit the lockfile.
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Status | Archie</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "archie-dashboard-v2",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc --noEmit && vite build",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astryxdesign/core": "0.7.4",
|
||||
"@astryxdesign/theme-neutral": "0.7.4",
|
||||
"@heroicons/react": "^2.2.0",
|
||||
"@stylexjs/stylex": "^0.8.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astryxdesign/cli": "0.7.4",
|
||||
"@types/react": "^19.1.0",
|
||||
"@types/react-dom": "^19.1.0",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"typescript": "~6.0.3",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"packageManager": "pnpm@12.10.1"
|
||||
}
|
||||
Generated
+158
@@ -0,0 +1,158 @@
|
||||
---
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
configDependencies: {}
|
||||
packageManagerDependencies:
|
||||
pnpm:
|
||||
specifier: 12.10.1
|
||||
version: 12.10.1
|
||||
|
||||
packages:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.10.1':
|
||||
resolution: {integrity: sha512-CVTlHPwNvadQCJD9bGSMzWIhFX8QpjtqC2c27dhdnn/9iKzEjZ3qL62o3gHpKbIuo6qn4WxTKRoaokgNdReBig==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.android-x64@12.10.1':
|
||||
resolution: {integrity: sha512-NFiYLIaodY7da0XIebwcU3JoP7IK/lzF7zgKSSP+9H+QcFnQ1GDfBkuBKCYJzZ+Xu0WH54neIPLBBCaOjaaauA==}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.10.1':
|
||||
resolution: {integrity: sha512-0O8tdQ8ijlPJudXspLMTcitMkdBEz6uUflazL5uQE0WMs85oQIp0U+5hfEktMFB64QqEhjqlvvujTwbzdr9oMg==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.10.1':
|
||||
resolution: {integrity: sha512-ud+1/uZOKEo8P/AsPynOJc/LNwfI0j6WwCElibj71rU9l4nIBnsSn+wWTIPZPkZ4BBSH5+82azSnAARMyJ1lNA==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.10.1':
|
||||
resolution: {integrity: sha512-mj9PE5rf8uAfQQ2K66HSATMSut+lNiB4eSqFd5+azFVCMnxNSy/32xpZQJT21PhnN3Y4qbK+iKHe5nWAxSuRhw==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.10.1':
|
||||
resolution: {integrity: sha512-xba+00wZJ8Um6rBJJjWl88uJj0tydB8dtomvjlCLvi0uL32vpa9CRP8Vv26FIXvbiZ1bo2RCzYt/eChxJVV52w==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.10.1':
|
||||
resolution: {integrity: sha512-oBdMp69ScC9UnniG4qZAQVr2fBDSXjm4yk/72vkEVyrlwS23yMxcRQl7Qdo3sgXPAygY6TWnPRKm4rXzjoyW7w==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.10.1':
|
||||
resolution: {integrity: sha512-Yyb3wu09h3c7mLme270uHFiVaAIUHC411Ru9LIU2BKUIstrGlXa9OqqVWoXaRgYRdFdOFknkwG7GNn6ygwLbnw==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.10.1':
|
||||
resolution: {integrity: sha512-PdkeUFFkybknnGkWP0H22eMpIiS4OZXL5BcQzF4lh+vmrW3IaC2HOkbANKgot/PKO0Kl77pzA/6PKFxgbgfXIQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.10.1':
|
||||
resolution: {integrity: sha512-1okKuHKJwJPAbofDxfhZWAUxEWtee4ZSf7Pah8kcvocaJkf2WxFJ5KVTiNIvDml5GLidDQsgf7Pcf/WHbCak7Q==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.10.1':
|
||||
resolution: {integrity: sha512-e6IqzVNkPa7srFKJKnY23uWJ+qz0LaRWiTUo/sHfFXRRMRzB5uNOr6qWWip/jqhdGwU91n9J7LrEYZ6e0tRczw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-x64@12.10.1':
|
||||
resolution: {integrity: sha512-ZByV0DRgWzGaDSjT5ddRBASdwz+r/qPMYh7o6RGmPQjtRGNFbSl94xY2DcAM8mqCOZJUUDtAXQ+wpBXcdpKlkg==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.10.1':
|
||||
resolution: {integrity: sha512-I7QZHcjioG7orFeCRUFUHByJ1G0zFPnAlaGGyrUvb6MGkv5oeNwNPl7t+Gp+7zHfnMcgLGJ1a+Wfim0IDw3lOw==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@pnpm/exe.win32-x64@12.10.1':
|
||||
resolution: {integrity: sha512-4WJFdp58EKlCj0zLobrXU0vpszSZIr4X/3y/uNbAQqGW0zE+VdruZB0gFc3L2kzsUzVwTYbaCn+XEhnCYSAlTg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
pnpm@12.10.1:
|
||||
resolution: {integrity: sha512-ukCjfrGjcNYP6oxM8dNkwTvMzvUY6YrSvO6VT1OdONo3RY5YJho/pV4GUjRQ6g//+fSXsTW+QfLBXBZCusrObA==}
|
||||
engines: {node: '>=18.*'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.android-x64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.10.1':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-x64@12.10.1':
|
||||
optional: true
|
||||
|
||||
pnpm@12.10.1:
|
||||
optionalDependencies:
|
||||
'@pnpm/exe.android-arm64': 12.10.1
|
||||
'@pnpm/exe.android-x64': 12.10.1
|
||||
'@pnpm/exe.darwin-arm64': 12.10.1
|
||||
'@pnpm/exe.darwin-x64': 12.10.1
|
||||
'@pnpm/exe.freebsd-x64': 12.10.1
|
||||
'@pnpm/exe.linux-arm64': 12.10.1
|
||||
'@pnpm/exe.linux-arm64-musl': 12.10.1
|
||||
'@pnpm/exe.linux-ppc64': 12.10.1
|
||||
'@pnpm/exe.linux-riscv64': 12.10.1
|
||||
'@pnpm/exe.linux-s390x': 12.10.1
|
||||
'@pnpm/exe.linux-x64': 12.10.1
|
||||
'@pnpm/exe.linux-x64-musl': 12.10.1
|
||||
'@pnpm/exe.win32-arm64': 12.10.1
|
||||
'@pnpm/exe.win32-x64': 12.10.1
|
||||
|
||||
---
|
||||
@@ -0,0 +1,6 @@
|
||||
import StatusPage from "./pages/StatusPage.tsx";
|
||||
|
||||
// One page so far, so no shell or router yet: they land with the second page.
|
||||
export default function App() {
|
||||
return <StatusPage />;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Theme wiring in the shape `astryx theme add neutral` generates. It could
|
||||
// not run before install (offline), so regenerate it then: install, run
|
||||
// `astryx theme add neutral`, and let it overwrite this module.
|
||||
import neutral from "@astryxdesign/theme-neutral/built";
|
||||
import "@astryxdesign/theme-neutral/theme.css";
|
||||
|
||||
export const themes = { neutral };
|
||||
export type ThemeSlug = keyof typeof themes;
|
||||
export const defaultThemeSlug: ThemeSlug = "neutral";
|
||||
@@ -0,0 +1,2 @@
|
||||
@import "@astryxdesign/core/reset.css";
|
||||
@import "@astryxdesign/core/astryx.css";
|
||||
@@ -0,0 +1,95 @@
|
||||
// Minimal port of the Vue dashboard's api client: same request semantics
|
||||
// (timeout, CSRF on mutation, server-first error text), only the endpoints
|
||||
// v2 pages use. The server owns every shape below.
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 15000;
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
|
||||
constructor(message: string, status: number) {
|
||||
super(message);
|
||||
this.name = "ApiError";
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
// errorMessage prefers what the server actually said: archie-ui answers with
|
||||
// a plain-text reason, the only part an operator can act on.
|
||||
async function errorMessage(res: Response): Promise<string> {
|
||||
try {
|
||||
const body = (await res.text()).trim();
|
||||
if (body) return body.split("\n")[0].slice(0, 200);
|
||||
} catch {
|
||||
// Body already consumed or unreadable; fall through to the status.
|
||||
}
|
||||
return `${res.status} ${res.statusText}`;
|
||||
}
|
||||
|
||||
interface RequestOptions {
|
||||
method?: string;
|
||||
body?: unknown;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
|
||||
async function request<T>(
|
||||
path: string,
|
||||
opts: RequestOptions = {},
|
||||
): Promise<T> {
|
||||
const { method = "GET", body, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
|
||||
const headers: Record<string, string> = { Accept: "application/json" };
|
||||
const init: RequestInit = {
|
||||
method,
|
||||
headers,
|
||||
signal: AbortSignal.timeout(timeoutMs),
|
||||
};
|
||||
if (method !== "GET") {
|
||||
headers["Content-Type"] = "application/json";
|
||||
headers["X-Archie-CSRF"] = "1";
|
||||
}
|
||||
if (body !== undefined) init.body = JSON.stringify(body);
|
||||
|
||||
const res = await fetch(path, init);
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
export interface ServiceCheck {
|
||||
name: string;
|
||||
status: "ok" | "degraded";
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export interface Service {
|
||||
service: string;
|
||||
instance_id: string;
|
||||
state: "up" | "degraded" | "down" | "unknown";
|
||||
version: string;
|
||||
install_type: string;
|
||||
started_at: string;
|
||||
reported_at: string;
|
||||
detail?: string;
|
||||
applied: {
|
||||
kind: string;
|
||||
applied_version: number;
|
||||
error?: string;
|
||||
state: "current" | "failed" | "unknown";
|
||||
}[];
|
||||
checks?: ServiceCheck[];
|
||||
}
|
||||
|
||||
export interface ComponentVersion {
|
||||
id: string;
|
||||
label: string;
|
||||
install_type?: string;
|
||||
reference?: string;
|
||||
running_version?: string;
|
||||
installed_claim?: string;
|
||||
latest_available?: string;
|
||||
status: "ok" | "update_available" | "drift" | "unknown";
|
||||
}
|
||||
|
||||
export const api = {
|
||||
services: () => request<Service[]>("/api/services"),
|
||||
version: () => request<{ components: ComponentVersion[] }>("/api/version"),
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
import { Theme } from "@astryxdesign/core/theme";
|
||||
|
||||
import { defaultThemeSlug, themes } from "./astryx-themes.ts";
|
||||
import App from "./App.tsx";
|
||||
import "./globals.css";
|
||||
|
||||
const root = document.getElementById("root");
|
||||
if (!root) throw new Error("missing #root element");
|
||||
|
||||
createRoot(root).render(
|
||||
<StrictMode>
|
||||
<Theme theme={themes[defaultThemeSlug]}>
|
||||
<App />
|
||||
</Theme>
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,292 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { Button } from "@astryxdesign/core/Button";
|
||||
import { Card } from "@astryxdesign/core/Card";
|
||||
import { Divider } from "@astryxdesign/core/Divider";
|
||||
import { Grid } from "@astryxdesign/core/Grid";
|
||||
import { Icon } from "@astryxdesign/core/Icon";
|
||||
import {
|
||||
HStack,
|
||||
Layout,
|
||||
LayoutContent,
|
||||
VStack,
|
||||
} from "@astryxdesign/core/Layout";
|
||||
import { StatusDot } from "@astryxdesign/core/StatusDot";
|
||||
import {
|
||||
Table,
|
||||
pixel,
|
||||
proportional,
|
||||
type TableColumn,
|
||||
} from "@astryxdesign/core/Table";
|
||||
import { Heading, Text } from "@astryxdesign/core/Text";
|
||||
import { ArrowPathIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
import {
|
||||
api,
|
||||
type ComponentVersion,
|
||||
type Service,
|
||||
} from "../lib/api.ts";
|
||||
|
||||
// Mirror of the Vue dashboard's SystemStatusPage: service health plus
|
||||
// per-component versions, in the dashboard template's frame.
|
||||
|
||||
function uptime(startedAt: string, state: Service["state"]): string {
|
||||
if (!startedAt || state === "down") return "not reported";
|
||||
const seconds = Math.max(
|
||||
0,
|
||||
Math.round((Date.now() - Date.parse(startedAt)) / 1000),
|
||||
);
|
||||
const days = Math.floor(seconds / 86400);
|
||||
const hours = Math.floor((seconds % 86400) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
if (days) return `${days}d ${hours}h`;
|
||||
if (hours) return `${hours}h ${minutes}m`;
|
||||
return `${minutes}m`;
|
||||
}
|
||||
|
||||
const serviceVariant = {
|
||||
up: "success",
|
||||
degraded: "warning",
|
||||
down: "error",
|
||||
unknown: "neutral",
|
||||
} as const;
|
||||
|
||||
const versionVariant = {
|
||||
ok: "success",
|
||||
update_available: "warning",
|
||||
drift: "error",
|
||||
unknown: "neutral",
|
||||
} as const;
|
||||
|
||||
const versionLabel = {
|
||||
ok: "Current",
|
||||
update_available: "Update available",
|
||||
drift: "Version drift",
|
||||
unknown: "Unknown",
|
||||
} as const;
|
||||
|
||||
function MetricCard({
|
||||
label,
|
||||
value,
|
||||
caption,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
caption: string;
|
||||
}) {
|
||||
return (
|
||||
<Card>
|
||||
<VStack gap={2}>
|
||||
<Heading level={4}>{label}</Heading>
|
||||
<Heading level={2}>{value}</Heading>
|
||||
<Text type="supporting" color="secondary">
|
||||
{caption}
|
||||
</Text>
|
||||
</VStack>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
interface ServiceRow extends Record<string, unknown> {
|
||||
id: string;
|
||||
service: string;
|
||||
state: Service["state"];
|
||||
version: string;
|
||||
uptime: string;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
const serviceColumns: TableColumn<ServiceRow>[] = [
|
||||
{ key: "service", header: "Service", width: proportional(1) },
|
||||
{
|
||||
key: "state",
|
||||
header: "State",
|
||||
width: pixel(160),
|
||||
renderCell: (item: ServiceRow) => (
|
||||
<HStack gap={2} vAlign="center">
|
||||
<StatusDot
|
||||
variant={serviceVariant[item.state]}
|
||||
label={item.state}
|
||||
tooltip={item.detail}
|
||||
/>
|
||||
<Text type="body">{item.state}</Text>
|
||||
</HStack>
|
||||
),
|
||||
},
|
||||
{ key: "version", header: "Version", width: pixel(120) },
|
||||
{ key: "uptime", header: "Uptime", width: pixel(120) },
|
||||
];
|
||||
|
||||
interface VersionRow extends Record<string, unknown> {
|
||||
id: string;
|
||||
component: string;
|
||||
running: string;
|
||||
latest: string;
|
||||
status: ComponentVersion["status"];
|
||||
}
|
||||
|
||||
const versionColumns: TableColumn<VersionRow>[] = [
|
||||
{ key: "component", header: "Component", width: proportional(1) },
|
||||
{ key: "running", header: "Running", width: pixel(140) },
|
||||
{ key: "latest", header: "Latest", width: pixel(140) },
|
||||
{
|
||||
key: "status",
|
||||
header: "State",
|
||||
width: pixel(180),
|
||||
renderCell: (item: VersionRow) => (
|
||||
<HStack gap={2} vAlign="center">
|
||||
<StatusDot
|
||||
variant={versionVariant[item.status]}
|
||||
label={versionLabel[item.status]}
|
||||
/>
|
||||
<Text type="body">{versionLabel[item.status]}</Text>
|
||||
</HStack>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export default function StatusPage() {
|
||||
const [services, setServices] = useState<Service[]>([]);
|
||||
const [components, setComponents] = useState<ComponentVersion[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const [fetchedServices, report] = await Promise.all([
|
||||
api.services(),
|
||||
api.version(),
|
||||
]);
|
||||
setServices(fetchedServices);
|
||||
setComponents(report.components);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Could not load status");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
const up = services.filter((s) => s.state === "up").length;
|
||||
const attention = services.filter(
|
||||
(s) => s.state === "degraded" || s.state === "down",
|
||||
).length;
|
||||
const current = components.filter((c) => c.status === "ok").length;
|
||||
|
||||
const serviceRows: ServiceRow[] = services.map((s) => ({
|
||||
id: `${s.service}/${s.instance_id}`,
|
||||
service: s.service,
|
||||
state: s.state,
|
||||
version: s.version || "not reported",
|
||||
uptime: uptime(s.started_at, s.state),
|
||||
detail: s.detail,
|
||||
}));
|
||||
|
||||
const versionRows: VersionRow[] = components.map((c) => ({
|
||||
id: c.id,
|
||||
component: c.label,
|
||||
running: c.running_version || c.installed_claim || "not reported",
|
||||
latest: c.latest_available || "not reported",
|
||||
status: c.status,
|
||||
}));
|
||||
|
||||
return (
|
||||
<Layout
|
||||
height="fill"
|
||||
content={
|
||||
<LayoutContent padding={6}>
|
||||
<VStack gap={6}>
|
||||
<VStack gap={6}>
|
||||
<HStack hAlign="between" vAlign="center">
|
||||
<Heading level={3}>System status</Heading>
|
||||
<Button
|
||||
label="Reload"
|
||||
variant="secondary"
|
||||
size="md"
|
||||
icon={<Icon icon={ArrowPathIcon} size="sm" />}
|
||||
onClick={() => void load()}
|
||||
/>
|
||||
</HStack>
|
||||
{loading ? (
|
||||
<Card>
|
||||
<Text type="body">Loading status…</Text>
|
||||
</Card>
|
||||
) : error ? (
|
||||
<Card>
|
||||
<VStack gap={4}>
|
||||
<Text type="body">{error}</Text>
|
||||
<Button
|
||||
label="Retry"
|
||||
variant="secondary"
|
||||
size="md"
|
||||
onClick={() => void load()}
|
||||
/>
|
||||
</VStack>
|
||||
</Card>
|
||||
) : (
|
||||
<Grid columns={{ minWidth: 240, repeat: "fit" }} gap={4}>
|
||||
<MetricCard
|
||||
label="Services up"
|
||||
value={`${up} of ${services.length}`}
|
||||
caption="Services reporting up"
|
||||
/>
|
||||
<MetricCard
|
||||
label="Needs attention"
|
||||
value={String(attention)}
|
||||
caption="Degraded or down"
|
||||
/>
|
||||
<MetricCard
|
||||
label="Components current"
|
||||
value={`${current} of ${components.length}`}
|
||||
caption="Running the latest version"
|
||||
/>
|
||||
</Grid>
|
||||
)}
|
||||
</VStack>
|
||||
|
||||
{!loading && !error && (
|
||||
<>
|
||||
<Divider />
|
||||
|
||||
<HStack hAlign="between" vAlign="center">
|
||||
<Heading level={3}>Services</Heading>
|
||||
</HStack>
|
||||
<Card>
|
||||
<Table<ServiceRow>
|
||||
data={serviceRows}
|
||||
columns={serviceColumns}
|
||||
idKey="id"
|
||||
density="compact"
|
||||
dividers="rows"
|
||||
hasHover
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Divider />
|
||||
|
||||
<HStack hAlign="between" vAlign="center">
|
||||
<Heading level={3}>Versions</Heading>
|
||||
</HStack>
|
||||
<Card>
|
||||
<Table<VersionRow>
|
||||
data={versionRows}
|
||||
columns={versionColumns}
|
||||
idKey="id"
|
||||
density="compact"
|
||||
dividers="rows"
|
||||
hasHover
|
||||
/>
|
||||
</Card>
|
||||
</>
|
||||
)}
|
||||
</VStack>
|
||||
</LayoutContent>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
||||
},
|
||||
"include": ["src", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
// The Vue dashboard owns 5173; v2 runs beside it during the migration.
|
||||
port: 5174,
|
||||
// Proxies the API to a locally running archie-ui so the frontend can be
|
||||
// developed without rebuilding Go. changeOrigin stays false: archie-ui
|
||||
// refuses a mutation whose Origin does not match its Host, and the
|
||||
// browser's Origin is this dev server.
|
||||
proxy: {
|
||||
"/api": { target: "http://127.0.0.1:8484", changeOrigin: false },
|
||||
"/health": { target: "http://127.0.0.1:8484", changeOrigin: false },
|
||||
"/webhooks": { target: "http://127.0.0.1:8484", changeOrigin: false },
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user