import Link from "next/link";
import { notFound } from "next/navigation";
import { ContentHeader } from "@/components/layout/ContentHeader";
import {
AblaufBadge,
Badge,
EinkaufBadge,
KeineMeldungBadge,
StatusBadge,
VerkaufBadge,
} from "@/components/ui/Badges";
import { Card } from "@/components/ui/Card";
import { CopyableCode } from "@/components/ui/CopyableCode";
import { Tabs } from "@/components/ui/Tabs";
import { formatDatum, formatDatumZeit, formatEuro, formatUptime, formatZahl } from "@/lib/format";
import { HEUTE } from "@/mock/data";
import {
PRODUKT_NAME,
alertsVonHost,
getHost,
getKunde,
hostMeldetNicht,
laufzeitenVonHost,
reportsVonHost,
} from "@/mock/queries";
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return { title: getHost(id)?.hostname ?? "Host" };
}
function Zeile({ bezeichnung, children }: { bezeichnung: string; children: React.ReactNode }) {
return (
{bezeichnung}
{children}
);
}
export default async function HostDetailSeite({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const host = getHost(id);
if (!host) notFound();
const kunde = getKunde(host.kundeId);
const standort = kunde?.standorte.find((s) => s.id === host.standortId);
const laufzeiten = laufzeitenVonHost(host.id);
const reports = reportsVonHost(host.id);
const alerts = alertsVonHost(host.id);
const keys = [...new Set(laufzeiten.map((l) => l.key))];
return (
<>
}
/>
{alerts.length > 0 ? (
{alerts.map((alert) => (
-
{alert.titel}
{" "}
{alert.beschreibung}
))}
) : null}
{host.hostname}
{host.fqdn ?? "Kein FQDN gemeldet"}
{hostMeldetNicht(host) ?
: null}
{kunde ? (
{kunde.name}
) : (
Nicht zugeordnet
)}
{standort?.name ?? "–"}
{PRODUKT_NAME[host.produkt]}
{host.produktVersion ?? "–"}
{host.kernel ?? "–"}
{host.clusterName ? `${host.clusterName} / ${host.nodeName}` : "–"}
{host.ips.join(", ")}
{host.cpuModell ?? "–"}
{host.subscription.lizenzierteSockets ?? "–"} / {host.sockets ?? "–"}
{formatUptime(host.uptimeSekunden)}
{formatZahl(host.paketUpdates)}
{host.agentVersion}
{formatDatumZeit(host.letzterReport)}
Kunde ändern (ab #006)
{host.subscription.produktname ?? "–"}
{host.subscription.level ?? "–"}
{formatDatum(host.subscription.regdate)}
{formatDatumZeit(host.subscription.checktime)}
{host.tags.map((tag) => (
{tag}
))}
>
),
},
{
id: "keys",
titel: "Subscription-Historie",
icon: "bi-key",
inhalt: (
| Key |
Erste Laufzeit |
Letzte Laufzeit |
{keys.map((key) => {
const zugehoerig = laufzeiten.filter((l) => l.key === key);
return (
|
|
{formatDatum(zugehoerig[zugehoerig.length - 1]?.start)} |
{formatDatum(zugehoerig[0]?.ende)} |
);
})}
),
},
{
id: "reports",
titel: "Reports",
icon: "bi-clock-history",
inhalt: (
| Zeitpunkt |
Status |
Key |
Ablauf |
Updates |
Agent |
{reports.map((report) => (
| {formatDatumZeit(report.zeitpunkt)} |
|
{report.key ?? "–"}
|
{formatDatum(report.nextduedate)} |
{formatZahl(report.paketUpdates)} |
{report.agentVersion} |
))}
),
},
{
id: "rechnungen",
titel: "Rechnungen",
icon: "bi-receipt",
inhalt: (
| Laufzeit |
Proxmox-Rechnung |
Einkauf |
Kundenrechnung |
Verkauf |
Marge |
{laufzeiten.map((laufzeit) => (
|
{formatDatum(laufzeit.start)} – {formatDatum(laufzeit.ende)}
{laufzeit.vorschlag ? (
Vorschlag
) : null}
|
|
{formatEuro(laufzeit.einkauf?.nettoBetrag)} |
|
{formatEuro(laufzeit.verkauf?.nettoBetrag)} |
{laufzeit.einkauf && laufzeit.verkauf?.nettoBetrag
? formatEuro(
(laufzeit.verkauf.nettoBetrag ?? 0) -
(laufzeit.einkauf.nettoBetrag ?? 0),
)
: "–"}
|
))}
),
},
{
id: "notizen",
titel: "Notizen",
icon: "bi-journal-text",
inhalt: (
{host.notizen ?? (
Keine Notizen hinterlegt.
)}
),
},
]}
/>
>
);
}