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:
@@ -1,16 +1,11 @@
|
||||
// components/modales/kueModal/pages/Knotenpunkte.tsx
|
||||
"use client";
|
||||
// components/modales/kueModal/pages/Knotenpunkte.tsx
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
leseKnotenpunkte?: (slotIndex: number) => void;
|
||||
knotenData?: {
|
||||
nodeIDs: string[];
|
||||
linkIDs: string[];
|
||||
linkLengths: number[];
|
||||
};
|
||||
kueNodeID?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,25 +18,27 @@ export default function Knotenpunkte({ slot }: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
const slotIndex = slot;
|
||||
const isDev =
|
||||
typeof window !== "undefined" && window.location.hostname === "localhost";
|
||||
|
||||
const scriptUrl = isDev
|
||||
? `/api/cpl/readKnotenpunktAPIHandler?slot=${slotIndex}`
|
||||
: `/CPL?/CPL/Service/kueDataKnoten/kueData${slotIndex}.js`;
|
||||
|
||||
// Schritt 1: Lade kueDataX.js vom CPL (oder Mock im Dev)
|
||||
const script = document.createElement("script");
|
||||
script.src = `/CPL?Service/kueData${slotIndex}.js`; // z. B. kueData0.js
|
||||
script.src = scriptUrl;
|
||||
script.async = true;
|
||||
|
||||
script.onload = () => {
|
||||
// Schritt 2: Lade Hilfs-Loader (dein JS zum Auslesen)
|
||||
const loaderScript = document.createElement("script");
|
||||
loaderScript.src = "/js/knotenAuslesen.js";
|
||||
loaderScript.async = true;
|
||||
loaderScript.onload = () => {
|
||||
if (typeof window.leseKnotenpunkte === "function") {
|
||||
window.leseKnotenpunkte(slotIndex);
|
||||
const knoten = window.knotenData?.nodeIDs ?? [];
|
||||
setKnotenNamen(knoten);
|
||||
}
|
||||
};
|
||||
document.body.appendChild(loaderScript);
|
||||
console.log("✅ Script geladen:", scriptUrl);
|
||||
const werte = window.kueNodeID ?? [];
|
||||
setKnotenNamen(werte);
|
||||
};
|
||||
|
||||
script.onerror = () => {
|
||||
console.error("❌ Fehler beim Laden von:", scriptUrl);
|
||||
};
|
||||
|
||||
document.body.appendChild(script);
|
||||
|
||||
return () => {
|
||||
@@ -51,9 +48,6 @@ export default function Knotenpunkte({ slot }: Props) {
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-lg font-semibold mb-2">
|
||||
Knotenpunkte – Slot {slot + 1}
|
||||
</h2>
|
||||
{knotenNamen.map((value, index) => (
|
||||
<div key={index} className="flex gap-2 items-center">
|
||||
<label className="w-24 text-right">Knoten {index + 1}:</label>
|
||||
|
||||
Reference in New Issue
Block a user