Racks, notes and to-do, OS support, suggested dependencies, Nginx Proxy Manager and Home Assistant
- Racks page and a network diagram (UniFi tree with servers, printable) - Notes on servers and devices; To do list shown in Coming up and My work - Agents report the operating system (Linux 7, Windows 6); end-of-life badge and alert - Suggested dependencies from where a service is reached - Nginx Proxy Manager integration: proxy hosts page, certificate and host alerts, suggested checks - Home Assistant integration: watch chosen entities, history chart, limit and unavailable alerts - TimeChart gets a "value" scale that fits negatives; docs updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
68b41b5586
commit
18ceed62e8
77 files changed
+20432
-35
No files matched your search
@@ -57,7 +57,8 @@ export default function TimeChart({
|
||||
to: number;
|
||||
/** Read out by screen readers in place of the picture. */
|
||||
label: string;
|
||||
unit?: "%" | "ms";
|
||||
/** "%" is a 0–100 scale; "ms" starts at zero and fits the data; "value" fits the data from its lowest to its highest, so negatives (a freezer's temperature) are drawn too. */
|
||||
unit?: "%" | "ms" | "value";
|
||||
compact?: boolean;
|
||||
/** One bar per point instead of a line (daily availability). */
|
||||
bars?: boolean;
|
||||
@@ -70,19 +71,30 @@ export default function TimeChart({
|
||||
// Where the cursor is, as a time (null: nowhere), and whether the keyboard put it there.
|
||||
const [cursor, setCursor] = useState<number | null>(null);
|
||||
|
||||
const fmt = format ?? ((v: number) => (unit === "%" ? `${Math.round(v * 10) / 10}%` : `${Math.round(v)} ms`));
|
||||
const fmt = format ?? ((v: number) => (unit === "%" ? `${Math.round(v * 10) / 10}%` : unit === "value" ? `${Math.round(v * 10) / 10}` : `${Math.round(v)} ms`));
|
||||
const parsed = useMemo(() => series.map((s) => ({ ...s, pts: s.points.map((p) => ({ ...p, x: Date.parse(p.t) })).filter((p) => Number.isFinite(p.x)) })), [series]);
|
||||
const any = parsed.some((s) => s.pts.length > 0);
|
||||
|
||||
const top = unit === "%" ? 100 : niceCeil(Math.max(0, ...parsed.flatMap((s) => s.pts.map((p) => p.hi ?? p.v))) * 1.05);
|
||||
const [bottom, top] = (() => {
|
||||
if (unit === "%") return [0, 100];
|
||||
const values = parsed.flatMap((s) => s.pts.flatMap((p) => [p.lo ?? p.v, p.hi ?? p.v]));
|
||||
if (unit !== "value") return [0, niceCeil(Math.max(0, ...values) * 1.05)];
|
||||
if (values.length === 0) return [0, 1];
|
||||
const lo = Math.min(...values);
|
||||
const hi = Math.max(...values);
|
||||
const span = hi - lo || Math.abs(hi) * 0.2 || 1;
|
||||
const step = niceCeil((span * 1.1) / 4);
|
||||
const low = Math.floor((lo - span * 0.05) / step) * step;
|
||||
return [low, Math.max(Math.ceil((hi + span * 0.05) / step) * step, low + step)];
|
||||
})();
|
||||
const x = (t: number) => PAD.left + ((t - from) / Math.max(to - from, 1)) * (W - PAD.left - PAD.right);
|
||||
const y = (v: number) => PAD.top + (1 - Math.min(top, Math.max(0, v)) / top) * (H - PAD.top - PAD.bottom);
|
||||
const y = (v: number) => PAD.top + (1 - (Math.min(top, Math.max(bottom, v)) - bottom) / (top - bottom)) * (H - PAD.top - PAD.bottom);
|
||||
|
||||
const spanDays = (to - from) / 86_400_000;
|
||||
const tickLabel = (t: number) =>
|
||||
spanDays <= 1.5 ? formatTime(new Date(t), false) : spanDays <= 45 ? new Date(t).toLocaleDateString(undefined, { day: "numeric", month: "short" }) : new Date(t).toLocaleDateString(undefined, { month: "short", year: "2-digit" });
|
||||
const ticks = (compact ? [0, 0.5, 1] : [0, 0.25, 0.5, 0.75, 1]).map((f) => from + f * (to - from));
|
||||
const grid = compact ? [0, top / 2, top] : [0, top / 4, top / 2, (3 * top) / 4, top];
|
||||
const grid = (compact ? [0, 0.5, 1] : [0, 0.25, 0.5, 0.75, 1]).map((f) => bottom + f * (top - bottom));
|
||||
|
||||
// Every moment any series has a point, for the arrow keys to step through.
|
||||
const moments = useMemo(() => [...new Set(parsed.flatMap((s) => s.pts.map((p) => p.x)))].sort((a, b) => a - b), [parsed]);
|
||||
@@ -149,7 +161,7 @@ export default function TimeChart({
|
||||
<g key={v}>
|
||||
<line x1={PAD.left} x2={W - PAD.right} y1={y(v)} y2={y(v)} stroke="currentColor" strokeOpacity={v === 0 ? 0.4 : 0.15} />
|
||||
<text x={PAD.left - 6} y={y(v) + 4} textAnchor="end" fontSize="11" fill="currentColor" fillOpacity="0.7">
|
||||
{unit === "%" ? `${v}%` : `${Math.round(v)}`}
|
||||
{unit === "%" ? `${v}%` : unit === "value" ? `${Math.round(v * 10) / 10}` : `${Math.round(v)}`}
|
||||
</text>
|
||||
</g>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user