Daten von Mock bekommen

This commit is contained in:
Ismail Ali
2025-03-05 17:47:28 +01:00
parent 82001a4beb
commit 4c5ef0e33e
22 changed files with 1009 additions and 345 deletions

View File

@@ -1,14 +1,14 @@
// /services/api/fetchUserRights.js
import * as config from "../../config/config";
export const fetchUserRights = async () => {
let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0;
userRightsRequestCount++;
localStorage.setItem("userRightsRequestCount", userRightsRequestCount);
console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`);
if (config.USE_MOCK_API) {
console.log("⚠️ Mock-API: Benutzerrechte geladen");
return [56, 57, 58]; // Beispielrechte
}
try {
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(`${config.serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, {
method: "GET",
headers: { Connection: "close" },
});
@@ -20,7 +20,7 @@ export const fetchUserRights = async () => {
return data.Rights.map((right) => right.IdRight);
} catch (error) {
console.error("Fehler beim Abrufen der Benutzerrechte", error);
console.error("Fehler beim Abrufen der Benutzerrechte:", error);
return [];
}
};

View File

@@ -1,13 +0,0 @@
export const fetchDeviceNameById = async (idLD) => {
console.log("⚠️ Mock-API: fetchDeviceNameById wird verwendet!");
// Simulierte Rückgabe basierend auf der ID (du kannst hier mehrere Fälle abdecken)
const mockData = {
50922: "CPL Ismael",
50950: "LTEModem",
50951: "GMA ISA",
// hier kannst du beliebig weitere hinzufügen, wenn du möchtest
};
return mockData[idLD] || "Unbekanntes Gerät";
};

View File

@@ -1,23 +0,0 @@
export const fetchGisStationsMeasurements = async (url, setGisStationsMeasurements) => {
console.log("⚠️ Mock-API: fetchGisStationsMeasurements wird verwendet!");
const mockData = {
Name: "Liste aller Messungen der Geraete",
Zeitstempel: "2025-03-05T12:23:16.0756875+01:00",
IdMap: "12",
Statis: [
{
IdLD: 50951,
IdL: 24101,
IdDP: 3,
Na: "FBT",
Val: "5",
Unit: "°C", // Umlaut korrigiert
Gr: "GMA",
Area_Name: "Rastede",
},
],
};
setGisStationsMeasurements(mockData.Statis); // Die Komponente erwartet direkt das Array
};

View File

@@ -1,68 +0,0 @@
export const fetchGisStationsStaticDistrict = async (url, dispatch, fetchOptions) => {
console.log("⚠️ Mock-API: fetchGisStationsStaticDistrict wird verwendet!");
const mockData = {
Name: "Liste aller Geraete einer bestimmten Karte",
Zeitstempel: "2025-03-05T10:51:20.8210755+01:00",
IdMap: "12",
Points: [
{
LD_Name: "CPL Ismael",
IdLD: 50922,
Device: "CPL V3.5 mit 24 Kü",
Link: "cpl.aspx?ver=35&kue=24&id=50922",
Location_Name: "Littwin",
Location_Short: "LTW",
IdLocation: 24101,
Area_Name: "Rastede",
Area_Short: "",
IdArea: 20998,
X: 53.246112,
Y: 8.162241,
Icon: 20,
System: 1,
Active: 1,
},
{
LD_Name: "LTEModem",
IdLD: 50950,
Device: "LTE Modem LR77",
Link: "lr77.aspx?ver=1&id=50950",
Location_Name: "Littwin",
Location_Short: "LTW",
IdLocation: 24101,
Area_Name: "Rastede",
Area_Short: "",
IdArea: 20998,
X: 53.246112,
Y: 8.162241,
Icon: 12,
System: 5,
Active: 1,
},
{
LD_Name: "GMA ISA",
IdLD: 50951,
Device: "Glättemeldeanlage",
Link: "gma.aspx?ver=1&id=50951",
Location_Name: "Littwin",
Location_Short: "LTW",
IdLocation: 24101,
Area_Name: "Rastede",
Area_Short: "",
IdArea: 20998,
X: 53.246112,
Y: 8.162241,
Icon: 1,
System: 11,
Active: 1,
},
// Die restlichen Daten fügst du genauso ein
],
};
dispatch({
type: "SET_GIS_STATIONS",
payload: mockData.Points,
});
};

View File

