fix: GIS-Messdaten-Service korrigiert – URL-Aufbau mit idMap, idUser und Port-Logik vereinheitlicht in fetchGisStationsMeasurementsService
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// /services/api/fetchDeviceNameById.js
|
||||
export const fetchDeviceNameById = async (idLD) => {
|
||||
try {
|
||||
const response = await fetch(`/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`);
|
||||
@@ -1,15 +0,0 @@
|
||||
export const fetchGisStationsMeasurements = async (url, setGisStationsMeasurements) => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const jsonResponse = await response.json();
|
||||
if (jsonResponse && jsonResponse.Statis) {
|
||||
setGisStationsMeasurements(jsonResponse.Statis);
|
||||
} else {
|
||||
console.error('Erwartete Daten im "Statis"-Array nicht gefunden', jsonResponse);
|
||||
setGisStationsMeasurements([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der Daten: ", error);
|
||||
setGisStationsMeasurements([]);
|
||||
}
|
||||
};
|
||||
30
services/api/fetchGisStationsMeasurementsService.js
Normal file
30
services/api/fetchGisStationsMeasurementsService.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// /services/api/fetchGisStationsMeasurementsService.js
|
||||
|
||||
export const fetchGisStationsMeasurementsService = 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}/GisStationsMeasurements?idMap=${idMap}&idUser=${idUser}`;
|
||||
console.log("📡 fetchGisStationsMeasurementsService 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;
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// /services/api/fetchGisStationsStaticDistrict.js
|
||||
import { setGisStationsStaticDistrict } from "../../redux/slices/webService/gisStationsStaticDistrictSlice";
|
||||
|
||||
export const fetchGisStationsStaticDistrict = async (url, dispatch, fetchOptions) => {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// /services/api/fetchGisStationsStatusDistrict.js
|
||||
|
||||
export const fetchGisStationsStatusDistrict = async (url, setGisStationsStatusDistrict) => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// /services/api/fetchGisSystemStatic.js
|
||||
|
||||
export const fetchGisSystemStatic = async (url, setGisSystemStatic, setGisSystemStaticLoaded) => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// /services/api/fetchPoiData.js
|
||||
|
||||
export const fetchPoiData = async (idPoi) => {
|
||||
try {
|
||||
const response = await fetch(`/api/talas_v5_DB/pois/getPoiById?idPoi=${idPoi}`);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// services/api/fetchWithTimeout.js
|
||||
|
||||
const fetchWithTimeout = (url, options, timeout = 5000) => {
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// /services/api/updateLocationInDatabase.js
|
||||
|
||||
export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => {
|
||||
const response = await fetch("/api/talas_v5_DB/pois/updateLocation", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user