feat: API-Proxy für SOAP-Webservice implementiert
- API-Route hinzugefügt: /api/gisStationsStaticDistrict - Dynamisches Lesen von URL-Parametern (idMap, idUser) aus Anfrage - SOAP-Anfrage an ASP.NET-Webservice weitergeleitet - XML-Antwort verarbeitet und zurückgegeben - CORS-Header und OPTIONS-Preflight für Sicherheit konfiguriert - Fehlerbehandlung und Debug-Logs integriert
This commit is contained in:
@@ -247,9 +247,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
};
|
||||
|
||||
// Fetch GIS Stations Static District
|
||||
await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, dispatch, fetchOptions);
|
||||
/* await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, dispatch, fetchOptions);
|
||||
requestCount++; // Zähler erhöhen
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount); */
|
||||
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
|
||||
|
||||
// Fetch GIS Stations Status District
|
||||
@@ -859,6 +859,50 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
initGeocoderFeature(map); // Geocoder-Feature initialisieren, kann von .env.local ausgeschaltet werden
|
||||
}
|
||||
}, [map]);
|
||||
//--------------------------------------------
|
||||
const fetchGisStationsStaticDistrict = async (idMap, idUser, dispatch) => {
|
||||
try {
|
||||
// API-Endpunkt mit Query-Parametern aufrufen
|
||||
const response = await fetch(`/api/gisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Netzwerkantwort war nicht ok.");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Ergebnis im Dispatch speichern oder State aktualisieren
|
||||
dispatch({ type: "SET_GIS_STATIONS", payload: data });
|
||||
|
||||
console.log("Daten erfolgreich geladen:", data);
|
||||
return data; // Optional: Rückgabe der Daten
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der GIS-Daten:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const [isDataLoaded, setIsDataLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const idMap = 12; // Beispielwert für die Map-ID
|
||||
const idUser = 484; // Beispielwert für die Benutzer-ID
|
||||
|
||||
// Daten aus der API abrufen
|
||||
await fetchGisStationsStaticDistrict(idMap, idUser, dispatch);
|
||||
|
||||
setIsDataLoaded(true); // Daten erfolgreich geladen
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der Daten:", error);
|
||||
setIsDataLoaded(false); // Fehler beim Laden
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, [dispatch]);
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
return (
|
||||
@@ -881,7 +925,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DataSheet className="z-50" />
|
||||
{isDataLoaded && <DataSheet className="z-50" />}
|
||||
|
||||
<div id="map" ref={mapRef} className="z-0" style={{ height: "100vh", width: "100vw" }}></div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user