Homelab Manager
-
+
+
diff --git a/web/public/apple-touch-icon.png b/web/public/apple-touch-icon.png
index 141e9db..b339d7a 100644
Binary files a/web/public/apple-touch-icon.png and b/web/public/apple-touch-icon.png differ
diff --git a/web/public/favicon-32.png b/web/public/favicon-32.png
new file mode 100644
index 0000000..3afd22c
Binary files /dev/null and b/web/public/favicon-32.png differ
diff --git a/web/public/icon-192.png b/web/public/icon-192.png
index fd04e10..ad79c0b 100644
Binary files a/web/public/icon-192.png and b/web/public/icon-192.png differ
diff --git a/web/public/icon-512.png b/web/public/icon-512.png
index 78cf380..d4b3b75 100644
Binary files a/web/public/icon-512.png and b/web/public/icon-512.png differ
diff --git a/web/public/icon-maskable-512.png b/web/public/icon-maskable-512.png
index 34dc6e9..9b96edd 100644
Binary files a/web/public/icon-maskable-512.png and b/web/public/icon-maskable-512.png differ
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 527418a..d8bd871 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -44,6 +44,7 @@ import AppShell from "./layout/AppShell";
import DialogHost from "./components/DialogHost";
import { setDateTimeSettings } from "./utils/date";
import { setPageSize } from "./utils/pageSize";
+import ToastHost from "./components/ToastHost";
const roleRank: Record = { viewer: 0, operator: 1, admin: 2 };
@@ -171,6 +172,7 @@ export default function App() {
+
);
}
diff --git a/web/src/components/Notice.tsx b/web/src/components/Notice.tsx
new file mode 100644
index 0000000..2a6b820
--- /dev/null
+++ b/web/src/components/Notice.tsx
@@ -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(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 (
+
+ {message}
+
+ );
+}
+
+/** 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 ;
+}
+
+/** 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 ;
+}
diff --git a/web/src/components/ServerPorts.tsx b/web/src/components/ServerPorts.tsx
index c669ca7..a984357 100644
--- a/web/src/components/ServerPorts.tsx
+++ b/web/src/components/ServerPorts.tsx
@@ -8,6 +8,7 @@ import { readableError } from "../utils/errors";
import Pagination from "./Pagination";
import SortableTh from "./SortableTh";
import { confirmDialog } from "../utils/dialogs";
+import { ErrorNotice } from "./Notice";
const PRESETS: { key: string; label: string; from: number; to: number }[] = [
{ key: "well-known", label: "1–1024 (well-known)", from: 1, to: 1024 },
@@ -235,7 +236,7 @@ export default function ServerPorts({
- {error &&
{error}
}
+
{data && (
diff --git a/web/src/components/ServerTags.tsx b/web/src/components/ServerTags.tsx
index 8a72ce5..bae6740 100644
--- a/web/src/components/ServerTags.tsx
+++ b/web/src/components/ServerTags.tsx
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
import { api } from "../api/client";
import { normalizeTagInput, tagBadge, useTagColors } from "../utils/tags";
import { readableError } from "../utils/errors";
+import { ErrorNotice } from "./Notice";
export function TagBadges({ tags, linked = false }: { tags: string[]; linked?: boolean }) {
const colors = useTagColors();
@@ -99,7 +100,7 @@ export default function ServerTags({
return (
- {error &&
{error}
}
+
{draftTags.map((tag) => {
diff --git a/web/src/components/TableToolbar.tsx b/web/src/components/TableToolbar.tsx
new file mode 100644
index 0000000..82a517f
--- /dev/null
+++ b/web/src/components/TableToolbar.tsx
@@ -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 (
+
+ );
+}
+
+/**
+ * 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 (
+
+
+
+ {filters}
+ {narrowed && {shown} of {total}}
+
+ {actions}
+ {onExport && (
+
+ )}
+
+
+
+ );
+}
diff --git a/web/src/components/ToastHost.tsx b/web/src/components/ToastHost.tsx
new file mode 100644
index 0000000..9948b1f
--- /dev/null
+++ b/web/src/components/ToastHost.tsx
@@ -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 (
+