WIP: Kues Nodes

This commit is contained in:
ISA
2025-04-22 15:22:54 +02:00
parent 8309efea20
commit 6f4f916421
6 changed files with 140 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
var kueNodeID = [
"1 Line 1",
"1 Line 2",
"1 Line 3",
"1 Line 4",
"1 Line 5",
"1 Line 6",
"1 Line 7",
"1 Line 8",
"1 Line 9",
"1 Line 10",
];
var kueLinkID = [
"Link 1 1",
"Link 1-2",
"Link 1 3",
"Link 1 4",
"Link 1 5",
"Link 1 6",
"Link 1 7",
"Link 1 8",
"Link 1 9",
"",
];
var kueLinkLength = [11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 0.0];
var kueLinkStatus = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -1,9 +1,86 @@
import React from "react";
// components/modales/kueModal/pages/Knotenpunkte.tsx
"use client";
import React, { useEffect, useState } from "react";
declare global {
interface Window {
leseKnotenpunkte?: (slotIndex: number) => void;
knotenData?: {
nodeIDs: string[];
linkIDs: string[];
linkLengths: number[];
};
}
}
interface Props {
slot: number;
}
export default function Knotenpunkte({ slot }: Props) {
return <div>Knotenpunkte Slot {slot + 1}</div>;
const [knotenNamen, setKnotenNamen] = useState<string[]>(Array(10).fill(""));
useEffect(() => {
const slotIndex = slot;
// 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.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);
};
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, [slot]);
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>
<input
type="text"
className="border border-gray-300 rounded px-2 py-1 w-full"
value={value}
onChange={(e) => {
const updated = [...knotenNamen];
updated[index] = e.target.value;
setKnotenNamen(updated);
}}
/>
</div>
))}
<div className="flex justify-end mt-4">
<button
onClick={() => {
alert("💾 Speichern kommt später jetzt nur Anzeige.");
console.log("Daten zum Speichern:", knotenNamen);
}}
className="bg-littwin-blue text-white px-4 py-2 rounded shadow hover:bg-blue-600 transition"
>
💾 Speichern
</button>
</div>
</div>
);
}

View File

@@ -6,5 +6,5 @@
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
*/
const webVersion = "1.6.252";
const webVersion = "1.6.253";
export default webVersion;

View File

@@ -0,0 +1,30 @@
// public/CPL/SERVICE/knotenAuslesen.js
window.knotenData = {
nodeIDs: [],
linkIDs: [],
linkLengths: [],
};
function leseKnotenpunkte(slotIndex) {
try {
for (let i = 0; i < 10; i++) {
const node = window.kueNodeID?.[i] ?? "";
window.knotenData.nodeIDs[i] = node;
}
for (let i = 0; i < 10; i++) {
const link = window.kueLinkID?.[i] ?? "";
window.knotenData.linkIDs[i] = link;
}
for (let i = 0; i < 10; i++) {
const length = window.kueLinkLength?.[i] ?? "";
window.knotenData.linkLengths[i] = length;
}
console.log("✅ Knotenpunkte geladen:", window.knotenData);
} catch (error) {
console.error("❌ Fehler beim Laden der Knotenpunkte:", error);
}
}

View File

@@ -0,0 +1,4 @@
// public/CPL/SERVICE/knotenpunkteTemplate.js
var KNA01 = "<%= KNA01 %>";
var KNB01 = "<%= KNB01 %>";
// ...