feat(ui): klickbarer Prototyp mit Beispieldaten (#002)
Layout im AdminLTE-Stil (Sidebar, Kopfleiste, Inhaltskopf, Footer), Logo als SVG-Komponente, Farbschema mit Dark-Mode, Dashboard, Kunden- und Host-Ansichten, Rechnungsuebersicht, Jahresbahn und globale Suche (Strg+K). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
|
||||
export const metadata = { title: "Benachrichtigungen" };
|
||||
|
||||
export default function BenachrichtigungenSeite() {
|
||||
return (
|
||||
<>
|
||||
<ContentHeader
|
||||
titel="Benachrichtigungen"
|
||||
brotkrumen={[{ titel: "Einstellungen" }, { titel: "Benachrichtigungen" }]}
|
||||
/>
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card titel="E-Mail und Webhook" rahmen="primary">
|
||||
<p className="text-body-secondary mb-0">
|
||||
SMTP (Microsoft 365), Webhooks und die tägliche Zusammenfassung werden in #012 umgesetzt.
|
||||
</p>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { APP_VERSION } from "@/lib/version";
|
||||
|
||||
export const metadata = { title: "System" };
|
||||
|
||||
export default function SystemSeite() {
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="System" brotkrumen={[{ titel: "Einstellungen" }, { titel: "System" }]} />
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card titel="Systeminformationen" rahmen="primary">
|
||||
<dl className="row mb-0">
|
||||
<dt className="col-4 fw-normal text-body-secondary">Version</dt>
|
||||
<dd className="col-8">{APP_VERSION}</dd>
|
||||
<dt className="col-4 fw-normal text-body-secondary">Datenquelle</dt>
|
||||
<dd className="col-8">Beispieldaten (Prototyp, #002)</dd>
|
||||
<dt className="col-4 fw-normal text-body-secondary">Warnregeln</dt>
|
||||
<dd className="col-8">Konfigurierbar ab #011</dd>
|
||||
</dl>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
|
||||
export const metadata = { title: "Agent-Tokens" };
|
||||
|
||||
export default function TokensSeite() {
|
||||
return (
|
||||
<>
|
||||
<ContentHeader
|
||||
titel="Agent-Tokens"
|
||||
brotkrumen={[{ titel: "Einstellungen" }, { titel: "Agent-Tokens" }]}
|
||||
/>
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card titel="Agent installieren" rahmen="primary">
|
||||
<p>
|
||||
Auf dem Proxmox-Host als root ausführen. Der Enrollment-Token gilt bis zum angegebenen Datum und
|
||||
kann mehrfach verwendet werden.
|
||||
</p>
|
||||
<pre className="bg-body-secondary p-3 rounded">
|
||||
<code className="pl-mono">
|
||||
curl -fsSL https://proxledger.example.de/install.sh | bash -s -- --token plx_e_BEISPIEL
|
||||
</code>
|
||||
</pre>
|
||||
<CopyableCode wert="plx_e_BEISPIEL" />
|
||||
</Card>
|
||||
<Card titel="Vorhandene Tokens" rahmen="info">
|
||||
<p className="text-body-secondary mb-0">
|
||||
Ausgabe, Ablauf und Widerruf von Enrollment- und Host-Tokens folgen in #006.
|
||||
</p>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
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, hosts } from "@/mock/data";
|
||||
import {
|
||||
PRODUKT_NAME,
|
||||
alertsVonHost,
|
||||
getHost,
|
||||
getKunde,
|
||||
hostMeldetNicht,
|
||||
laufzeitenVonHost,
|
||||
reportsVonHost,
|
||||
} from "@/mock/queries";
|
||||
|
||||
export function generateStaticParams() {
|
||||
return hosts.map((host) => ({ id: host.id }));
|
||||
}
|
||||
|
||||
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 (
|
||||
<div className="d-flex justify-content-between gap-3 py-2 border-bottom">
|
||||
<span className="text-body-secondary">{bezeichnung}</span>
|
||||
<span className="text-end">{children}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<>
|
||||
<ContentHeader
|
||||
titel={host.hostname}
|
||||
brotkrumen={[{ titel: "Hosts", href: "/hosts" }, { titel: host.hostname }]}
|
||||
aktion={<StatusBadge status={host.subscription.status} />}
|
||||
/>
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
{alerts.length > 0 ? (
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<Card titel="Offene Warnungen" rahmen="danger">
|
||||
<ul className="list-unstyled mb-0">
|
||||
{alerts.map((alert) => (
|
||||
<li key={alert.id} className="mb-2">
|
||||
<Badge
|
||||
farbe={
|
||||
alert.schwere === "gefahr"
|
||||
? "danger"
|
||||
: alert.schwere === "warnung"
|
||||
? "warning"
|
||||
: "info"
|
||||
}
|
||||
>
|
||||
{alert.titel}
|
||||
</Badge>{" "}
|
||||
<span className="small text-body-secondary">{alert.beschreibung}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="row">
|
||||
<div className="col-lg-4">
|
||||
<Card titel="Host" rahmen="primary">
|
||||
<div className="text-center mb-3">
|
||||
<i className="bi bi-hdd-rack fs-1 text-body-secondary" aria-hidden="true" />
|
||||
<h2 className="h5 mt-2 mb-1">{host.hostname}</h2>
|
||||
<div className="text-body-secondary small">{host.fqdn ?? "Kein FQDN gemeldet"}</div>
|
||||
{hostMeldetNicht(host) ? <KeineMeldungBadge /> : null}
|
||||
</div>
|
||||
|
||||
<Zeile bezeichnung="Kunde">
|
||||
{kunde ? (
|
||||
<Link href={`/kunden/${kunde.id}`}>{kunde.name}</Link>
|
||||
) : (
|
||||
<Link href="/hosts/nicht-zugeordnet" className="badge pl-bg-neutral text-decoration-none">
|
||||
Nicht zugeordnet
|
||||
</Link>
|
||||
)}
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Standort">{standort?.name ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Produkt">{PRODUKT_NAME[host.produkt]}</Zeile>
|
||||
<Zeile bezeichnung="Version">{host.produktVersion ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Kernel">{host.kernel ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Server-ID">
|
||||
<CopyableCode wert={host.serverId} />
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Cluster / Node">
|
||||
{host.clusterName ? `${host.clusterName} / ${host.nodeName}` : "–"}
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="IP-Adressen">{host.ips.join(", ")}</Zeile>
|
||||
<Zeile bezeichnung="CPU">{host.cpuModell ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Sockets (lizenziert / physisch)">
|
||||
{host.subscription.lizenzierteSockets ?? "–"} / {host.sockets ?? "–"}
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Uptime">{formatUptime(host.uptimeSekunden)}</Zeile>
|
||||
<Zeile bezeichnung="Paket-Updates">{formatZahl(host.paketUpdates)}</Zeile>
|
||||
<Zeile bezeichnung="Agent-Version">{host.agentVersion}</Zeile>
|
||||
<Zeile bezeichnung="Letzte Meldung">{formatDatumZeit(host.letzterReport)}</Zeile>
|
||||
<div className="d-grid gap-2 mt-3">
|
||||
<span className="btn btn-outline-secondary disabled">Kunde ändern (ab #006)</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="col-lg-8">
|
||||
<Tabs
|
||||
tabs={[
|
||||
{
|
||||
id: "uebersicht",
|
||||
titel: "Übersicht",
|
||||
icon: "bi-info-circle",
|
||||
inhalt: (
|
||||
<>
|
||||
<Zeile bezeichnung="Subscription-Key">
|
||||
<CopyableCode wert={host.subscription.key} />
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Status">
|
||||
<StatusBadge status={host.subscription.status} />
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Produktname">{host.subscription.produktname ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Level">{host.subscription.level ?? "–"}</Zeile>
|
||||
<Zeile bezeichnung="Registriert am">{formatDatum(host.subscription.regdate)}</Zeile>
|
||||
<Zeile bezeichnung="Läuft ab am">
|
||||
<AblaufBadge datum={host.subscription.nextduedate} heute={HEUTE} />
|
||||
</Zeile>
|
||||
<Zeile bezeichnung="Letzte Prüfung durch Proxmox">
|
||||
{formatDatumZeit(host.subscription.checktime)}
|
||||
</Zeile>
|
||||
<div className="mt-3">
|
||||
{host.tags.map((tag) => (
|
||||
<span key={tag} className="badge pl-bg-neutral me-1">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "keys",
|
||||
titel: "Subscription-Historie",
|
||||
icon: "bi-key",
|
||||
inhalt: (
|
||||
<table className="table table-striped align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Erste Laufzeit</th>
|
||||
<th scope="col">Letzte Laufzeit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{keys.map((key) => {
|
||||
const zugehoerig = laufzeiten.filter((l) => l.key === key);
|
||||
return (
|
||||
<tr key={key}>
|
||||
<td>
|
||||
<CopyableCode wert={key} />
|
||||
</td>
|
||||
<td>{formatDatum(zugehoerig[zugehoerig.length - 1]?.start)}</td>
|
||||
<td>{formatDatum(zugehoerig[0]?.ende)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "reports",
|
||||
titel: "Reports",
|
||||
icon: "bi-clock-history",
|
||||
inhalt: (
|
||||
<table className="table table-striped align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Zeitpunkt</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Ablauf</th>
|
||||
<th scope="col">Updates</th>
|
||||
<th scope="col">Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{reports.map((report) => (
|
||||
<tr key={report.id}>
|
||||
<td>{formatDatumZeit(report.zeitpunkt)}</td>
|
||||
<td>
|
||||
<StatusBadge status={report.status} />
|
||||
</td>
|
||||
<td>
|
||||
<span className="pl-mono">{report.key ?? "–"}</span>
|
||||
</td>
|
||||
<td>{formatDatum(report.nextduedate)}</td>
|
||||
<td>{formatZahl(report.paketUpdates)}</td>
|
||||
<td>{report.agentVersion}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "rechnungen",
|
||||
titel: "Rechnungen",
|
||||
icon: "bi-receipt",
|
||||
inhalt: (
|
||||
<table className="table table-striped align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Laufzeit</th>
|
||||
<th scope="col">Proxmox-Rechnung</th>
|
||||
<th scope="col">Einkauf</th>
|
||||
<th scope="col">Kundenrechnung</th>
|
||||
<th scope="col">Verkauf</th>
|
||||
<th scope="col">Marge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{laufzeiten.map((laufzeit) => (
|
||||
<tr key={laufzeit.id}>
|
||||
<td>
|
||||
{formatDatum(laufzeit.start)} – {formatDatum(laufzeit.ende)}
|
||||
{laufzeit.vorschlag ? (
|
||||
<span className="badge pl-bg-info ms-2">Vorschlag</span>
|
||||
) : null}
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.einkauf?.nummer ?? null} />
|
||||
<div>
|
||||
<EinkaufBadge
|
||||
bezahlt={laufzeit.einkauf ? laufzeit.einkauf.bezahlt : null}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.einkauf?.nettoBetrag)}</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.verkauf?.nummer ?? null} />
|
||||
<div>
|
||||
<VerkaufBadge
|
||||
erstellt={laufzeit.verkauf?.erstellt ?? false}
|
||||
bezahlt={laufzeit.verkauf?.bezahlt ?? false}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.verkauf?.nettoBetrag)}</td>
|
||||
<td>
|
||||
{laufzeit.einkauf && laufzeit.verkauf?.nettoBetrag
|
||||
? formatEuro(
|
||||
(laufzeit.verkauf.nettoBetrag ?? 0) -
|
||||
(laufzeit.einkauf.nettoBetrag ?? 0),
|
||||
)
|
||||
: "–"}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "notizen",
|
||||
titel: "Notizen",
|
||||
icon: "bi-journal-text",
|
||||
inhalt: (
|
||||
<p className="mb-0">
|
||||
{host.notizen ?? (
|
||||
<span className="text-body-secondary">Keine Notizen hinterlegt.</span>
|
||||
)}
|
||||
</p>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Callout } from "@/components/ui/Callout";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
import { formatDatumZeit } from "@/lib/format";
|
||||
import { kunden } from "@/mock/data";
|
||||
import { PRODUKT_NAME, nichtZugeordneteHosts } from "@/mock/queries";
|
||||
|
||||
export const metadata = { title: "Nicht zugeordnete Hosts" };
|
||||
|
||||
export default function NichtZugeordnetSeite() {
|
||||
const liste = nichtZugeordneteHosts();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader
|
||||
titel="Nicht zugeordnete Hosts"
|
||||
brotkrumen={[{ titel: "Hosts", href: "/hosts" }, { titel: "Nicht zugeordnet" }]}
|
||||
/>
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Callout titel="Schnellzuweisung" farbe="info">
|
||||
Mehrere Hosts auswählen und gemeinsam einem Kunden zuweisen. Im Prototyp ist das Formular noch
|
||||
ohne Funktion – die Zuweisung folgt in #006.
|
||||
</Callout>
|
||||
|
||||
<Card titel={`${liste.length} Hosts ohne Kunde`} rahmen="warning" tabelle>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<input type="checkbox" className="form-check-input" aria-label="Alle auswählen" />
|
||||
</th>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Produkt</th>
|
||||
<th scope="col">Server-ID</th>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Erste Meldung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{liste.map((host) => (
|
||||
<tr key={host.id}>
|
||||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="form-check-input"
|
||||
aria-label={`${host.hostname} auswählen`}
|
||||
defaultChecked
|
||||
/>
|
||||
</td>
|
||||
<td className="fw-semibold">{host.hostname}</td>
|
||||
<td>{PRODUKT_NAME[host.produkt]}</td>
|
||||
<td>
|
||||
<CopyableCode wert={host.serverId} />
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={host.subscription.key} />
|
||||
</td>
|
||||
<td>{formatDatumZeit(host.letzterReport)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card titel="Ausgewählte Hosts zuweisen">
|
||||
<div className="row g-2 align-items-end">
|
||||
<div className="col-md-5">
|
||||
<label className="form-label" htmlFor="kunde">
|
||||
Kunde
|
||||
</label>
|
||||
<select id="kunde" className="form-select">
|
||||
{kunden.map((kunde) => (
|
||||
<option key={kunde.id}>{kunde.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-md-5">
|
||||
<label className="form-label" htmlFor="standort">
|
||||
Standort (optional)
|
||||
</label>
|
||||
<select id="standort" className="form-select">
|
||||
<option>– kein Standort –</option>
|
||||
{kunden[0].standorte.map((standort) => (
|
||||
<option key={standort.id}>{standort.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-md-2">
|
||||
<button type="button" className="btn btn-primary w-100" disabled>
|
||||
Zuweisen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import Link from "next/link";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { AblaufBadge, KeineMeldungBadge, StatusBadge } from "@/components/ui/Badges";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
import { HEUTE, hosts } from "@/mock/data";
|
||||
import { PRODUKT_NAME, getKunde, hostMeldetNicht, suche } from "@/mock/queries";
|
||||
|
||||
export const metadata = { title: "Hosts" };
|
||||
|
||||
export default async function HostsSeite({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ q?: string; status?: string; kunde?: string }>;
|
||||
}) {
|
||||
const { q, status, kunde } = await searchParams;
|
||||
|
||||
let liste = q ? suche(q).hosts : hosts;
|
||||
if (status) liste = liste.filter((h) => h.subscription.status === status);
|
||||
if (kunde) liste = liste.filter((h) => h.kundeId === kunde);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="Hosts" brotkrumen={[{ titel: "Hosts" }]} />
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card
|
||||
titel={`${liste.length} von ${hosts.length} Hosts`}
|
||||
rahmen="primary"
|
||||
tabelle
|
||||
werkzeuge={
|
||||
<>
|
||||
<Link href="/hosts/nicht-zugeordnet" className="btn btn-sm btn-outline-primary">
|
||||
Nicht zugeordnete
|
||||
</Link>
|
||||
<span className="btn btn-sm btn-outline-secondary disabled">CSV-Export (ab #007)</span>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<form className="p-3 border-bottom row g-2" role="search">
|
||||
<div className="col-md-5">
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
defaultValue={q ?? ""}
|
||||
className="form-control"
|
||||
placeholder="Hostname, Key, Server-ID oder IP …"
|
||||
aria-label="Hosts durchsuchen"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<select name="status" defaultValue={status ?? ""} className="form-select" aria-label="Status">
|
||||
<option value="">Alle Status</option>
|
||||
<option value="active">Aktiv</option>
|
||||
<option value="expired">Abgelaufen</option>
|
||||
<option value="notfound">Keine Subscription</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-md-2">
|
||||
<button type="submit" className="btn btn-primary w-100">
|
||||
Filtern
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Kunde</th>
|
||||
<th scope="col">Produkt</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Ablauf</th>
|
||||
<th scope="col">Sockets</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{liste.map((host) => {
|
||||
const kundeDesHosts = getKunde(host.kundeId);
|
||||
const socketAbweichung =
|
||||
host.subscription.lizenzierteSockets !== null &&
|
||||
host.sockets !== null &&
|
||||
host.subscription.lizenzierteSockets !== host.sockets;
|
||||
return (
|
||||
<tr key={host.id}>
|
||||
<td>
|
||||
<Link href={`/hosts/${host.id}`} className="fw-semibold text-decoration-none">
|
||||
{host.hostname}
|
||||
</Link>
|
||||
{hostMeldetNicht(host) ? <KeineMeldungBadge /> : null}
|
||||
<div className="small text-body-secondary">{host.ips.join(", ")}</div>
|
||||
</td>
|
||||
<td>
|
||||
{kundeDesHosts ? (
|
||||
<Link href={`/kunden/${kundeDesHosts.id}`} className="text-decoration-none">
|
||||
{kundeDesHosts.name}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="badge pl-bg-neutral">Nicht zugeordnet</span>
|
||||
)}
|
||||
</td>
|
||||
<td>{PRODUKT_NAME[host.produkt]}</td>
|
||||
<td>
|
||||
<StatusBadge status={host.subscription.status} />
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={host.subscription.key} />
|
||||
</td>
|
||||
<td>
|
||||
<AblaufBadge datum={host.subscription.nextduedate} heute={HEUTE} />
|
||||
</td>
|
||||
<td>
|
||||
{host.subscription.lizenzierteSockets ?? "–"} / {host.sockets ?? "–"}
|
||||
{socketAbweichung ? (
|
||||
<i
|
||||
className="bi bi-exclamation-triangle-fill pl-text-warning ms-2"
|
||||
title="Lizenzierte und physische Sockets weichen ab"
|
||||
/>
|
||||
) : null}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
{liste.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={7} className="text-center text-body-secondary py-4">
|
||||
Keine Hosts gefunden.
|
||||
</td>
|
||||
</tr>
|
||||
) : null}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import Link from "next/link";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { formatDatum, tageBis } from "@/lib/format";
|
||||
import { HEUTE, hosts, kunden } from "@/mock/data";
|
||||
|
||||
export const metadata = { title: "Jahresbahn" };
|
||||
|
||||
const MONATE = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
|
||||
|
||||
export default function JahresbahnSeite() {
|
||||
const start = new Date(Date.UTC(HEUTE.getUTCFullYear(), HEUTE.getUTCMonth(), 1));
|
||||
const gesamtTage = 365;
|
||||
|
||||
function position(datum: string): number | null {
|
||||
const tage = Math.round((new Date(datum).getTime() - start.getTime()) / 86_400_000);
|
||||
if (tage < 0 || tage > gesamtTage) return null;
|
||||
return (tage / gesamtTage) * 100;
|
||||
}
|
||||
|
||||
const heutePosition = position(HEUTE.toISOString().slice(0, 10)) ?? 0;
|
||||
|
||||
const monatsBeschriftung = Array.from({ length: 12 }, (_, i) => {
|
||||
const datum = new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth() + i, 1));
|
||||
return `${MONATE[datum.getUTCMonth()]} ${String(datum.getUTCFullYear()).slice(2)}`;
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="Jahresbahn" brotkrumen={[{ titel: "Jahresbahn" }]} />
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card titel="Abläufe der nächsten 12 Monate" rahmen="primary">
|
||||
<div className="table-responsive">
|
||||
<div style={{ minWidth: "760px" }}>
|
||||
<div className="d-flex text-body-secondary small mb-2" style={{ marginLeft: "12rem" }}>
|
||||
{monatsBeschriftung.map((monat) => (
|
||||
<div key={monat} style={{ width: `${100 / 12}%` }}>
|
||||
{monat}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{kunden.map((kunde) => {
|
||||
const eigene = hosts.filter(
|
||||
(h) => h.kundeId === kunde.id && h.subscription.nextduedate !== null,
|
||||
);
|
||||
if (eigene.length === 0) return null;
|
||||
return (
|
||||
<div key={kunde.id} className="mb-3">
|
||||
<div className="fw-semibold small mb-1">
|
||||
<Link href={`/kunden/${kunde.id}`} className="text-decoration-none">
|
||||
{kunde.name}
|
||||
</Link>
|
||||
</div>
|
||||
{eigene.map((host) => {
|
||||
const datum = host.subscription.nextduedate!;
|
||||
const links = position(datum.slice(0, 10));
|
||||
const tage = tageBis(datum, HEUTE);
|
||||
const farbe =
|
||||
tage === null || tage < 14
|
||||
? "var(--pl-danger)"
|
||||
: tage < 30
|
||||
? "var(--pl-warning)"
|
||||
: "var(--pl-info)";
|
||||
return (
|
||||
<div key={host.id} className="d-flex align-items-center mb-1">
|
||||
<div className="small text-truncate" style={{ width: "12rem" }}>
|
||||
<Link href={`/hosts/${host.id}`} className="text-decoration-none">
|
||||
{host.hostname}
|
||||
</Link>
|
||||
</div>
|
||||
<div className="pl-timeline-row flex-grow-1 position-relative">
|
||||
<div className="pl-timeline-heute" style={{ left: `${heutePosition}%` }} />
|
||||
{links === null ? (
|
||||
<span className="small text-body-secondary ms-2">
|
||||
außerhalb des Zeitraums ({formatDatum(datum)})
|
||||
</span>
|
||||
) : (
|
||||
<div
|
||||
className="pl-timeline-bar"
|
||||
style={{
|
||||
left: `${Math.max(0, links - 6)}%`,
|
||||
backgroundColor: farbe,
|
||||
color: farbe === "var(--pl-warning)" ? "var(--pl-warning-text)" : "#fff",
|
||||
}}
|
||||
title={`${host.hostname} läuft am ${formatDatum(datum)} ab`}
|
||||
>
|
||||
{formatDatum(datum)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<p className="small text-body-secondary mb-0">
|
||||
Die rote Linie markiert heute ({formatDatum(HEUTE)}). Farbe der Balken: rot unter 14 Tagen, gelb
|
||||
unter 30 Tagen, sonst blau.
|
||||
</p>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import {
|
||||
AblaufBadge,
|
||||
EinkaufBadge,
|
||||
KeineMeldungBadge,
|
||||
StatusBadge,
|
||||
VerkaufBadge,
|
||||
} from "@/components/ui/Badges";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
import { InfoBox } from "@/components/ui/SmallBox";
|
||||
import { formatDatum, formatEuro } from "@/lib/format";
|
||||
import { HEUTE, kunden } from "@/mock/data";
|
||||
import {
|
||||
PRODUKT_NAME,
|
||||
alertsVonKunde,
|
||||
getKunde,
|
||||
hostMeldetNicht,
|
||||
hostsVonKunde,
|
||||
laufzeitenVonKunde,
|
||||
summenProJahr,
|
||||
summenVonKunde,
|
||||
} from "@/mock/queries";
|
||||
|
||||
export function generateStaticParams() {
|
||||
return kunden.map((kunde) => ({ id: kunde.id }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
return { title: getKunde(id)?.name ?? "Kunde" };
|
||||
}
|
||||
|
||||
export default async function KundenDetailSeite({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const kunde = getKunde(id);
|
||||
if (!kunde) notFound();
|
||||
|
||||
const eigeneHosts = hostsVonKunde(kunde.id);
|
||||
const laufzeiten = laufzeitenVonKunde(kunde.id);
|
||||
const summen = summenVonKunde(kunde.id);
|
||||
const proJahr = summenProJahr(laufzeiten);
|
||||
const alerts = alertsVonKunde(kunde.id);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader
|
||||
titel={kunde.name}
|
||||
brotkrumen={[{ titel: "Kunden", href: "/kunden" }, { titel: kunde.name }]}
|
||||
/>
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<div className="row">
|
||||
<div className="col-6 col-lg-3">
|
||||
<InfoBox text="Hosts" wert={String(eigeneHosts.length)} icon="bi-hdd-stack" farbe="info" />
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<InfoBox
|
||||
text="Einkauf netto"
|
||||
wert={formatEuro(summen.einkauf)}
|
||||
icon="bi-cart"
|
||||
farbe="neutral"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<InfoBox
|
||||
text="Verkauf netto"
|
||||
wert={formatEuro(summen.verkauf)}
|
||||
icon="bi-receipt"
|
||||
farbe="primary"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<InfoBox
|
||||
text="Marge"
|
||||
wert={formatEuro(summen.marge)}
|
||||
icon="bi-graph-up-arrow"
|
||||
farbe="success"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="row">
|
||||
<div className="col-lg-4">
|
||||
<Card titel="Stammdaten" rahmen="primary">
|
||||
<dl className="row mb-0">
|
||||
<dt className="col-5 fw-normal text-body-secondary">Kundennummer</dt>
|
||||
<dd className="col-7 pl-mono">{kunde.kundennummer}</dd>
|
||||
<dt className="col-5 fw-normal text-body-secondary">Ansprechpartner</dt>
|
||||
<dd className="col-7">{kunde.ansprechpartner ?? "–"}</dd>
|
||||
<dt className="col-5 fw-normal text-body-secondary">E-Mail</dt>
|
||||
<dd className="col-7">
|
||||
{kunde.email ? <a href={`mailto:${kunde.email}`}>{kunde.email}</a> : "–"}
|
||||
</dd>
|
||||
<dt className="col-5 fw-normal text-body-secondary">Telefon</dt>
|
||||
<dd className="col-7">{kunde.telefon ?? "–"}</dd>
|
||||
<dt className="col-5 fw-normal text-body-secondary">Standorte</dt>
|
||||
<dd className="col-7">
|
||||
{kunde.standorte.map((s) => (
|
||||
<div key={s.id}>
|
||||
{s.name}
|
||||
{s.ort ? <span className="text-body-secondary"> · {s.ort}</span> : null}
|
||||
</div>
|
||||
))}
|
||||
</dd>
|
||||
</dl>
|
||||
<hr />
|
||||
<h4 className="h6">Notizen</h4>
|
||||
<p className="mb-0 small">
|
||||
{kunde.notizen ?? <span className="text-body-secondary">Keine Notizen hinterlegt.</span>}
|
||||
</p>
|
||||
</Card>
|
||||
|
||||
<Card titel="Offene Warnungen" rahmen={alerts.length > 0 ? "danger" : "info"}>
|
||||
{alerts.length === 0 ? (
|
||||
<p className="mb-0 text-body-secondary">Keine offenen Warnungen.</p>
|
||||
) : (
|
||||
<ul className="list-unstyled mb-0 small">
|
||||
{alerts.map((alert) => (
|
||||
<li key={alert.id} className="mb-2">
|
||||
<strong>{alert.titel}</strong>
|
||||
<div className="text-body-secondary">{alert.beschreibung}</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="col-lg-8">
|
||||
<Card titel="Hosts" rahmen="primary" tabelle>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Produkt</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Ablauf</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{eigeneHosts.map((host) => (
|
||||
<tr key={host.id}>
|
||||
<td>
|
||||
<Link href={`/hosts/${host.id}`} className="fw-semibold text-decoration-none">
|
||||
{host.hostname}
|
||||
</Link>
|
||||
{hostMeldetNicht(host) ? <KeineMeldungBadge /> : null}
|
||||
</td>
|
||||
<td>{PRODUKT_NAME[host.produkt]}</td>
|
||||
<td>
|
||||
<StatusBadge status={host.subscription.status} />
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={host.subscription.key} />
|
||||
</td>
|
||||
<td>
|
||||
<AblaufBadge datum={host.subscription.nextduedate} heute={HEUTE} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card titel="Laufzeiten und Rechnungen" rahmen="info" tabelle>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Laufzeit</th>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Proxmox</th>
|
||||
<th scope="col">Einkauf</th>
|
||||
<th scope="col">Kundenrechnung</th>
|
||||
<th scope="col">Verkauf</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{laufzeiten.map((laufzeit) => {
|
||||
const host = eigeneHosts.find((h) => h.id === laufzeit.hostId);
|
||||
return (
|
||||
<tr key={laufzeit.id}>
|
||||
<td>
|
||||
{formatDatum(laufzeit.start)} – {formatDatum(laufzeit.ende)}
|
||||
{laufzeit.vorschlag ? (
|
||||
<span className="badge pl-bg-info ms-2">Vorschlag</span>
|
||||
) : null}
|
||||
</td>
|
||||
<td>{host?.hostname ?? "–"}</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.einkauf?.nummer ?? null} />
|
||||
<div>
|
||||
<EinkaufBadge bezahlt={laufzeit.einkauf ? laufzeit.einkauf.bezahlt : null} />
|
||||
</div>
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.einkauf?.nettoBetrag)}</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.verkauf?.nummer ?? null} />
|
||||
<div>
|
||||
<VerkaufBadge
|
||||
erstellt={laufzeit.verkauf?.erstellt ?? false}
|
||||
bezahlt={laufzeit.verkauf?.bezahlt ?? false}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.verkauf?.nettoBetrag)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card titel="Summen pro Jahr" rahmen="info" tabelle>
|
||||
<table className="table table-striped align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Jahr</th>
|
||||
<th scope="col">Einkauf netto</th>
|
||||
<th scope="col">Verkauf netto</th>
|
||||
<th scope="col">Marge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{proJahr.map((jahr) => (
|
||||
<tr key={jahr.jahr}>
|
||||
<td>{jahr.jahr}</td>
|
||||
<td>{formatEuro(jahr.einkauf)}</td>
|
||||
<td>{formatEuro(jahr.verkauf)}</td>
|
||||
<td className={jahr.marge >= 0 ? "pl-text-success" : "pl-text-danger"}>
|
||||
{formatEuro(jahr.marge)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import Link from "next/link";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { AblaufBadge, Badge } from "@/components/ui/Badges";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { formatEuro } from "@/lib/format";
|
||||
import { HEUTE } from "@/mock/data";
|
||||
import { kundenUebersicht, summenVonKunde } from "@/mock/queries";
|
||||
|
||||
export const metadata = { title: "Kunden" };
|
||||
|
||||
export default function KundenSeite() {
|
||||
const uebersicht = kundenUebersicht();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="Kunden" brotkrumen={[{ titel: "Kunden" }]} />
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card
|
||||
titel={`${uebersicht.length} Kunden`}
|
||||
rahmen="primary"
|
||||
tabelle
|
||||
werkzeuge={<span className="btn btn-sm btn-primary disabled">Kunde anlegen (ab #006)</span>}
|
||||
>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Kunde</th>
|
||||
<th scope="col">Kundennummer</th>
|
||||
<th scope="col">Hosts</th>
|
||||
<th scope="col">Aktiv</th>
|
||||
<th scope="col">Nächster Ablauf</th>
|
||||
<th scope="col">Warnungen</th>
|
||||
<th scope="col">Rechnungen</th>
|
||||
<th scope="col">Marge (netto)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{uebersicht.map((eintrag) => {
|
||||
const summen = summenVonKunde(eintrag.kunde.id);
|
||||
return (
|
||||
<tr key={eintrag.kunde.id}>
|
||||
<td>
|
||||
<Link
|
||||
href={`/kunden/${eintrag.kunde.id}`}
|
||||
className="fw-semibold text-decoration-none"
|
||||
>
|
||||
{eintrag.kunde.name}
|
||||
</Link>
|
||||
<div className="small text-body-secondary">
|
||||
{eintrag.kunde.ansprechpartner ?? "–"}
|
||||
</div>
|
||||
</td>
|
||||
<td className="pl-mono">{eintrag.kunde.kundennummer}</td>
|
||||
<td>{eintrag.hosts}</td>
|
||||
<td>{eintrag.aktiv}</td>
|
||||
<td>
|
||||
<AblaufBadge datum={eintrag.naechsterAblauf} heute={HEUTE} />
|
||||
</td>
|
||||
<td>
|
||||
{eintrag.offeneAlerts > 0 ? (
|
||||
<Badge farbe="warning">{eintrag.offeneAlerts} offen</Badge>
|
||||
) : (
|
||||
<Badge farbe="success">keine</Badge>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{eintrag.offeneRechnungspunkte > 0 ? (
|
||||
<Badge farbe="danger">{eintrag.offeneRechnungspunkte} offen</Badge>
|
||||
) : (
|
||||
<Badge farbe="success">erledigt</Badge>
|
||||
)}
|
||||
</td>
|
||||
<td>{formatEuro(summen.marge)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
import { Header } from "@/components/layout/Header";
|
||||
import { Sidebar } from "@/components/layout/Sidebar";
|
||||
import { hosts } from "@/mock/data";
|
||||
import { dashboardKennzahlen, offeneAlerts } from "@/mock/queries";
|
||||
import { suchIndex } from "@/mock/suchindex";
|
||||
|
||||
const BENUTZER = "Florian";
|
||||
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
const kennzahlen = dashboardKennzahlen();
|
||||
|
||||
return (
|
||||
<div className="app-wrapper">
|
||||
<Header alerts={offeneAlerts()} suchEintraege={suchIndex()} benutzer={BENUTZER} />
|
||||
<Sidebar
|
||||
hostsAnzahl={hosts.length}
|
||||
offeneRechnungspunkte={kennzahlen.offeneRechnungspunkte}
|
||||
benutzer={BENUTZER}
|
||||
/>
|
||||
<main className="app-main">{children}</main>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
import Link from "next/link";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { AblaufBadge, EinkaufBadge, KeineMeldungBadge, VerkaufBadge } from "@/components/ui/Badges";
|
||||
import { Callout, ProgressBar } from "@/components/ui/Callout";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
import { SmallBox } from "@/components/ui/SmallBox";
|
||||
import { TodoList, type Aufgabe } from "@/components/ui/TodoList";
|
||||
import { formatDatum, formatEuro } from "@/lib/format";
|
||||
import { HEUTE } from "@/mock/data";
|
||||
import {
|
||||
laufzeitZuAblauf,
|
||||
dashboardKennzahlen,
|
||||
getKunde,
|
||||
hostMeldetNicht,
|
||||
hostsNachAblauf,
|
||||
nichtZugeordneteHosts,
|
||||
offeneRechnungsLaufzeiten,
|
||||
rechnungsFortschrittProKunde,
|
||||
} from "@/mock/queries";
|
||||
|
||||
export const metadata = { title: "Dashboard" };
|
||||
|
||||
function aufgabenliste(): Aufgabe[] {
|
||||
return offeneRechnungsLaufzeiten().flatMap((laufzeit) => {
|
||||
const host = hostsNachAblauf().find((h) => h.id === laufzeit.hostId);
|
||||
const kunde = getKunde(host?.kundeId ?? null);
|
||||
const basis = `${host?.hostname ?? "?"} · ${kunde?.name ?? "Nicht zugeordnet"}`;
|
||||
const aufgaben: Aufgabe[] = [];
|
||||
|
||||
if (laufzeit.einkauf && !laufzeit.einkauf.bezahlt) {
|
||||
aufgaben.push({
|
||||
id: `${laufzeit.id}-einkauf`,
|
||||
titel: `Proxmox-Rechnung ${laufzeit.einkauf.nummer} bezahlen`,
|
||||
detail: `${basis} · ${formatEuro(laufzeit.einkauf.nettoBetrag)} netto · fällig am ${formatDatum(
|
||||
laufzeit.einkauf.faelligAm,
|
||||
)}`,
|
||||
dringlichkeit: "gefahr",
|
||||
badgeText: "Einkauf",
|
||||
href: `/hosts/${laufzeit.hostId}`,
|
||||
});
|
||||
}
|
||||
|
||||
if (laufzeit.einkauf && (!laufzeit.verkauf || !laufzeit.verkauf.erstellt)) {
|
||||
aufgaben.push({
|
||||
id: `${laufzeit.id}-verkauf`,
|
||||
titel: "Kundenrechnung erstellen",
|
||||
detail: `${basis} · Laufzeit ${formatDatum(laufzeit.start)} – ${formatDatum(laufzeit.ende)}`,
|
||||
dringlichkeit: "warnung",
|
||||
badgeText: "Verkauf",
|
||||
href: `/rechnungen`,
|
||||
});
|
||||
}
|
||||
|
||||
return aufgaben;
|
||||
});
|
||||
}
|
||||
|
||||
export default function DashboardSeite() {
|
||||
const kennzahlen = dashboardKennzahlen();
|
||||
const ohneKunde = nichtZugeordneteHosts();
|
||||
const fortschritt = rechnungsFortschrittProKunde();
|
||||
const aufgaben = aufgabenliste();
|
||||
|
||||
const nichtZugeordnetAufgaben: Aufgabe[] = ohneKunde.map((host) => ({
|
||||
id: `zuweisen-${host.id}`,
|
||||
titel: `${host.hostname} einem Kunden zuweisen`,
|
||||
detail: `Server-ID ${host.serverId} · seit ${formatDatum(host.letzterReport)} gemeldet`,
|
||||
dringlichkeit: "info",
|
||||
badgeText: "Zuweisen",
|
||||
href: "/hosts/nicht-zugeordnet",
|
||||
}));
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="Dashboard" brotkrumen={[{ titel: "Dashboard" }]} />
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
{ohneKunde.length > 0 ? (
|
||||
<Callout
|
||||
titel={`${ohneKunde.length} Host${ohneKunde.length === 1 ? "" : "s"} ohne Kunde`}
|
||||
aktion={
|
||||
<Link href="/hosts/nicht-zugeordnet" className="btn btn-primary pl-touch-target">
|
||||
Jetzt zuweisen
|
||||
</Link>
|
||||
}
|
||||
>
|
||||
Neu registrierte Hosts erscheinen hier, bis sie einem Kunden zugewiesen sind:{" "}
|
||||
{ohneKunde.map((h) => h.hostname).join(", ")}
|
||||
</Callout>
|
||||
) : null}
|
||||
|
||||
<div className="row">
|
||||
<div className="col-6 col-lg-3">
|
||||
<SmallBox
|
||||
wert={kennzahlen.hostsGesamt}
|
||||
text="Hosts gemeldet"
|
||||
zusatz={`${kennzahlen.ohneMeldung} ohne Meldung`}
|
||||
icon="bi-hdd-stack"
|
||||
farbe="info"
|
||||
href="/hosts"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<SmallBox
|
||||
wert={kennzahlen.aktivLizenziert}
|
||||
text="Aktiv lizenziert"
|
||||
zusatz={`${kennzahlen.ohneSubscription} ohne gültige Subscription`}
|
||||
icon="bi-patch-check"
|
||||
farbe="success"
|
||||
href="/hosts?status=active"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<SmallBox
|
||||
wert={kennzahlen.baldAblaufend}
|
||||
text="Läuft in 30 Tagen ab"
|
||||
zusatz="Verlängerung vorbereiten"
|
||||
icon="bi-hourglass-split"
|
||||
farbe="warning"
|
||||
href="/jahresbahn"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-6 col-lg-3">
|
||||
<SmallBox
|
||||
wert={kennzahlen.offeneRechnungspunkte}
|
||||
text="Offene Rechnungspunkte"
|
||||
zusatz={`${kennzahlen.offeneEinkaufsrechnungen} Einkauf · ${kennzahlen.fehlendeKundenrechnungen} Verkauf`}
|
||||
icon="bi-receipt"
|
||||
farbe="danger"
|
||||
href="/rechnungen"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="row">
|
||||
<div className="col-lg-8">
|
||||
<Card titel="Subscriptions nach Ablaufdatum" rahmen="primary" tabelle>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Kunde</th>
|
||||
<th scope="col">Key</th>
|
||||
<th scope="col">Ablauf</th>
|
||||
<th scope="col">Proxmox</th>
|
||||
<th scope="col">Kundenrechnung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{hostsNachAblauf().map((host) => {
|
||||
const kunde = getKunde(host.kundeId);
|
||||
const laufzeit = laufzeitZuAblauf(host);
|
||||
return (
|
||||
<tr key={host.id}>
|
||||
<td>
|
||||
<Link href={`/hosts/${host.id}`} className="fw-semibold text-decoration-none">
|
||||
{host.hostname}
|
||||
</Link>
|
||||
{hostMeldetNicht(host) ? <KeineMeldungBadge /> : null}
|
||||
</td>
|
||||
<td>
|
||||
{kunde ? (
|
||||
<Link href={`/kunden/${kunde.id}`} className="text-decoration-none">
|
||||
{kunde.name}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="badge pl-bg-neutral">Nicht zugeordnet</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={host.subscription.key} />
|
||||
</td>
|
||||
<td>
|
||||
<AblaufBadge datum={host.subscription.nextduedate} heute={HEUTE} />
|
||||
</td>
|
||||
<td>
|
||||
<EinkaufBadge bezahlt={laufzeit?.einkauf ? laufzeit.einkauf.bezahlt : null} />
|
||||
</td>
|
||||
<td>
|
||||
<VerkaufBadge
|
||||
erstellt={laufzeit?.verkauf?.erstellt ?? false}
|
||||
bezahlt={laufzeit?.verkauf?.bezahlt ?? false}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="col-lg-4">
|
||||
<Card
|
||||
titel="Aufgaben"
|
||||
rahmen="warning"
|
||||
werkzeuge={
|
||||
<span className="badge pl-bg-warning">
|
||||
{aufgaben.length + nichtZugeordnetAufgaben.length}
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<TodoList aufgaben={[...aufgaben, ...nichtZugeordnetAufgaben]} />
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="row">
|
||||
<div className="col-lg-8">
|
||||
<Card titel="Rechnungsstatus je Kunde" rahmen="info">
|
||||
{fortschritt.map((eintrag) => (
|
||||
<div className="mb-3" key={eintrag.kunde.id}>
|
||||
<div className="d-flex justify-content-between small mb-1">
|
||||
<Link href={`/kunden/${eintrag.kunde.id}`} className="text-decoration-none">
|
||||
{eintrag.kunde.name}
|
||||
</Link>
|
||||
<span className="text-body-secondary">
|
||||
{eintrag.erledigt} von {eintrag.gesamt} Punkten erledigt
|
||||
</span>
|
||||
</div>
|
||||
<ProgressBar
|
||||
prozent={eintrag.prozent}
|
||||
beschriftung={`Rechnungsstatus ${eintrag.kunde.name}`}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</div>
|
||||
<div className="col-lg-4">
|
||||
<Card titel="Nächste Schritte" rahmen="info">
|
||||
<ul className="list-unstyled mb-0 small">
|
||||
<li className="mb-2">
|
||||
<i className="bi bi-arrow-right-short" aria-hidden="true" />{" "}
|
||||
<Link href="/kunden">Kundenübersicht öffnen</Link>
|
||||
</li>
|
||||
<li className="mb-2">
|
||||
<i className="bi bi-arrow-right-short" aria-hidden="true" />{" "}
|
||||
<Link href="/rechnungen">Rechnungen pflegen</Link>
|
||||
</li>
|
||||
<li>
|
||||
<i className="bi bi-arrow-right-short" aria-hidden="true" />{" "}
|
||||
<Link href="/jahresbahn">Abläufe der nächsten 12 Monate ansehen</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import Link from "next/link";
|
||||
import { ContentHeader } from "@/components/layout/ContentHeader";
|
||||
import { Card } from "@/components/ui/Card";
|
||||
import { CopyableCode } from "@/components/ui/CopyableCode";
|
||||
import { formatDatum, formatEuro } from "@/lib/format";
|
||||
import { hosts, laufzeiten } from "@/mock/data";
|
||||
import { getKunde, istAbgeschlossen } from "@/mock/queries";
|
||||
|
||||
export const metadata = { title: "Rechnungen" };
|
||||
|
||||
export default async function RechnungenSeite({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ filter?: string }>;
|
||||
}) {
|
||||
const { filter = "offen" } = await searchParams;
|
||||
const alle = laufzeiten.filter((l) => !l.vorschlag);
|
||||
const liste =
|
||||
filter === "erledigt"
|
||||
? alle.filter(istAbgeschlossen)
|
||||
: filter === "alle"
|
||||
? alle
|
||||
: alle.filter((l) => !istAbgeschlossen(l));
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentHeader titel="Rechnungen" brotkrumen={[{ titel: "Rechnungen" }]} />
|
||||
|
||||
<div className="app-content">
|
||||
<div className="container-fluid">
|
||||
<Card
|
||||
titel={`${liste.length} Laufzeiten`}
|
||||
rahmen="primary"
|
||||
tabelle
|
||||
werkzeuge={
|
||||
<div className="btn-group btn-group-sm" role="group" aria-label="Filter">
|
||||
{[
|
||||
["offen", "Offen"],
|
||||
["erledigt", "Erledigt"],
|
||||
["alle", "Alle"],
|
||||
].map(([wert, text]) => (
|
||||
<Link
|
||||
key={wert}
|
||||
href={`/rechnungen?filter=${wert}`}
|
||||
className={`btn ${filter === wert ? "btn-primary" : "btn-outline-primary"}`}
|
||||
>
|
||||
{text}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-striped align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Kunde</th>
|
||||
<th scope="col">Host</th>
|
||||
<th scope="col">Laufzeit</th>
|
||||
<th scope="col">Proxmox-Rechnung</th>
|
||||
<th scope="col">Netto</th>
|
||||
<th scope="col" className="text-center">
|
||||
Proxmox bezahlt
|
||||
</th>
|
||||
<th scope="col">Kundenrechnung</th>
|
||||
<th scope="col">Netto</th>
|
||||
<th scope="col" className="text-center">
|
||||
Kundenrechnung erstellt
|
||||
</th>
|
||||
<th scope="col">Marge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{liste.map((laufzeit) => {
|
||||
const host = hosts.find((h) => h.id === laufzeit.hostId);
|
||||
const kunde = getKunde(host?.kundeId ?? null);
|
||||
const marge = (laufzeit.verkauf?.nettoBetrag ?? 0) - (laufzeit.einkauf?.nettoBetrag ?? 0);
|
||||
return (
|
||||
<tr key={laufzeit.id}>
|
||||
<td>
|
||||
{kunde ? (
|
||||
<Link href={`/kunden/${kunde.id}`} className="text-decoration-none">
|
||||
{kunde.name}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="badge pl-bg-neutral">Nicht zugeordnet</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<Link href={`/hosts/${laufzeit.hostId}`} className="text-decoration-none">
|
||||
{host?.hostname}
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
{formatDatum(laufzeit.start)} – {formatDatum(laufzeit.ende)}
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.einkauf?.nummer ?? null} />
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.einkauf?.nettoBetrag)}</td>
|
||||
<td className="text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="form-check-input pl-touch-target"
|
||||
defaultChecked={laufzeit.einkauf?.bezahlt ?? false}
|
||||
aria-label="Proxmox-Rechnung bezahlt"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<CopyableCode wert={laufzeit.verkauf?.nummer ?? null} />
|
||||
</td>
|
||||
<td>{formatEuro(laufzeit.verkauf?.nettoBetrag)}</td>
|
||||
<td className="text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="form-check-input pl-touch-target"
|
||||
defaultChecked={laufzeit.verkauf?.erstellt ?? false}
|
||||
aria-label="Kundenrechnung erstellt"
|
||||
/>
|
||||
</td>
|
||||
<td className={marge >= 0 ? "pl-text-success" : "pl-text-danger"}>
|
||||
{laufzeit.verkauf?.nettoBetrag ? formatEuro(marge) : "–"}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
<p className="small text-body-secondary">
|
||||
Im Prototyp sind die Häkchen noch ohne Wirkung. Ab #008 setzen sie den Status direkt.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user