feat: Healthcheck um Webservices, API-Routen und .env-Prüfungen erweitert

- Externe Webservices von TALAS V5 integriert und geprüft (Statuscode + Antwortstruktur)
- Eigene API-Endpunkte wie /api/talas_v5_DB/getDevices hinzugefügt und validiert
- Prüfung von NEXT_PUBLIC_USE_MOCKS zur Vermeidung von Mockdaten in Produktion
- Validierung der Umgebungsvariablen wie DB_HOST, DB_NAME und NODE_ENV ergänzt
- Response-Status 200 bei vollständigem Erfolg, 207 bei Teilfehlern
- Verbesserung der JSON-Antwortstruktur zur einfacheren Analyse
This commit is contained in:
ISA
2025-06-05 15:23:59 +02:00
parent 9273195d8f
commit ec31b36b3d
31 changed files with 397 additions and 163 deletions

View File

@@ -1,37 +0,0 @@
// components/TestScript.js
import { useEffect } from "react";
import setupPolylinesCode from "!!raw-loader!../utils/polylines/setupPolylines.js"; // Lädt die gesamte setupPolylines.js als Text
export default function TestScript() {
useEffect(() => {
// Regulärer Ausdruck für "Stützpunkt entfernen" im Kontextmenü
const removeRegex = /marker\.on\("mouseover", function \(\) {\s*this\.bindContextMenu\({\s*contextmenuItems: \[\s*\{\s*text: "Stützpunkt entfernen"/;
// Regulärer Ausdruck für "Stützpunkt hinzufügen" im Kontextmenü
const addRegex = /contextmenuItems: \[\s*\{\s*text: "Stützpunkt hinzufügen"/;
// Stilvorlagen für das Konsolen-Logging
const successStyle = "color: #fff; background-color: #28a745; padding: 4px 8px; font-size: 14px; border-radius: 4px;";
const failStyle = "color: #fff; background-color: #dc3545; padding: 4px 8px; font-size: 14px; border-radius: 4px;";
const neutralStyle = "color: #006400; font-size: 14px; background-color: #f0f0f0; padding: 4px 8px; border-radius: 4px;";
// Überprüfung für "Stützpunkt entfernen"
if (removeRegex.test(setupPolylinesCode)) {
console.log("%c✔ Test bestanden: Der Text für 'Stützpunkt entfernen' wurde gefunden.", successStyle);
} else {
console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt entfernen' wurde nicht gefunden.", failStyle);
}
// Überprüfung für "Stützpunkt hinzufügen"
if (addRegex.test(setupPolylinesCode)) {
console.log("%c✔ Test bestanden: Der Text für 'Stützpunkt hinzufügen' wurde gefunden.", successStyle);
} else {
//console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt hinzufügen' wurde nicht gefunden.", failStyle);
}
// Beispiel einer neutralen Nachricht (falls benötigt)
console.log("%c Info: Überprüfung abgeschlossen.", neutralStyle);
}, []);
return null; // Keine visuelle Ausgabe erforderlich
}

View File

@@ -12,7 +12,7 @@ const addItemsToMapContextMenu = (
setPopupCoordinates,
openPopupWithCoordinates // Hier wird die Funktion als Parameter hinzugefügt
) => {
const openPoiModal = (e) => {
const openPoiModal = e => {
setShowCoordinatesModal(false); // ✅ Jetzt verfügbar, weil als Parameter übergeben
setPopupCoordinates(e.latlng);
setShowPoiModal(true);
@@ -29,7 +29,7 @@ const addItemsToMapContextMenu = (
map.contextmenu.addItem({
text: "Reinzoomen",
icon: "img/zoom_in.png",
callback: (e) => {
callback: e => {
const currentZoom = map.getZoom();
const newZoom = Math.min(15, currentZoom + 3); // Stellt sicher, dass max. 15 erreicht wird
const zoomDifference = Math.abs(newZoom - currentZoom); // Anzahl der Zoom-Stufen
@@ -61,7 +61,7 @@ const addItemsToMapContextMenu = (
map.contextmenu.addItem({
text: "Hier zentrieren",
icon: "img/center_focus.png",
callback: (e) => {
callback: e => {
map.panTo(e.latlng);
},
});
@@ -71,8 +71,9 @@ const addItemsToMapContextMenu = (
if (!menuItemAdded && map && map.contextmenu) {
const editMode = localStorage.getItem("editMode") === "true";
if (editMode) {
console.log("editMode localStorage:", localStorage.getItem("editMode"));
//console.log("editMode:", editMode);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("editMode localStorage:", localStorage.getItem("editMode"));
}
map.contextmenu.addItem({
text: "POI hinzufügen",

View File

@@ -148,7 +148,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
// Konstanten für die URLs
//console.log("priorityConfig in MapComponent1: ", priorityConfig);
//-----------------------------------------
const [linePositions, setLinePositions] = useState([]);
const { lineColors, tooltipContents } = useLineData();
@@ -234,7 +233,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}
locations.forEach(location => {});
};
//console.log("trigger in MapComponent.js:", poiReadTrigger);
}, [map, locations, poiReadTrigger]);
//--------------------------------------------
@@ -275,7 +273,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
]);
//---------------------------------------------
//console.log("priorityConfig in MapComponent2: ", priorityConfig);
useEffect(() => {
if (map) {
}
@@ -319,7 +317,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
);
newPolylines.forEach((polyline, index) => {
//console.log("polyline: ", polyline);
const tooltipContent =
tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] ||
"Die Linie ist noch nicht in Webservice vorhanden oder bekommt keine Daten";
@@ -380,14 +377,18 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//Test in useEffect
useEffect(() => {
if (map) {
console.log("🗺️ Map-Einstellungen werden wiederhergestellt...");
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("🗺️ Map-Einstellungen werden wiederhergestellt...");
}
restoreMapSettings(map);
}
}, [map]);
//--------------------------------------------
useEffect(() => {
if (map) {
console.log("map in MapComponent: ", map);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("map in MapComponent: ", map);
}
const handleMapMoveEnd = event => {
const newCenter = map.getCenter();
const newZoom = map.getZoom();
@@ -411,8 +412,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//--------------------------------------------
// Area in DataSheet ->dropdownmenu
useEffect(() => {
//console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict);
// Sicherstellen, dass `Points` existiert und ein Array ist
const points = GisStationsStaticDistrict?.Points;
@@ -420,7 +419,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
const station = points.find(s => s.Area_Name === selectedArea);
if (station) {
console.log("📌 Gefundene Station:", station);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("📌 Gefundene Station:", station);
}
map.flyTo([station.X, station.Y], 14);
} else {
console.warn("⚠️ Keine passende Station für die Area gefunden:", selectedArea);
@@ -464,7 +465,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//--------------------------------------------
useEffect(() => {
if (map) {
console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert");
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert");
}
}
}, [map]);
//--------------------------------------------
@@ -474,7 +477,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
map.whenReady(() => {
setTimeout(() => {
if (map.contextmenu) {
//console.log("Contextmenu ist vorhanden");
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
//console.log("Contextmenu ist vorhanden");
}
} else {
console.warn("Contextmenu ist nicht verfügbar.");
}
@@ -499,7 +504,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
const handleLocationUpdate = async (idLocation, idMap, newCoords) => {
try {
await dispatch(updateAreaThunk({ idLocation, idMap, newCoords })).unwrap();
console.log("Koordinaten erfolgreich aktualisiert:", result);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("Koordinaten erfolgreich aktualisiert:", result);
}
} catch (error) {
console.error("Fehler beim Aktualisieren der Location:", error);
}
@@ -661,15 +668,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//--------------------------------------
useEffect(() => {
if (isPolylineContextMenuOpen && countdownActive) {
//console.log("🔄 Starte Redux-Countdown für Kontextmenü!");
const interval = setInterval(() => {
dispatch(updateCountdown());
// console.log(`⏳ Redux Countdown: ${countdown} Sekunden`);
if (countdown <= 2) {
console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen.");
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen.");
}
dispatch(closePolylineContextMenu());
if (window.map?.contextmenu) {
@@ -690,7 +697,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
useEffect(() => {
if (map) {
window.map = map;
console.log("✅ window.map wurde gesetzt:", window.map);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("✅ window.map wurde gesetzt:", window.map);
}
}
}, [map]);
@@ -756,7 +765,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
// 🧠 Optional für Debugging für überlappende Markers
useEffect(() => {
if (oms) {
console.log("📌 OMS ready:", oms);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("📌 OMS ready:", oms);
}
window.oms = oms; // Für Debugging global
}
}, [oms]);
@@ -764,7 +775,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//----------------------------------------------
useEffect(() => {
if (process.env.NODE_ENV === "development") {
alert("🚧 Development Mode aktiviert Mock-Daten werden verwendet!");
console.log("🚧 Development Mode aktiviert Mock-Daten werden verwendet!");
} else {
console.log("Production Mode aktiviert");
}
}, []);
//---------------------------------------------

View File

@@ -143,7 +143,9 @@ function MapLayersControlPanel() {
//------------------------------
useEffect(() => {
console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict);
}
if (!GisStationsStaticDistrict) {
console.warn("⚠️ GisStationsStaticDistrict ist `null` oder nicht geladen.");
@@ -172,8 +174,9 @@ function MapLayersControlPanel() {
}
return isUnique;
});
console.log("📌 stationListing aktualisiert:", filteredAreas);
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
console.log("📌 stationListing aktualisiert:", filteredAreas);
}
}, [GisStationsStaticDistrict, GisSystemStatic]);
//---------------------------