feat: Integration von CGI-Interface für dynamische Knotenpunktdaten in Produktionsumgebung

- Knotenpunkte.tsx angepasst: <script>-basierte Einbindung von kueDataX.js über CGI-Endpoint (/CPL?/CPL/Service/kueDataKnoten/kueDataX.js)
- Verwendung von window.kueNodeID zur Anzeige der dynamisch geladenen Daten
- Files in Browser DevTools > Sources sichtbar dank echter Script-Einbindung
- Platzhalterlose kueDataX.js-Dateien erstellt und eingebunden
- Produktionsbuild erfolgreich getestet und in /out-Verzeichnis übertragen
This commit is contained in:
ISA
2025-04-23 09:56:01 +02:00
parent 5aaedc346d
commit 83ff40f27f
68 changed files with 2477 additions and 54 deletions

View File

@@ -0,0 +1,41 @@
// pages/api/cpl/readKnotenpunktAPIHandler.ts
import fs from "fs";
import path from "path";
import { NextApiRequest, NextApiResponse } from "next";
/**
* API-Handler, um eine Knotenpunkt-Mockdatei für einen bestimmten Slot (031) als JavaScript zu laden.
* Diese Datei wird im Frontend als <script src="..."> eingebunden.
*/
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const { slot } = req.query;
const slotIndex = Number(slot);
// Sicherheitsprüfung
if (isNaN(slotIndex) || slotIndex < 0 || slotIndex > 31) {
return res.status(400).send("// ❌ Ungültiger Slot-Index");
}
const filePath = path.resolve(
process.cwd(),
`apiMockData/SERVICE/knotenpunkte/slot${slotIndex}.js`
);
// Datei vorhanden?
if (!fs.existsSync(filePath)) {
return res
.status(404)
.send(`// ❌ Datei slot${slotIndex}.js nicht gefunden`);
}
try {
const fileContent = fs.readFileSync(filePath, "utf8");
res.setHeader("Content-Type", "application/javascript");
res.status(200).send(fileContent);
} catch (error) {
console.error("Fehler beim Lesen der Knotenpunkt-Datei:", error);
res.status(500).send("// ❌ Fehler beim Lesen der Datei");
}
}