Add status pages (a share link kind) and a downloadable Grafana dashboard
- Share links can open a status page: an admin picks servers, integrations and Uptime Kuma monitors and names them; the public sees only those names, Working / Not working / Being worked on / Can't tell, an optional message and the 30-day figure (share_links.kind/ title/message and status_items, migration 0033). A status address doesn't open the wall and the other way round; Uptime Kuma is asked at most every 30 seconds - Grafana dashboard built from code (download in Settings -> API and webhooks); a test checks it only uses series /metrics serves - Tests and docs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2744a84719
commit
5cc51c57de
24 files changed
+4880
-35
No files matched your search
+52
-2
@@ -14,11 +14,48 @@ export interface CurrentUser {
|
||||
|
||||
export type ShareLinkDetail = "summary" | "names";
|
||||
|
||||
/** A link that opens the wall display without signing in, as the settings list shows it (never the secret). */
|
||||
export type ShareLinkKind = "wall" | "status";
|
||||
export type StatusItemKind = "server" | "integration" | "monitor";
|
||||
|
||||
/** One thing on a status page, as the editor sees it. */
|
||||
export interface StatusPageItem {
|
||||
id: number;
|
||||
label: string;
|
||||
kind: StatusItemKind;
|
||||
targetId: number;
|
||||
monitorId: string | null;
|
||||
/** What it points at (the server's, integration's or monitor's own name). */
|
||||
targetName: string | null;
|
||||
}
|
||||
|
||||
/** What somebody who opens a status page's address is given: names and states, nothing else. */
|
||||
export interface PublicStatusItem {
|
||||
id: number;
|
||||
label: string;
|
||||
state: "up" | "down" | "maintenance" | "unknown";
|
||||
uptime30d: number | null;
|
||||
}
|
||||
export interface PublicStatus {
|
||||
title: string;
|
||||
message: string | null;
|
||||
level: "ok" | "issue" | "maintenance" | "unknown";
|
||||
counts: Record<PublicStatusItem["state"], number>;
|
||||
items: PublicStatusItem[];
|
||||
generatedAt: string;
|
||||
display: { dateFormat: string; timeFormat: string };
|
||||
}
|
||||
|
||||
/** A link that opens the wall display, or a status page, without signing in, as the settings list shows it (never the secret). */
|
||||
export interface ShareLink {
|
||||
id: number;
|
||||
label: string;
|
||||
tokenPrefix: string;
|
||||
kind: ShareLinkKind;
|
||||
/** A status page's own heading and message. */
|
||||
title: string | null;
|
||||
message: string | null;
|
||||
/** How many things a status page shows. */
|
||||
itemCount: number;
|
||||
detail: ShareLinkDetail;
|
||||
createdBy: string | null;
|
||||
createdAt: string;
|
||||
@@ -1632,10 +1669,23 @@ export const api = {
|
||||
},
|
||||
shareLinks: {
|
||||
list: () => request<{ links: ShareLink[] }>("/api/share-links"),
|
||||
create: (data: { label: string; detail: ShareLinkDetail; expiresInDays: number | null }) =>
|
||||
create: (data: { label: string; detail?: ShareLinkDetail; kind?: ShareLinkKind; title?: string; message?: string; expiresInDays: number | null }) =>
|
||||
request<{ link: ShareLink; token: string; path: string }>("/api/share-links", { method: "POST", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/share-links/${id}`, { method: "DELETE" }),
|
||||
},
|
||||
statusPages: {
|
||||
get: (linkId: number) => request<{ title: string; message: string; items: StatusPageItem[]; maxItems: number }>("/api/share-links/" + linkId + "/status"),
|
||||
choices: () => request<{ servers: { id: number; name: string }[]; integrations: { id: number; name: string; type: string }[] }>("/api/share-links/status-choices"),
|
||||
save: (linkId: number, data: { title: string; message: string; items: { label: string; kind: StatusItemKind; targetId: number; monitorId: string | null }[] }) =>
|
||||
request<{ title: string; message: string; items: StatusPageItem[] }>("/api/share-links/" + linkId + "/status", { method: "PUT", body: JSON.stringify(data) }),
|
||||
},
|
||||
publicStatus: {
|
||||
get: async (token: string): Promise<PublicStatus> => {
|
||||
const res = await fetch("/api/public/status/" + encodeURIComponent(token), { credentials: "omit", cache: "no-store" });
|
||||
if (!res.ok) throw Object.assign(new Error("Request failed (" + res.status + ")"), { status: res.status });
|
||||
return (await res.json()) as PublicStatus;
|
||||
},
|
||||
},
|
||||
// Opened by someone who isn't signed in: no cookies, and the status is kept so a link that has ended can say so.
|
||||
publicWall: {
|
||||
get: async (token: string): Promise<PublicWall> => {
|
||||
|
||||
Reference in new issue
Block a user