Datasheet Markdown
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
# Redux Slice Dokumentation: `gisStationsStaticSlice.js`
|
||||
|
||||
## Zweck
|
||||
Dieses Slice verwaltet die Daten für **GisStationsStatic**, welche statische Standorte (z. B. Bereiche oder Stationen) für die Kartenanwendung darstellen. Diese Daten werden im `DataSheet.js` Dropdown-Menü verwendet, um auswählbare Stationen darzustellen.
|
||||
|
||||
---
|
||||
|
||||
## Speicherort
|
||||
```
|
||||
/redux/slices/webService/gisStationsStaticSlice.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Zustandsstruktur (`initialState`)
|
||||
```js
|
||||
{
|
||||
data: null, // enthält die API-Datenstruktur (z. B. { Points: [...] })
|
||||
status: "idle", // "idle" | "loading" | "succeeded" | "failed"
|
||||
error: null // Fehlernachricht bei einem API-Fehler
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Enthaltene Funktionen
|
||||
|
||||
### 1. `fetchGisStationsStatic`
|
||||
Ein `createAsyncThunk`, der die GIS-Daten vom Webservice lädt.
|
||||
|
||||
```js
|
||||
export const fetchGisStationsStatic = createAsyncThunk(
|
||||
"gisStationsStatic/fetchGisStationsStatic",
|
||||
async (_, { rejectWithValue }) => { ... }
|
||||
);
|
||||
```
|
||||
|
||||
- Die URL wird dynamisch aus `window.location.protocol`, `window.location.hostname` und Port 80 zusammengesetzt.
|
||||
- `idMap` wird aus der aktuellen URL gelesen (`?m=...`).
|
||||
- Es wird erwartet, dass der Webservice JSON im Format `{ Points: [...] }` zurückliefert.
|
||||
|
||||
### 2. `gisStationsStaticSlice`
|
||||
Das eigentliche Redux-Slice mit `createSlice`:
|
||||
|
||||
- Behandelt `pending`, `fulfilled`, `rejected` für `fetchGisStationsStatic`
|
||||
- Speichert den Ladezustand und die API-Antwort
|
||||
|
||||
### 3. `selectGisStationsStatic`
|
||||
Selector zum Zugriff auf `state.gisStationsStatic.data`.
|
||||
|
||||
```js
|
||||
export const selectGisStationsStatic = (state) => state.gisStationsStatic.data;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API-Endpunkt
|
||||
Der folgende Endpunkt wird aufgerufen:
|
||||
|
||||
```
|
||||
http://<hostname>:80/talas5/ClientData/WebServiceMap.asmx/GisStationsStatic?idMap=<id>
|
||||
```
|
||||
|
||||
Dabei wird `idMap` dynamisch aus der aktuellen Browser-URL geholt.
|
||||
|
||||
---
|
||||
|
||||
## Verwendungsbeispiel
|
||||
Wird z. B. in `DataSheet.js` verwendet, um die Dropdown-Auswahl zu befüllen:
|
||||
|
||||
```js
|
||||
const GisStationsStatic = useSelector(selectGisStationsStatic) || [];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Besonderheiten
|
||||
- Der API-Port ist **hart auf 80 gesetzt**, da der Webservice sowohl in Dev- als auch Prod-Umgebung darüber erreichbar ist.
|
||||
- Eine Browser-basierte URL-Analyse (`window.location`) bestimmt dynamisch den Host.
|
||||
- Fehler werden über `rejectWithValue` zurückgegeben und im Slice gespeichert.
|
||||
|
||||
---
|
||||
|
||||
## Verknüpfte Komponenten
|
||||
- `DataSheet.js`
|
||||
- `useMapComponentState.js`
|
||||
- Webservice: `WebServiceMap.asmx`
|
||||
|
||||
---
|
||||
|
||||
## Ziel für Dokumentation
|
||||
Empfohlener Pfad: `/docs/gisStationsStaticSlice.md`
|
||||
Reference in New Issue
Block a user