diff --git a/components/main/kabelueberwachung/kue705FO/modals/TdrEinstellung.tsx b/components/main/kabelueberwachung/kue705FO/modals/TdrEinstellung.tsx index b16f313..478d847 100644 --- a/components/main/kabelueberwachung/kue705FO/modals/TdrEinstellung.tsx +++ b/components/main/kabelueberwachung/kue705FO/modals/TdrEinstellung.tsx @@ -1,10 +1,13 @@ "use client"; - +// /components/main/kabelueberwachung/kue705FO/modals/TdrEinstellung.tsx import React, { useState, useEffect } from "react"; declare global { interface Window { win_tdrActive?: number[]; + win_tdrAmp?: string[]; + win_tdrPulse?: string[]; + win_tdrTrigger?: string[]; } } @@ -14,25 +17,41 @@ interface Props { export default function TdrEinstellung({ slot }: Props) { const [tdrActive, setTdrActive] = useState(false); - const [params, setParams] = useState({ + const [tdrData, setTdrData] = useState({ verstarkung: "", pulsweite: "", trigger: "", }); useEffect(() => { - if ( - typeof window !== "undefined" && - Array.isArray(window.win_tdrActive) && - typeof window.win_tdrActive[slot] !== "undefined" - ) { - const status = parseInt(String(window.win_tdrActive[slot])); - setTdrActive(status === 1); - } else { - console.warn("⚠️ win_tdrActive ist nicht definiert oder Slot ungültig"); + if (typeof window !== "undefined") { + if (Array.isArray(window.win_tdrActive)) { + const status = parseInt(String(window.win_tdrActive[slot])); + setTdrActive(status === 1); + } + setTdrData({ + verstarkung: window.win_tdrAmp?.[slot] ?? "", + pulsweite: window.win_tdrPulse?.[slot] ?? "", + trigger: window.win_tdrTrigger?.[slot] ?? "", + }); } }, [slot]); + const handleSave = () => { + const v = tdrData.verstarkung.trim(); + const p = tdrData.pulsweite.trim(); + const t = tdrData.trigger.trim(); + + if (!v || !p || !t) { + alert("Bitte alle Felder ausfüllen."); + return; + } + + const url = `/CPL?KTT${slot}=0&V=${v}&P=${p}&T=${t}`; + alert(`Sende: ${url}`); + window.location.href = url; + }; + return (