From e01c6f9324d90f3291c92e1da1b4a1158f5b6d46 Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Sat, 17 May 2025 01:17:59 +0200 Subject: [PATCH] refactor+docs: fetchGisStatusStations.js URL-Handling vereinheitlicht (v1.1.78) - entfernt: NEXT_PUBLIC_SERVER_URL aus fetchGisStatusStations.js - ersetzt durch dynamischen URL-Aufbau via NEXT_PUBLIC_API_PORT_MODE - neue Doku erstellt: docs/frontend/services/api/fetchGisStatusStations.md - CHANGELOG.md aktualisiert (v1.1.78) --- .env.local | 1 - CHANGELOG.md | 16 ++++ config/appVersion.js | 2 +- .../services/api/fetchGisStatusStations.md | 84 +++++++++++++++++++ services/api/fetchGisStatusStations.js | 6 +- 5 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 docs/frontend/services/api/fetchGisStatusStations.md diff --git a/.env.local b/.env.local index 926b980f6..3b42bf1ae 100644 --- a/.env.local +++ b/.env.local @@ -7,7 +7,6 @@ DB_NAME=talas_v5 DB_PORT=3306 # Public Settings (Client braucht IP/Domain) , Variablen mit dem Präfix "NEXT_PUBLIC" ist in Browser sichtbar -NEXT_PUBLIC_SERVER_URL="http://192.168.10.33" NEXT_PUBLIC_ENABLE_GEOCODER=true NEXT_PUBLIC_USE_MOCK_API=false NEXT_PUBLIC_DEBUG_LOG=true diff --git a/CHANGELOG.md b/CHANGELOG.md index fb5d03057..3ef593aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.78] – 2025-05-17 + +### Changed + +- `fetchGisStatusStations.js`: + - feste URL-Variable `NEXT_PUBLIC_SERVER_URL` entfernt + - stattdessen dynamische URL-Berechnung per `NEXT_PUBLIC_API_PORT_MODE` + - Zugriff auf Webservice `GisStationsStatusDistrict` funktioniert jetzt ohne `.env.local` + +### Added + +- Dokumentation ergänzt: + - `docs/frontend/services/api/fetchGisStatusStations.md` + +--- + ## [1.1.77] – 2025-05-17 ### Changed diff --git a/config/appVersion.js b/config/appVersion.js index d0722fd76..9fb063a3b 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.78"; +export const APP_VERSION = "1.1.79"; diff --git a/docs/frontend/services/api/fetchGisStatusStations.md b/docs/frontend/services/api/fetchGisStatusStations.md new file mode 100644 index 000000000..5ab3bc319 --- /dev/null +++ b/docs/frontend/services/api/fetchGisStatusStations.md @@ -0,0 +1,84 @@ +# 🛰️ fetchGisStatusStations – Geräte-Statusdaten abrufen + +## Zweck + +Diese Funktion ruft den aktuellen Status aller Stationen (Geräte) für eine bestimmte Karte ab. +Sie basiert auf dem Webservice `GisStationsStatusDistrict`. + +--- + +## Webservice-Endpunkt + +``` +GET /talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap={idMap}&idUser={idUser} +``` + +--- + +## Dynamische URL-Erzeugung + +Die Funktion nutzt **keine feste URL** aus `.env.local`, sondern erkennt die Umgebung anhand von: + +```env +NEXT_PUBLIC_API_PORT_MODE=dev +``` + +### Beispiel aus dem Code: + +```js +const mode = process.env.NEXT_PUBLIC_API_PORT_MODE; + +const SERVER_URL = + mode === "dev" + ? \`\${window.location.protocol}//\${window.location.hostname}:80\` + : \`\${window.location.origin}\`; +``` + +--- + +## Parameter + +| Name | Typ | Beschreibung | +|----------|--------|--------------------------| +| `idMap` | string | Karten-ID | +| `idUser` | string | Benutzer-ID | + +--- + +## Verwendung + +Die Funktion nutzt `fetchWithTimeout` mit einem Timeout von 5000 ms. + +```js +fetchWithTimeout( + \`\${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=\${idMap}&idUser=\${idUser}\`, + { method: "GET", headers: { Connection: "close" } }, + 5000 +) +``` + +--- + +## Fehlerbehandlung + +Bei HTTP-Fehlern oder Zeitüberschreitung wird ein Fehler geloggt und erneut geworfen. + +```js +if (!response.ok) throw new Error(...); +.catch((error) => { + console.error(...); + throw error; +}); +``` + +--- + +## Siehe auch + +- `.env.local` → `NEXT_PUBLIC_API_PORT_MODE` +- `fetchWithTimeout.js` +- `GisStationsStaticDistrict`, `GisSystemStatic` + +--- + +📄 Pfad: `/docs/frontend/services/api/fetchGisStatusStations.md` \ No newline at end of file diff --git a/services/api/fetchGisStatusStations.js b/services/api/fetchGisStatusStations.js index 218249457..64a82f003 100644 --- a/services/api/fetchGisStatusStations.js +++ b/services/api/fetchGisStatusStations.js @@ -1,7 +1,11 @@ +// /services/api/fetchGisStatusStations.js import fetchWithTimeout from "./fetchWithTimeout"; export const fetchGisStatusStations = async (idMap, idUser) => { - const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; + const mode = process.env.NEXT_PUBLIC_API_PORT_MODE; + + const SERVER_URL = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80` : `${window.location.origin}`; + return fetchWithTimeout( `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, {