Version 1.0.2 mit node_modules Verzeichnis

This commit is contained in:
ISA
2024-10-02 07:58:24 +02:00
parent f353a06b1b
commit 62b6e55a0a
68228 changed files with 4548477 additions and 651 deletions

View File

@@ -2,24 +2,60 @@
import * as config from "../config/config";
import * as urls from "../config/urls";
export const fetchGisStatusStations = async (idMap, idUser) => {
let timeoutId;
const fetchWithTimeout = async (url, options, timeout = 5000) => {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout);
try {
const response = await fetch(`/api/talas5/webserviceMap/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`);
if (!response.ok) {
throw new Error(`Error: ${response.statusText}
MySQL Datenbankverbindung fehlgeschlagen!
MySQL-Mode: SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
prüfen oder nodeMap Dienst neu starten`);
}
const data = await response.json();
//console.log("GisStatusStations:", data);
return data;
const response = await fetch(url, {
...options,
signal: controller.signal,
});
clearTimeout(id);
return response;
} catch (error) {
console.error("Fehler beim Abrufen der Daten:", error);
throw error; // Fehler weiter werfen, um ihn in der Komponente behandeln zu können
clearTimeout(id); // Im Falle eines Fehlers den Timeout abbrechen
throw error;
}
};
export const fetchGisStatusStations = async (idMap, idUser) => {
// Verhindere wiederholte schnelle API-Aufrufe durch Debouncing
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(async () => {
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL;
try {
// Verwende das Timeout für die API-Anfrage
const response = await fetchWithTimeout(
`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`,
{
method: "GET",
headers: {
Connection: "close", // Dieser Header stellt sicher, dass die Verbindung nach dem Abruf geschlossen wird
},
},
5000 // Timeout auf 5 Sekunden gesetzt
);
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error("Fehler beim Abrufen der Daten:", error);
throw error;
}
}, 500); // Debounce-Zeit auf 500ms gesetzt
};
// ----------------------------------------------
/* export const fetchPriorityConfig = async () => {
try {
@@ -44,6 +80,7 @@ export const fetchPoiData = async (idPoi) => {
idPoi,
name: data.name,
description: data.description,
idLD: data.idLD,
};
} catch (error) {
console.error("Fehler beim Abrufen der POI-Daten", error);
@@ -99,15 +136,25 @@ export const fetchDeviceNameById = async (idLD) => {
// ----------------------------------------------
// services/apiService.js
export const fetchUserRights = async () => {
// Zähler für API-Aufrufe in localStorage speichern
let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0;
userRightsRequestCount++;
localStorage.setItem("userRightsRequestCount", userRightsRequestCount);
console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`);
try {
// const response = await fetch(`${urls.SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`);
const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`);
const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, {
method: "GET",
headers: {
Connection: "close",
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
// console.log("Benutzerrechte in fetchRights:", data);
// Überprüfen der Struktur der Antwort
if (!data || !data.Rights || !Array.isArray(data.Rights)) {
@@ -115,13 +162,8 @@ export const fetchUserRights = async () => {
}
const rightsArray = data.Rights; // Nehmen an, dass 'Rights' das Array von Rechten ist
//console.log("rightsArray in apiService:", rightsArray);
// Speichert die IDs der Rechte in einem Array
const userRightsIds = rightsArray.map((right) => right.IdRight);
// Wenn alles gut geht, logge die erfolgreichen Abschluss
// console.log("Benutzerrechte erfolgreich abgerufen:", userRightsIds);
return userRightsIds;
} catch (error) {
console.error("Fehler beim Abrufen der Benutzerrechte", error);