Files
CPLv4.0/components/main/settingsPageComponents/handlers/dbHandlers/handleClearConfig.ts
ISA 2cc9e6cbe2 feat: Datenbank-Reiter ergänzt mit neuen Löschfunktionen
- Neuen Tab „Datenbank“ in Einstellungen-Seite eingebaut
- Separate Buttons für:
  - vollständiges Löschen der Datenbank
  - Konfiguration löschen (DBC1)
  - Meldungen löschen (DBC2)
  - Logger-Messwerte löschen (DBC3)
- Logik über eigene Handler-Funktionen umgesetzt
- „Datenbank leeren“-Button aus GeneralSettings entfernt
2025-04-25 08:45:28 +02:00

35 lines
1.1 KiB
TypeScript

// components/main/settingsPageComponents/handlers/dbHandlers/handleClearConfig.ts
const handleClearConfig = async () => {
const confirmClear = window.confirm(
"Sind Sie sicher, dass Sie die Datenbank Konfiguration löschen möchten?"
);
if (!confirmClear) return;
// Get the current path and ensure it ends with ".html"
let currentPath = window.location.pathname;
if (!currentPath.endsWith(".html")) {
currentPath += ".html";
}
// Full URL with host, current path, and clear database command
const url = `${window.location.origin}/CPL?${currentPath}&DBC1=1`;
// Log the full URL to the console for debugging
console.log(url);
// Send the clear database command to the server using fetch and GET method
try {
const response = await fetch(url, { method: "GET" });
if (response.ok) {
alert("Datenbank Konfiguration erfolgreich gelöscht!");
} else {
alert("Fehler beim Löschen der Datenbank Konfiguration!");
}
} catch (error) {
console.error("Fehler:", error);
alert("Fehler beim Löschen der Datenbank Konfiguration!");
}
};
export default handleClearConfig;