refactor: fetchGisStationsStatusDistrictService korrigiert und aktiv im Projekt eingebunden
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// /components/mainComponent/hooks/useFetchWebServiceMap.js
|
// /components/mainComponent/hooks/useFetchWebServiceMap.js
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { fetchGisStationsStatusDistrict } from "../../../services/api/fetchGisStationsStatusDistrict";
|
import { fetchGisStationsStatusDistrictService } from "../../../services/api/fetchGisStationsStatusDistrictService";
|
||||||
import { fetchGisStationsMeasurementsService } from "../../../services/api/fetchGisStationsMeasurementsService";
|
import { fetchGisStationsMeasurementsService } from "../../../services/api/fetchGisStationsMeasurementsService";
|
||||||
import { fetchGisSystemStatic } from "../../../services/api/fetchGisSystemStatic";
|
import { fetchGisSystemStatic } from "../../../services/api/fetchGisSystemStatic";
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@ const useFetchWebServiceMap = (mapGisStationsStatusDistrictUrl, mapGisStationsMe
|
|||||||
|
|
||||||
// GIS Stations Status District abrufen
|
// GIS Stations Status District abrufen
|
||||||
//console.log("⏳ Abrufen von GIS Stations Status District...");
|
//console.log("⏳ Abrufen von GIS Stations Status District...");
|
||||||
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
await fetchGisStationsStatusDistrictService(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
||||||
// console.log("✅ fetchGisStationsStatusDistrict erfolgreich!");
|
// console.log("✅ fetchGisStationsStatusDistrictService erfolgreich!");
|
||||||
requestCount++;
|
requestCount++;
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.115";
|
export const APP_VERSION = "1.1.116";
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
// /services/api/fetchGisStationsStaticDistrict.js
|
|
||||||
import { setGisStationsStaticDistrict } from "../../redux/slices/webService/gisStationsStaticDistrictSlice";
|
|
||||||
|
|
||||||
export const fetchGisStationsStaticDistrict = async (url, dispatch, fetchOptions) => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(url, fetchOptions);
|
|
||||||
const jsonResponse = await response.json();
|
|
||||||
if (jsonResponse && jsonResponse.Points) {
|
|
||||||
dispatch(setGisStationsStaticDistrict(jsonResponse.Points));
|
|
||||||
} else {
|
|
||||||
console.error('Erwartete Daten im "Points"-Array nicht gefunden', jsonResponse);
|
|
||||||
dispatch(setGisStationsStaticDistrict([]));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Laden der Daten: ", error);
|
|
||||||
dispatch(setGisStationsStaticDistrict([]));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
36
services/api/fetchGisStationsStaticDistrictService.js
Normal file
36
services/api/fetchGisStationsStaticDistrictService.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// /services/api/fetchGisStationsStaticDistrictService.js
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt statische GIS-Stationen-Daten für Bezirke.
|
||||||
|
*
|
||||||
|
* @returns {Promise<Array>} Liste mit Points[]
|
||||||
|
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
|
||||||
|
*/
|
||||||
|
export const fetchGisStationsStaticDistrictService = async () => {
|
||||||
|
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 url = `${apiBaseUrl}/GisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`;
|
||||||
|
console.log("📡 fetchGisStationsStaticDistrictService URL:", url);
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const message = `❌ Fehler: ${response.status} ${response.statusText}`;
|
||||||
|
console.error(message);
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonResponse = await response.json();
|
||||||
|
|
||||||
|
if (!jsonResponse?.Points) {
|
||||||
|
throw new Error("Antwortstruktur ungültig – 'Points' fehlt");
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonResponse.Points;
|
||||||
|
};
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// /services/api/fetchGisStationsStatusDistrict.js
|
|
||||||
|
|
||||||
export const fetchGisStationsStatusDistrict = async (url, setGisStationsStatusDistrict) => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
const jsonResponse = await response.json();
|
|
||||||
if (jsonResponse && jsonResponse.Statis) {
|
|
||||||
setGisStationsStatusDistrict(jsonResponse.Statis);
|
|
||||||
} else {
|
|
||||||
console.error('Erwartete Daten im "Statis"-Array nicht gefunden', jsonResponse);
|
|
||||||
setGisStationsStatusDistrict([]);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Laden der Daten: ", error);
|
|
||||||
setGisStationsStatusDistrict([]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
36
services/api/fetchGisStationsStatusDistrictService.js
Normal file
36
services/api/fetchGisStationsStatusDistrictService.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// /services/api/fetchGisStationsStatusDistrictService.js
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt Statusinformationen der GIS-Bezirksstationen.
|
||||||
|
*
|
||||||
|
* @returns {Promise<Array>} Liste mit Statis[]
|
||||||
|
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
|
||||||
|
*/
|
||||||
|
export const fetchGisStationsStatusDistrictService = async () => {
|
||||||
|
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 url = `${apiBaseUrl}/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`;
|
||||||
|
console.log("📡 fetchGisStationsStatusDistrictService URL:", url);
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const message = `❌ Fehler: ${response.status} ${response.statusText}`;
|
||||||
|
console.error(message);
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonResponse = await response.json();
|
||||||
|
|
||||||
|
if (!jsonResponse?.Statis) {
|
||||||
|
throw new Error("Antwortstruktur ungültig – 'Statis' fehlt");
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonResponse.Statis;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user