Add saved filter views, a customisable dashboard, server comparison, row keyboard navigation and share links
- Table search, status, tag and sort live in the address; Save view pins one as a favourite. - Dashboard cards can be moved and hidden per user (users.dashboard_layout, migration 0022). - Compare two to four servers' load, memory or disk on one chart. - j/k move through table rows that open a detail panel. - Share links open a read-only wall without signing in, numbers only or with names (share_links, migration 0023); the wall is split into a shared view over two data sources. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
906220040e
commit
44e393f172
50 files changed
+6114
-258
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { IconArrowLeft, IconArrowRight, IconEye, IconEyeOff } from "@tabler/icons-react";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import WhatChanged from "../components/WhatChanged";
|
||||
import { UNPLACED, moveCard, resetDashboardLayout, setCardHidden, setEditingDashboard, useDashboardLayout } from "../utils/dashboardLayout";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
api,
|
||||
@@ -187,10 +189,30 @@ function MiniStat({ label, value, accent }: { label: string; value: ReactNode; a
|
||||
|
||||
/** The single card shape shared by every dashboard widget — DNS, Secrets, and each integration — so they all read as one family: a label + status badge, then whatever stats/breakdown that widget has. */
|
||||
function WidgetCard({ label, badge, hide, children }: { label: string; badge?: ReactNode; /** Nothing is set up for this yet: it is listed under "Not set up yet" instead of taking a card. */ hide?: boolean; children: ReactNode }) {
|
||||
const { layout, editing } = useDashboardLayout();
|
||||
if (hide) return null;
|
||||
// The person's own arrangement: cards they hid are gone (shown dimmed while arranging, so they can be brought back), and the
|
||||
// rest follow the order they chose — a card nobody has placed goes last, in the order it was drawn.
|
||||
const hidden = layout.hidden.includes(label);
|
||||
if (hidden && !editing) return null;
|
||||
return (
|
||||
<div className="col-md-6">
|
||||
<div className="card h-100">
|
||||
<div className="col-md-6" data-card={label} style={{ order: layout.order[label] ?? UNPLACED }}>
|
||||
<div className={`card h-100 ${hidden ? "card-hidden" : ""}`}>
|
||||
{editing && (
|
||||
<div className="card-customise">
|
||||
<button type="button" className="btn btn-sm btn-icon" aria-label={`Move ${label} earlier`} title="Move earlier" onClick={(e) => void moveCard(e.currentTarget.closest<HTMLElement>("[data-card]")!, -1)}>
|
||||
<IconArrowLeft size={16} aria-hidden="true" />
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm btn-icon" aria-label={`Move ${label} later`} title="Move later" onClick={(e) => void moveCard(e.currentTarget.closest<HTMLElement>("[data-card]")!, 1)}>
|
||||
<IconArrowRight size={16} aria-hidden="true" />
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm ms-auto d-inline-flex align-items-center gap-1" aria-pressed={hidden} onClick={() => void setCardHidden(label, !hidden)}>
|
||||
{hidden ? <IconEye size={16} aria-hidden="true" /> : <IconEyeOff size={16} aria-hidden="true" />}
|
||||
{hidden ? "Show" : "Hide"}
|
||||
<span className="visually-hidden"> {label}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="card-body">
|
||||
<div className="d-flex align-items-center mb-2">
|
||||
<div className="subheader">{label}</div>
|
||||
@@ -291,6 +313,7 @@ function formatBytes(bytes: number | null): string {
|
||||
}
|
||||
|
||||
export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
const { editing } = useDashboardLayout();
|
||||
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||
const [tailscaleSummary, setTailscaleSummary] = useState<TailscaleDevicesResponse["summary"] | null>(null);
|
||||
const [tailscaleExtra, setTailscaleExtra] = useState<TailscaleExtra | null>(null);
|
||||
@@ -588,10 +611,23 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
<div className="col-12">
|
||||
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
||||
<h2 className="page-title mb-0">Dashboard</h2>
|
||||
<Link to="/wall" className="btn btn-sm btn-outline-secondary ms-auto" title="A full-screen status board for a spare monitor or tablet">
|
||||
Wall display
|
||||
</Link>
|
||||
<div className="ms-auto d-flex gap-2">
|
||||
<button type="button" className={`btn btn-sm ${editing ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={editing} onClick={() => setEditingDashboard(!editing)}>
|
||||
{editing ? "Done" : "Customise"}
|
||||
</button>
|
||||
<Link to="/wall" className="btn btn-sm btn-outline-secondary" title="A full-screen status board for a spare monitor or tablet">
|
||||
Wall display
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
{editing && (
|
||||
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2" role="status">
|
||||
<span>Move the cards with the arrows and hide the ones you don't use. It saves as you go, for you only, and follows you to other browsers.</span>
|
||||
<button type="button" className="btn btn-sm ms-auto" onClick={() => void resetDashboardLayout()}>
|
||||
Reset to default
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<p className="text-secondary">
|
||||
Welcome back, {user.name ?? user.email ?? user.sub}.
|
||||
</p>
|
||||
@@ -760,7 +796,12 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
{serverSummary.offline.length > 3 && <span className="text-secondary"> +{serverSummary.offline.length - 3} more</span>}
|
||||
{serverSummary.offline.length > 3 && (
|
||||
<>
|
||||
{" "}
|
||||
<Link to="/servers?status=offline">+{serverSummary.offline.length - 3} more</Link>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{serverSummary.fullDisks.length > 0 && (
|
||||
|
||||
Reference in new issue
Block a user