Version 1.0.6.1
This commit is contained in:
122
components/settingsPageComponents/GeneralSettings.tsx
Normal file
122
components/settingsPageComponents/GeneralSettings.tsx
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import handleClearDatabase from "../modales/settingsModal/handlers/handleClearDatabase";
|
||||||
|
import handleReboot from "../modales/settingsModal/handlers/handleReboot";
|
||||||
|
import handleSetDateTime from "../modales/settingsModal/handlers/handleSetDateTime";
|
||||||
|
import handleSubmit from "../modales/settingsModal/handlers/handleSubmit";
|
||||||
|
|
||||||
|
const GeneralSettings = () => {
|
||||||
|
const deviceName_Redux = useSelector((state) => state.variables.deviceName);
|
||||||
|
const ip_Redux = useSelector((state) => state.variables.ip);
|
||||||
|
const subnet_Redux = useSelector((state) => state.variables.subnet);
|
||||||
|
const gateway_Redux = useSelector((state) => state.variables.gateway);
|
||||||
|
const datetime_Redux = useSelector(
|
||||||
|
(state) => state.variables.cplInternalTimestamp
|
||||||
|
);
|
||||||
|
const ntp1_Redux = useSelector((state) => state.variables.ntp1);
|
||||||
|
const ntp2_Redux = useSelector((state) => state.variables.ntp2);
|
||||||
|
const ntp3_Redux = useSelector((state) => state.variables.ntp3);
|
||||||
|
const ntpTimezone_Redux = useSelector((state) => state.variables.ntpTimezone);
|
||||||
|
const active_Redux = useSelector((state) => state.variables.ntpActive);
|
||||||
|
|
||||||
|
const [name, setName] = useState(deviceName_Redux || "");
|
||||||
|
const [ip, setIp] = useState(ip_Redux || "");
|
||||||
|
const [subnet, setSubnet] = useState(subnet_Redux || "");
|
||||||
|
const [gateway, setGateway] = useState(gateway_Redux || "");
|
||||||
|
const [systemUhr, setSystemUhr] = useState(datetime_Redux || "");
|
||||||
|
const [ntp1, setNtp1] = useState(ntp1_Redux || "");
|
||||||
|
const [ntp2, setNtp2] = useState(ntp2_Redux || "");
|
||||||
|
const [ntp3, setNtp3] = useState(ntp3_Redux || "");
|
||||||
|
const [ntpTimezone, setNtpTimezone] = useState(ntpTimezone_Redux || "");
|
||||||
|
const [active, setActive] = useState(active_Redux || "");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setName(deviceName_Redux || "");
|
||||||
|
setIp(ip_Redux || "");
|
||||||
|
setSubnet(subnet_Redux || "");
|
||||||
|
setGateway(gateway_Redux || "");
|
||||||
|
setSystemUhr(datetime_Redux || "");
|
||||||
|
setNtp1(ntp1_Redux || "");
|
||||||
|
setNtp2(ntp2_Redux || "");
|
||||||
|
setNtp3(ntp3_Redux || "");
|
||||||
|
setNtpTimezone(ntpTimezone_Redux || "");
|
||||||
|
setActive(active_Redux || "");
|
||||||
|
}, [
|
||||||
|
deviceName_Redux,
|
||||||
|
ip_Redux,
|
||||||
|
subnet_Redux,
|
||||||
|
gateway_Redux,
|
||||||
|
datetime_Redux,
|
||||||
|
ntp1_Redux,
|
||||||
|
ntp2_Redux,
|
||||||
|
ntp3_Redux,
|
||||||
|
ntpTimezone_Redux,
|
||||||
|
active_Redux,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-4 bg-gray-100">
|
||||||
|
<h2 className="text-lg font-bold mb-4">General Settings</h2>
|
||||||
|
<form>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium">Name:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="border border-gray-300 rounded p-2 w-full"
|
||||||
|
value={name}
|
||||||
|
onChange={(e) => setName(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-4 grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium">IP:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="border border-gray-300 rounded p-2 w-full"
|
||||||
|
value={ip}
|
||||||
|
onChange={(e) => setIp(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium">Subnet:</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="border border-gray-300 rounded p-2 w-full"
|
||||||
|
value={subnet}
|
||||||
|
onChange={(e) => setSubnet(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-between mt-4">
|
||||||
|
<button
|
||||||
|
className="bg-blue-500 text-white px-4 py-2 rounded"
|
||||||
|
onClick={() => handleReboot()}
|
||||||
|
>
|
||||||
|
Neustart CPL
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="bg-blue-500 text-white px-4 py-2 rounded"
|
||||||
|
onClick={() => handleClearDatabase()}
|
||||||
|
>
|
||||||
|
Datenbank leeren
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
handleSubmit(
|
||||||
|
{ name, ip, subnet, gateway },
|
||||||
|
{ name: deviceName_Redux, ip: ip_Redux, subnet: subnet_Redux }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="bg-blue-500 text-white px-4 py-2 rounded"
|
||||||
|
>
|
||||||
|
Übernehmen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GeneralSettings;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function OPCUAInterfaceSettings() {
|
||||||
|
return <div>OPCUAInterfaceSettings</div>;
|
||||||
|
}
|
||||||
@@ -209,7 +209,7 @@ function Dashboard() {
|
|||||||
className="text-xl lg:text-base text-blue-400"
|
className="text-xl lg:text-base text-blue-400"
|
||||||
/>
|
/>
|
||||||
<p className="text-sm sm:text-xs md:text-sm lg:text-base text-gray-600">
|
<p className="text-sm sm:text-xs md:text-sm lg:text-base text-gray-600">
|
||||||
<span className="font-bold"></span> Webserverversion: 1.0.6.0
|
<span className="font-bold"></span> Webserverversion: 1.0.6.1
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,41 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
|
import GeneralSettings from "../components/settingsPageComponents/generalSettings";
|
||||||
|
import OPCUAInterfaceSettings from "../components/settingsPageComponents/OPCUAInterfaceSettings";
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
return <div>Settings</div>;
|
const [activeTab, setActiveTab] = useState("tab1");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-4">
|
||||||
|
{/* Tab-Navigation */}
|
||||||
|
<div className="flex border-b border-gray-200">
|
||||||
|
<button
|
||||||
|
className={`px-4 py-2 ${
|
||||||
|
activeTab === "tab1"
|
||||||
|
? "border-b-2 border-blue-500 text-blue-500"
|
||||||
|
: ""
|
||||||
|
}`}
|
||||||
|
onClick={() => setActiveTab("tab1")}
|
||||||
|
>
|
||||||
|
Allgemeine Einstellung
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`px-4 py-2 ${
|
||||||
|
activeTab === "tab2"
|
||||||
|
? "border-b-2 border-blue-500 text-blue-500"
|
||||||
|
: ""
|
||||||
|
}`}
|
||||||
|
onClick={() => setActiveTab("tab2")}
|
||||||
|
>
|
||||||
|
OPCUA
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tab-Inhalt */}
|
||||||
|
<div className="mt-4">
|
||||||
|
{activeTab === "tab1" && <GeneralSettings />}
|
||||||
|
{activeTab === "tab2" && <OPCUAInterfaceSettings />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user