feat: NTP-Einstellungen im GeneralSettings-Tab optimiert
- NTP Server 1–3, Zeitzone und Aktiv-Checkbox eingefügt - 2-Spalten-Layout für bessere Übersicht auf Laptop-Bildschirmen - Scrollbereich hinzugefügt, um Buttons bei kleiner Bildschirmhöhe sichtbar zu halten
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"use client"; // /components/main/settingsPageComponents/GeneralSettings.tsx
|
||||
"use client";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { RootState } from "../../../redux/store";
|
||||
import { useSelector } from "react-redux";
|
||||
@@ -40,6 +40,7 @@ const GeneralSettings: React.FC = () => {
|
||||
systemSettings.ntpTimezone || ""
|
||||
);
|
||||
const [active, setActive] = useState(systemSettings.ntpActive || false);
|
||||
|
||||
const handleLogin = async () => {
|
||||
handleAdminLogin(
|
||||
username,
|
||||
@@ -52,25 +53,23 @@ const GeneralSettings: React.FC = () => {
|
||||
setLoginSuccess(false);
|
||||
setError(errorMsg);
|
||||
},
|
||||
dispatch // ✅ hier übergeben
|
||||
dispatch
|
||||
);
|
||||
};
|
||||
|
||||
//-------------------------------
|
||||
useEffect(() => {
|
||||
if (!systemSettings.deviceName) {
|
||||
dispatch(fetchSystemSettingsThunk());
|
||||
}
|
||||
}, []);
|
||||
|
||||
//-------------------------------
|
||||
return (
|
||||
<div className="p-6 md:p-3 bg-gray-100 max-w-5xl mr-auto">
|
||||
<div className="p-6 md:p-3 bg-gray-100 max-w-5xl mr-auto overflow-y-auto max-h-[calc(100vh-200px)] ">
|
||||
<h2 className="text-sm md:text-md font-bold mb-2">
|
||||
Allgemeine Einstellungen
|
||||
</h2>
|
||||
<form className="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
{/* ✅ Geräte-Name */}
|
||||
{/* Geräte-Name */}
|
||||
<div className="col-span-2">
|
||||
<label className="block text-xs md:text-sm font-medium">Name:</label>
|
||||
<input
|
||||
@@ -81,7 +80,7 @@ const GeneralSettings: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ✅ MAC Adresse (nur Anzeige) */}
|
||||
{/* MAC Adresse */}
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
MAC Adresse 1:
|
||||
@@ -94,7 +93,7 @@ const GeneralSettings: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ✅ Systemzeit & Setzen */}
|
||||
{/* Systemzeit */}
|
||||
<div className="flex flex-col md:flex-row md:items-center gap-1 col-span-2">
|
||||
<div className="flex-1">
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
@@ -116,7 +115,7 @@ const GeneralSettings: React.FC = () => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ✅ Netzwerk-Einstellungen */}
|
||||
{/* Netzwerk */}
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">IP:</label>
|
||||
<input
|
||||
@@ -149,7 +148,63 @@ const GeneralSettings: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ✅ Admin-Login/Logout */}
|
||||
{/* NTP */}
|
||||
<div className="md:grid md:grid-cols-2 md:gap-2 col-span-2">
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
NTP Server 1:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="border border-gray-300 rounded h-8 p-1 w-full text-xs"
|
||||
value={ntp1}
|
||||
onChange={(e) => setNtp1(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
NTP Server 2:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="border border-gray-300 rounded h-8 p-1 w-full text-xs"
|
||||
value={ntp2}
|
||||
onChange={(e) => setNtp2(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
NTP Server 3:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="border border-gray-300 rounded h-8 p-1 w-full text-xs"
|
||||
value={ntp3}
|
||||
onChange={(e) => setNtp3(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs md:text-sm font-medium">
|
||||
Zeitzone:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="border border-gray-300 rounded h-8 p-1 w-full text-xs"
|
||||
value={ntpTimezone}
|
||||
onChange={(e) => setNtpTimezone(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-2 flex items-center gap-2 mt-2">
|
||||
<label className="text-xs md:text-sm font-medium">NTP aktiv:</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={active}
|
||||
onChange={(e) => setActive(e.target.checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Admin Login */}
|
||||
<div className="col-span-2 flex flex-col gap-1">
|
||||
{isAdminLoggedIn ? (
|
||||
<button
|
||||
@@ -186,13 +241,13 @@ const GeneralSettings: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ✅ Feedback für den Benutzer */}
|
||||
{/* Feedback */}
|
||||
{loginSuccess && (
|
||||
<p className="text-green-600 text-xs">Login erfolgreich!</p>
|
||||
)}
|
||||
{error && <p className="text-red-500 text-xs">{error}</p>}
|
||||
|
||||
{/* ✅ Buttons */}
|
||||
{/* Buttons */}
|
||||
<div className="col-span-2 flex flex-wrap md:justify-between gap-1 mt-2">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user