@@ -1,25 +0,0 @@
export const fetchGisStationsStatusDistrict = async (url, setGisStationsStatusDistrict) => {
console.log("⚠️ Mock-API: fetchGisStationsStatusDistrict wird verwendet!");
const mockData = {
Name: "Liste aller Statis der Geraete",
Zeitstempel: "2025-03-05T09:19:55.0004433+01:00",
IdMap: "12",
Statis: [
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 01 test", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 05 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 17 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 31 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 32 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Station offline", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "minor", Le: 3, Co: "#FFFF00", Me: "Eingang DE 02 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "minor", Le: 3, Co: "#FFFF00", Me: "KÜG 08: Überspannung gehend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "major", Le: 2, Co: "#FF9900", Me: "Eingang DE 03 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 01: Aderbruch kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 02: Aderbruch kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 03: Aderbruch kommend", Feld: 4, Icon: 0 },
],
};
setGisStationsStatusDistrict(mockData.Statis); // Die Komponente erwartet direkt das Array
};

View File

@@ -1,25 +0,0 @@
export const fetchGisStationsStatusDistrict = async (url, setGisStationsStatusDistrict, fetchOptions) => {
console.log("⚠️ Mock-API: fetchGisStationsStatusDistrict wird verwendet!");
const mockData = {
Name: "Liste aller Statis der Geraete",
Zeitstempel: "2025-03-05T12:26:29.4884924+01:00",
IdMap: "12",
Statis: [
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 01 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 05 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 17 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 31 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Eingang DE 32 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "system", Le: 4, Co: "#FF00FF", Me: "Station offline", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "minor", Le: 3, Co: "#FFFF00", Me: "Eingang DE 02 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "minor", Le: 3, Co: "#FFFF00", Me: "KÜG 08: Überspannung gehend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "major", Le: 2, Co: "#FF9900", Me: "Eingang DE 03 kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 01: Aderbruch kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 02: Aderbruch kommend", Feld: 4, Icon: 0 },
{ IdLD: 50922, Na: "critical", Le: 1, Co: "#FF0000", Me: "KÜG 03: Aderbruch kommend", Feld: 4, Icon: 0 },
],
};
setGisStationsStatusDistrict(mockData.Statis); // Direkt das Array übergeben
};

View File

@@ -1,14 +0,0 @@
export const fetchGisSystemStatic = async (url, setGisSystemStatic, setGisSystemStaticLoaded) => {
console.log("⚠️ Mock-API: fetchGisSystemStatic wird verwendet!");
const mockData = {
Systems: [
{ IdSystem: 1, Name: "System A", Allow: 1 },
{ IdSystem: 2, Name: "System B", Allow: 0 },
{ IdSystem: 3, Name: "System C", Allow: 1 },
],
};
setGisSystemStatic(mockData.Systems);
setGisSystemStaticLoaded(true);
};

View File

@@ -1,12 +0,0 @@
export const fetchPoiData = async (idPoi) => {
console.log("⚠️ Mock-API: fetchPoiData wird verwendet!");
const mockPoiData = {
1: { name: "Test POI 1", description: "Beschreibung für POI 1", idLD: 1001 },
2: { name: "Test POI 2", description: "Beschreibung für POI 2", idLD: 1002 },
3: { name: "Test POI 3", description: "Beschreibung für POI 3", idLD: 1003 },
// hier kannst du weitere POIs ergänzen
};
return mockPoiData[idPoi] || { name: "Unbekannter POI", description: "-", idLD: 0 };
};

View File

@@ -1,59 +0,0 @@
export const fetchUserRights = async () => {
console.log("⚠️ Mock-API: fetchUserRights wird verwendet!");
const mockData = {
Rights: [
{ IdRight: 1 },
{ IdRight: 2 },
{ IdRight: 3 },
{ IdRight: 5 },
{ IdRight: 6 },
{ IdRight: 7 },
{ IdRight: 8 },
{ IdRight: 10 },
{ IdRight: 11 },
{ IdRight: 12 },
{ IdRight: 20 },
{ IdRight: 22 },
{ IdRight: 23 },
{ IdRight: 25 },
{ IdRight: 30 },
{ IdRight: 40 },
{ IdRight: 41 },
{ IdRight: 42 },
{ IdRight: 43 },
{ IdRight: 44 },
{ IdRight: 45 },
{ IdRight: 46 },
{ IdRight: 47 },
{ IdRight: 48 },
{ IdRight: 49 },
{ IdRight: 50 },
{ IdRight: 51 },
{ IdRight: 52 },
{ IdRight: 55 },
{ IdRight: 56 },
{ IdRight: 60 },
{ IdRight: 61 },
{ IdRight: 62 },
{ IdRight: 63 },
{ IdRight: 64 },
{ IdRight: 65 },
{ IdRight: 68 },
{ IdRight: 69 },
{ IdRight: 70 },
{ IdRight: 71 },
{ IdRight: 72 },
{ IdRight: 73 },
{ IdRight: 79 },
{ IdRight: 80 },
{ IdRight: 90 },
{ IdRight: 93 },
{ IdRight: 94 },
{ IdRight: 95 },
{ IdRight: 96 },
],
};
return mockData.Rights.map((right) => right.IdRight);
};