From 128b8fea5d264364a1bbbd9c94a58bb84a166a01 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 16 May 2025 13:27:48 +0200 Subject: [PATCH] docs+refactor: fetchGisStationsStatic API-Aufruf vereinheitlicht MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fetchGisStationsStatic.js verwendet jetzt zentrale Port-Logik über .env.local (NEXT_PUBLIC_API_PORT_MODE) - Map-ID wird direkt aus der URL gelesen (?m=...) - Fehlerprüfung auf JSON-Antwort eingebaut - Doku erstellt: /docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md - CHANGELOG.md aktualisiert (v1.1.71) --- CHANGELOG.md | 16 ++++ config/appVersion.js | 2 +- .../fromWebService/fetchGisStationsStatic.md | 78 +++++++++++++++++++ .../fromWebService/fetchGisStationsStatic.js | 15 ++-- 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md diff --git a/CHANGELOG.md b/CHANGELOG.md index b09385965..4c370ab95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.71] – 2025-05-17 + +### Changed + +- `fetchGisStationsStatic.js` aktualisiert: + - zentrale Steuerung der API-Port-Logik über `.env.local` → `NEXT_PUBLIC_API_PORT_MODE` + - Map-ID (`idMap`) wird direkt aus der URL gelesen (`?m=...`) + - Fehlerbehandlung und Content-Type-Prüfung eingebaut + +### Added + +- Dokumentation hinzugefügt: + - `docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md` + +--- + ## [1.1.70] – 2025-05-17 ### Changed diff --git a/config/appVersion.js b/config/appVersion.js index 9cef17dfe..bd120fb58 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.71"; +export const APP_VERSION = "1.1.72"; diff --git a/docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md b/docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md new file mode 100644 index 000000000..ef65e5ecb --- /dev/null +++ b/docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md @@ -0,0 +1,78 @@ +# 🌐 fetchGisStationsStatic – Standortdaten der Karte abrufen + +## Zweck + +Diese Funktion ruft die statischen Standortinformationen aller Geräte für eine bestimmte Karte ab. +Sie nutzt den Webservice-Endpunkt `GisStationsStatic`. + +--- + +## Webservice-Endpunkt + +``` +GisStationsStatic?idMap={idMap} +``` + +--- + +## Besonderheit: Port-Steuerung über Umgebungsvariable + +Die Webservices laufen immer auf Port 80 – auch in der Entwicklungsumgebung. + +Die Funktion erkennt dies anhand der Umgebungsvariable in `.env.local`: + +```env +NEXT_PUBLIC_API_PORT_MODE=dev +``` + +### Codeauszug: + +```js +const mode = process.env.NEXT_PUBLIC_API_PORT_MODE; + +const apiBaseUrl = + mode === "dev" + ? `${window.location.protocol}//${window.location.hostname}:80/talas5/ClientData/WebServiceMap.asmx` + : `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`; +``` + +--- + +## Parameter + +| URL-Parameter | Beschreibung | Übergabe durch TALAS.web | +|---------------|--------------|---------------------------| +| `m` | Map-ID | Ja | + +Die Map-ID wird aus der URL gelesen: + +```js +const params = new URLSearchParams(window.location.search); +const idMap = params.get("m"); +``` + +--- + +## Beispiel + +``` +http://10.10.0.13/talas5/MessagesMap/mapTypeC.aspx?m=12&u=484 +``` + +→ wird zu: + +``` +http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatic?idMap=12 +``` + +--- + +## Siehe auch + +- `.env.local` → `NEXT_PUBLIC_API_PORT_MODE` +- `fetchGisSystemStatic.md` +- `fetchGisStationsMeasurements.md` + +--- + +📄 Pfad: `/docs/frontend/redux/api/fromWebService/fetchGisStationsStatic.md` \ No newline at end of file diff --git a/redux/api/fromWebService/fetchGisStationsStatic.js b/redux/api/fromWebService/fetchGisStationsStatic.js index cc94b4d20..8d50e1ddf 100644 --- a/redux/api/fromWebService/fetchGisStationsStatic.js +++ b/redux/api/fromWebService/fetchGisStationsStatic.js @@ -1,20 +1,21 @@ // /redux/api/fromWebService/fetchGisStationsStatic.js -const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`; - export const fetchGisStationsStatic = async () => { try { + const mode = process.env.NEXT_PUBLIC_API_PORT_MODE; + + const apiBaseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/ClientData/WebServiceMap.asmx` : `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`; + const params = new URLSearchParams(window.location.search); const idMap = params.get("m"); - const idUser = params.get("u"); - const response = await fetch(`${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`); - //console.log("📡 API Response Status:", response.status); - //console.log("📡 API Response Headers:", response.headers.get("content-type")); + const url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`; + console.log("🔍 fetchGisStationsStatic - URL:", url); + + const response = await fetch(url); const text = await response.text(); console.log("📡 API Response Text von fetch:", text); - console.log("📡 API Response response von fetch:", response); if (!response.ok || !response.headers.get("content-type")?.includes("application/json")) { throw new Error("❌ Fehler: Antwort ist kein gültiges JSON");