Hub v1: install API, licences, health dashboard, alerts
- Protocol 1 (docs/hub-protocol.md): public key, register, signed heartbeats - Ed25519 licence tokens (30-day validity, status, expiry, grace, limits) - Dashboard: installs, install detail, customers and licences, alerts, settings and audit log; two-factor login required - Alert checks every 5 minutes, emailed once; heartbeat roll-up after 30 days - Unit tests for encryption, tokens, signatures, TOTP and alert rules Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mt6TCv85T9VKRq3cV7rXq
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import React from "react";
|
||||
import type { LicenceStatus, Problem } from "@/lib/types";
|
||||
|
||||
const STATUS_TONE: Record<string, string> = {
|
||||
ok: "bg-green-50 text-green-700 ring-green-200",
|
||||
warning: "bg-amber-50 text-amber-800 ring-amber-200",
|
||||
critical: "bg-red-50 text-red-700 ring-red-200",
|
||||
info: "bg-slate-100 text-slate-600 ring-slate-200",
|
||||
active: "bg-green-50 text-green-700 ring-green-200",
|
||||
suspended: "bg-amber-50 text-amber-800 ring-amber-200",
|
||||
revoked: "bg-red-50 text-red-700 ring-red-200",
|
||||
};
|
||||
const STATUS_LABEL: Record<string, string> = { ok: "Healthy", warning: "Warning", critical: "Critical", info: "Info" };
|
||||
|
||||
export function Badge({ value, label }: { value: Problem["level"] | "ok" | LicenceStatus; label?: string }) {
|
||||
return (
|
||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset ${STATUS_TONE[value] || STATUS_TONE.info}`}>
|
||||
{label || STATUS_LABEL[value] || value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function PageTitle({ title, subtitle, actions }: { title: string; subtitle?: React.ReactNode; actions?: React.ReactNode }) {
|
||||
return (
|
||||
<div className="mb-6 flex flex-wrap items-end justify-between gap-3">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">{title}</h1>
|
||||
{subtitle && <p className="mt-1 text-sm text-slate-500">{subtitle}</p>}
|
||||
</div>
|
||||
{actions}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Message({ msg }: { msg: { type: "ok" | "err"; text: string } | null }) {
|
||||
if (!msg) return null;
|
||||
return (
|
||||
<div className={`rounded-lg border p-3 text-sm ${msg.type === "ok" ? "border-green-200 bg-green-50 text-green-800" : "border-red-200 bg-red-50 text-red-800"}`}>
|
||||
{msg.text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Stat({ label, value, tone }: { label: string; value: React.ReactNode; tone?: "red" | "amber" | "green" }) {
|
||||
const color = tone === "red" ? "text-red-700" : tone === "amber" ? "text-amber-700" : tone === "green" ? "text-green-700" : "text-slate-900";
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="text-sm text-slate-500">{label}</div>
|
||||
<div className={`mt-1 text-2xl font-semibold tabular-nums ${color}`}>{value}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Loading() {
|
||||
return <p className="text-sm text-slate-400">Loading…</p>;
|
||||
}
|
||||
Reference in New Issue
Block a user