Toasts, logo icons, shared table toolbar with search, and a density toggle
Feedback: toasts confirm common actions, and a page's error or success message that appears out of view is also shown as a toast. Icons: the tab, app and home-screen icons are the house from the logo; a dev instance gets a coloured dot on its tab icon. Tables: Secrets, Admin Links, IP Addresses and Alerts share one toolbar (search, filters, row count, actions, Export CSV); twelve more tables get a multi-word search box; long tables keep their column headings in view on wide screens. Density: Compact / Normal / Roomy in the user menu, remembered per browser. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
No files matched your search
@@ -5,7 +5,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Homelab Manager</title>
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="icon" type="image/png" href="/icon-192.png" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/icon-192.png" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<meta name="theme-color" content="#182433" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
|
||||
|
Before Width: | Height: | Size: 797 B After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 108 KiB |
@@ -44,6 +44,7 @@ import AppShell from "./layout/AppShell";
|
||||
import DialogHost from "./components/DialogHost";
|
||||
import { setDateTimeSettings } from "./utils/date";
|
||||
import { setPageSize } from "./utils/pageSize";
|
||||
import ToastHost from "./components/ToastHost";
|
||||
|
||||
const roleRank: Record<UserRole, number> = { viewer: 0, operator: 1, admin: 2 };
|
||||
|
||||
@@ -171,6 +172,7 @@ export default function App() {
|
||||
</Route>
|
||||
</Routes>
|
||||
<DialogHost />
|
||||
<ToastHost />
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
function Notice({ message, kind, className = "" }: { message: string | null | undefined; kind: "danger" | "success"; className?: string }) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
// A message that appears where you are looking needs nothing more. One that appears out of view — above after scrolling, or
|
||||
// far down a long page — would otherwise go unseen, so it is also raised as a toast.
|
||||
useEffect(() => {
|
||||
if (!message) return;
|
||||
const rect = ref.current?.getBoundingClientRect();
|
||||
const inView = !!rect && rect.height > 0 && rect.bottom > 0 && rect.top < window.innerHeight;
|
||||
if (!inView) (kind === "danger" ? toast.error : toast.success)(message);
|
||||
}, [message, kind]);
|
||||
|
||||
if (!message) return null;
|
||||
return (
|
||||
<div ref={ref} className={`alert alert-${kind} ${className}`.trim()} role={kind === "danger" ? "alert" : "status"}>
|
||||
{message}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The usual red message under a page title. Also shown as a toast when it appears out of view. */
|
||||
export function ErrorNotice({ error, className }: { error: string | null | undefined; className?: string }) {
|
||||
return <Notice message={error} kind="danger" className={className} />;
|
||||
}
|
||||
|
||||
/** The usual green message after something worked. Also shown as a toast when it appears out of view. */
|
||||
export function SuccessNotice({ notice, className }: { notice: string | null | undefined; className?: string }) {
|
||||
return <Notice message={notice} kind="success" className={className} />;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { readableError } from "../utils/errors";
|
||||
import Pagination from "./Pagination";
|
||||
import SortableTh from "./SortableTh";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "./Notice";
|
||||
|
||||
const PRESETS: { key: string; label: string; from: number; to: number }[] = [
|
||||
{ key: "well-known", label: "1–1024 (well-known)", from: 1, to: 1024 },
|
||||
@@ -235,7 +236,7 @@ export default function ServerPorts({
|
||||
</div>
|
||||
|
||||
<div className="card-body pb-2">
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{data && (
|
||||
<div className="text-secondary small mb-2">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
|
||||
import { api } from "../api/client";
|
||||
import { normalizeTagInput, tagBadge, useTagColors } from "../utils/tags";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "./Notice";
|
||||
|
||||
export function TagBadges({ tags, linked = false }: { tags: string[]; linked?: boolean }) {
|
||||
const colors = useTagColors();
|
||||
@@ -99,7 +100,7 @@ export default function ServerTags({
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-body">
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<label className="form-label">Tags</label>
|
||||
<div className="d-flex flex-wrap align-items-center gap-1 mb-2">
|
||||
{draftTags.map((tag) => {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
|
||||
/** The search box every table uses, so they look and behave alike. Esc clears it. */
|
||||
export function SearchBox({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = "Search…",
|
||||
className = "",
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={`input-icon table-search ${className}`.trim()}>
|
||||
<span className="input-icon-addon">
|
||||
<IconSearch size={16} />
|
||||
</span>
|
||||
<input
|
||||
type="search"
|
||||
className="form-control form-control-sm"
|
||||
placeholder={placeholder}
|
||||
aria-label={placeholder}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Escape" && value && onChange("")}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The strip across the top of a table card: search and filters on the left, how many rows are showing, then the table's own
|
||||
* actions (Add, Sync…) and Export CSV last on the right. Every table that can be searched uses this, in this order.
|
||||
*/
|
||||
export default function TableToolbar({
|
||||
search,
|
||||
onSearch,
|
||||
placeholder,
|
||||
filters,
|
||||
actions,
|
||||
onExport,
|
||||
exportDisabled,
|
||||
shown,
|
||||
total,
|
||||
}: {
|
||||
search: string;
|
||||
onSearch: (value: string) => void;
|
||||
placeholder?: string;
|
||||
/** Selects and tick-boxes that narrow the rows, shown beside the search box. */
|
||||
filters?: ReactNode;
|
||||
/** Buttons for this table (Add, Sync…), shown before Export CSV. */
|
||||
actions?: ReactNode;
|
||||
onExport?: () => void;
|
||||
exportDisabled?: boolean;
|
||||
/** Rows showing now, and rows there are in all — shown as "12 of 40" once something narrows them. */
|
||||
shown?: number;
|
||||
total?: number;
|
||||
}) {
|
||||
const narrowed = shown !== undefined && total !== undefined && shown !== total;
|
||||
return (
|
||||
<div className="card-header table-toolbar">
|
||||
<div className="table-toolbar-inner">
|
||||
<SearchBox value={search} onChange={onSearch} placeholder={placeholder} />
|
||||
{filters}
|
||||
{narrowed && <span className="text-secondary small">{shown} of {total}</span>}
|
||||
<div className="table-toolbar-actions">
|
||||
{actions}
|
||||
{onExport && (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={onExport} disabled={exportDisabled}>
|
||||
Export CSV
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { IconAlertTriangle, IconCircleCheck, IconInfoCircle, IconX } from "@tabler/icons-react";
|
||||
import { dismissToast, subscribeToasts, type ToastItem } from "../utils/toast";
|
||||
|
||||
const LIFETIME_MS = { success: 4_500, info: 6_000, error: 9_000 } as const;
|
||||
|
||||
function ToastView({ item }: { item: ToastItem }) {
|
||||
const [paused, setPaused] = useState(false);
|
||||
|
||||
// Goes away by itself — unless the pointer is on it, so a long message can be read.
|
||||
useEffect(() => {
|
||||
if (paused) return;
|
||||
const timer = setTimeout(() => dismissToast(item.id), LIFETIME_MS[item.kind]);
|
||||
return () => clearTimeout(timer);
|
||||
}, [paused, item.id, item.kind]);
|
||||
|
||||
const Icon = item.kind === "success" ? IconCircleCheck : item.kind === "error" ? IconAlertTriangle : IconInfoCircle;
|
||||
return (
|
||||
<div
|
||||
className={`toast-item toast-${item.kind}`}
|
||||
role={item.kind === "error" ? "alert" : "status"}
|
||||
onMouseEnter={() => setPaused(true)}
|
||||
onMouseLeave={() => setPaused(false)}
|
||||
>
|
||||
<Icon size={18} className="flex-shrink-0 mt-1" />
|
||||
<div className="flex-fill">{item.message}</div>
|
||||
<button type="button" className="toast-close" aria-label="Dismiss" onClick={() => dismissToast(item.id)}>
|
||||
<IconX size={16} />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Draws the toasts raised through utils/toast. Mount once, near the root. */
|
||||
export default function ToastHost() {
|
||||
const [items, setItems] = useState<ToastItem[]>([]);
|
||||
useEffect(() => subscribeToasts(setItems), []);
|
||||
if (items.length === 0) return null;
|
||||
return createPortal(
|
||||
<div className="toast-stack" aria-live="polite">
|
||||
{items.map((t) => (
|
||||
<ToastView key={t.id} item={t} />
|
||||
))}
|
||||
</div>,
|
||||
document.body,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
const haystacks = new WeakMap<object, string>();
|
||||
|
||||
/** Every readable value in a row — text and numbers, however deep — as one lowercase string to search in. */
|
||||
function haystackOf(row: unknown): string {
|
||||
if (row !== null && typeof row === "object") {
|
||||
const cached = haystacks.get(row);
|
||||
if (cached !== undefined) return cached;
|
||||
}
|
||||
const parts: string[] = [];
|
||||
const walk = (value: unknown, depth: number) => {
|
||||
if (typeof value === "string") parts.push(value);
|
||||
else if (typeof value === "number") parts.push(String(value));
|
||||
else if (depth < 3 && Array.isArray(value)) for (const v of value) walk(v, depth + 1);
|
||||
else if (depth < 3 && value !== null && typeof value === "object") for (const v of Object.values(value)) walk(v, depth + 1);
|
||||
};
|
||||
walk(row, 0);
|
||||
const text = parts.join(" \n").toLowerCase();
|
||||
if (row !== null && typeof row === "object") haystacks.set(row, text);
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text search over a table's rows. Several words must all appear (in any column, in any order), so "elsa running" finds a running
|
||||
* container on elsa. Returns the rows unchanged while the box is empty, and `null`/`undefined` as they came while loading.
|
||||
*/
|
||||
export function useTableSearch<T>(items: T[] | null | undefined) {
|
||||
const [query, setQuery] = useState("");
|
||||
const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||
const key = terms.join(" ");
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
if (!items || key === "") return items;
|
||||
const wanted = key.split(" ");
|
||||
return items.filter((row) => {
|
||||
const hay = haystackOf(row);
|
||||
return wanted.every((t) => hay.includes(t));
|
||||
});
|
||||
}, [items, key]);
|
||||
|
||||
return { query, setQuery, filtered, active: key !== "" };
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
||||
import { formatRemaining } from "../utils/duration";
|
||||
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
||||
import { DENSITIES, getDensity, setDensity, type Density } from "../utils/density";
|
||||
import CommandPalette from "../components/CommandPalette";
|
||||
import { isLightColor, useEnvironment } from "../utils/environment";
|
||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
@@ -178,6 +179,7 @@ function isCurrent(pathname: string, to: string): boolean {
|
||||
export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
||||
const [density, setDensityState] = useState<Density>(() => getDensity());
|
||||
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
||||
const environment = useEnvironment();
|
||||
const { report } = useAlertsReport();
|
||||
@@ -361,6 +363,25 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
<div className="navbar-footer px-3 user-menu" ref={menuRef}>
|
||||
{menuOpen && (
|
||||
<div className="user-menu-list" role="menu">
|
||||
<div className="user-menu-density" role="group" aria-label="How tightly pages are packed">
|
||||
<span className="small opacity-75">Density</span>
|
||||
<div className="btn-group btn-group-sm w-100">
|
||||
{DENSITIES.map((d) => (
|
||||
<button
|
||||
key={d.value}
|
||||
type="button"
|
||||
className={`btn ${density === d.value ? "active" : ""}`}
|
||||
aria-pressed={density === d.value}
|
||||
onClick={() => {
|
||||
setDensity(d.value);
|
||||
setDensityState(d.value);
|
||||
}}
|
||||
>
|
||||
{d.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" className="user-menu-item" role="menuitem" onClick={toggleTheme}>
|
||||
{theme === "dark" ? <IconSun size={16} /> : <IconMoon size={16} />}
|
||||
{theme === "dark" ? "Light mode" : "Dark mode"}
|
||||
|
||||
@@ -5,9 +5,11 @@ import App from "./App";
|
||||
import "@tabler/core/dist/css/tabler.min.css";
|
||||
import "./styles.css";
|
||||
import { loadEnvironment } from "./utils/environment";
|
||||
import { applyStoredDensity } from "./utils/density";
|
||||
|
||||
// Dev and production can be told apart (ENVIRONMENT_NAME / ENVIRONMENT_COLOR on the server); do it before anything is drawn.
|
||||
void loadEnvironment();
|
||||
applyStoredDensity();
|
||||
|
||||
// Production only — in dev the worker would just add another layer between Vite and the browser.
|
||||
if ("serviceWorker" in navigator && import.meta.env.PROD) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
|
||||
interface LinkForm {
|
||||
serverId: number | "";
|
||||
@@ -153,7 +155,7 @@ export default function AdminLinks({ user }: { user: CurrentUser }) {
|
||||
Every admin bookmark added to a server's own page (Infrastructure → Servers → a server → Admin Links) — Dockge,
|
||||
Webmin, Cockpit, and the like — in one place, instead of visiting each server to find them.
|
||||
</p>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{canEdit && showForm && (
|
||||
<div className="card mb-3">
|
||||
@@ -249,25 +251,22 @@ export default function AdminLinks({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<input
|
||||
className="form-control"
|
||||
style={{ maxWidth: 280 }}
|
||||
<TableToolbar
|
||||
search={search}
|
||||
onSearch={setSearch}
|
||||
placeholder="Search server, label, URL…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
<div className="card-actions">
|
||||
{canEdit && !showForm && (
|
||||
shown={filtered.length}
|
||||
total={links?.length}
|
||||
actions={
|
||||
canEdit && !showForm ? (
|
||||
<button className="btn btn-primary btn-sm" onClick={startAdd}>
|
||||
Add link
|
||||
</button>
|
||||
)}
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted?.length}>
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : undefined
|
||||
}
|
||||
onExport={exportCsv}
|
||||
exportDisabled={!sorted?.length}
|
||||
/>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -9,6 +9,8 @@ import { downloadCsv } from "../utils/csv";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
|
||||
const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: number }> = {
|
||||
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
|
||||
@@ -113,7 +115,7 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{!report && !error && (
|
||||
<div className="card">
|
||||
@@ -172,16 +174,19 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
||||
</div>
|
||||
) : (
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
||||
<input className="form-control" style={{ maxWidth: 260 }} placeholder="Search alerts…" value={search} onChange={(e) => setSearch(e.target.value)} />
|
||||
<select className="form-select w-auto" value={severity} onChange={(e) => setSeverity(e.target.value as "all" | AlertSeverity)}>
|
||||
<TableToolbar
|
||||
search={search}
|
||||
onSearch={setSearch}
|
||||
placeholder="Search alerts…"
|
||||
filters={
|
||||
<>
|
||||
<select className="form-select form-select-sm w-auto" value={severity} onChange={(e) => setSeverity(e.target.value as "all" | AlertSeverity)}>
|
||||
<option value="all">All severities</option>
|
||||
<option value="critical">Critical</option>
|
||||
<option value="warning">Warning</option>
|
||||
<option value="info">Info</option>
|
||||
</select>
|
||||
<select className="form-select w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
|
||||
<select className="form-select form-select-sm w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
|
||||
<option value="all">All kinds</option>
|
||||
{presentCategories.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
@@ -195,8 +200,9 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
||||
<span className="form-check-label">Show silenced</span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -6,6 +6,9 @@ import SortableTh from "../components/SortableTh";
|
||||
import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function targetLabel(e: AuditLogEntry): string {
|
||||
if (!e.targetType) return "—";
|
||||
@@ -50,7 +53,8 @@ export default function AuditLog() {
|
||||
.catch((err) => setError(String(err)));
|
||||
}, []);
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(entries, "createdAt", "desc");
|
||||
const tableSearch = useTableSearch(entries);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "createdAt", "desc");
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -70,8 +74,11 @@ export default function AuditLog() {
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { formatDateTime, parseDbTimestamp } from "../utils/date";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { promptDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice, SuccessNotice } from "../components/Notice";
|
||||
|
||||
const KINDS: { kind: ConsistencyKind; title: string; blurb: string }[] = [
|
||||
{ kind: "ip_conflict", title: "Address conflicts", blurb: "The same address reported by more than one server." },
|
||||
@@ -169,8 +170,8 @@ export default function Consistency({ user }: { user: CurrentUser }) {
|
||||
Where IPAM, DNS and your servers disagree about what lives at an address. It compares what's already stored — nothing is
|
||||
fetched from the servers or DNS providers when you open this page.
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
{notice && <div className="alert alert-success">{notice}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<SuccessNotice notice={notice} />
|
||||
|
||||
{report && (
|
||||
<div className="card mb-3">
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
} from "../api/client";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import StatusStrip from "../components/StatusStrip";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const DNS_TYPE_COLORS: Record<string, string> = {
|
||||
A: "#60a5fa",
|
||||
@@ -576,7 +577,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
)
|
||||
}
|
||||
>
|
||||
{dnsError && <div className="alert alert-danger mb-2">{dnsError}</div>}
|
||||
<ErrorNotice error={dnsError} className="mb-2" />
|
||||
{!dnsStats ? (
|
||||
<div className="text-secondary">Fetching status…</div>
|
||||
) : dnsStats.totalProviders === 0 ? (
|
||||
@@ -669,7 +670,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
)
|
||||
}
|
||||
>
|
||||
{serverError && <div className="alert alert-danger mb-2">{serverError}</div>}
|
||||
<ErrorNotice error={serverError} className="mb-2" />
|
||||
{!serverSummary ? (
|
||||
!serverError && <div className="text-secondary">Fetching status…</div>
|
||||
) : serverSummary.total === 0 ? (
|
||||
@@ -762,7 +763,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
)
|
||||
}
|
||||
>
|
||||
{domainError && <div className="alert alert-danger mb-2">{domainError}</div>}
|
||||
<ErrorNotice error={domainError} className="mb-2" />
|
||||
{!domainList ? (
|
||||
!domainError && <div className="text-secondary">Fetching status…</div>
|
||||
) : domains.length === 0 ? (
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const SOURCE_LABELS: Record<string, string> = {
|
||||
cloudflare: "Cloudflare",
|
||||
@@ -103,7 +104,7 @@ export default function DiagLog() {
|
||||
{clearing ? "Clearing…" : "Clear log"}
|
||||
</button>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-body">
|
||||
|
||||
@@ -17,6 +17,8 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const PROVIDER_LABELS: Record<DnsProviderType, string> = {
|
||||
cloudflare: "Cloudflare",
|
||||
@@ -168,8 +170,10 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
||||
try {
|
||||
if (editingRecordId) {
|
||||
await api.dns.records.update(selectedProviderId, selectedZone.id, editingRecordId, recordForm);
|
||||
toast.success("Record updated.");
|
||||
} else {
|
||||
await api.dns.records.create(selectedProviderId, selectedZone.id, recordForm);
|
||||
toast.success("Record added.");
|
||||
}
|
||||
setRecordForm(null);
|
||||
setEditingRecordId(null);
|
||||
@@ -187,6 +191,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
||||
setError(null);
|
||||
try {
|
||||
await api.dns.records.remove(selectedProviderId, selectedZone.id, r.id);
|
||||
toast.success(`Deleted ${r.type} record ${r.name}.`);
|
||||
loadRecords(selectedProviderId, selectedZone);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -270,7 +275,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{managingProviders ? (
|
||||
<>
|
||||
@@ -402,7 +407,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{zonesError && <div className="alert alert-danger m-3 mb-0">{zonesError}</div>}
|
||||
<ErrorNotice error={zonesError} className="m-3 mb-0" />
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -14,6 +14,10 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function updateBadge(c: DockhandContainer) {
|
||||
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
|
||||
@@ -91,7 +95,8 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
const hosts = [...new Set((data?.containers ?? []).map((c) => c.environmentName))].sort();
|
||||
const filteredContainers = (data?.containers ?? []).filter((c) => !hostFilter || c.environmentName === hostFilter);
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(filteredContainers);
|
||||
const tableSearch = useTableSearch(filteredContainers);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -131,6 +136,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
setError(null);
|
||||
try {
|
||||
await api.integrations.dockhand[action](selectedId, c.environmentId, c.id);
|
||||
toast.success(`${action === "start" ? "Started" : action === "stop" ? "Stopped" : "Restarted"} ${c.name}.`);
|
||||
loadContainers(selectedId);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -142,7 +148,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Docker" adminName="Dockhand" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -193,6 +199,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
)}
|
||||
</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions d-flex gap-2">
|
||||
{hosts.length > 1 && (
|
||||
<select
|
||||
|
||||
@@ -9,6 +9,9 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function statusBadge(d: DomainRecord) {
|
||||
switch (d.status) {
|
||||
@@ -40,7 +43,8 @@ export default function Domains({ user }: { user: CurrentUser }) {
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}, []);
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(data?.domains, "expiresAt");
|
||||
const tableSearch = useTableSearch(data?.domains);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "expiresAt");
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
async function add(e: React.FormEvent) {
|
||||
@@ -130,7 +134,7 @@ export default function Domains({ user }: { user: CurrentUser }) {
|
||||
When each domain registration expires, read from the registry itself. Domains for the DNS zones you've added show up
|
||||
here automatically; add any others by hand.
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
{notice && <div className="alert alert-info">{notice}</div>}
|
||||
|
||||
{canEdit && (
|
||||
@@ -158,6 +162,7 @@ export default function Domains({ user }: { user: CurrentUser }) {
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Registrations</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||
Export CSV
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
type UsernameOptions,
|
||||
type PasswordOptions,
|
||||
} from "../utils/generators";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const MIXED = "mixed";
|
||||
|
||||
@@ -103,7 +104,7 @@ export default function Generator({ user }: { user: CurrentUser }) {
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
{themesError && <div className="alert alert-danger py-2">{themesError}</div>}
|
||||
<ErrorNotice error={themesError} className="py-2" />
|
||||
<label className="form-label">Theme</label>
|
||||
<select className="form-select mb-1" value={theme} onChange={(e) => setTheme(e.target.value)} disabled={!themes}>
|
||||
<option value={MIXED}>Mixed — all lists</option>
|
||||
|
||||
@@ -9,6 +9,9 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function runStatusBadge(repo: GiteaRepo) {
|
||||
const run = repo.latestRun;
|
||||
@@ -93,7 +96,8 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(repos);
|
||||
const tableSearch = useTableSearch(repos);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -115,7 +119,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Gitea" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -153,6 +157,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Repositories</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||
Export CSV
|
||||
|
||||
@@ -7,6 +7,8 @@ import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
tailscale: "Tailscale",
|
||||
@@ -61,6 +63,7 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
async function toggleEnabled(i: IntegrationSummary) {
|
||||
try {
|
||||
await api.integrations.update(i.id, { enabled: !i.enabled });
|
||||
toast.success(`${i.name} ${i.enabled ? "disabled" : "enabled"}.`);
|
||||
loadIntegrations();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -83,6 +86,7 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
if (!(await confirmDialog({ title: "Delete integration", message: `Delete integration "${i.name}"?`, confirmLabel: "Delete", danger: true }))) return;
|
||||
try {
|
||||
await api.integrations.remove(i.id);
|
||||
toast.success(`Deleted ${i.name}.`);
|
||||
loadIntegrations();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -116,7 +120,7 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{editingIntegration ? (
|
||||
<IntegrationEditForm
|
||||
|
||||
@@ -8,6 +8,8 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { useSelection } from "../hooks/useSelection";
|
||||
import { confirmDialog, promptDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
|
||||
const emptyForm: IpamInput = { ipAddress: "", label: "", vendor: "", location: "", notes: "" };
|
||||
|
||||
@@ -219,7 +221,7 @@ export default function Ipam({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">IP Addresses</h2>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
{syncResult && <div className="alert alert-success">Synced from {syncResult}</div>}
|
||||
|
||||
<div className="card mb-3">
|
||||
@@ -351,38 +353,36 @@ export default function Ipam({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
||||
<input
|
||||
className="form-control"
|
||||
style={{ maxWidth: 280 }}
|
||||
<TableToolbar
|
||||
search={search}
|
||||
onSearch={setSearch}
|
||||
placeholder="Search IP, label, vendor, location…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
shown={filtered.length}
|
||||
total={entries?.length}
|
||||
actions={
|
||||
<>
|
||||
{canEdit && !showForm && (
|
||||
<button className="btn btn-primary" onClick={startAdd}>
|
||||
<button className="btn btn-sm btn-primary" onClick={startAdd}>
|
||||
Add IP address
|
||||
</button>
|
||||
)}
|
||||
{canEdit && (
|
||||
<>
|
||||
<button className="btn btn-outline-secondary" onClick={() => runSync("tailscale")} disabled={!!syncing}>
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("tailscale")} disabled={!!syncing}>
|
||||
{syncing === "tailscale" ? "Syncing…" : "Sync from Tailscale"}
|
||||
</button>
|
||||
<button className="btn btn-outline-secondary" onClick={() => runSync("proxmox")} disabled={!!syncing}>
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("proxmox")} disabled={!!syncing}>
|
||||
{syncing === "proxmox" ? "Syncing…" : "Sync from Proxmox"}
|
||||
</button>
|
||||
<button className="btn btn-outline-secondary" onClick={() => runSync("phpipam")} disabled={!!syncing}>
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("phpipam")} disabled={!!syncing}>
|
||||
{syncing === "phpipam" ? "Syncing…" : "Sync from phpIPAM"}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
onExport={exportCsv}
|
||||
/>
|
||||
{canEdit && selection.count > 0 && (
|
||||
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
||||
<span>{selection.count} selected</span>
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { formatRemaining } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const DURATIONS: { minutes: number; label: string }[] = [
|
||||
{ minutes: 30, label: "30 minutes" },
|
||||
@@ -102,6 +104,7 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
||||
});
|
||||
setTarget("");
|
||||
setReason("");
|
||||
toast.success("Maintenance started. Alerts for it are silenced until it ends.");
|
||||
load();
|
||||
announceChange();
|
||||
} catch (err) {
|
||||
@@ -143,6 +146,7 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
||||
setError(null);
|
||||
try {
|
||||
await api.maintenance.end(w.id);
|
||||
toast.success(w.startedAt > new Date().toISOString() ? "Scheduled window cancelled." : "Maintenance ended. Alerts for it are active again.");
|
||||
load();
|
||||
announceChange();
|
||||
} catch (err) {
|
||||
@@ -194,7 +198,7 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
||||
Silence alerts about one server or integration while you work on it. Every window ends on its own — anything
|
||||
still wrong when it ends alerts then, so nothing stays hidden.
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{canEdit && (
|
||||
<div className="card mb-3">
|
||||
|
||||
@@ -6,6 +6,9 @@ import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function priorityBadge(t: OsTicketTicket) {
|
||||
if (!t.priorityName) return <span className="text-secondary">—</span>;
|
||||
@@ -58,7 +61,8 @@ export default function OsTicket({ user: _user }: { user: CurrentUser }) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedId]);
|
||||
|
||||
const { sorted: sortedTickets, sortKey, sortDir, requestSort } = useSortable(data?.tickets);
|
||||
const tableSearch = useTableSearch(data?.tickets);
|
||||
const { sorted: sortedTickets, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
|
||||
function exportCsv() {
|
||||
if (!sortedTickets) return;
|
||||
@@ -85,7 +89,7 @@ export default function OsTicket({ user: _user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">osTicket</h2>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -157,6 +161,7 @@ export default function OsTicket({ user: _user }: { user: CurrentUser }) {
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Open tickets</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
function formatBytes(bytes: number | null): string {
|
||||
if (bytes === null) return "—";
|
||||
@@ -128,7 +129,7 @@ export default function PbsBackup({ user: _user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Proxmox Backup Server" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
|
||||
@@ -15,6 +15,7 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const emptyForm: PortForwardInput = {
|
||||
label: "",
|
||||
@@ -197,7 +198,7 @@ export default function Ports({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{agentError && <div className="alert alert-danger m-3">{agentError}</div>}
|
||||
<ErrorNotice error={agentError} className="m-3" />
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
@@ -366,7 +367,7 @@ export default function Ports({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{forwardError && <div className="alert alert-danger m-3">{forwardError}</div>}
|
||||
<ErrorNotice error={forwardError} className="m-3" />
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { api, type PrivacyOverview } from "../api/client";
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const CHANNEL_LABELS = { gotify: "Gotify", ntfy: "ntfy", smtp: "email (SMTP)", webhook: "webhook" } as const;
|
||||
|
||||
@@ -57,7 +58,7 @@ export default function Privacy() {
|
||||
for this installation.
|
||||
</div>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{data && (
|
||||
<div className="card mb-3">
|
||||
|
||||
@@ -17,6 +17,10 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function proxmoxStatusBadge(status: string) {
|
||||
return status === "running" ? (
|
||||
@@ -181,6 +185,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
setError(null);
|
||||
try {
|
||||
await api.integrations.proxmox[action](selectedId, g.node, g.type, g.vmid);
|
||||
toast.success(`${{ start: "Started", stop: "Stopped", restart: "Restarted", shutdown: "Shut down" }[action]} ${g.name}.`);
|
||||
loadGuests(selectedId);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -189,7 +194,8 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted: sortedGuests, sortKey: guestSortKey, sortDir: guestSortDir, requestSort: requestGuestSort } = useSortable(data?.guests);
|
||||
const tableSearch = useTableSearch(data?.guests);
|
||||
const { sorted: sortedGuests, sortKey: guestSortKey, sortDir: guestSortDir, requestSort: requestGuestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems: guestPageItems, page: guestPage, setPage: setGuestPage, pageCount: guestPageCount, totalCount: guestTotalCount } =
|
||||
usePagination(sortedGuests);
|
||||
|
||||
@@ -205,7 +211,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Proxmox" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -241,7 +247,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{nodeStatsError && <div className="alert alert-danger">{nodeStatsError}</div>}
|
||||
<ErrorNotice error={nodeStatsError} />
|
||||
<div className="row row-cards mb-3">
|
||||
{nodeStats?.map((n) => (
|
||||
<div className="col-12" key={n.node}>
|
||||
@@ -355,7 +361,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{backupsError && <div className="alert alert-danger mb-3">{backupsError}</div>}
|
||||
<ErrorNotice error={backupsError} className="mb-3" />
|
||||
{backupTasks && backupTasks.length > 0 && !backupTasks[0].ok && backupTasks[0].status !== "running" && (
|
||||
<div className="alert alert-danger">
|
||||
Most recent backup run on <strong>{backupTasks[0].node}</strong>
|
||||
@@ -473,6 +479,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
)}
|
||||
</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
|
||||
@@ -10,6 +10,9 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { useSelection } from "../hooks/useSelection";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
|
||||
const TYPE_LABELS: Record<SecretRecord["type"], string> = {
|
||||
api_token: "API Token",
|
||||
@@ -119,8 +122,10 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
};
|
||||
if (editingId) {
|
||||
await api.secrets.update(editingId, payload);
|
||||
toast.success(`Saved ${form.name}.`);
|
||||
} else {
|
||||
await api.secrets.create(payload);
|
||||
toast.success(`Added ${form.name}.`);
|
||||
}
|
||||
cancelEdit();
|
||||
load();
|
||||
@@ -150,6 +155,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
setError(null);
|
||||
try {
|
||||
await api.secrets.remove(s.id);
|
||||
toast.success(`Deleted ${s.name}.`);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -199,7 +205,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Secrets</h2>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{canEdit && (
|
||||
<div className="card mb-3">
|
||||
@@ -324,18 +330,13 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
||||
<input
|
||||
className="form-control"
|
||||
style={{ maxWidth: 260 }}
|
||||
<TableToolbar
|
||||
search={search}
|
||||
onSearch={setSearch}
|
||||
placeholder="Search name or description…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
filters={
|
||||
<select
|
||||
className="form-select"
|
||||
style={{ maxWidth: 160 }}
|
||||
className="form-select form-select-sm w-auto"
|
||||
value={statusFilter}
|
||||
onChange={(e) => setStatusFilter(e.target.value as typeof statusFilter)}
|
||||
>
|
||||
@@ -345,11 +346,11 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
||||
<option value="expired">Expired</option>
|
||||
<option value="never">No expiry</option>
|
||||
</select>
|
||||
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
shown={filtered.length}
|
||||
total={secrets?.length}
|
||||
onExport={exportCsv}
|
||||
/>
|
||||
{canEdit && selection.count > 0 && (
|
||||
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
||||
<span>{selection.count} selected</span>
|
||||
|
||||
@@ -15,6 +15,9 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
||||
const status = template.lastTask?.status;
|
||||
@@ -100,7 +103,8 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(data?.templates);
|
||||
const tableSearch = useTableSearch(data?.templates);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -120,7 +124,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Semaphore" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -164,6 +168,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
||||
<span className="text-red fw-normal ms-2">{data.summary.failing} failing</span>
|
||||
)}
|
||||
</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||
Export CSV
|
||||
|
||||
@@ -18,6 +18,7 @@ import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskT
|
||||
import { formatDateTime } from "../utils/date";
|
||||
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const SCHEDULE_TYPE_OPTIONS: { value: ScheduleType; label: string }[] = Object.entries(SCHEDULE_TYPE_LABELS).map(
|
||||
([value, label]) => ({ value: value as ScheduleType, label }),
|
||||
@@ -391,7 +392,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
{refreshing ? "Refreshing…" : "Refresh"}
|
||||
</button>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
<ServerTags
|
||||
serverId={serverId}
|
||||
@@ -412,7 +413,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{adminLinkError && <div className="alert alert-danger">{adminLinkError}</div>}
|
||||
<ErrorNotice error={adminLinkError} />
|
||||
|
||||
{adminLinkForm && (
|
||||
<form onSubmit={submitAdminLink} className="row g-2 align-items-end mb-3">
|
||||
@@ -629,7 +630,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{guestActionError && <div className="alert alert-danger">{guestActionError}</div>}
|
||||
<ErrorNotice error={guestActionError} />
|
||||
<div className="row g-3">
|
||||
<div className="col-sm-6">
|
||||
<div className="text-secondary small">CPU</div>
|
||||
|
||||
@@ -12,6 +12,10 @@ import { TagBadges } from "../components/ServerTags";
|
||||
import { AGENT_RUN_HINT, agentOsOf, installCommand, uninstallCommand, type AgentOs } from "../utils/agentCommands";
|
||||
import { tagBadge, useTagColors } from "../utils/tags";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function typeBadgeStyle(colors: Record<string, string>, type: string): CSSProperties {
|
||||
const color = colors[type];
|
||||
@@ -66,6 +70,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
osType: serverOs,
|
||||
});
|
||||
setNewToken(result);
|
||||
toast.success(`Added ${serverName}. Its install command is shown below.`);
|
||||
setServerName("");
|
||||
setServerHostname("");
|
||||
setServerDescription("");
|
||||
@@ -89,13 +94,15 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
if (!(await confirmDialog({ title: "Remove server", message: "Remove this server and all its tracked tasks?", confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.servers.remove(id);
|
||||
toast.success("Server removed.");
|
||||
await loadServers();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted: sortedServers, sortKey, sortDir, requestSort } = useSortable(servers);
|
||||
const tableSearch = useTableSearch(servers);
|
||||
const { sorted: sortedServers, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems: serverPageItems, page: serverPage, setPage: setServerPage, pageCount: serverPageCount, totalCount: serverTotalCount } =
|
||||
usePagination(sortedServers);
|
||||
|
||||
@@ -136,7 +143,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{managingServers ? (
|
||||
<>
|
||||
@@ -257,8 +264,9 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
)}
|
||||
|
||||
<div className="card">
|
||||
<div className="card-header justify-content-end">
|
||||
<button className="btn btn-outline-secondary btn-sm" onClick={exportCsv} disabled={servers.length === 0}>
|
||||
<div className="card-header">
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||
<button className="btn btn-outline-secondary btn-sm ms-auto" onClick={exportCsv} disabled={servers.length === 0}>
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,9 @@ import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function friendlyUserAgent(ua: string | null): string {
|
||||
if (!ua) return "—";
|
||||
@@ -72,7 +75,8 @@ export default function Sessions() {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(sessions);
|
||||
const tableSearch = useTableSearch(sessions);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
|
||||
function exportCsv() {
|
||||
if (!sorted) return;
|
||||
@@ -102,8 +106,11 @@ export default function Sessions() {
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
function healthBadge(status: string) {
|
||||
return status === "normal" ? (
|
||||
@@ -135,7 +136,7 @@ export default function Synology({ user: _user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Synology" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
|
||||
@@ -16,6 +16,10 @@ import { downloadCsv } from "../utils/csv";
|
||||
import { useSelection } from "../hooks/useSelection";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
const KEY_EXPIRY_WARN_DAYS = 30;
|
||||
|
||||
@@ -83,6 +87,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
if (!selectedId) return;
|
||||
try {
|
||||
await api.integrations.tailscale.setAuthorized(selectedId, device.id, authorized);
|
||||
toast.success(`${authorized ? "Authorized" : "Deauthorized"} ${device.label || device.hostname}.`);
|
||||
loadDevices(selectedId);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -94,6 +99,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
if (!(await confirmDialog({ title: "Remove device", message: `Remove device "${device.label || device.hostname}" from the tailnet?`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.integrations.tailscale.remove(selectedId, device.id);
|
||||
toast.success(`Removed ${device.label || device.hostname} from the tailnet.`);
|
||||
loadDevices(selectedId);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
@@ -135,7 +141,8 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(data?.devices);
|
||||
const tableSearch = useTableSearch(data?.devices);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -158,7 +165,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Tailscale" url="https://login.tailscale.com/admin/machines" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -206,6 +213,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
)}
|
||||
</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||
Export CSV
|
||||
|
||||
@@ -8,6 +8,9 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { readableError } from "../utils/errors";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
function statusBadge(monitor: UptimeKumaMonitor) {
|
||||
switch (monitor.status) {
|
||||
@@ -74,7 +77,8 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedId]);
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(data?.monitors, "name");
|
||||
const tableSearch = useTableSearch(data?.monitors);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "name");
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -99,7 +103,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<>
|
||||
<IntegrationPageTitle title="Uptime Kuma" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
<div className="card">
|
||||
@@ -138,6 +142,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
||||
<span className="text-yellow fw-normal ms-2">{data.summary.pending} pending</span>
|
||||
)}
|
||||
</h3>
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||
Export CSV
|
||||
|
||||
@@ -4,6 +4,9 @@ import { formatDateTime } from "../utils/date";
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { SearchBox } from "../components/TableToolbar";
|
||||
import { useTableSearch } from "../hooks/useTableSearch";
|
||||
|
||||
const ROLES: UserRole[] = ["viewer", "operator", "admin"];
|
||||
|
||||
@@ -34,7 +37,8 @@ export default function Users() {
|
||||
}
|
||||
}
|
||||
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(users);
|
||||
const tableSearch = useTableSearch(users);
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||
|
||||
function exportCsv() {
|
||||
if (!sorted) return;
|
||||
@@ -53,8 +57,11 @@ export default function Users() {
|
||||
Export CSV
|
||||
</button>
|
||||
</div>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { api, type AlertTicketOverview, type AlertTicketRunSummary, type AlertTi
|
||||
import { formatDateTime } from "../../utils/date";
|
||||
import { formatAgo } from "../../utils/duration";
|
||||
import { readableError } from "../../utils/errors";
|
||||
import { ErrorNotice, SuccessNotice } from "../../components/Notice";
|
||||
|
||||
const SEVERITIES: { value: AlertTicketSeverity; label: string; hint: string }[] = [
|
||||
{ value: "critical", label: "Critical", hint: "A server down, a disk nearly full, a failed backup, something expired" },
|
||||
@@ -108,8 +109,8 @@ export default function AlertTicketSettings() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
{notice && <div className="alert alert-success">{notice}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<SuccessNotice notice={notice} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { api, type EncryptedExportFile, type ImportResult } from "../../api/client";
|
||||
import { confirmDialog } from "../../utils/dialogs";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
function downloadJson(filename: string, data: unknown) {
|
||||
const blob = new Blob([JSON.stringify(data)], { type: "application/json" });
|
||||
@@ -103,7 +104,7 @@ export default function BackupSettings() {
|
||||
somewhere you trust and don't lose the passphrase — it can't be recovered.
|
||||
</p>
|
||||
<p className="text-secondary">Not included: DNS records, secrets, IPAM, servers, or the audit/diagnostic logs — this is configuration only.</p>
|
||||
{exportError && <div className="alert alert-danger">{exportError}</div>}
|
||||
<ErrorNotice error={exportError} />
|
||||
<div className="mb-2">
|
||||
<label className="form-label">Passphrase</label>
|
||||
<input
|
||||
@@ -149,8 +150,8 @@ export default function BackupSettings() {
|
||||
onto the current ones. Integrations and DNS providers are only <strong>added</strong> — anything
|
||||
that already exists with the same name is left alone, so this is safe to run more than once.
|
||||
</p>
|
||||
{importError && <div className="alert alert-danger">{importError}</div>}
|
||||
{importFileError && <div className="alert alert-danger">{importFileError}</div>}
|
||||
<ErrorNotice error={importError} />
|
||||
<ErrorNotice error={importFileError} />
|
||||
{importResult && (
|
||||
<div className="alert alert-success">
|
||||
<div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api } from "../../api/client";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
const PROVIDER_NAMES: Record<string, string> = {
|
||||
cloudflare: "Cloudflare",
|
||||
@@ -106,7 +107,7 @@ export default function BadgeSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
||||
<ErrorNotice error={loadError} />
|
||||
|
||||
<div className="row row-cards">
|
||||
<div className="col-md-6">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { api } from "../../api/client";
|
||||
import { confirmDialog } from "../../utils/dialogs";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
export default function CacheSettings() {
|
||||
const [clearing, setClearing] = useState(false);
|
||||
@@ -35,7 +36,7 @@ export default function CacheSettings() {
|
||||
The DNS module keeps a local copy of every synced zone and record so pages load instantly. Clear it if
|
||||
you see stale or incorrect data — every zone will need to be re-synced from its provider afterwards.
|
||||
</p>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
</div>
|
||||
<div className="card-footer">
|
||||
<button className="btn btn-danger" onClick={handleClear} disabled={clearing}>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { api, type AppSettings, type DateFormat, type TimeFormat } from "../../api/client";
|
||||
import { setDateTimeSettings } from "../../utils/date";
|
||||
import { setPageSize } from "../../utils/pageSize";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
const DATE_FORMAT_OPTIONS: { value: DateFormat; label: string; example: string }[] = [
|
||||
{ value: "ymd", label: "Year-Month-Day", example: "2026-09-15" },
|
||||
@@ -69,7 +70,7 @@ export default function DisplaySettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
||||
<ErrorNotice error={loadError} />
|
||||
|
||||
<div className="row row-cards">
|
||||
<div className="col-md-7">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, type AppSettings } from "../../api/client";
|
||||
import { confirmDialog } from "../../utils/dialogs";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
const INTERVAL_OPTIONS: { value: number; label: string }[] = [
|
||||
{ value: 1, label: "Every hour" },
|
||||
@@ -81,7 +82,7 @@ export default function LogSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
||||
<ErrorNotice error={loadError} />
|
||||
|
||||
<div className="row row-cards">
|
||||
<div className="col-md-7">
|
||||
@@ -145,7 +146,7 @@ export default function LogSettings() {
|
||||
Runs a purge immediately using the retention period above, regardless of whether automatic
|
||||
purging is enabled.
|
||||
</p>
|
||||
{purgeError && <div className="alert alert-danger mb-0">{purgeError}</div>}
|
||||
<ErrorNotice error={purgeError} className="mb-0" />
|
||||
{purgeResult && (
|
||||
<div className="alert alert-success mb-0">
|
||||
Deleted {purgeResult.diagDeleted} diagnostic log and {purgeResult.auditDeleted} audit log
|
||||
|
||||
@@ -4,6 +4,7 @@ import { confirmDialog } from "../../utils/dialogs";
|
||||
import { formatDateTime } from "../../utils/date";
|
||||
import { readableError } from "../../utils/errors";
|
||||
import { parseNames } from "../../utils/nameLists";
|
||||
import { ErrorNotice, SuccessNotice } from "../../components/Notice";
|
||||
|
||||
/** One list as it's being edited. The names are kept as the text in the box, so typing stays natural. */
|
||||
interface Draft {
|
||||
@@ -221,8 +222,8 @@ export default function NameSettings() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
{notice && <div className="alert alert-success">{notice}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<SuccessNotice notice={notice} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
@@ -334,7 +335,7 @@ export default function NameSettings() {
|
||||
{fetching ? "Fetching…" : "Fetch names"}
|
||||
</button>
|
||||
</div>
|
||||
{importError && <div className="alert alert-danger mt-3 mb-0">{importError}</div>}
|
||||
<ErrorNotice error={importError} className="mt-3 mb-0" />
|
||||
{preview && (
|
||||
<div className="mt-3">
|
||||
<div className="mb-2">
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type QuietHoursSettings,
|
||||
type HealthCheckSettings,
|
||||
} from "../../api/client";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
|
||||
const TIMEZONES = [
|
||||
"UTC",
|
||||
@@ -212,7 +213,7 @@ export default function NotificationSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
||||
<ErrorNotice error={loadError} />
|
||||
|
||||
<div className="row row-cards">
|
||||
<div className="col-md-6">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { api, type TagEntry } from "../../api/client";
|
||||
import { readableError } from "../../utils/errors";
|
||||
import { normalizeTagInput, refreshTagColors, tagBadge } from "../../utils/tags";
|
||||
import { confirmDialog, promptDialog } from "../../utils/dialogs";
|
||||
import { ErrorNotice, SuccessNotice } from "../../components/Notice";
|
||||
|
||||
const DEFAULT_PICK = "#3b82f6";
|
||||
|
||||
@@ -99,8 +100,8 @@ export default function TagSettings() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
{notice && <div className="alert alert-success">{notice}</div>}
|
||||
<ErrorNotice error={error} />
|
||||
<SuccessNotice notice={notice} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
|
||||
@@ -150,3 +150,135 @@ html[data-env] .navbar-vertical {
|
||||
padding-top: 0.3rem;
|
||||
padding-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
/* Toasts: short results that appear in the corner and fade away (utils/toast). */
|
||||
.toast-stack {
|
||||
position: fixed;
|
||||
right: 1rem;
|
||||
bottom: 1rem;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
width: min(24rem, calc(100vw - 2rem));
|
||||
}
|
||||
|
||||
.toast-item {
|
||||
display: flex;
|
||||
gap: 0.6rem;
|
||||
padding: 0.7rem 0.8rem;
|
||||
color: #fff;
|
||||
background: #1f2937;
|
||||
border-left: 4px solid #6b7280;
|
||||
border-radius: var(--tblr-border-radius, 4px);
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
|
||||
animation: toast-in 0.18s ease-out;
|
||||
}
|
||||
|
||||
.toast-success {
|
||||
border-left-color: #22c55e;
|
||||
}
|
||||
|
||||
.toast-error {
|
||||
border-left-color: #ef4444;
|
||||
}
|
||||
|
||||
.toast-info {
|
||||
border-left-color: #3b82f6;
|
||||
}
|
||||
|
||||
.toast-close {
|
||||
flex-shrink: 0;
|
||||
align-self: flex-start;
|
||||
padding: 0.1rem;
|
||||
color: inherit;
|
||||
opacity: 0.7;
|
||||
background: none;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.toast-close:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@keyframes toast-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(0.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.toast-item {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Table toolbar: search and filters on the left, row count, then the table's actions and Export CSV on the right. ── */
|
||||
.table-toolbar-inner {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-toolbar-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.table-search {
|
||||
width: 16rem;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* ── Long tables scroll inside their card with the column headings kept in view (wide screens only: on a phone the page scrolls). ── */
|
||||
@media (min-width: 992px) {
|
||||
.card > .table-responsive {
|
||||
max-height: calc(100vh - 12rem);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.card > .table-responsive > .table > thead > tr > th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background-color: var(--tblr-bg-surface-secondary, var(--tblr-card-bg));
|
||||
box-shadow: inset 0 -1px 0 var(--tblr-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Density: how tightly pages are packed. Normal is Tabler's own look; the choice is in the user menu. ── */
|
||||
html[data-density="compact"] {
|
||||
--tblr-body-font-size: 0.8125rem;
|
||||
--tblr-card-spacer-y: 0.85rem;
|
||||
--tblr-card-spacer-x: 1rem;
|
||||
}
|
||||
|
||||
html[data-density="compact"] .table > :not(caption) > * > * {
|
||||
padding: 0.35rem 0.6rem;
|
||||
}
|
||||
|
||||
html[data-density="compact"] .page-body {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
html[data-density="roomy"] {
|
||||
--tblr-body-font-size: 0.975rem;
|
||||
--tblr-card-spacer-y: 1.5rem;
|
||||
--tblr-card-spacer-x: 1.5rem;
|
||||
}
|
||||
|
||||
html[data-density="roomy"] .table > :not(caption) > * > * {
|
||||
padding: 1rem 0.9rem;
|
||||
}
|
||||
|
||||
.user-menu-density {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding: 0.4rem 0.5rem;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// How tightly the pages are packed: Compact fits more on screen, Roomy is easier to read on a big monitor or a tablet.
|
||||
// Chosen per browser (the styles key off the data-density attribute on <html>); Normal is the original look.
|
||||
|
||||
export type Density = "compact" | "normal" | "roomy";
|
||||
|
||||
export const DENSITIES: { value: Density; label: string }[] = [
|
||||
{ value: "compact", label: "Compact" },
|
||||
{ value: "normal", label: "Normal" },
|
||||
{ value: "roomy", label: "Roomy" },
|
||||
];
|
||||
|
||||
const KEY = "hlm-density";
|
||||
|
||||
export function getDensity(): Density {
|
||||
const value = document.documentElement.getAttribute("data-density");
|
||||
return value === "compact" || value === "roomy" ? value : "normal";
|
||||
}
|
||||
|
||||
function apply(density: Density): void {
|
||||
if (density === "normal") document.documentElement.removeAttribute("data-density");
|
||||
else document.documentElement.setAttribute("data-density", density);
|
||||
}
|
||||
|
||||
/** Called once at start-up, before anything is drawn, so the page never flashes in the wrong density. */
|
||||
export function applyStoredDensity(): void {
|
||||
try {
|
||||
const stored = localStorage.getItem(KEY);
|
||||
if (stored === "compact" || stored === "roomy") apply(stored);
|
||||
} catch {
|
||||
// storage blocked: the normal look
|
||||
}
|
||||
}
|
||||
|
||||
export function setDensity(density: Density): void {
|
||||
apply(density);
|
||||
try {
|
||||
if (density === "normal") localStorage.removeItem(KEY);
|
||||
else localStorage.setItem(KEY, density);
|
||||
} catch {
|
||||
// not remembered; it still applies for this visit
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,39 @@ function applyEnvironment(look: EnvironmentLook | null): void {
|
||||
root.setAttribute("data-env", look.name || "custom");
|
||||
document.title = look.name ? `[${look.name}] ${BASE_TITLE}` : BASE_TITLE;
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", look.color);
|
||||
tintFavicon(look.color);
|
||||
}
|
||||
|
||||
/** The tab icon gets a dot in the environment's colour in its corner, so this tab stands out among several. */
|
||||
function tintFavicon(color: string): void {
|
||||
const links = document.querySelectorAll<HTMLLinkElement>('link[rel~="icon"]');
|
||||
if (links.length === 0) return;
|
||||
const image = new Image();
|
||||
image.onload = () => {
|
||||
try {
|
||||
const size = 64;
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = canvas.height = size;
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) return;
|
||||
ctx.drawImage(image, 0, 0, size, size);
|
||||
ctx.beginPath();
|
||||
ctx.arc(size - 19, size - 19, 18, 0, Math.PI * 2);
|
||||
ctx.fillStyle = color;
|
||||
ctx.fill();
|
||||
ctx.lineWidth = 5;
|
||||
ctx.strokeStyle = "#ffffff";
|
||||
ctx.stroke();
|
||||
const href = canvas.toDataURL("image/png");
|
||||
links.forEach((link) => {
|
||||
link.href = href;
|
||||
link.removeAttribute("sizes");
|
||||
});
|
||||
} catch {
|
||||
// The plain icon stays; this is only a nicety.
|
||||
}
|
||||
};
|
||||
image.src = "/icon-192.png";
|
||||
}
|
||||
|
||||
/** Whether white text on this colour would be hard to read. */
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Short messages that appear in a corner of the screen and go away by themselves — for the result of something you just did
|
||||
// when the place you did it may no longer be in view. Anything can call toast.success() / toast.error() / toast.info(); one
|
||||
// <ToastHost /> (mounted once, in App) draws them.
|
||||
|
||||
export type ToastKind = "success" | "error" | "info";
|
||||
|
||||
export interface ToastItem {
|
||||
id: number;
|
||||
kind: ToastKind;
|
||||
message: string;
|
||||
}
|
||||
|
||||
let nextId = 1;
|
||||
let items: ToastItem[] = [];
|
||||
const listeners = new Set<(items: ToastItem[]) => void>();
|
||||
|
||||
function emit() {
|
||||
for (const l of listeners) l(items);
|
||||
}
|
||||
|
||||
export function subscribeToasts(listener: (items: ToastItem[]) => void): () => void {
|
||||
listeners.add(listener);
|
||||
listener(items);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
}
|
||||
|
||||
export function dismissToast(id: number): void {
|
||||
items = items.filter((t) => t.id !== id);
|
||||
emit();
|
||||
}
|
||||
|
||||
function show(kind: ToastKind, message: string): void {
|
||||
const text = message.trim();
|
||||
if (!text) return;
|
||||
// The same message twice in a row is one toast, not two.
|
||||
if (items.some((t) => t.kind === kind && t.message === text)) return;
|
||||
// A handful at most: the newest few are what matter.
|
||||
items = [...items, { id: nextId++, kind, message: text }].slice(-4);
|
||||
emit();
|
||||
}
|
||||
|
||||
export const toast = {
|
||||
success: (message: string) => show("success", message),
|
||||
error: (message: string) => show("error", message),
|
||||
info: (message: string) => show("info", message),
|
||||
};
|
||||