procon aggregate

This commit is contained in:
marco committed 2026-10-22 07:57:57 +02:00
1 parent 3bea468d23
commit 734aa81710
16 files changed
+656 -12

No files matched your search

+2
View File
@@ -36,6 +36,8 @@ export default function AnlageLayout({ children }: Props) {
<h2 className="mb-4 font-semibold">Anlage</h2>
<ul className="space-y-2">
<li><a href="/rk2/visu-aggregate">VisuAggregate</a></li>
<li><a href="/rk2/visu-aggregate/grafiken">Grafikübersicht</a></li>
<li>
<a href="/rk2/groups">Groups</a>
</li>
@@ -0,0 +1,18 @@
import Link from 'next/link';
import { api_viewAggregate } from '@/actions/rk2/api-procon-view-aggregate';
import ViewAggregateForm from '@/components/rk2/visu-aggregate/viewAggregateForm';
export default async function Page({ params }: { params: Promise<{ componentId: string }> }) {
const { componentId } = await params;
try {
const data = await api_viewAggregate(componentId);
return <div><Link href="/rk2/visu-aggregate" className="underline">Zurück zu VisuAggregate</Link>
<h1 className="my-4 text-xl font-semibold">Grafiken – {data.name}</h1>
<ViewAggregateForm componentId={componentId} initial={data} />
</div>;
} catch (error) {
return <div><Link href="/rk2/visu-aggregate" className="underline">Zurück zur Tabelle</Link>
<p role="alert" className="mt-4 text-red-600">{error instanceof Error ? error.message : 'Laden fehlgeschlagen'}</p></div>;
}
}
@@ -0,0 +1,15 @@
export async function GET() {
try {
const response = await fetch('http://localhost:3000/rk2/visu-aggregate/export', { cache: 'no-store' });
if (!response.ok) return new Response('Excel-Export fehlgeschlagen.', { status: 502 });
return new Response(response.body, {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition': 'attachment; filename="VisuAggregate.xlsx"',
'Cache-Control': 'no-store',
},
});
} catch {
return new Response('Keine Verbindung zum Backend.', { status: 502 });
}
}
@@ -0,0 +1,39 @@
import Link from 'next/link';
import { api_viewAggregate_overview } from '@/actions/rk2/api-procon-view-aggregate';
export default async function GraphicsOverviewPage() {
let aggregates;
try { aggregates = await api_viewAggregate_overview(); }
catch { return <p role="alert">Die Grafikübersicht konnte nicht geladen werden. Bitte Backend-Verbindung und ausgewählte Anlage prüfen.</p>; }
const count = aggregates.reduce((sum, item) => sum + item.elemente.length, 0);
return <div>
<Link href="/rk2/visu-aggregate" className="text-sm underline">Zur VisuAggregate-Tabelle</Link>
<h1 className="my-3 text-xl font-semibold">Grafikübersicht</h1>
<p className="mb-4 text-sm text-gray-600">{count} Elemente in {aggregates.length} gespeicherten Aggregaten der ausgewählten Anlage. Angezeigt wird der gespeicherte Stand.</p>
{!aggregates.length && <p>Noch keine VisuAggregate gespeichert.</p>}
<div className="space-y-3">{aggregates.map(aggregate => <section key={aggregate.componentId} className="rounded border bg-white">
<div className="flex flex-wrap items-center justify-between gap-2 bg-gray-50 p-2">
<div><h2 className="text-sm font-semibold">{aggregate.antriebId} · {aggregate.name}</h2><p className="text-xs text-gray-500">{aggregate.viewName || 'Kein View-Name'}</p></div>
<Link className="text-sm underline" href={`/rk2/visu-aggregate/${aggregate.componentId}/grafiken`}>Grafiken bearbeiten</Link>
</div>
{!aggregate.elemente.length ? <p className="p-2 text-xs text-gray-500">Noch keine Grafikelemente.</p> : <div className="overflow-x-auto">
<table className="w-full border-collapse text-left text-xs">
<thead><tr>{['Element', 'Typ', 'Breite', 'Höhe', 'X', 'Y', 'Z', 'Sichtbar', 'Zustände / Dateien'].map(label =>
<th key={label} className="border-b p-2" scope="col">{label}</th>)}</tr></thead>
<tbody>{aggregate.elemente.map(element => <tr key={element._id ?? element.key} className="align-top">
<th scope="row" className="border-b p-2 font-medium">{element.key}{element.name && <span className="block font-normal text-gray-500">{element.name}</span>}</th>
<td className="border-b p-2">{element.typ}</td>
{[element.width, element.height, element.posX, element.posY, element.zIndex].map((value, index) => <td key={index} className="border-b p-2">{value}</td>)}
<td className="border-b p-2">{element.show ? 'Ja' : 'Nein'}</td>
<td className="border-b p-2">{element.darstellung === 'standard' ? <span className="text-gray-500">Standardanzeige · keine XAML</span>
: !element.varianten.length ? <span className="text-gray-500">Keine Zustände</span>
: <ul className="space-y-1">{element.varianten.map(variant => <li key={variant.zustand}>
<span className={variant.xamlBase64 ? 'text-green-700' : 'text-gray-500'}>{variant.zustand} · {variant.xamlBase64 ? 'XAML vorhanden' : 'ohne XAML'}</span>
<span className="block break-all text-gray-500">{aggregate.viewName}_{element.key}_{variant.zustand}.xaml</span>
</li>)}</ul>}</td>
</tr>)}</tbody>
</table>
</div>}
</section>)}</div>
</div>;
}
@@ -0,0 +1,19 @@
import { api_visuAggregate } from '@/actions/rk2/api-visu-aggregate';
import VisuAggregateTable from '@/components/rk2/visu-aggregate/visuAggregateTable';
import Breadcrumbs from '@/components/ui/navigation/breadcrumbs';
export default async function VisuAggregatePage() {
let rows;
try { rows = await api_visuAggregate(); }
catch {
return <div><h1 className="mb-4 text-xl font-semibold">VisuAggregate</h1>
<p role="alert">Die Tabelle konnte nicht geladen werden. Bitte die Backend-Verbindung und die ausgewählte Anlage prüfen und die Seite neu laden.</p></div>;
}
return <div>
<Breadcrumbs items={[{ label: 'Anlage', href: '/rk2' }, { label: 'VisuAggregate' }]} />
<h1 className="my-4 text-xl font-semibold">VisuAggregate</h1>
<p className="mb-4">Werte direkt in der Tabelle bearbeiten und je Zeile speichern. Weitere Spalten sind durch horizontales Scrollen erreichbar.</p>
<VisuAggregateTable rows={rows} />
</div>;
}