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:
@@ -14,5 +14,6 @@ NEXT_PUBLIC_DEBUG_LOG=true
|
|||||||
|
|
||||||
# für Polylines/kabelstecken -> in Konextmenü "Station öffnen" "
|
# für Polylines/kabelstecken -> in Konextmenü "Station öffnen" "
|
||||||
NEXT_PUBLIC_BASE_URL=http://10.10.0.70/talas5/devices/
|
NEXT_PUBLIC_BASE_URL=http://10.10.0.70/talas5/devices/
|
||||||
NEXT_PUBLIC_API_BASE_URL=http://10.10.0.70/talas5/ClientData/WebServiceMap.asmx
|
|
||||||
|
|
||||||
|
#auf dem Entwicklungsrechner dev und auf dem Server prod
|
||||||
|
NEXT_PUBLIC_API_PORT_MODE=dev
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ function DataSheet() {
|
|||||||
useInitGisStationsStatic();
|
useInitGisStationsStatic();
|
||||||
//---------------------------
|
//---------------------------
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//console.log("🔍 GisStationsStatic Inhalt:", GisStationsStatic);
|
console.log("🔍 GisStationsStatic Inhalt:", GisStationsStatic);
|
||||||
|
|
||||||
if (!GisStationsStatic) {
|
if (!GisStationsStatic) {
|
||||||
console.warn("⚠️ GisStationsStatic ist `null` oder nicht geladen.");
|
console.warn("⚠️ GisStationsStatic ist `null` oder nicht geladen.");
|
||||||
@@ -177,7 +177,7 @@ function DataSheet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!GisStationsStatic.Points || !Array.isArray(GisStationsStatic.Points)) {
|
if (!GisStationsStatic.Points || !Array.isArray(GisStationsStatic.Points)) {
|
||||||
//console.warn("⚠️ GisStationsStatic.Points ist nicht vorhanden oder kein Array.", GisStationsStatic);
|
console.warn("⚠️ GisStationsStatic.Points ist nicht vorhanden oder kein Array.", GisStationsStatic);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ function DataSheet() {
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log("📌 stationListing aktualisiert:", filteredAreas);
|
console.log("📌 stationListing aktualisiert:", filteredAreas);
|
||||||
}, [GisStationsStatic]);
|
}, [GisStationsStatic]);
|
||||||
|
|
||||||
//---------------------------
|
//---------------------------
|
||||||
|
|||||||
@@ -130,7 +130,9 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("currentPoi von PoiUpdateModal.js : ", currentPoi.idLD);
|
console.log("currentPoi von PoiUpdateModal.js : ", currentPoi.idLD);
|
||||||
fetch("/api/talas_v5_DB/locationDevice/locationDevices")
|
const API_BASE_URL = `${window.location.origin}:3000`;
|
||||||
|
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/locationDevice/locationDevices`);
|
||||||
|
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
setLocationDeviceData(data);
|
setLocationDeviceData(data);
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.69";
|
export const APP_VERSION = "1.1.70";
|
||||||
|
|||||||
@@ -4,18 +4,12 @@ In diesem Verzeichnis befinden sich alle Webservice-Fetch-Funktionen für die Ko
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Aktueller Stand
|
|
||||||
|
|
||||||
Jede Funktion liest `idMap` und `idUser` **ausschließlich aus der URL**, wie sie von TALAS.web übergeben werden.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Übergabe der Parameter über URL (`m`, `u`)
|
## Übergabe der Parameter über URL (`m`, `u`)
|
||||||
|
|
||||||
TALAS.web ruft die Kartenansicht in der Regel so auf:
|
TALAS.web ruft die Kartenansicht in der Regel so auf:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://localhost:3000/?m=10&u=484
|
http://[SERVER]:3000/?m=10&u=484
|
||||||
```
|
```
|
||||||
|
|
||||||
Daraus ergeben sich folgende Zuweisungen:
|
Daraus ergeben sich folgende Zuweisungen:
|
||||||
@@ -25,14 +19,12 @@ Daraus ergeben sich folgende Zuweisungen:
|
|||||||
| `m` | `idMap` | `const idMap = params.get("m")` |
|
| `m` | `idMap` | `const idMap = params.get("m")` |
|
||||||
| `u` | `idUser` | `const idUser = params.get("u")` |
|
| `u` | `idUser` | `const idUser = params.get("u")` |
|
||||||
|
|
||||||
🔔 Achtung: Diese Kurzform (`m`, `u`) ist systembedingt durch TALAS.web vorgegeben und **soll nicht durch `idMap` oder `idUser` ersetzt werden**, da die Parameter sonst nicht erkannt werden.
|
|
||||||
|
|
||||||
### Beispiel:
|
### Beispiel:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const idMap = params.get("m"); // statt "idMap"
|
const idMap = params.get("m");
|
||||||
const idUser = params.get("u"); // statt "idUser"
|
const idUser = params.get("u");
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -49,11 +41,26 @@ Das wurde entfernt, um folgende Ziele zu erreichen:
|
|||||||
|
|
||||||
- ❌ Keine fest eingetragenen Defaults im Browser sichtbar
|
- ❌ Keine fest eingetragenen Defaults im Browser sichtbar
|
||||||
- ✅ Verbindlichkeit: TALAS.web übergibt die Werte immer korrekt via URL
|
- ✅ Verbindlichkeit: TALAS.web übergibt die Werte immer korrekt via URL
|
||||||
- 🔐 Sicherheit: Kein versehentliches Verwenden eines falschen Users (z. B. ID 484)
|
- 🔐 Sicherheit: Kein versehentliches Verwenden eines falschen Users
|
||||||
- 🔍 Fehler leichter erkennbar (Parameter nicht gefunden = echter Fehler)
|
- 🔍 Fehler leichter erkennbar (Parameter nicht gefunden = echter Fehler)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Hinweis zur Webservice-Konfiguration
|
||||||
|
|
||||||
|
Die Webservice-Basisadresse wird **nicht mehr über `.env.local` gesteuert**.
|
||||||
|
|
||||||
|
Stattdessen wird sie dynamisch im Client anhand des aktuellen Hostnamens bestimmt:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const baseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
|
```
|
||||||
|
|
||||||
|
➡ Dadurch ist kein Rebuild mehr nötig bei IP-Wechseln oder Serverumzügen.
|
||||||
|
Die Build-Version kann auf jedem Server wiederverwendet werden.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Optional: Validierung einbauen
|
## Optional: Validierung einbauen
|
||||||
|
|
||||||
Falls gewünscht, kann ein expliziter Fehler ausgelöst werden:
|
Falls gewünscht, kann ein expliziter Fehler ausgelöst werden:
|
||||||
@@ -80,12 +87,4 @@ Diese Änderung betrifft alle Funktionen in:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Hinweis zur Konfiguration
|
Diese Konvention stellt sicher, dass Webservices unabhängig von IP und Serverkonfiguration aufgerufen werden können.
|
||||||
|
|
||||||
Die Webservice-Basisadresse wird weiterhin über `.env.local` konfiguriert:
|
|
||||||
|
|
||||||
```env
|
|
||||||
NEXT_PUBLIC_API_BASE_URL=http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx
|
|
||||||
```
|
|
||||||
|
|
||||||
Aber `idMap` und `idUser` werden **nicht** mehr über Umgebungsvariablen gesteuert.
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
# 🌐 fetchGisSystemStatic – Geräte-Systemdaten abrufen
|
||||||
|
|
||||||
|
## Zweck
|
||||||
|
|
||||||
|
Diese Funktion ruft die Gerätestatus-Übersicht für eine bestimmte Karte ab:
|
||||||
|
|
||||||
|
WebService-Endpunkt:
|
||||||
|
|
||||||
|
```
|
||||||
|
GisSystemStatic?idMap={idMap}&idUser={idUser}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Besonderheit bei der URL
|
||||||
|
|
||||||
|
Die Webservices (z. B. `WebServiceMap.asmx`) laufen **immer auf Port 80**,
|
||||||
|
egal ob im Entwicklungsmodus (`localhost`, `:3000`) oder auf dem Testserver (`10.10.0.13`).
|
||||||
|
|
||||||
|
Daher wird im Code explizit `:80` gesetzt – gesteuert über die Umgebungsvariable:
|
||||||
|
|
||||||
|
```env
|
||||||
|
NEXT_PUBLIC_API_PORT_MODE=dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Beispiel (aus dem Code):
|
||||||
|
|
||||||
|
```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
|
||||||
|
|
||||||
|
Die Funktion liest folgende URL-Parameter ein:
|
||||||
|
|
||||||
|
| URL-Parameter | Beschreibung | Übergabe durch TALAS.web |
|
||||||
|
| ------------- | ------------ | ------------------------ |
|
||||||
|
| `m` | Map-ID | Ja |
|
||||||
|
| `u` | User-ID | Ja |
|
||||||
|
|
||||||
|
Diese werden aus der URL wie folgt gelesen:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const idMap = params.get("m");
|
||||||
|
const idUser = params.get("u");
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Beispiel-Aufruf
|
||||||
|
|
||||||
|
TALAS-Aufruf:
|
||||||
|
|
||||||
|
```
|
||||||
|
http://10.10.0.13/talas5/MessagesMap/mapTypeC.aspx?m=12&u=484
|
||||||
|
```
|
||||||
|
|
||||||
|
wird im Webservice-Request zu:
|
||||||
|
|
||||||
|
```
|
||||||
|
http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisSystemStatic?idMap=12&idUser=484
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Siehe auch
|
||||||
|
|
||||||
|
- `.env.local` → `NEXT_PUBLIC_API_PORT_MODE`
|
||||||
|
- `docs/fromWebService.md`
|
||||||
|
- API-Datei: `/redux/api/fromWebService/fetchGisSystemStatic.js`
|
||||||
|
- 📄 Pfad: `/docs/frontend/redux/api/fromWebService/fetchGisSystemStatic.md`
|
||||||
@@ -49,31 +49,29 @@ export const useMapComponentState = () => {
|
|||||||
|
|
||||||
const fetchDeviceData = async () => {
|
const fetchDeviceData = async () => {
|
||||||
try {
|
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 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}`;
|
const url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`;
|
||||||
|
|
||||||
//console.log("📡 API Request URL:", url);
|
//console.log("URL:", url);
|
||||||
|
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|
||||||
//console.log("📡 API Response Status:", response.status);
|
// 🔄 KORREKT: Webservice liefert direkt JSON
|
||||||
// console.log("📡 API Response Headers:", response.headers.get("content-type"));
|
const data = await response.json();
|
||||||
|
//console.log("Standort- und Gerätedaten:", data);
|
||||||
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);
|
|
||||||
|
|
||||||
setLocationDeviceData(data.Points || []);
|
setLocationDeviceData(data.Points || []);
|
||||||
|
|
||||||
if (data.Points && data.Points.length > 0) {
|
if (data.Points && data.Points.length > 0) {
|
||||||
setDeviceName(data.Points[0].LD_Name);
|
setDeviceName(data.Points[0].LD_Name);
|
||||||
|
//console.log("Gerätename:", data.Points[0].LD_Name);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Fehler beim Abrufen der Gerätedaten:", error);
|
console.error("❌ Fehler beim Abrufen der Gerätedaten:", error);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// /redux/api/fromWebService/fetchGisStationsMeasurements.js
|
// /redux/api/fromWebService/fetchGisStationsMeasurements.js
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
||||||
|
|
||||||
export const fetchGisStationsMeasurements = async () => {
|
export const fetchGisStationsMeasurements = async () => {
|
||||||
|
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const idMap = params.get("m");
|
const idMap = params.get("m");
|
||||||
const idUser = params.get("u");
|
const idUser = params.get("u");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// /redux/api/fromWebService/fetchGisStationsStatic.js
|
// /redux/api/fromWebService/fetchGisStationsStatic.js
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
|
|
||||||
export const fetchGisStationsStatic = async () => {
|
export const fetchGisStationsStatic = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// /redux/api/fromWebService/fetchGisStationsStaticDistrict.js
|
// /redux/api/fromWebService/fetchGisStationsStaticDistrict.js
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
||||||
|
|
||||||
export const fetchGisStationsStaticDistrict = async () => {
|
export const fetchGisStationsStaticDistrict = async () => {
|
||||||
|
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const idMap = params.get("m");
|
const idMap = params.get("m");
|
||||||
const idUser = params.get("u");
|
const idUser = params.get("u");
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// /redux/api/fromWebService/fetchGisStationsStatusDistrict.js
|
// /redux/api/fromWebService/fetchGisStationsStatusDistrict.js
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
||||||
|
|
||||||
export const fetchGisStationsStatusDistrict = async () => {
|
export const fetchGisStationsStatusDistrict = async () => {
|
||||||
|
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const idMap = params.get("m");
|
const idMap = params.get("m");
|
||||||
const idUser = params.get("u");
|
const idUser = params.get("u");
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
// /redux/api/fromWebService/fetchGisSystemStatic.js
|
// /redux/api/fromWebService/fetchGisSystemStatic.js
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
||||||
|
|
||||||
export async function fetchGisSystemStatic() {
|
export async function fetchGisSystemStatic() {
|
||||||
|
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 params = new URLSearchParams(window.location.search);
|
||||||
const idMap = params.get("m");
|
const idMap = params.get("m");
|
||||||
const idUser = params.get("u");
|
const idUser = params.get("u");
|
||||||
//console.log("🔍 fetchGisSystemStatic - idMap:", idMap);
|
console.log("🔍 fetchGisSystemStatic - idMap:", idMap);
|
||||||
//console.log("🔍 fetchGisSystemStatic - idUser:", idUser);
|
console.log("🔍 fetchGisSystemStatic - idUser:", idUser);
|
||||||
//console.log("🔍 fetchGisSystemStatic - URL:", `${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`);
|
console.log("🔍 fetchGisSystemStatic - URL:", `${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`);
|
||||||
|
|
||||||
const response = await fetch(`${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`);
|
const response = await fetch(`${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
|||||||
// API-Fetch-Funktion für GIS Stations Static mit dynamischem URL-Parameter
|
// API-Fetch-Funktion für GIS Stations Static mit dynamischem URL-Parameter
|
||||||
export const fetchGisStationsStatic = createAsyncThunk("gisStationsStatic/fetchGisStationsStatic", async (_, { rejectWithValue }) => {
|
export const fetchGisStationsStatic = createAsyncThunk("gisStationsStatic/fetchGisStationsStatic", async (_, { rejectWithValue }) => {
|
||||||
try {
|
try {
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
const apiBaseUrl = `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
|
||||||
|
|
||||||
// URL-Parameter aus der aktuellen Browser-URL holen
|
// URL-Parameter aus der aktuellen Browser-URL holen
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|||||||
Reference in New Issue
Block a user