import React, { useState, useEffect } from "react"; import ReactModal from "react-modal"; import "bootstrap-icons/font/bootstrap-icons.css"; // Import Bootstrap Icons function SettingModal({ showModal, onClose }) { const [name, setName] = useState("CPLV4"); const [mac1, setMac1] = useState("0 48 86 81 46 157"); const [mac2, setMac2] = useState("0 48 86 81 46 158"); const [ip, setIp] = useState("10.10.0.118"); const [subnet, setSubnet] = useState("255.255.255.0"); const [gateway, setGateway] = useState("10.10.0.1"); const [systemUhr, setSystemUhr] = useState("16.10.24 15:27:23 Uhr"); const [ntp1, setNtp1] = useState("192.53.103.108"); const [ntp2, setNtp2] = useState("0.0.0.0"); const [ntp3, setNtp3] = useState("0.0.0.0"); const [zeitzone, setZeitzone] = useState("2"); const [activ, setActiv] = useState("1"); useEffect(() => { if (window.deviceName) setName(window.deviceName); if (window.mac1) setMac1(window.mac1); if (window.mac2) setMac2(window.mac2); if (window.ip) setIp(window.ip); if (window.subnet) setSubnet(window.subnet); if (window.gateway) setGateway(window.gateway); if (window.datetime) setSystemUhr(window.datetime); if (window.ntpServer1Ip) setNtp1(window.ntpServer1Ip); if (window.ntpServer2Ip) setNtp2(window.ntpServer2Ip); if (window.ntpServer3Ip) setNtp3(window.ntpServer3Ip); if (window.ntpTimezone) setZeitzone(window.ntpTimezone); if (window.ntpActive) setActiv(window.ntpActive); }, []); const handleSubmit = () => { const url = `CPL?SNNA=${name}&SEI01=${ip}&SEI02=${subnet}&SEI03=${gateway}&SNIP1=${ntp1}&SNIP2=${ntp2}&SNIP3=${ntp3}&SNTZ=${zeitzone}&SNAC=${activ}`; fetch(url) .then((response) => { if (response.ok) { alert("Daten erfolgreich gesendet!"); } else { alert("Fehler beim Senden der Daten!"); } }) .catch((error) => { console.error("Fehler:", error); alert("Fehler beim Senden der Daten!"); }); }; const handleReboot = () => { const rebootUrl = `CPL?BOOT=1`; fetch(rebootUrl) .then((response) => { if (response.ok) { alert( "Neustart Befehl erfolgreich gesendet! CPL wird neu gestartet." ); } else { alert("Fehler beim Senden des Neustart-Befehls!"); } }) .catch((error) => { console.error("Fehler:", error); alert("Fehler beim Senden des Neustart-Befehls!"); }); }; const handleClearDatabase = () => { const clearDbUrl = `CPL?DEDB=1`; fetch(clearDbUrl) .then((response) => { if (response.ok) { alert("Befehl zum Leeren der Datenbank erfolgreich gesendet!"); } else { alert("Fehler beim Senden des Befehls zum Leeren der Datenbank!"); } }) .catch((error) => { console.error("Fehler:", error); alert("Fehler beim Senden des Befehls zum Leeren der Datenbank!"); }); }; return ( {/* Close Icon */}

System:

setName(e.target.value)} />
setMac1(e.target.value)} />
setMac2(e.target.value)} />
setIp(e.target.value)} />
setSubnet(e.target.value)} />
setGateway(e.target.value)} />
{/* SNTP Client */}

SNTP Client:

setNtp1(e.target.value)} />
setNtp2(e.target.value)} />
setNtp3(e.target.value)} />
setZeitzone(e.target.value)} />
setActiv(e.target.value)} />
{/* Datenbank leeren und Neustart CPL */}
{/* Modal Footer */}
); } export default SettingModal;