diverse änderungen

This commit is contained in:
marco committed 2026-11-05 15:17:01 +01:00
1 parent 0e7b53e558
commit 54d5e58798
60 files changed
+1637 -122

No files matched your search

@@ -1,5 +1,6 @@
import Link from 'next/link';
import { api_ProconAggregate_Visualisierungen } from '@/actions/procon/api-procon-aggregate';
import AggregateSourceInfo from '@/components/procon/aggregateSourceInfo';
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
@@ -8,11 +9,14 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
try {
const { aggregat: aggregate, visualisierungen } = await api_ProconAggregate_Visualisierungen(Number(id));
return <div>{back}
<h2 className="my-3 text-xl font-semibold">{aggregate.SPSAntriebId} · {aggregate.Bezeichnung}</h2>
<h1 className="my-3 text-xl font-semibold">ProCon-Visualisierungen (SQL)</h1>
<h2 className="mb-3 font-semibold">SPS-Antrieb {aggregate.SPSAntriebId} · {aggregate.Bezeichnung}</h2>
<p className="mb-3 text-sm">Diese Ansicht zeigt den gespeicherten Stand der verbundenen ProCon-SQL-Datenbank. Eigene Grafiken erstellst du in MongoDB; die gemeinsame Arbeitsfläche dient zum Vergleichen und Abgleichen.</p>
<dl className="mb-4 grid grid-cols-2 gap-3 rounded border bg-gray-50 p-3 md:grid-cols-4">
{[['Datenbank-ID', aggregate.Id], ['BMK', aggregate.BMK], ['View', aggregate.ViewName], ['Motoren', aggregate.AnzahlMotor]].map(([label, value]) =>
{[['ProCon-Aggregat-ID (SQL)', aggregate.Id], ['BMK', aggregate.BMK], ['View', aggregate.ViewName], ['Motoren', aggregate.AnzahlMotor]].map(([label, value]) =>
<div key={label}><dt className="text-xs text-gray-500">{label}</dt><dd className="break-all text-sm">{value ?? '—'}</dd></div>)}
</dl>
<AggregateSourceInfo source="sql" id={id} spsAntriebId={aggregate.SPSAntriebId} />
<h3 className="mb-2 font-semibold">Visualisierungen ({visualisierungen.length})</h3>
<Link className="mb-3 inline-block rounded border bg-blue-600 px-3 py-2 text-sm text-white" href={`/procon/aggregate/${id}/arbeitsflaeche`}>Gemeinsame Arbeitsfläche öffnen</Link>
{!visualisierungen.length ? <p>Für dieses Aggregat sind keine Visualisierungen vorhanden.</p> : <div className="overflow-auto rounded border">
+9
View File
@@ -0,0 +1,9 @@
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
import { AnlagePdfViewer } from '@/components/rk/anlage/anlagePdfViewer';
export default async function Page({ searchParams }: { searchParams: Promise<{ unit?: string }> }) {
const anlage = await api_anlage_getSelected();
if (!anlage?.id) return <p className="p-4">Bitte zuerst eine Anlage auswählen.</p>;
const { unit } = await searchParams;
return <AnlagePdfViewer key={anlage.id} anlage={anlage} initialUnitId={unit} />;
}
+1 -1
View File
@@ -3,6 +3,6 @@ export async function GET() {
const response = await fetch('http://localhost:3000/rk2/anzeigewerte/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="Anzeigewerte.xlsx"', 'Cache-Control': 'no-store' } });
'Content-Disposition': 'attachment; filename="AllgemeinAnlagenVisualisierung.xlsx"', 'Cache-Control': 'no-store' } });
} catch { return new Response('Keine Verbindung zum Backend', { status: 502 }); }
}
@@ -0,0 +1,37 @@
import { NextRequest } from 'next/server';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
type Context = { params: Promise<{ id: string; path?: string[] }> };
async function proxy(request: NextRequest, context: Context) {
const { id, path = [] } = await context.params;
if (!/^[a-f\d]{24}$/i.test(id) || !(
path.length === 0 || path.length === 1 && ['file', 'units'].includes(path[0]) ||
path.length === 2 && path[0] === 'units' && /^[a-f\d]{24}$/i.test(path[1])
)) return Response.json({ message: 'Ungültiger PDF-Pfad' }, { status: 400 });
const url = new URL(`http://localhost:3000/anlage/${id}/pdf${path.length ? '/' + path.join('/') : ''}`);
url.search = request.nextUrl.search;
const headers = new Headers();
for (const name of ['content-type', 'range', 'if-range']) {
const value = request.headers.get(name);
if (value) headers.set(name, value);
}
try {
const response = await fetch(url, {
method: request.method, headers, cache: 'no-store',
body: request.method === 'GET' ? undefined : await request.arrayBuffer(),
});
const outgoing = new Headers({ 'Cache-Control': 'no-store' });
for (const name of ['content-type', 'content-length', 'content-range', 'accept-ranges']) {
const value = response.headers.get(name);
if (value) outgoing.set(name, value);
}
return new Response(response.body, { status: response.status, headers: outgoing });
} catch {
return Response.json({ message: 'Keine Verbindung zum Backend' }, { status: 502 });
}
}
export { proxy as GET, proxy as POST, proxy as PATCH };
+18
View File
@@ -0,0 +1,18 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
export const runtime = 'nodejs';
export async function GET(_request: Request, { params }: { params: Promise<{ path: string[] }> }) {
const { path } = await params;
const worker = path.length === 1 && path[0] === 'pdf.worker.min.mjs';
const resource = path.length === 2 && ['cmaps', 'standard_fonts', 'wasm'].includes(path[0]) && /^[\w.-]+$/.test(path[1]);
if (!worker && !resource) return new Response(null, { status: 404 });
try {
const file = await readFile(join(process.cwd(), 'node_modules/pdfjs-dist', ...(worker ? ['build', path[0]] : path)));
return new Response(file, { headers: {
'Content-Type': worker ? 'text/javascript' : path.at(-1)?.endsWith('.wasm') ? 'application/wasm' : 'application/octet-stream',
'Cache-Control': 'no-cache',
} });
} catch { return new Response(null, { status: 404 }); }
}
+20 -2
View File
@@ -29,7 +29,9 @@ export default async function AssignmentsPage() {
return names;
};
const rows: AssignmentRow[] = signals.filter((signal) => signal.anlageId === anlage.id && signal.ioId).map((signal) => {
const plantSignals = signals.filter(signal => signal.anlageId === anlage.id);
const assignedIoIds = new Set(plantSignals.map(signal => signal.ioId).filter(Boolean));
const rows: AssignmentRow[] = plantSignals.map((signal) => {
const context = signal.componentId ? componentMap.get(signal.componentId) : undefined;
const io = ioMap.get(signal.ioId!);
return {
@@ -48,12 +50,28 @@ export default async function AssignmentsPage() {
byte: io?.adrByte,
bit: io?.adrBit,
functionText: io?.functionText ?? '',
pageReference: io?.seiteName ?? '',
description: signal.description ?? '',
signalType: signal.type,
status: !signal.ioId ? 'Signal ohne IO' : !io ? 'IO nicht gefunden' : signal.type !== io.adrType ? 'Typabweichung' : 'Zugeordnet',
assigned: !!io,
};
});
for (const io of ioMap.values()) {
if (assignedIoIds.has(io.id)) continue;
rows.push({
id: `io-${io.id}`, type: io.adrType, byte: io.adrByte, bit: io.adrBit,
functionText: io.functionText ?? '', pageReference: io.seiteName ?? '',
group: '', bmk: '', unit: '', component: '', signal: '', signalType: '', description: '',
status: 'IO ohne Signal', assigned: false,
exportName: '', variableTable: '', exportComment: '',
});
}
return <div className="m-4">
<Breadcrumbs items={[{ label: 'Signale', href: '/signals' }, { label: 'Alle Zuordnungen' }, { label: `${anlage.anlageNr} ${anlage.name}` }]} />
<h1 className="my-4 text-xl font-semibold">IO-Zuordnungen ({rows.length})</h1>
<h1 className="my-4 text-xl font-semibold">MongoDB-IOs / meine Signale</h1>
<p className="mb-3">Alle IOs und Signale der ausgewählten Anlage. Abgleich über die gespeicherte IO-Zuordnung; IOs ohne Signal und Signale ohne IO bleiben sichtbar.</p>
<Link className="mb-4 inline-block underline" href="/signals/assignment">Zuordnungen bearbeiten</Link>
<AssignmentsTable rows={rows} />
</div>;
+3
View File
@@ -24,6 +24,9 @@ export default async function PageSignale() {
<div className="flex flex-col m-4 w-170 ">
<List variant={"default"} size={"lg"} >
<ListItem hover={true}>
<Link href="/signals/assignments">MongoDB-IOs / meine Signale vergleichen</Link>
</ListItem>
<ListItem hover={true}>
<Link href="/signals/assignments">Alle IO-Zuordnungen</Link>
</ListItem>
@@ -1,13 +1,17 @@
import Link from 'next/link';
import { api_viewAggregate } from '@/actions/rk2/api-procon-view-aggregate';
import ViewAggregateForm from '@/components/rk2/visu-aggregate/viewAggregateForm';
import AggregateSourceInfo from '@/components/procon/aggregateSourceInfo';
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="/visu-aggregate" className="underline">Zurück zu VisuAggregate</Link>
<h1 className="my-4 text-xl font-semibold">Grafiken – {data.name}</h1>
<h1 className="my-4 text-xl font-semibold">Eigene Grafiken (MongoDB) – {data.name}</h1>
<p className="mb-3 text-sm">Hier erstellst und speicherst du deine Hauptgrafik, Pfeile und weiteren Grafikelemente in MongoDB. Änderungen werden über Export/Import oder Abgleich nach ProCon übertragen.</p>
<p className="mb-3 break-all text-xs text-slate-600">Unit-Komponenten-ID: {componentId} · View: {data.viewName || 'Nicht vergeben'}</p>
<AggregateSourceInfo source="mongo" id={data.visuAggregateId} />
<ViewAggregateForm componentId={componentId} initial={data} />
</div>;
} catch (error) {