umstellung auf claud
This commit is contained in:
1 parent
79c5f0c5cd
commit
5bb4e063da
171 files changed
+5471
-1333
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import Link from 'next/link';
|
||||
import { notFound, redirect } from 'next/navigation';
|
||||
import { api_anlagen_getAll, api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
import { api_units } from '@/actions/rk2/api-units';
|
||||
import { api_groups } from '@/actions/rk2/api-groups';
|
||||
import AnlageUnitSummary from '@/components/rk/anlage/anlageUnitSummary';
|
||||
|
||||
const sections = [
|
||||
{ href: '/units', title: 'Units' },
|
||||
{ href: '/groups', title: 'Gruppen' },
|
||||
{ href: '/ablaeufe', title: 'Abläufe' },
|
||||
{ href: '/procon', title: 'ProCon' },
|
||||
{ href: '/visualisierung', title: 'Visualisierung' },
|
||||
];
|
||||
|
||||
export default async function AnlagenOverviewPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const anlagen = await api_anlagen_getAll();
|
||||
const anlage = anlagen.find(item => item.id === id);
|
||||
|
||||
if (!anlage) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const selected = await api_anlage_getSelected();
|
||||
|
||||
// Ein alter Link darf keine Daten einer inzwischen anderen aktiven Anlage zeigen.
|
||||
if (selected?.id !== id) {
|
||||
redirect('/projekte');
|
||||
}
|
||||
|
||||
const [units, groups] = await Promise.all([api_units(), api_groups()]);
|
||||
const current = await api_anlage_getSelected();
|
||||
if (current?.id !== id || units.some(unit => unit.anlageId && unit.anlageId !== id)) {
|
||||
redirect('/projekte');
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="mx-auto max-w-6xl space-y-6">
|
||||
<header>
|
||||
<p className="text-sm text-slate-500">Anlage {anlage.anlageNr}</p>
|
||||
<h1 className="text-2xl font-semibold">Übersicht</h1>
|
||||
<p className="mt-1 text-slate-600">{anlage.name}</p>
|
||||
</header>
|
||||
|
||||
<nav aria-label="Anlagenbereiche" className="flex flex-wrap gap-1 rounded-lg border bg-slate-50 p-1">
|
||||
{sections.map(section => (
|
||||
<Link
|
||||
key={section.href}
|
||||
href={section.href}
|
||||
className="rounded px-4 py-2 text-sm font-medium hover:bg-blue-100 focus-visible:outline-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
{section.title}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<AnlageUnitSummary units={units} groups={groups} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
|
||||
export default async function SettingsLayout({ children }: { children: ReactNode }) {
|
||||
const anlage = await api_anlage_getSelected();
|
||||
if (!anlage?.id) {
|
||||
redirect('/projekte');
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { BACKEND_URL } from '@/_config/backend';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const params = new URL(request.url).searchParams;
|
||||
const id = params.get('id');
|
||||
const anlageId = params.get('anlageId');
|
||||
|
||||
if (!id || !anlageId) {
|
||||
return new Response('Verbindung fehlt', { status: 400 });
|
||||
}
|
||||
|
||||
const certificateUrl = `${BACKEND_URL}/rk2/opcua/${encodeURIComponent(id)}/certificate`
|
||||
+ `?anlageId=${encodeURIComponent(anlageId)}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(certificateUrl, { cache: 'no-store' });
|
||||
|
||||
if (!response.ok) {
|
||||
return new Response('Zertifikat konnte nicht geladen werden. Anlage und Verbindung pruefen.', {
|
||||
status: response.status,
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(response.body, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-pem-file',
|
||||
'Content-Disposition': 'attachment; filename="RK-OpcUaClient.pem"',
|
||||
'Cache-Control': 'no-store',
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return new Response('Backend nicht erreichbar', { status: 502 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { api_opcConfiguration } from '@/actions/opcua/api-opcua';
|
||||
import OpcPanel from '@/components/opcua/opcPanel';
|
||||
|
||||
export default async function OpcSettingsPage() {
|
||||
try {
|
||||
const configuration = await api_opcConfiguration();
|
||||
return <OpcPanel initial={configuration} />;
|
||||
} catch {
|
||||
return <p role="alert">OPC-Konfiguration konnte nicht geladen werden.</p>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import Link from 'next/link';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
|
||||
const settings = [
|
||||
{
|
||||
href: '/anlagen/einstellungen/pdf',
|
||||
title: 'Anlagen-PDF',
|
||||
description: 'PDF auswählen, hochladen oder ersetzen und Seiten den Units zuordnen.',
|
||||
},
|
||||
{
|
||||
href: '/anlagen/einstellungen/procon',
|
||||
title: 'ProCon-Verbindungen',
|
||||
description: 'Datenbankverbindungen der aktiven Anlage verwalten.',
|
||||
},
|
||||
{
|
||||
href: '/anlagen/einstellungen/opcua',
|
||||
title: 'OPC-Verbindungen',
|
||||
description: 'OPC-UA-Verbindungen und Sicherheit konfigurieren und die Verbindung prüfen.',
|
||||
},
|
||||
];
|
||||
|
||||
export default async function AnlagenEinstellungenPage() {
|
||||
const anlage = await api_anlage_getSelected();
|
||||
if (!anlage?.id) {
|
||||
redirect('/projekte');
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="max-w-3xl space-y-6">
|
||||
<header>
|
||||
<h1 className="text-2xl font-semibold">Anlageneinstellungen</h1>
|
||||
<p className="mt-1 text-slate-600">Anlage {anlage.anlageNr} · {anlage.name}</p>
|
||||
</header>
|
||||
<div className="grid gap-4">
|
||||
{settings.map(setting => (
|
||||
<Link
|
||||
key={setting.href}
|
||||
href={setting.href}
|
||||
className="block rounded-lg border p-5 hover:border-blue-500 hover:bg-blue-50 focus-visible:outline-2 focus-visible:outline-blue-600"
|
||||
>
|
||||
<h2 className="font-semibold">{setting.title}</h2>
|
||||
<p className="mt-2 text-sm text-slate-600">{setting.description}</p>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
import { AnlagePdfViewer } from '@/components/rk/anlage/anlagePdfViewer';
|
||||
|
||||
export default async function AnlagenPdfSettingsPage({ searchParams }: {
|
||||
searchParams: Promise<{ unit?: string }>;
|
||||
}) {
|
||||
const anlage = await api_anlage_getSelected();
|
||||
const { unit } = await searchParams;
|
||||
|
||||
return <AnlagePdfViewer key={anlage.id} anlage={anlage} initialUnitId={unit} />;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
import { api_connections } from '@/actions/rk/api-procon-verbindungen';
|
||||
import ProConConnectionsForm from '@/components/rk/anlage/proconConnections';
|
||||
|
||||
export default async function ProConSettingsPage() {
|
||||
try {
|
||||
const anlage = await api_anlage_getSelected();
|
||||
const connections = await api_connections(anlage.id);
|
||||
return <ProConConnectionsForm initial={connections} />;
|
||||
} catch {
|
||||
return <p role="alert">ProCon-Verbindungen konnten nicht geladen werden.</p>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
|
||||
export default async function SelectedAnlagePage() {
|
||||
const anlage = await api_anlage_getSelected();
|
||||
redirect(anlage?.id ? `/anlagen/${anlage.id}` : '/projekte');
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { api_anlage_getSelected } from '@/actions/rk/api-anlage';
|
||||
import { AnlagePdfViewer } from '@/components/rk/anlage/anlagePdfViewer';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
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} />;
|
||||
export default async function PreviousPdfPage({ searchParams }: {
|
||||
searchParams: Promise<{ unit?: string }>;
|
||||
}) {
|
||||
const { unit } = await searchParams;
|
||||
const query = unit ? '?unit=' + encodeURIComponent(unit) : '';
|
||||
redirect('/anlagen/einstellungen/pdf' + query);
|
||||
}
|
||||
Reference in new issue
Block a user