NTP Reiter/Tab erstellt

This commit is contained in:
ISA
2025-04-25 10:09:04 +02:00
parent 2cc9e6cbe2
commit 23953facc8
6 changed files with 259 additions and 72 deletions

View File

@@ -0,0 +1,67 @@
// /components/main/settingsPageComponents/handlers/handleGeneralSubmit.ts
const handleGeneralSubmit = (
original: {
name: string;
ip: string;
subnet: string;
gateway: string;
},
current: {
name: string;
ip: string;
subnet: string;
gateway: string;
}
) => {
const changes: { [key: string]: string } = {};
let networkChanges = false;
let newIp: string | null = null;
if (current.name !== original.name) {
changes.SNNA = current.name;
networkChanges = true;
}
if (current.ip !== original.ip) {
changes.SEI01 = current.ip;
newIp = current.ip;
networkChanges = true;
}
if (current.subnet !== original.subnet) {
changes.SEI02 = current.subnet;
networkChanges = true;
}
if (current.gateway !== original.gateway) {
changes.SEI03 = current.gateway;
networkChanges = true;
}
if (Object.keys(changes).length === 0) {
alert("Keine Änderungen vorgenommen.");
return;
}
let url = `${window.location.origin}/CPL?${window.location.pathname}`;
Object.entries(changes).forEach(([key, value]) => {
url += `&${key}=${encodeURIComponent(value)}`;
});
console.log(url);
fetch(url, { method: "GET" })
.then(() => {
alert("Netzwerkdaten erfolgreich gesendet!");
if (networkChanges) {
alert(
"Ein Neustart ist erforderlich, um die Netzwerkeinstellungen zu übernehmen."
);
// Optional: handleReboot(newIp);
}
})
.catch((err) => {
console.error("Fehler:", err);
alert("Fehler beim Senden der Netzwerkdaten.");
});
};
export default handleGeneralSubmit;

View File

@@ -0,0 +1,59 @@
// /components/main/settingsPageComponents/handlers/handleNtpSubmit.ts
const handleNtpSubmit = (
original: {
ntp1: string;
ntp2: string;
ntp3: string;
ntpTimezone: string;
active: boolean;
},
current: {
ntp1: string;
ntp2: string;
ntp3: string;
ntpTimezone: string;
active: boolean;
}
) => {
const changes: { [key: string]: string | boolean } = {};
if (current.ntp1 !== original.ntp1) {
changes.SNIP1 = current.ntp1;
}
if (current.ntp2 !== original.ntp2) {
changes.SNIP2 = current.ntp2;
}
if (current.ntp3 !== original.ntp3) {
changes.SNIP3 = current.ntp3;
}
if (current.ntpTimezone !== original.ntpTimezone) {
changes.SNTZ = current.ntpTimezone;
}
if (current.active !== original.active) {
changes.SNAC = current.active ? "1" : "0";
}
if (Object.keys(changes).length === 0) {
alert("Keine Änderungen vorgenommen.");
return;
}
let url = `${window.location.origin}/CPL?${window.location.pathname}`;
Object.entries(changes).forEach(([key, value]) => {
url += `&${key}=${encodeURIComponent(value)}`;
});
console.log(url);
fetch(url, { method: "GET" })
.then(() => {
alert("NTP-Daten erfolgreich gesendet!");
})
.catch((err) => {
console.error("Fehler:", err);
alert("Fehler beim Senden der NTP-Daten.");
});
};
export default handleNtpSubmit;