esLint
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import { useSelector } from "react-redux";
|
||||
import handleClearDatabase from "./handlers/dbHandlers/handleClearDatabase";
|
||||
|
||||
import handleReboot from "./handlers/handleReboot";
|
||||
import handleSetDateTime from "./handlers/handleSetDateTime";
|
||||
import { useAdminAuth } from "./hooks/useAdminAuth";
|
||||
import handleAdminLogin from "./handlers/handleAdminLogin";
|
||||
// import { useAdminAuth } from "./hooks/useAdminAuth";
|
||||
// import handleAdminLogin from "./handlers/handleAdminLogin";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { AppDispatch } from "../../../redux/store";
|
||||
import { getSystemSettingsThunk } from "../../../redux/thunks/getSystemSettingsThunk";
|
||||
@@ -18,12 +18,7 @@ const GeneralSettings: React.FC = () => {
|
||||
(state: RootState) => state.systemSettingsSlice
|
||||
);
|
||||
|
||||
const { isAdminLoggedIn, logoutAdmin } = useAdminAuth(true);
|
||||
const [loginSuccess, setLoginSuccess] = useState(false);
|
||||
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
// const [error, setError] = useState("");
|
||||
|
||||
const [name, setName] = useState(systemSettings.deviceName || "");
|
||||
const [mac1, setMac1] = useState(systemSettings.mac1 || "");
|
||||
@@ -34,26 +29,14 @@ const GeneralSettings: React.FC = () => {
|
||||
systemSettings.cplInternalTimestamp || ""
|
||||
);
|
||||
|
||||
const handleLogin = async () => {
|
||||
handleAdminLogin(
|
||||
username,
|
||||
password,
|
||||
() => {
|
||||
setLoginSuccess(true);
|
||||
setError("");
|
||||
},
|
||||
(errorMsg) => {
|
||||
setLoginSuccess(false);
|
||||
setError(errorMsg);
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
};
|
||||
// Add loginSuccess state if you want to use it for feedback
|
||||
// const [loginSuccess, setLoginSuccess] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!systemSettings.deviceName) {
|
||||
dispatch(getSystemSettingsThunk());
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
/*
|
||||
fix: Initialwerte in Allgemeine Einstellungen bei Seitenaufruf setzen
|
||||
@@ -198,10 +181,7 @@ const GeneralSettings: React.FC = () => {
|
||||
*/}
|
||||
|
||||
{/* Feedback */}
|
||||
{loginSuccess && (
|
||||
<p className="text-green-600 text-xs">Login erfolgreich!</p>
|
||||
)}
|
||||
{error && <p className="text-red-500 text-xs">{error}</p>}
|
||||
{/* You can add feedback here if needed */}
|
||||
|
||||
{/* Buttons */}
|
||||
<div className="col-span-2 flex flex-wrap md:justify-between gap-1 mt-2">
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../../../redux/store";
|
||||
|
||||
import handleNtpSubmit from "./handlers/handleNtpSubmit";
|
||||
|
||||
const NTPSettings: React.FC = () => {
|
||||
const dispatch = useDispatch();
|
||||
const systemSettings = useSelector(
|
||||
(state: RootState) => state.systemSettingsSlice
|
||||
);
|
||||
|
||||
// Lokale States mit Fallback-Werten absichern
|
||||
const [ntp1, setNtp1] = React.useState(systemSettings?.ntp1 ?? "");
|
||||
const [ntp2, setNtp2] = React.useState(systemSettings?.ntp2 ?? "");
|
||||
const [ntp3, setNtp3] = React.useState(systemSettings?.ntp3 ?? "");
|
||||
const [ntpTimezone, setNtpTimezone] = React.useState(
|
||||
systemSettings?.ntpTimezone ?? ""
|
||||
);
|
||||
const [active, setActive] = React.useState(
|
||||
systemSettings?.ntpActive ?? false
|
||||
);
|
||||
|
||||
// Wenn Daten noch nicht geladen sind, Ladeanzeige anzeigen
|
||||
if (!systemSettings || systemSettings.ntp1 === undefined) {
|
||||
return <p className="text-xs text-gray-500">Lade NTP-Daten...</p>;
|
||||
}
|
||||
|
||||
// Lokale States mit Fallback-Werten absichern
|
||||
const [ntp1, setNtp1] = React.useState(systemSettings.ntp1 ?? "");
|
||||
const [ntp2, setNtp2] = React.useState(systemSettings.ntp2 ?? "");
|
||||
const [ntp3, setNtp3] = React.useState(systemSettings.ntp3 ?? "");
|
||||
const [ntpTimezone, setNtpTimezone] = React.useState(
|
||||
systemSettings.ntpTimezone ?? ""
|
||||
);
|
||||
const [active, setActive] = React.useState(systemSettings.ntpActive ?? false);
|
||||
|
||||
return (
|
||||
<div className="p-6 md:p-3 bg-gray-100 max-w-5xl mr-auto">
|
||||
<h2 className="text-sm md:text-md font-bold mb-4">NTP Einstellungen</h2>
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
"use client"; // /components/main/settingsPageComponents/OPCUAInterfaceSettings.tsx
|
||||
import React, { useState } from "react";
|
||||
import Image from "next/image";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import {
|
||||
setOpcUaEncryption,
|
||||
toggleOpcUaServer,
|
||||
setOpcUaNodesetName,
|
||||
addOpcUaUser,
|
||||
removeOpcUaUser,
|
||||
} from "../../../redux/slices/opcuaSettingsSlice";
|
||||
import { toggleOpcUaServer } from "../../../redux/slices/opcuaSettingsSlice";
|
||||
|
||||
export default function OPCUAInterfaceSettings() {
|
||||
const dispatch = useDispatch();
|
||||
@@ -17,29 +12,28 @@ export default function OPCUAInterfaceSettings() {
|
||||
);
|
||||
|
||||
// Lokale Zustände für das neue Benutzerformular
|
||||
const [newUsername, setNewUsername] = useState("");
|
||||
const [newPassword, setNewPassword] = useState("");
|
||||
|
||||
const [nodesetName, setNodesetName] = useState(
|
||||
opcuaSettings.opcUaNodesetName
|
||||
);
|
||||
|
||||
const handleAddUser = () => {
|
||||
if (newUsername.trim() && newPassword.trim()) {
|
||||
dispatch(addOpcUaUser({ username: newUsername, password: newPassword }));
|
||||
setNewUsername("");
|
||||
setNewPassword("");
|
||||
}
|
||||
};
|
||||
|
||||
const handleNodesetUpdate = () => {
|
||||
dispatch(setOpcUaNodesetName(nodesetName));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-6 md:p-3 bg-gray-100 max-w-5xl mr-auto ">
|
||||
<div className="flex justify-between items-center mb-3">
|
||||
<h2 className="text-base font-semibold">OPCUA Server Einstellungen</h2>
|
||||
<img src="/images/OPCUA.jpg" alt="OPCUA Logo" className="h-12 w-auto" />
|
||||
<Image
|
||||
src="/images/OPCUA.jpg"
|
||||
alt="OPCUA Logo"
|
||||
width={48}
|
||||
height={48}
|
||||
className="h-12 w-auto"
|
||||
/>
|
||||
<Image
|
||||
src="/images/OPCUA.jpg"
|
||||
alt="OPCUA Logo"
|
||||
width={48}
|
||||
height={48}
|
||||
className="h-12 w-auto"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ✅ Server Aktivierung */}
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { generateToken } from "../utils/cryptoUtils";
|
||||
import USERS from "../config/users";
|
||||
import { setAdminLoggedIn } from "../../../../redux/slices/authSlice"; // ✅ Wichtig
|
||||
import { setAdminLoggedIn } from "@/redux/slices/authSlice"; // ✅ Wichtig
|
||||
import { AppDispatch } from "@/redux/store"; // Import your AppDispatch type
|
||||
|
||||
const handleAdminLogin = (
|
||||
username: string,
|
||||
password: string,
|
||||
onSuccess: () => void,
|
||||
onError: (errorMsg: string) => void,
|
||||
dispatch: any // ✅ neu
|
||||
onError: (message: string) => void,
|
||||
dispatch: AppDispatch // Use the correct dispatch type
|
||||
) => {
|
||||
const user = USERS.Admin;
|
||||
bcrypt.compare(password, user.password, (err, isMatch) => {
|
||||
|
||||
@@ -16,7 +16,6 @@ const handleGeneralSubmit = (
|
||||
) => {
|
||||
const changes: { [key: string]: string } = {};
|
||||
let networkChanges = false;
|
||||
let newIp: string | null = null;
|
||||
|
||||
if (current.name !== original.name) {
|
||||
changes.SNNA = current.name;
|
||||
@@ -24,7 +23,6 @@ const handleGeneralSubmit = (
|
||||
}
|
||||
if (current.ip !== original.ip) {
|
||||
changes.SEI01 = current.ip;
|
||||
newIp = current.ip;
|
||||
networkChanges = true;
|
||||
}
|
||||
if (current.subnet !== original.subnet) {
|
||||
|
||||
Reference in New Issue
Block a user