About 1,600 more headings, buttons, table columns, status words, placeholders and short messages are translated. Tables of words built when the app loads are now read when they are drawn, so they follow the language, and a test fails if text is translated at load time. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
2.9 KiB
TypeScript
71 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";
|
|
import { t } from "../i18n";
|
|
|
|
/** 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">{t("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">{t("Type and place")}</div>
|
|
{s.type ?? "—"} · {s.location ?? "?"}
|
|
</div>
|
|
<div className="col-6 col-lg-3">
|
|
<div className="text-secondary small">{t("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">{t("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>
|
|
);
|
|
}
|