diff --git a/components/modales/SettingsModal.jsx b/components/modales/SettingsModal.jsx index fa58abd..b25ee34 100644 --- a/components/modales/SettingsModal.jsx +++ b/components/modales/SettingsModal.jsx @@ -1,5 +1,6 @@ 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"); @@ -15,7 +16,6 @@ function SettingModal({ showModal, onClose }) { const [zeitzone, setZeitzone] = useState("2"); const [activ, setActiv] = useState("1"); - // UseEffect to get initial values from window object useEffect(() => { if (window.deviceName) setName(window.deviceName); if (window.mac1) setMac1(window.mac1); @@ -34,7 +34,6 @@ function SettingModal({ showModal, onClose }) { const handleSubmit = () => { const url = `CPL?SNNA=${name}&SEI01=${ip}&SEI02=${subnet}&SEI03=${gateway}&SNIP1=${ntp1}&SNIP2=${ntp2}&SNIP3=${ntp3}&SNTZ=${zeitzone}&SNAC=${activ}`; - // Send data to the server fetch(url) .then((response) => { if (response.ok) { @@ -49,6 +48,42 @@ function SettingModal({ showModal, onClose }) { }); }; + 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:

@@ -82,7 +134,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={name} - onChange={(e) => setName(e.target.value)} // Update state on change + onChange={(e) => setName(e.target.value)} />
@@ -95,7 +147,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={mac1} - onChange={(e) => setMac1(e.target.value)} // Update state on change + onChange={(e) => setMac1(e.target.value)} />
@@ -106,7 +158,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={mac2} - onChange={(e) => setMac2(e.target.value)} // Update state on change + onChange={(e) => setMac2(e.target.value)} />
@@ -118,7 +170,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={ip} - onChange={(e) => setIp(e.target.value)} // Update state on change + onChange={(e) => setIp(e.target.value)} />
@@ -127,7 +179,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={subnet} - onChange={(e) => setSubnet(e.target.value)} // Update state on change + onChange={(e) => setSubnet(e.target.value)} />
@@ -139,7 +191,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={gateway} - onChange={(e) => setGateway(e.target.value)} // Update state on change + onChange={(e) => setGateway(e.target.value)} />
@@ -148,7 +200,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={systemUhr} - disabled // Disable input to make it non-editable + disabled />
@@ -164,7 +216,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={ntp1} - onChange={(e) => setNtp1(e.target.value)} // Update state on change + onChange={(e) => setNtp1(e.target.value)} />
@@ -175,7 +227,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={ntp2} - onChange={(e) => setNtp2(e.target.value)} // Update state on change + onChange={(e) => setNtp2(e.target.value)} />
@@ -186,7 +238,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={ntp3} - onChange={(e) => setNtp3(e.target.value)} // Update state on change + onChange={(e) => setNtp3(e.target.value)} />
@@ -195,7 +247,7 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={zeitzone} - onChange={(e) => setZeitzone(e.target.value)} // Update state on change + onChange={(e) => setZeitzone(e.target.value)} />
@@ -204,16 +256,16 @@ function SettingModal({ showModal, onClose }) { type="text" className="border border-gray-300 rounded p-2 w-full" value={activ} - onChange={(e) => setActiv(e.target.value)} // Update state on change + onChange={(e) => setActiv(e.target.value)} />
{/* Datenbank leeren und Neustart CPL */} -
+
@@ -223,22 +275,16 @@ function SettingModal({ showModal, onClose }) {
-