docs: Webservice fetchGisSystemStatic dokumentiert mit Portlogik und URL-Parameter

- .env-Variable NEXT_PUBLIC_API_PORT_MODE beschrieben
- Beispielaufruf und URL-Mapping ergänzt
- Pfadstruktur /docs/frontend/redux/api/... übernommen
This commit is contained in:
ISA
2025-05-16 10:24:04 +02:00
parent 69830a1185
commit 21205d0981
13 changed files with 129 additions and 54 deletions

View File

@@ -49,31 +49,29 @@ export const useMapComponentState = () => {
const fetchDeviceData = async () => {
try {
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
const host = window.location.hostname;
const port = host === "10.10.0.70" ? "3000" : "80";
//const apiBaseUrl = `http://${host}:${port}/talas5/ClientData/WebServiceMap.asmx`;
const apiBaseUrl = `http://10.10.0.70/talas5/ClientData/WebServiceMap.asmx`;
// URL-Parameter aus der aktuellen Browser-URL holen
const params = new URLSearchParams(window.location.search);
const idMap = params.get("idMap") || "12"; // Fallback auf "12" falls nicht gesetzt
const idMap = params.get("m");
//console.log("idMap:", idMap);
const url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`;
//console.log("📡 API Request URL:", url);
//console.log("URL:", url);
const response = await fetch(url);
//console.log("📡 API Response Status:", response.status);
// console.log("📡 API Response Headers:", response.headers.get("content-type"));
const text = await response.text();
//console.log("📡 API Response Text:", text);
// JSON manuell parsen, falls die API keinen JSON-Header sendet
const data = JSON.parse(text);
// 🔄 KORREKT: Webservice liefert direkt JSON
const data = await response.json();
//console.log("Standort- und Gerätedaten:", data);
setLocationDeviceData(data.Points || []);
if (data.Points && data.Points.length > 0) {
setDeviceName(data.Points[0].LD_Name);
//console.log("Gerätename:", data.Points[0].LD_Name);
}
} catch (error) {
console.error("❌ Fehler beim Abrufen der Gerätedaten:", error);