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" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Homelab Manager</title>
|
<title>Homelab Manager</title>
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
<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" />
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||||
<meta name="theme-color" content="#182433" />
|
<meta name="theme-color" content="#182433" />
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<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 DialogHost from "./components/DialogHost";
|
||||||
import { setDateTimeSettings } from "./utils/date";
|
import { setDateTimeSettings } from "./utils/date";
|
||||||
import { setPageSize } from "./utils/pageSize";
|
import { setPageSize } from "./utils/pageSize";
|
||||||
|
import ToastHost from "./components/ToastHost";
|
||||||
|
|
||||||
const roleRank: Record<UserRole, number> = { viewer: 0, operator: 1, admin: 2 };
|
const roleRank: Record<UserRole, number> = { viewer: 0, operator: 1, admin: 2 };
|
||||||
|
|
||||||
@@ -171,6 +172,7 @@ export default function App() {
|
|||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
<DialogHost />
|
<DialogHost />
|
||||||
|
<ToastHost />
|
||||||
</AppShell>
|
</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 Pagination from "./Pagination";
|
||||||
import SortableTh from "./SortableTh";
|
import SortableTh from "./SortableTh";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "./Notice";
|
||||||
|
|
||||||
const PRESETS: { key: string; label: string; from: number; to: number }[] = [
|
const PRESETS: { key: string; label: string; from: number; to: number }[] = [
|
||||||
{ key: "well-known", label: "1–1024 (well-known)", from: 1, to: 1024 },
|
{ key: "well-known", label: "1–1024 (well-known)", from: 1, to: 1024 },
|
||||||
@@ -235,7 +236,7 @@ export default function ServerPorts({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="card-body pb-2">
|
<div className="card-body pb-2">
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{data && (
|
{data && (
|
||||||
<div className="text-secondary small mb-2">
|
<div className="text-secondary small mb-2">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
|
|||||||
import { api } from "../api/client";
|
import { api } from "../api/client";
|
||||||
import { normalizeTagInput, tagBadge, useTagColors } from "../utils/tags";
|
import { normalizeTagInput, tagBadge, useTagColors } from "../utils/tags";
|
||||||
import { readableError } from "../utils/errors";
|
import { readableError } from "../utils/errors";
|
||||||
|
import { ErrorNotice } from "./Notice";
|
||||||
|
|
||||||
export function TagBadges({ tags, linked = false }: { tags: string[]; linked?: boolean }) {
|
export function TagBadges({ tags, linked = false }: { tags: string[]; linked?: boolean }) {
|
||||||
const colors = useTagColors();
|
const colors = useTagColors();
|
||||||
@@ -99,7 +100,7 @@ export default function ServerTags({
|
|||||||
return (
|
return (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
<label className="form-label">Tags</label>
|
<label className="form-label">Tags</label>
|
||||||
<div className="d-flex flex-wrap align-items-center gap-1 mb-2">
|
<div className="d-flex flex-wrap align-items-center gap-1 mb-2">
|
||||||
{draftTags.map((tag) => {
|
{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 { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
||||||
import { formatRemaining } from "../utils/duration";
|
import { formatRemaining } from "../utils/duration";
|
||||||
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
||||||
|
import { DENSITIES, getDensity, setDensity, type Density } from "../utils/density";
|
||||||
import CommandPalette from "../components/CommandPalette";
|
import CommandPalette from "../components/CommandPalette";
|
||||||
import { isLightColor, useEnvironment } from "../utils/environment";
|
import { isLightColor, useEnvironment } from "../utils/environment";
|
||||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
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 }) {
|
export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) {
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
||||||
|
const [density, setDensityState] = useState<Density>(() => getDensity());
|
||||||
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
||||||
const environment = useEnvironment();
|
const environment = useEnvironment();
|
||||||
const { report } = useAlertsReport();
|
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}>
|
<div className="navbar-footer px-3 user-menu" ref={menuRef}>
|
||||||
{menuOpen && (
|
{menuOpen && (
|
||||||
<div className="user-menu-list" role="menu">
|
<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}>
|
<button type="button" className="user-menu-item" role="menuitem" onClick={toggleTheme}>
|
||||||
{theme === "dark" ? <IconSun size={16} /> : <IconMoon size={16} />}
|
{theme === "dark" ? <IconSun size={16} /> : <IconMoon size={16} />}
|
||||||
{theme === "dark" ? "Light mode" : "Dark mode"}
|
{theme === "dark" ? "Light mode" : "Dark mode"}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import App from "./App";
|
|||||||
import "@tabler/core/dist/css/tabler.min.css";
|
import "@tabler/core/dist/css/tabler.min.css";
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
import { loadEnvironment } from "./utils/environment";
|
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.
|
// Dev and production can be told apart (ENVIRONMENT_NAME / ENVIRONMENT_COLOR on the server); do it before anything is drawn.
|
||||||
void loadEnvironment();
|
void loadEnvironment();
|
||||||
|
applyStoredDensity();
|
||||||
|
|
||||||
// Production only — in dev the worker would just add another layer between Vite and the browser.
|
// Production only — in dev the worker would just add another layer between Vite and the browser.
|
||||||
if ("serviceWorker" in navigator && import.meta.env.PROD) {
|
if ("serviceWorker" in navigator && import.meta.env.PROD) {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import SortableTh from "../components/SortableTh";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import TableToolbar from "../components/TableToolbar";
|
||||||
|
|
||||||
interface LinkForm {
|
interface LinkForm {
|
||||||
serverId: number | "";
|
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,
|
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.
|
Webmin, Cockpit, and the like — in one place, instead of visiting each server to find them.
|
||||||
</p>
|
</p>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{canEdit && showForm && (
|
{canEdit && showForm && (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
@@ -249,25 +251,22 @@ export default function AdminLinks({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<TableToolbar
|
||||||
<input
|
search={search}
|
||||||
className="form-control"
|
onSearch={setSearch}
|
||||||
style={{ maxWidth: 280 }}
|
placeholder="Search server, label, URL…"
|
||||||
placeholder="Search server, label, URL…"
|
shown={filtered.length}
|
||||||
value={search}
|
total={links?.length}
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
actions={
|
||||||
/>
|
canEdit && !showForm ? (
|
||||||
<div className="card-actions">
|
|
||||||
{canEdit && !showForm && (
|
|
||||||
<button className="btn btn-primary btn-sm" onClick={startAdd}>
|
<button className="btn btn-primary btn-sm" onClick={startAdd}>
|
||||||
Add link
|
Add link
|
||||||
</button>
|
</button>
|
||||||
)}
|
) : undefined
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted?.length}>
|
}
|
||||||
Export CSV
|
onExport={exportCsv}
|
||||||
</button>
|
exportDisabled={!sorted?.length}
|
||||||
</div>
|
/>
|
||||||
</div>
|
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { downloadCsv } from "../utils/csv";
|
|||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import { readableError } from "../utils/errors";
|
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 }> = {
|
const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: number }> = {
|
||||||
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
|
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
|
||||||
@@ -113,7 +115,7 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{!report && !error && (
|
{!report && !error && (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -172,31 +174,35 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<TableToolbar
|
||||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
search={search}
|
||||||
<input className="form-control" style={{ maxWidth: 260 }} placeholder="Search alerts…" value={search} onChange={(e) => setSearch(e.target.value)} />
|
onSearch={setSearch}
|
||||||
<select className="form-select w-auto" value={severity} onChange={(e) => setSeverity(e.target.value as "all" | AlertSeverity)}>
|
placeholder="Search alerts…"
|
||||||
<option value="all">All severities</option>
|
filters={
|
||||||
<option value="critical">Critical</option>
|
<>
|
||||||
<option value="warning">Warning</option>
|
<select className="form-select form-select-sm w-auto" value={severity} onChange={(e) => setSeverity(e.target.value as "all" | AlertSeverity)}>
|
||||||
<option value="info">Info</option>
|
<option value="all">All severities</option>
|
||||||
</select>
|
<option value="critical">Critical</option>
|
||||||
<select className="form-select w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
|
<option value="warning">Warning</option>
|
||||||
<option value="all">All kinds</option>
|
<option value="info">Info</option>
|
||||||
{presentCategories.map((c) => (
|
</select>
|
||||||
<option key={c} value={c}>
|
<select className="form-select form-select-sm w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
|
||||||
{CATEGORY_LABELS[c]}
|
<option value="all">All kinds</option>
|
||||||
</option>
|
{presentCategories.map((c) => (
|
||||||
))}
|
<option key={c} value={c}>
|
||||||
</select>
|
{CATEGORY_LABELS[c]}
|
||||||
{(counts?.silenced ?? 0) > 0 && (
|
</option>
|
||||||
<label className="form-check mb-0">
|
))}
|
||||||
<input type="checkbox" className="form-check-input" checked={showSilenced} onChange={(e) => setShowSilenced(e.target.checked)} />
|
</select>
|
||||||
<span className="form-check-label">Show silenced</span>
|
{(counts?.silenced ?? 0) > 0 && (
|
||||||
</label>
|
<label className="form-check mb-0">
|
||||||
)}
|
<input type="checkbox" className="form-check-input" checked={showSilenced} onChange={(e) => setShowSilenced(e.target.checked)} />
|
||||||
</div>
|
<span className="form-check-label">Show silenced</span>
|
||||||
</div>
|
</label>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import SortableTh from "../components/SortableTh";
|
|||||||
import { usePagination } from "../hooks/usePagination";
|
import { usePagination } from "../hooks/usePagination";
|
||||||
import Pagination from "../components/Pagination";
|
import Pagination from "../components/Pagination";
|
||||||
import { downloadCsv } from "../utils/csv";
|
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 {
|
function targetLabel(e: AuditLogEntry): string {
|
||||||
if (!e.targetType) return "—";
|
if (!e.targetType) return "—";
|
||||||
@@ -50,7 +53,8 @@ export default function AuditLog() {
|
|||||||
.catch((err) => setError(String(err)));
|
.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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -70,8 +74,11 @@ export default function AuditLog() {
|
|||||||
Export CSV
|
Export CSV
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
<div className="card-header">
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||||
|
</div>
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { formatDateTime, parseDbTimestamp } from "../utils/date";
|
|||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import { readableError } from "../utils/errors";
|
import { readableError } from "../utils/errors";
|
||||||
import { promptDialog } from "../utils/dialogs";
|
import { promptDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice, SuccessNotice } from "../components/Notice";
|
||||||
|
|
||||||
const KINDS: { kind: ConsistencyKind; title: string; blurb: string }[] = [
|
const KINDS: { kind: ConsistencyKind; title: string; blurb: string }[] = [
|
||||||
{ kind: "ip_conflict", title: "Address conflicts", blurb: "The same address reported by more than one server." },
|
{ 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
|
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.
|
fetched from the servers or DNS providers when you open this page.
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
{notice && <div className="alert alert-success">{notice}</div>}
|
<SuccessNotice notice={notice} />
|
||||||
|
|
||||||
{report && (
|
{report && (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "../api/client";
|
} from "../api/client";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import StatusStrip from "../components/StatusStrip";
|
import StatusStrip from "../components/StatusStrip";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const DNS_TYPE_COLORS: Record<string, string> = {
|
const DNS_TYPE_COLORS: Record<string, string> = {
|
||||||
A: "#60a5fa",
|
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 ? (
|
{!dnsStats ? (
|
||||||
<div className="text-secondary">Fetching status…</div>
|
<div className="text-secondary">Fetching status…</div>
|
||||||
) : dnsStats.totalProviders === 0 ? (
|
) : 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 ? (
|
{!serverSummary ? (
|
||||||
!serverError && <div className="text-secondary">Fetching status…</div>
|
!serverError && <div className="text-secondary">Fetching status…</div>
|
||||||
) : serverSummary.total === 0 ? (
|
) : 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 ? (
|
{!domainList ? (
|
||||||
!domainError && <div className="text-secondary">Fetching status…</div>
|
!domainError && <div className="text-secondary">Fetching status…</div>
|
||||||
) : domains.length === 0 ? (
|
) : domains.length === 0 ? (
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useSortable } from "../hooks/useSortable";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const SOURCE_LABELS: Record<string, string> = {
|
const SOURCE_LABELS: Record<string, string> = {
|
||||||
cloudflare: "Cloudflare",
|
cloudflare: "Cloudflare",
|
||||||
@@ -103,7 +104,7 @@ export default function DiagLog() {
|
|||||||
{clearing ? "Clearing…" : "Clear log"}
|
{clearing ? "Clearing…" : "Clear log"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import { usePagination } from "../hooks/usePagination";
|
|||||||
import Pagination from "../components/Pagination";
|
import Pagination from "../components/Pagination";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { toast } from "../utils/toast";
|
||||||
|
|
||||||
const PROVIDER_LABELS: Record<DnsProviderType, string> = {
|
const PROVIDER_LABELS: Record<DnsProviderType, string> = {
|
||||||
cloudflare: "Cloudflare",
|
cloudflare: "Cloudflare",
|
||||||
@@ -168,8 +170,10 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
|||||||
try {
|
try {
|
||||||
if (editingRecordId) {
|
if (editingRecordId) {
|
||||||
await api.dns.records.update(selectedProviderId, selectedZone.id, editingRecordId, recordForm);
|
await api.dns.records.update(selectedProviderId, selectedZone.id, editingRecordId, recordForm);
|
||||||
|
toast.success("Record updated.");
|
||||||
} else {
|
} else {
|
||||||
await api.dns.records.create(selectedProviderId, selectedZone.id, recordForm);
|
await api.dns.records.create(selectedProviderId, selectedZone.id, recordForm);
|
||||||
|
toast.success("Record added.");
|
||||||
}
|
}
|
||||||
setRecordForm(null);
|
setRecordForm(null);
|
||||||
setEditingRecordId(null);
|
setEditingRecordId(null);
|
||||||
@@ -187,6 +191,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await api.dns.records.remove(selectedProviderId, selectedZone.id, r.id);
|
await api.dns.records.remove(selectedProviderId, selectedZone.id, r.id);
|
||||||
|
toast.success(`Deleted ${r.type} record ${r.name}.`);
|
||||||
loadRecords(selectedProviderId, selectedZone);
|
loadRecords(selectedProviderId, selectedZone);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(err));
|
setError(err instanceof Error ? err.message : String(err));
|
||||||
@@ -270,7 +275,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{managingProviders ? (
|
{managingProviders ? (
|
||||||
<>
|
<>
|
||||||
@@ -402,7 +407,7 @@ export default function Dns({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
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) {
|
function updateBadge(c: DockhandContainer) {
|
||||||
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
|
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 hosts = [...new Set((data?.containers ?? []).map((c) => c.environmentName))].sort();
|
||||||
const filteredContainers = (data?.containers ?? []).filter((c) => !hostFilter || c.environmentName === hostFilter);
|
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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -131,6 +136,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await api.integrations.dockhand[action](selectedId, c.environmentId, c.id);
|
await api.integrations.dockhand[action](selectedId, c.environmentId, c.id);
|
||||||
|
toast.success(`${action === "start" ? "Started" : action === "stop" ? "Stopped" : "Restarted"} ${c.name}.`);
|
||||||
loadContainers(selectedId);
|
loadContainers(selectedId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(err));
|
setError(err instanceof Error ? err.message : String(err));
|
||||||
@@ -142,7 +148,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Docker" adminName="Dockhand" integration={selected} />
|
<IntegrationPageTitle title="Docker" adminName="Dockhand" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -193,6 +199,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions d-flex gap-2">
|
<div className="card-actions d-flex gap-2">
|
||||||
{hosts.length > 1 && (
|
{hosts.length > 1 && (
|
||||||
<select
|
<select
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { usePagination } from "../hooks/usePagination";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import Pagination from "../components/Pagination";
|
import Pagination from "../components/Pagination";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
|
||||||
function statusBadge(d: DomainRecord) {
|
function statusBadge(d: DomainRecord) {
|
||||||
switch (d.status) {
|
switch (d.status) {
|
||||||
@@ -40,7 +43,8 @@ export default function Domains({ user }: { user: CurrentUser }) {
|
|||||||
.catch((err) => setError(readableError(err)));
|
.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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
async function add(e: React.FormEvent) {
|
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
|
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.
|
here automatically; add any others by hand.
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
{notice && <div className="alert alert-info">{notice}</div>}
|
{notice && <div className="alert alert-info">{notice}</div>}
|
||||||
|
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
@@ -158,6 +162,7 @@ export default function Domains({ user }: { user: CurrentUser }) {
|
|||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<h3 className="card-title">Registrations</h3>
|
<h3 className="card-title">Registrations</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||||
Export CSV
|
Export CSV
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
type UsernameOptions,
|
type UsernameOptions,
|
||||||
type PasswordOptions,
|
type PasswordOptions,
|
||||||
} from "../utils/generators";
|
} from "../utils/generators";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const MIXED = "mixed";
|
const MIXED = "mixed";
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ export default function Generator({ user }: { user: CurrentUser }) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{themesError && <div className="alert alert-danger py-2">{themesError}</div>}
|
<ErrorNotice error={themesError} className="py-2" />
|
||||||
<label className="form-label">Theme</label>
|
<label className="form-label">Theme</label>
|
||||||
<select className="form-select mb-1" value={theme} onChange={(e) => setTheme(e.target.value)} disabled={!themes}>
|
<select className="form-select mb-1" value={theme} onChange={(e) => setTheme(e.target.value)} disabled={!themes}>
|
||||||
<option value={MIXED}>Mixed — all lists</option>
|
<option value={MIXED}>Mixed — all lists</option>
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
|
||||||
function runStatusBadge(repo: GiteaRepo) {
|
function runStatusBadge(repo: GiteaRepo) {
|
||||||
const run = repo.latestRun;
|
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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -115,7 +119,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Gitea" integration={selected} />
|
<IntegrationPageTitle title="Gitea" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -153,6 +157,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
|||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<h3 className="card-title">Repositories</h3>
|
<h3 className="card-title">Repositories</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||||
Export CSV
|
Export CSV
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { useSortable } from "../hooks/useSortable";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { toast } from "../utils/toast";
|
||||||
|
|
||||||
const TYPE_LABELS: Record<IntegrationType, string> = {
|
const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||||
tailscale: "Tailscale",
|
tailscale: "Tailscale",
|
||||||
@@ -61,6 +63,7 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
|||||||
async function toggleEnabled(i: IntegrationSummary) {
|
async function toggleEnabled(i: IntegrationSummary) {
|
||||||
try {
|
try {
|
||||||
await api.integrations.update(i.id, { enabled: !i.enabled });
|
await api.integrations.update(i.id, { enabled: !i.enabled });
|
||||||
|
toast.success(`${i.name} ${i.enabled ? "disabled" : "enabled"}.`);
|
||||||
loadIntegrations();
|
loadIntegrations();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(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;
|
if (!(await confirmDialog({ title: "Delete integration", message: `Delete integration "${i.name}"?`, confirmLabel: "Delete", danger: true }))) return;
|
||||||
try {
|
try {
|
||||||
await api.integrations.remove(i.id);
|
await api.integrations.remove(i.id);
|
||||||
|
toast.success(`Deleted ${i.name}.`);
|
||||||
loadIntegrations();
|
loadIntegrations();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(err));
|
setError(err instanceof Error ? err.message : String(err));
|
||||||
@@ -116,7 +120,7 @@ export default function Integrations({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{editingIntegration ? (
|
{editingIntegration ? (
|
||||||
<IntegrationEditForm
|
<IntegrationEditForm
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { usePagination } from "../hooks/usePagination";
|
|||||||
import Pagination from "../components/Pagination";
|
import Pagination from "../components/Pagination";
|
||||||
import { useSelection } from "../hooks/useSelection";
|
import { useSelection } from "../hooks/useSelection";
|
||||||
import { confirmDialog, promptDialog } from "../utils/dialogs";
|
import { confirmDialog, promptDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import TableToolbar from "../components/TableToolbar";
|
||||||
|
|
||||||
const emptyForm: IpamInput = { ipAddress: "", label: "", vendor: "", location: "", notes: "" };
|
const emptyForm: IpamInput = { ipAddress: "", label: "", vendor: "", location: "", notes: "" };
|
||||||
|
|
||||||
@@ -219,7 +221,7 @@ export default function Ipam({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2 className="page-title mb-3">IP Addresses</h2>
|
<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>}
|
{syncResult && <div className="alert alert-success">Synced from {syncResult}</div>}
|
||||||
|
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
@@ -351,38 +353,36 @@ export default function Ipam({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<TableToolbar
|
||||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
search={search}
|
||||||
<input
|
onSearch={setSearch}
|
||||||
className="form-control"
|
placeholder="Search IP, label, vendor, location…"
|
||||||
style={{ maxWidth: 280 }}
|
shown={filtered.length}
|
||||||
placeholder="Search IP, label, vendor, location…"
|
total={entries?.length}
|
||||||
value={search}
|
actions={
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
<>
|
||||||
/>
|
{canEdit && !showForm && (
|
||||||
{canEdit && !showForm && (
|
<button className="btn btn-sm btn-primary" onClick={startAdd}>
|
||||||
<button className="btn btn-primary" onClick={startAdd}>
|
Add IP address
|
||||||
Add IP address
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{canEdit && (
|
|
||||||
<>
|
|
||||||
<button className="btn btn-outline-secondary" onClick={() => runSync("tailscale")} disabled={!!syncing}>
|
|
||||||
{syncing === "tailscale" ? "Syncing…" : "Sync from Tailscale"}
|
|
||||||
</button>
|
</button>
|
||||||
<button className="btn btn-outline-secondary" onClick={() => runSync("proxmox")} disabled={!!syncing}>
|
)}
|
||||||
{syncing === "proxmox" ? "Syncing…" : "Sync from Proxmox"}
|
{canEdit && (
|
||||||
</button>
|
<>
|
||||||
<button className="btn btn-outline-secondary" onClick={() => runSync("phpipam")} disabled={!!syncing}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("tailscale")} disabled={!!syncing}>
|
||||||
{syncing === "phpipam" ? "Syncing…" : "Sync from phpIPAM"}
|
{syncing === "tailscale" ? "Syncing…" : "Sync from Tailscale"}
|
||||||
</button>
|
</button>
|
||||||
</>
|
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("proxmox")} disabled={!!syncing}>
|
||||||
)}
|
{syncing === "proxmox" ? "Syncing…" : "Sync from Proxmox"}
|
||||||
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
|
</button>
|
||||||
Export CSV
|
<button className="btn btn-sm btn-outline-secondary" onClick={() => runSync("phpipam")} disabled={!!syncing}>
|
||||||
</button>
|
{syncing === "phpipam" ? "Syncing…" : "Sync from phpIPAM"}
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
onExport={exportCsv}
|
||||||
|
/>
|
||||||
{canEdit && selection.count > 0 && (
|
{canEdit && selection.count > 0 && (
|
||||||
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
||||||
<span>{selection.count} selected</span>
|
<span>{selection.count} selected</span>
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { formatRemaining } from "../utils/duration";
|
import { formatRemaining } from "../utils/duration";
|
||||||
import { readableError } from "../utils/errors";
|
import { readableError } from "../utils/errors";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { toast } from "../utils/toast";
|
||||||
|
|
||||||
const DURATIONS: { minutes: number; label: string }[] = [
|
const DURATIONS: { minutes: number; label: string }[] = [
|
||||||
{ minutes: 30, label: "30 minutes" },
|
{ minutes: 30, label: "30 minutes" },
|
||||||
@@ -102,6 +104,7 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
|||||||
});
|
});
|
||||||
setTarget("");
|
setTarget("");
|
||||||
setReason("");
|
setReason("");
|
||||||
|
toast.success("Maintenance started. Alerts for it are silenced until it ends.");
|
||||||
load();
|
load();
|
||||||
announceChange();
|
announceChange();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -143,6 +146,7 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await api.maintenance.end(w.id);
|
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();
|
load();
|
||||||
announceChange();
|
announceChange();
|
||||||
} catch (err) {
|
} 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
|
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.
|
still wrong when it ends alerts then, so nothing stays hidden.
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import SortableTh from "../components/SortableTh";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
|
||||||
function priorityBadge(t: OsTicketTicket) {
|
function priorityBadge(t: OsTicketTicket) {
|
||||||
if (!t.priorityName) return <span className="text-secondary">—</span>;
|
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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [selectedId]);
|
}, [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() {
|
function exportCsv() {
|
||||||
if (!sortedTickets) return;
|
if (!sortedTickets) return;
|
||||||
@@ -85,7 +89,7 @@ export default function OsTicket({ user: _user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2 className="page-title mb-3">osTicket</h2>
|
<h2 className="page-title mb-3">osTicket</h2>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -157,6 +161,7 @@ export default function OsTicket({ user: _user }: { user: CurrentUser }) {
|
|||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<h3 className="card-title">Open tickets</h3>
|
<h3 className="card-title">Open tickets</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-secondary"
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { useSortable } from "../hooks/useSortable";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
function formatBytes(bytes: number | null): string {
|
function formatBytes(bytes: number | null): string {
|
||||||
if (bytes === null) return "—";
|
if (bytes === null) return "—";
|
||||||
@@ -128,7 +129,7 @@ export default function PbsBackup({ user: _user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Proxmox Backup Server" integration={selected} />
|
<IntegrationPageTitle title="Proxmox Backup Server" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const emptyForm: PortForwardInput = {
|
const emptyForm: PortForwardInput = {
|
||||||
label: "",
|
label: "",
|
||||||
@@ -197,7 +198,7 @@ export default function Ports({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{agentError && <div className="alert alert-danger m-3">{agentError}</div>}
|
<ErrorNotice error={agentError} className="m-3" />
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -366,7 +367,7 @@ export default function Ports({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{forwardError && <div className="alert alert-danger m-3">{forwardError}</div>}
|
<ErrorNotice error={forwardError} className="m-3" />
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { api, type PrivacyOverview } from "../api/client";
|
|||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import { readableError } from "../utils/errors";
|
import { readableError } from "../utils/errors";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const CHANNEL_LABELS = { gotify: "Gotify", ntfy: "ntfy", smtp: "email (SMTP)", webhook: "webhook" } as const;
|
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.
|
for this installation.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{data && (
|
{data && (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
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) {
|
function proxmoxStatusBadge(status: string) {
|
||||||
return status === "running" ? (
|
return status === "running" ? (
|
||||||
@@ -181,6 +185,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await api.integrations.proxmox[action](selectedId, g.node, g.type, g.vmid);
|
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);
|
loadGuests(selectedId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(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 } =
|
const { pageItems: guestPageItems, page: guestPage, setPage: setGuestPage, pageCount: guestPageCount, totalCount: guestTotalCount } =
|
||||||
usePagination(sortedGuests);
|
usePagination(sortedGuests);
|
||||||
|
|
||||||
@@ -205,7 +211,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Proxmox" integration={selected} />
|
<IntegrationPageTitle title="Proxmox" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -241,7 +247,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{nodeStatsError && <div className="alert alert-danger">{nodeStatsError}</div>}
|
<ErrorNotice error={nodeStatsError} />
|
||||||
<div className="row row-cards mb-3">
|
<div className="row row-cards mb-3">
|
||||||
{nodeStats?.map((n) => (
|
{nodeStats?.map((n) => (
|
||||||
<div className="col-12" key={n.node}>
|
<div className="col-12" key={n.node}>
|
||||||
@@ -355,7 +361,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-body">
|
<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" && (
|
{backupTasks && backupTasks.length > 0 && !backupTasks[0].ok && backupTasks[0].status !== "running" && (
|
||||||
<div className="alert alert-danger">
|
<div className="alert alert-danger">
|
||||||
Most recent backup run on <strong>{backupTasks[0].node}</strong>
|
Most recent backup run on <strong>{backupTasks[0].node}</strong>
|
||||||
@@ -473,6 +479,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-secondary"
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import { usePagination } from "../hooks/usePagination";
|
|||||||
import Pagination from "../components/Pagination";
|
import Pagination from "../components/Pagination";
|
||||||
import { useSelection } from "../hooks/useSelection";
|
import { useSelection } from "../hooks/useSelection";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
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> = {
|
const TYPE_LABELS: Record<SecretRecord["type"], string> = {
|
||||||
api_token: "API Token",
|
api_token: "API Token",
|
||||||
@@ -119,8 +122,10 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
|||||||
};
|
};
|
||||||
if (editingId) {
|
if (editingId) {
|
||||||
await api.secrets.update(editingId, payload);
|
await api.secrets.update(editingId, payload);
|
||||||
|
toast.success(`Saved ${form.name}.`);
|
||||||
} else {
|
} else {
|
||||||
await api.secrets.create(payload);
|
await api.secrets.create(payload);
|
||||||
|
toast.success(`Added ${form.name}.`);
|
||||||
}
|
}
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
load();
|
load();
|
||||||
@@ -150,6 +155,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
|||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await api.secrets.remove(s.id);
|
await api.secrets.remove(s.id);
|
||||||
|
toast.success(`Deleted ${s.name}.`);
|
||||||
load();
|
load();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(err));
|
setError(err instanceof Error ? err.message : String(err));
|
||||||
@@ -199,7 +205,7 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2 className="page-title mb-3">Secrets</h2>
|
<h2 className="page-title mb-3">Secrets</h2>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
@@ -324,18 +330,13 @@ export default function Secrets({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header">
|
<TableToolbar
|
||||||
<div className="d-flex flex-wrap gap-2 align-items-center w-100">
|
search={search}
|
||||||
<input
|
onSearch={setSearch}
|
||||||
className="form-control"
|
placeholder="Search name or description…"
|
||||||
style={{ maxWidth: 260 }}
|
filters={
|
||||||
placeholder="Search name or description…"
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
/>
|
|
||||||
<select
|
<select
|
||||||
className="form-select"
|
className="form-select form-select-sm w-auto"
|
||||||
style={{ maxWidth: 160 }}
|
|
||||||
value={statusFilter}
|
value={statusFilter}
|
||||||
onChange={(e) => setStatusFilter(e.target.value as typeof 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="expired">Expired</option>
|
||||||
<option value="never">No expiry</option>
|
<option value="never">No expiry</option>
|
||||||
</select>
|
</select>
|
||||||
<button className="btn btn-outline-secondary ms-auto" onClick={exportCsv}>
|
}
|
||||||
Export CSV
|
shown={filtered.length}
|
||||||
</button>
|
total={secrets?.length}
|
||||||
</div>
|
onExport={exportCsv}
|
||||||
</div>
|
/>
|
||||||
{canEdit && selection.count > 0 && (
|
{canEdit && selection.count > 0 && (
|
||||||
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
<div className="card-header bg-blue-lt d-flex align-items-center gap-2">
|
||||||
<span>{selection.count} selected</span>
|
<span>{selection.count} selected</span>
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
|
||||||
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
||||||
const status = template.lastTask?.status;
|
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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -120,7 +124,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Semaphore" integration={selected} />
|
<IntegrationPageTitle title="Semaphore" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<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>
|
<span className="text-red fw-normal ms-2">{data.summary.failing} failing</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||||
Export CSV
|
Export CSV
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskT
|
|||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
const SCHEDULE_TYPE_OPTIONS: { value: ScheduleType; label: string }[] = Object.entries(SCHEDULE_TYPE_LABELS).map(
|
const SCHEDULE_TYPE_OPTIONS: { value: ScheduleType; label: string }[] = Object.entries(SCHEDULE_TYPE_LABELS).map(
|
||||||
([value, label]) => ({ value: value as ScheduleType, label }),
|
([value, label]) => ({ value: value as ScheduleType, label }),
|
||||||
@@ -391,7 +392,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
|||||||
{refreshing ? "Refreshing…" : "Refresh"}
|
{refreshing ? "Refreshing…" : "Refresh"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
<ServerTags
|
<ServerTags
|
||||||
serverId={serverId}
|
serverId={serverId}
|
||||||
@@ -412,7 +413,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
{adminLinkError && <div className="alert alert-danger">{adminLinkError}</div>}
|
<ErrorNotice error={adminLinkError} />
|
||||||
|
|
||||||
{adminLinkForm && (
|
{adminLinkForm && (
|
||||||
<form onSubmit={submitAdminLink} className="row g-2 align-items-end mb-3">
|
<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>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{guestActionError && <div className="alert alert-danger">{guestActionError}</div>}
|
<ErrorNotice error={guestActionError} />
|
||||||
<div className="row g-3">
|
<div className="row g-3">
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<div className="text-secondary small">CPU</div>
|
<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 { AGENT_RUN_HINT, agentOsOf, installCommand, uninstallCommand, type AgentOs } from "../utils/agentCommands";
|
||||||
import { tagBadge, useTagColors } from "../utils/tags";
|
import { tagBadge, useTagColors } from "../utils/tags";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
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 {
|
function typeBadgeStyle(colors: Record<string, string>, type: string): CSSProperties {
|
||||||
const color = colors[type];
|
const color = colors[type];
|
||||||
@@ -66,6 +70,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
|||||||
osType: serverOs,
|
osType: serverOs,
|
||||||
});
|
});
|
||||||
setNewToken(result);
|
setNewToken(result);
|
||||||
|
toast.success(`Added ${serverName}. Its install command is shown below.`);
|
||||||
setServerName("");
|
setServerName("");
|
||||||
setServerHostname("");
|
setServerHostname("");
|
||||||
setServerDescription("");
|
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;
|
if (!(await confirmDialog({ title: "Remove server", message: "Remove this server and all its tracked tasks?", confirmLabel: "Remove", danger: true }))) return;
|
||||||
try {
|
try {
|
||||||
await api.servers.remove(id);
|
await api.servers.remove(id);
|
||||||
|
toast.success("Server removed.");
|
||||||
await loadServers();
|
await loadServers();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(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 } =
|
const { pageItems: serverPageItems, page: serverPage, setPage: setServerPage, pageCount: serverPageCount, totalCount: serverTotalCount } =
|
||||||
usePagination(sortedServers);
|
usePagination(sortedServers);
|
||||||
|
|
||||||
@@ -136,7 +143,7 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{managingServers ? (
|
{managingServers ? (
|
||||||
<>
|
<>
|
||||||
@@ -257,8 +264,9 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-header justify-content-end">
|
<div className="card-header">
|
||||||
<button className="btn btn-outline-secondary btn-sm" onClick={exportCsv} disabled={servers.length === 0}>
|
<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
|
Export CSV
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { useSortable } from "../hooks/useSortable";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
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 {
|
function friendlyUserAgent(ua: string | null): string {
|
||||||
if (!ua) return "—";
|
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() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -102,8 +106,11 @@ export default function Sessions() {
|
|||||||
Export CSV
|
Export CSV
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
<div className="card-header">
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||||
|
</div>
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useSortable } from "../hooks/useSortable";
|
|||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
|
||||||
function healthBadge(status: string) {
|
function healthBadge(status: string) {
|
||||||
return status === "normal" ? (
|
return status === "normal" ? (
|
||||||
@@ -135,7 +136,7 @@ export default function Synology({ user: _user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Synology" integration={selected} />
|
<IntegrationPageTitle title="Synology" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import { downloadCsv } from "../utils/csv";
|
|||||||
import { useSelection } from "../hooks/useSelection";
|
import { useSelection } from "../hooks/useSelection";
|
||||||
import { confirmDialog } from "../utils/dialogs";
|
import { confirmDialog } from "../utils/dialogs";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
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;
|
const KEY_EXPIRY_WARN_DAYS = 30;
|
||||||
|
|
||||||
@@ -83,6 +87,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
if (!selectedId) return;
|
if (!selectedId) return;
|
||||||
try {
|
try {
|
||||||
await api.integrations.tailscale.setAuthorized(selectedId, device.id, authorized);
|
await api.integrations.tailscale.setAuthorized(selectedId, device.id, authorized);
|
||||||
|
toast.success(`${authorized ? "Authorized" : "Deauthorized"} ${device.label || device.hostname}.`);
|
||||||
loadDevices(selectedId);
|
loadDevices(selectedId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(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;
|
if (!(await confirmDialog({ title: "Remove device", message: `Remove device "${device.label || device.hostname}" from the tailnet?`, confirmLabel: "Remove", danger: true }))) return;
|
||||||
try {
|
try {
|
||||||
await api.integrations.tailscale.remove(selectedId, device.id);
|
await api.integrations.tailscale.remove(selectedId, device.id);
|
||||||
|
toast.success(`Removed ${device.label || device.hostname} from the tailnet.`);
|
||||||
loadDevices(selectedId);
|
loadDevices(selectedId);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : String(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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -158,7 +165,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Tailscale" url="https://login.tailscale.com/admin/machines" integration={selected} />
|
<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 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
@@ -206,6 +213,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||||
Export CSV
|
Export CSV
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import Pagination from "../components/Pagination";
|
|||||||
import { downloadCsv } from "../utils/csv";
|
import { downloadCsv } from "../utils/csv";
|
||||||
import { readableError } from "../utils/errors";
|
import { readableError } from "../utils/errors";
|
||||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
|
||||||
function statusBadge(monitor: UptimeKumaMonitor) {
|
function statusBadge(monitor: UptimeKumaMonitor) {
|
||||||
switch (monitor.status) {
|
switch (monitor.status) {
|
||||||
@@ -74,7 +77,8 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [selectedId]);
|
}, [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);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
@@ -99,7 +103,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntegrationPageTitle title="Uptime Kuma" integration={selected} />
|
<IntegrationPageTitle title="Uptime Kuma" integration={selected} />
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
|
|
||||||
{integrations?.length === 0 ? (
|
{integrations?.length === 0 ? (
|
||||||
<div className="card">
|
<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>
|
<span className="text-yellow fw-normal ms-2">{data.summary.pending} pending</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} className="ms-3" />
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
<button className="btn btn-sm btn-outline-secondary" onClick={exportCsv} disabled={!sorted || sorted.length === 0}>
|
||||||
Export CSV
|
Export CSV
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { formatDateTime } from "../utils/date";
|
|||||||
import { useSortable } from "../hooks/useSortable";
|
import { useSortable } from "../hooks/useSortable";
|
||||||
import SortableTh from "../components/SortableTh";
|
import SortableTh from "../components/SortableTh";
|
||||||
import { downloadCsv } from "../utils/csv";
|
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"];
|
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() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -53,8 +57,11 @@ export default function Users() {
|
|||||||
Export CSV
|
Export CSV
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
<div className="card">
|
<div className="card">
|
||||||
|
<div className="card-header">
|
||||||
|
<SearchBox value={tableSearch.query} onChange={tableSearch.setQuery} />
|
||||||
|
</div>
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-vcenter card-table">
|
<table className="table table-vcenter card-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { api, type AlertTicketOverview, type AlertTicketRunSummary, type AlertTi
|
|||||||
import { formatDateTime } from "../../utils/date";
|
import { formatDateTime } from "../../utils/date";
|
||||||
import { formatAgo } from "../../utils/duration";
|
import { formatAgo } from "../../utils/duration";
|
||||||
import { readableError } from "../../utils/errors";
|
import { readableError } from "../../utils/errors";
|
||||||
|
import { ErrorNotice, SuccessNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const SEVERITIES: { value: AlertTicketSeverity; label: string; hint: string }[] = [
|
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" },
|
{ 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
{notice && <div className="alert alert-success">{notice}</div>}
|
<SuccessNotice notice={notice} />
|
||||||
|
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { api, type EncryptedExportFile, type ImportResult } from "../../api/client";
|
import { api, type EncryptedExportFile, type ImportResult } from "../../api/client";
|
||||||
import { confirmDialog } from "../../utils/dialogs";
|
import { confirmDialog } from "../../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
function downloadJson(filename: string, data: unknown) {
|
function downloadJson(filename: string, data: unknown) {
|
||||||
const blob = new Blob([JSON.stringify(data)], { type: "application/json" });
|
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.
|
somewhere you trust and don't lose the passphrase — it can't be recovered.
|
||||||
</p>
|
</p>
|
||||||
<p className="text-secondary">Not included: DNS records, secrets, IPAM, servers, or the audit/diagnostic logs — this is configuration only.</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">
|
<div className="mb-2">
|
||||||
<label className="form-label">Passphrase</label>
|
<label className="form-label">Passphrase</label>
|
||||||
<input
|
<input
|
||||||
@@ -149,8 +150,8 @@ export default function BackupSettings() {
|
|||||||
onto the current ones. Integrations and DNS providers are only <strong>added</strong> — anything
|
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.
|
that already exists with the same name is left alone, so this is safe to run more than once.
|
||||||
</p>
|
</p>
|
||||||
{importError && <div className="alert alert-danger">{importError}</div>}
|
<ErrorNotice error={importError} />
|
||||||
{importFileError && <div className="alert alert-danger">{importFileError}</div>}
|
<ErrorNotice error={importFileError} />
|
||||||
{importResult && (
|
{importResult && (
|
||||||
<div className="alert alert-success">
|
<div className="alert alert-success">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { api } from "../../api/client";
|
import { api } from "../../api/client";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const PROVIDER_NAMES: Record<string, string> = {
|
const PROVIDER_NAMES: Record<string, string> = {
|
||||||
cloudflare: "Cloudflare",
|
cloudflare: "Cloudflare",
|
||||||
@@ -106,7 +107,7 @@ export default function BadgeSettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
<ErrorNotice error={loadError} />
|
||||||
|
|
||||||
<div className="row row-cards">
|
<div className="row row-cards">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { api } from "../../api/client";
|
import { api } from "../../api/client";
|
||||||
import { confirmDialog } from "../../utils/dialogs";
|
import { confirmDialog } from "../../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
export default function CacheSettings() {
|
export default function CacheSettings() {
|
||||||
const [clearing, setClearing] = useState(false);
|
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
|
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.
|
you see stale or incorrect data — every zone will need to be re-synced from its provider afterwards.
|
||||||
</p>
|
</p>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
</div>
|
</div>
|
||||||
<div className="card-footer">
|
<div className="card-footer">
|
||||||
<button className="btn btn-danger" onClick={handleClear} disabled={clearing}>
|
<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 { api, type AppSettings, type DateFormat, type TimeFormat } from "../../api/client";
|
||||||
import { setDateTimeSettings } from "../../utils/date";
|
import { setDateTimeSettings } from "../../utils/date";
|
||||||
import { setPageSize } from "../../utils/pageSize";
|
import { setPageSize } from "../../utils/pageSize";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const DATE_FORMAT_OPTIONS: { value: DateFormat; label: string; example: string }[] = [
|
const DATE_FORMAT_OPTIONS: { value: DateFormat; label: string; example: string }[] = [
|
||||||
{ value: "ymd", label: "Year-Month-Day", example: "2026-09-15" },
|
{ value: "ymd", label: "Year-Month-Day", example: "2026-09-15" },
|
||||||
@@ -69,7 +70,7 @@ export default function DisplaySettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
<ErrorNotice error={loadError} />
|
||||||
|
|
||||||
<div className="row row-cards">
|
<div className="row row-cards">
|
||||||
<div className="col-md-7">
|
<div className="col-md-7">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { api, type AppSettings } from "../../api/client";
|
import { api, type AppSettings } from "../../api/client";
|
||||||
import { confirmDialog } from "../../utils/dialogs";
|
import { confirmDialog } from "../../utils/dialogs";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const INTERVAL_OPTIONS: { value: number; label: string }[] = [
|
const INTERVAL_OPTIONS: { value: number; label: string }[] = [
|
||||||
{ value: 1, label: "Every hour" },
|
{ value: 1, label: "Every hour" },
|
||||||
@@ -81,7 +82,7 @@ export default function LogSettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
<ErrorNotice error={loadError} />
|
||||||
|
|
||||||
<div className="row row-cards">
|
<div className="row row-cards">
|
||||||
<div className="col-md-7">
|
<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
|
Runs a purge immediately using the retention period above, regardless of whether automatic
|
||||||
purging is enabled.
|
purging is enabled.
|
||||||
</p>
|
</p>
|
||||||
{purgeError && <div className="alert alert-danger mb-0">{purgeError}</div>}
|
<ErrorNotice error={purgeError} className="mb-0" />
|
||||||
{purgeResult && (
|
{purgeResult && (
|
||||||
<div className="alert alert-success mb-0">
|
<div className="alert alert-success mb-0">
|
||||||
Deleted {purgeResult.diagDeleted} diagnostic log and {purgeResult.auditDeleted} audit log
|
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 { formatDateTime } from "../../utils/date";
|
||||||
import { readableError } from "../../utils/errors";
|
import { readableError } from "../../utils/errors";
|
||||||
import { parseNames } from "../../utils/nameLists";
|
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. */
|
/** One list as it's being edited. The names are kept as the text in the box, so typing stays natural. */
|
||||||
interface Draft {
|
interface Draft {
|
||||||
@@ -221,8 +222,8 @@ export default function NameSettings() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
{notice && <div className="alert alert-success">{notice}</div>}
|
<SuccessNotice notice={notice} />
|
||||||
|
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
@@ -334,7 +335,7 @@ export default function NameSettings() {
|
|||||||
{fetching ? "Fetching…" : "Fetch names"}
|
{fetching ? "Fetching…" : "Fetch names"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{importError && <div className="alert alert-danger mt-3 mb-0">{importError}</div>}
|
<ErrorNotice error={importError} className="mt-3 mb-0" />
|
||||||
{preview && (
|
{preview && (
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type QuietHoursSettings,
|
type QuietHoursSettings,
|
||||||
type HealthCheckSettings,
|
type HealthCheckSettings,
|
||||||
} from "../../api/client";
|
} from "../../api/client";
|
||||||
|
import { ErrorNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const TIMEZONES = [
|
const TIMEZONES = [
|
||||||
"UTC",
|
"UTC",
|
||||||
@@ -212,7 +213,7 @@ export default function NotificationSettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loadError && <div className="alert alert-danger">{loadError}</div>}
|
<ErrorNotice error={loadError} />
|
||||||
|
|
||||||
<div className="row row-cards">
|
<div className="row row-cards">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { api, type TagEntry } from "../../api/client";
|
|||||||
import { readableError } from "../../utils/errors";
|
import { readableError } from "../../utils/errors";
|
||||||
import { normalizeTagInput, refreshTagColors, tagBadge } from "../../utils/tags";
|
import { normalizeTagInput, refreshTagColors, tagBadge } from "../../utils/tags";
|
||||||
import { confirmDialog, promptDialog } from "../../utils/dialogs";
|
import { confirmDialog, promptDialog } from "../../utils/dialogs";
|
||||||
|
import { ErrorNotice, SuccessNotice } from "../../components/Notice";
|
||||||
|
|
||||||
const DEFAULT_PICK = "#3b82f6";
|
const DEFAULT_PICK = "#3b82f6";
|
||||||
|
|
||||||
@@ -99,8 +100,8 @@ export default function TagSettings() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{error && <div className="alert alert-danger">{error}</div>}
|
<ErrorNotice error={error} />
|
||||||
{notice && <div className="alert alert-success">{notice}</div>}
|
<SuccessNotice notice={notice} />
|
||||||
|
|
||||||
<div className="card mb-3">
|
<div className="card mb-3">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
|
|||||||
@@ -150,3 +150,135 @@ html[data-env] .navbar-vertical {
|
|||||||
padding-top: 0.3rem;
|
padding-top: 0.3rem;
|
||||||
padding-bottom: 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");
|
root.setAttribute("data-env", look.name || "custom");
|
||||||
document.title = look.name ? `[${look.name}] ${BASE_TITLE}` : BASE_TITLE;
|
document.title = look.name ? `[${look.name}] ${BASE_TITLE}` : BASE_TITLE;
|
||||||
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", look.color);
|
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. */
|
/** 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),
|
||||||
|
};
|
||||||