Files
Homelab-manager/web/src/components/HetznerServerCard.tsx
T
bobbanandClaude Sonnet 5.5 d9083adb5b Sonarr/Radarr/Prowlarr, Hetzner load balancers/floating IPs/certificates, traffic forecast
New integration kinds sonarr, radarr and prowlarr (shared adapter and sync, page under
Apps -> Media managers): own health findings, stuck downloads, nearly full disks.
Hetzner now reads load balancers (target health), floating IPs and certificates, includes
them in the cost estimate, and forecasts the month's traffic against the quota.
Migrations 0072 and 0073; docs, metrics and tests included.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 20:04:55 +01:00

70 lines
2.9 KiB
TypeScript

import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type HetznerForServer } from "../api/client";
import TimeAgo from "./TimeAgo";
import { ForecastText, StatusBadge, TrafficBar } from "../pages/Hetzner";
/** On a server's page: the Hetzner Cloud server it is (matched by address, else by name), when there is one. Nothing is shown for a server that is not at Hetzner. */
export default function HetznerServerCard({ serverId }: { serverId: number }) {
const [match, setMatch] = useState<HetznerForServer["match"]>(null);
useEffect(() => {
let live = true;
api.hetzner
.forServer(serverId)
.then((r) => live && setMatch(r.match))
.catch(() => live && setMatch(null));
return () => {
live = false;
};
}, [serverId]);
if (!match) return null;
const s = match.server;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Hetzner Cloud</h3>
<div className="card-actions">
<Link to="/hetzner" className="btn btn-sm btn-outline-secondary">
{match.integrationName}
</Link>
</div>
</div>
<div className="card-body">
{match.problems.length > 0 && (
<ul className="mb-3">
{match.problems.map((p) => (
<li key={p.key} className={p.severity === "critical" ? "text-red" : ""}>
{p.message}
</li>
))}
</ul>
)}
<div className="row g-3">
<div className="col-6 col-lg-3">
<div className="text-secondary small">Status</div>
<StatusBadge status={s.status} />
{s.rescueEnabled && <span className="badge bg-yellow-lt text-yellow ms-1">rescue on</span>}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Type and place</div>
{s.type ?? "—"} · {s.location ?? "?"}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Backups</div>
{s.backupWindow ? (match.newestBackup ? <>newest <TimeAgo value={match.newestBackup} /></> : "on, none made yet") : "off"}
{match.snapshots > 0 && <span className="text-secondary small"> · {match.snapshots} snapshot{match.snapshots === 1 ? "" : "s"}</span>}
</div>
<div className="col-6 col-lg-3">
<div className="text-secondary small">Traffic this month</div>
<TrafficBar used={s.outgoingTraffic} included={s.includedTraffic} />
<ForecastText forecast={match.forecast} included={s.includedTraffic} />
</div>
</div>
<div className="text-secondary small mt-2">
{match.fresh ? <>read <TimeAgo value={match.updatedAt} /></> : "Hetzner could not be read lately — this is how it was"}
</div>
</div>
</div>
);
}