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

@@ -7,6 +7,7 @@ DB_NAME=talas_v5
DB_PORT=3306
# Public Settings (Client braucht IP/Domain)
NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" # oder evtl. später https://nodemap.firma.de
NEXT_PUBLIC_SERVER_URL="http://192.168.10.33" # oder evtl. später https://nodemap.firma.de
NEXT_PUBLIC_ENABLE_GEOCODER=true
NEXT_PUBLIC_USE_MOCK_API=true

View File

@@ -1,2 +1,2 @@
// /config/appVersion
export const APP_VERSION = "1.1.6";
export const APP_VERSION = "1.1.7";

View File

@@ -1,58 +1,63 @@
// /config/config.js
// Datei: /config/config.js
import * as urls from "../config/urls.js";
// Definieren der grundlegenden Umgebungseinstellungen und Konfigurationen der Karte
const mapVersion = "0.5.3";
const standardSideMenu = true;
const fullSideMenu = false;
const serverURL = process.env.NEXT_PUBLIC_SERVER_URL;
if (!serverURL) {
// Server-URL aus Umgebungsvariable holen (nur bei echter API benötigt)
const serverURL = process.env.NEXT_PUBLIC_SERVER_URL || "";
if (!serverURL && !isMockMode()) {
throw new Error("Die Umgebungsvariable NEXT_PUBLIC_SERVER_URL ist nicht gesetzt!");
}
console.log("%c 1- serverURL in config:", "color: #006400;", serverURL);
// Mock-Switch direkt in der config.js
// true = Mock-Daten verwenden
// false = Echte Daten von Webservice
const USE_MOCK_API = true; // <--- Hier nicht mit "export" direkt, sondern erst unten im Export
// Initialisieren von Variablen, die später im Browserkontext gesetzt werden
let windowHeight, url_string, url, idMap, idUser;
let mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, mapDataIconUrl, webserviceGisLinesStatusUrl;
// Prüfen, ob das Code im Browser ausgeführt wird
// Prüfen, ob Mock-Modus aktiv ist
function isMockMode() {
return process.env.NEXT_PUBLIC_USE_MOCK_API === "true";
}
// URL-Setup - dynamisch abhängig von Mock oder Echtbetrieb
if (typeof window !== "undefined") {
windowHeight = window.innerHeight;
url_string = window.location.href;
url = new URL(url_string);
console.log("%c 2- URL in config:", "color: #006400; font-size: 16px; background-color: #f0f0f0;", url);
console.log("%c 3- URL origin in config:", "color: #006400;", url.origin);
idMap = url.searchParams.get("m");
idUser = url.searchParams.get("u");
console.log(`4- Parameter 'idMap' : ${idMap}`);
console.log(`5- Parameter 'idUser': ${idUser}`);
if (!USE_MOCK_API) {
if (isMockMode()) {
// Mock-Daten direkt aus public/mockData
mapGisStationsStaticDistrictUrl = "/mockData/gisStationsStaticDistrictMock.json";
mapGisStationsStatusDistrictUrl = "/mockData/gisStationsStatusDistrictMock.json";
mapGisStationsMeasurementsUrl = "/mockData/gisStationsMeasurementsMock.json";
mapGisSystemStaticUrl = "/mockData/gisSystemStaticMock.json";
mapDataIconUrl = "/mockData/deviceNameByIdMock.json";
webserviceGisLinesStatusUrl = "/mockData/gisStationsStatusMock.json";
console.log("📡 Mock-Mode aktiv: Daten werden aus /public/mockData geladen.");
} else {
// Echte URLs zur Webservice-API
mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`;
mapGisStationsStatusDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`;
mapGisStationsMeasurementsUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsMeasurements?idMap=${idMap}`;
mapGisSystemStaticUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`;
mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`;
webserviceGisLinesStatusUrl = `${serverURL}/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${idMap}`;
} else {
mapGisStationsStaticDistrictUrl = "/services/mockApi/fetchGisStationsStaticDistrict.js";
mapGisStationsStatusDistrictUrl = "/services/mockApi/fetchGisStationsStatusDistrict.js";
mapGisStationsMeasurementsUrl = "/services/mockApi/fetchGisStationsMeasurements.js";
mapGisSystemStaticUrl = "/services/mockApi/fetchGisSystemStatic.js";
// mapDataIconUrl = "/services/mockApi/fetchGisDataIcon.js"; // noch nicht vorhanden
// webserviceGisLinesStatusUrl = "/services/mockApi/"; // noch nicht vorhanden
console.log("🌐 Echt-Mode aktiv: Daten werden von der API geholt.");
}
}
// Export der definierten Variablen und URLs
// Export der Variablen und URLs
export {
mapVersion,
standardSideMenu,
fullSideMenu,
serverURL,
@@ -67,5 +72,5 @@ export {
mapGisSystemStaticUrl,
mapDataIconUrl,
webserviceGisLinesStatusUrl,
USE_MOCK_API, // Hier exportieren wir den Mock-Switch
isMockMode,
};

View File

@@ -3,6 +3,7 @@ import { useState, useEffect } from "react";
import usePoiTypData from "./usePoiTypData";
import { useRecoilValue } from "recoil";
import { poiLayerVisibleState } from "../redux/slices/poiLayerVisibleSlice";
import { isMockMode } from "../config/config";
export const useMapComponentState = () => {
const { poiTypData, isPoiTypLoaded } = usePoiTypData("/api/talas_v5_DB/poiTyp/readPoiTyp");
@@ -12,25 +13,32 @@ export const useMapComponentState = () => {
const [menuItemAdded, setMenuItemAdded] = useState(false);
const poiLayerVisible = useRecoilValue(poiLayerVisibleState);
// Fetch devices when the component is mounted
useEffect(() => {
const fetchDeviceData = async () => {
try {
const response = await fetch("/api/talas5/location_device"); // API call to get devices
const data = await response.json();
setLocationDeviceData(data); // Set the device data
if (isMockMode()) {
console.log("⚠️ Mock-API: Gerätedaten geladen");
const mockData = [{ name: "Mock-Gerät 1" }, { name: "Mock-Gerät 2" }];
setLocationDeviceData(mockData);
setDeviceName(mockData[0].name);
return;
}
try {
const response = await fetch("/api/talas5/location_device");
const data = await response.json();
setLocationDeviceData(data);
// Optional: set a default deviceName if needed
if (data.length > 0) {
setDeviceName(data[0].name); // Set the first device's name
setDeviceName(data[0].name);
}
} catch (error) {
console.error("Error fetching device data:", error);
console.error("❌ Fehler beim Abrufen der Gerätedaten:", error);
}
};
fetchDeviceData();
}, []); // Runs only once when the component is mounted
}, []);
return {
poiTypData,

View File

@@ -0,0 +1 @@
{ "50922": "CPL Ismael" }

View File

@@ -0,0 +1,17 @@
{
"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",
"Gr": "GMA",
"Area_Name": "Rastede"
}
]
}

View File

@@ -0,0 +1,381 @@
{
"Name": "Liste aller Geraete einer bestimmten Karte",
"Zeitstempel": "2025-03-05T14:55:10.1184475+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
},
{
"LD_Name": "Cisco Router 1841 ISA",
"IdLD": 50953,
"Device": "Cisco 1841",
"Link": "cisco1841.aspx?ver=1&id=50953",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 21,
"System": 6,
"Active": 1
},
{
"LD_Name": "Cisco Router 1921 ISA",
"IdLD": 50954,
"Device": "Cisco 1921",
"Link": "cisco1921.aspx?ver=1&id=50954",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 21,
"System": 6,
"Active": 1
},
{
"LD_Name": "Cisco Router 8200 ISA",
"IdLD": 50955,
"Device": "Cisco 8200",
"Link": "cisco8200.aspx?ver=1&id=50955",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 21,
"System": 6,
"Active": 1
},
{
"LD_Name": "Dauerzählstelle DZ ISA",
"IdLD": 50956,
"Device": "Dauerzählstelle DZ",
"Link": "dauz.aspx?ver=1&id=50956",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 14,
"System": 110,
"Active": 1
},
{
"LD_Name": "ECI Gerät ISA",
"IdLD": 50957,
"Device": "ECI",
"Link": "eci.aspx?ver=1&id=50957",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 17,
"System": 2,
"Active": 1
},
{
"LD_Name": "LTE-Modem LR77",
"IdLD": 50958,
"Device": "LTE Modem LR77",
"Link": "lr77.aspx?ver=1&id=50958",
"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": "Glasfaserüberwachung OTU ISA",
"IdLD": 50959,
"Device": "OTU",
"Link": "otu.aspx?ver=1&id=50959",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 24,
"System": 9,
"Active": 1
},
{
"LD_Name": "Siemens Notrufsystem ISA",
"IdLD": 50960,
"Device": "Notruf Server NRS 2000",
"Link": "nrs_server.aspx?ver=1&id=50960",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 19,
"System": 8,
"Active": 1
},
{
"LD_Name": "SMS-Modem ISA",
"IdLD": 50961,
"Device": "SMS Funkmodem",
"Link": "sms_modem.aspx?ver=1&id=50961",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 12,
"System": 111,
"Active": 1
},
{
"LD_Name": "Basisgerät Sonstige ISA",
"IdLD": 50962,
"Device": "Basisgerät",
"Link": "basis.aspx?ver=1&id=50962",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 31,
"System": 200,
"Active": 0
},
{
"LD_Name": "Talasmeldestation ISA",
"IdLD": 50963,
"Device": "CPL V3.5 mit 16 Kü",
"Link": "cpl.aspx?ver=35&kue=16&id=50963",
"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": "TALAS ICL M4 Meldestation ISA",
"IdLD": 50964,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50964",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 23,
"System": 100,
"Active": 1
},
{
"LD_Name": "TALAS ICL M2 Meldestation ISA",
"IdLD": 50965,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50965",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 23,
"System": 100,
"Active": 1
},
{
"LD_Name": "TALAS ICL M3 Meldestation ISA",
"IdLD": 50966,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50966",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 23,
"System": 100,
"Active": 1
},
{
"LD_Name": "TALAS ICL M1 Meldestation ISA",
"IdLD": 50967,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50967",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 23,
"System": 100,
"Active": 1
},
{
"LD_Name": "TL-Komponente-Router ISA",
"IdLD": 50968,
"Device": "TK-Router",
"Link": "tk_router.aspx?ver=1&id=50968",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 14,
"System": 30,
"Active": 1
},
{
"LD_Name": "TK-Anlage Alcatel OXO ISA",
"IdLD": 50969,
"Device": "TK-Anlage Alcatel OXO",
"Link": "tk_oxo.aspx?ver=1&id=50969",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 14,
"System": 30,
"Active": 1
},
{
"LD_Name": "WAGO Klemmen 16 ISA",
"IdLD": 50971,
"Device": "WAGO 16 DE",
"Link": "wago.aspx?ver=1&DE=16&id=50971",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 9,
"System": 7,
"Active": 1
},
{
"LD_Name": "WAGO Klemmen 32 ISA",
"IdLD": 50972,
"Device": "WAGO 32 DE",
"Link": "wago.aspx?ver=1&DE=32&id=50972",
"Location_Name": "Littwin",
"Location_Short": "LTW",
"IdLocation": 24101,
"Area_Name": "Rastede",
"Area_Short": "",
"IdArea": 20998,
"X": 53.246112,
"Y": 8.162241,
"Icon": 9,
"System": 7,
"Active": 1
}
]
}

View File

@@ -0,0 +1,115 @@
{
"Name": "Liste aller Statis der Geraete",
"Zeitstempel": "2025-03-05T14:56:54.4913452+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
}
]
}

View File

@@ -0,0 +1,115 @@
{
"Name": "Liste aller Statis der Geraete",
"Zeitstempel": "2025-03-05T15:04:09.206634+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
}
]
}

View File

@@ -0,0 +1,268 @@
{
"Name": "Liste aller angezeigten Systeme",
"Zeitstempel": "2025-03-05T15:04:55.2507517+01:00",
"IdMap": "12",
"Systems": [
{
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 3,
"Name": "ULAF",
"Longname": "ULAF Geräte",
"Allow": 0,
"Icon": 3
},
{
"IdSystem": 5,
"Name": "LTE Modem",
"Longname": "LR77 GSM Modems",
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 1,
"Icon": 6
},
{
"IdSystem": 7,
"Name": "WAGO",
"Longname": "WAGO I/O Systeme",
"Allow": 1,
"Icon": 7
},
{
"IdSystem": 8,
"Name": "Siemens",
"Longname": "Siemens Notrufsysteme",
"Allow": 1,
"Icon": 8
},
{
"IdSystem": 9,
"Name": "OTDR",
"Longname": "Glasfaserüberwachung OTU",
"Allow": 1,
"Icon": 9
},
{
"IdSystem": 10,
"Name": "WDM",
"Longname": " Wavelength Division Multiplexing",
"Allow": 1,
"Icon": 10
},
{
"IdSystem": 11,
"Name": "GMA",
"Longname": "Glättemeldeanlagen",
"Allow": 1,
"Icon": 11
},
{
"IdSystem": 13,
"Name": "Messstellen",
"Longname": "Messstellen",
"Allow": 0,
"Icon": 13
},
{
"IdSystem": 30,
"Name": "TK-Komponenten",
"Longname": "TK-Komponenten",
"Allow": 1,
"Icon": 30
},
{
"IdSystem": 100,
"Name": "TALAS ICL",
"Longname": "Talas ICL Unterstationen",
"Allow": 1,
"Icon": 100
},
{
"IdSystem": 110,
"Name": "DAUZ",
"Longname": "Dauerzählstellen",
"Allow": 1,
"Icon": 110
},
{
"IdSystem": 111,
"Name": "SMS Modem",
"Longname": "SMS Modem",
"Allow": 1,
"Icon": 111
},
{
"IdSystem": 200,
"Name": "Sonstige",
"Longname": "Sonstige",
"Allow": 1,
"Icon": 200
}
],
"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
}
]
}

View File

View File

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);
};

View File

@@ -4,7 +4,6 @@ import "leaflet.smooth_marker_bouncing";
import { toast } from "react-toastify";
import * as config from "../config/config.js";
import { disablePolylineEvents, enablePolylineEvents } from "./setupPolylines";
//import { setPolylineEventsDisabled } from "../store/atoms/polylineEventsDisabledState";
import { store } from "../redux/store";
import { updateLineStatus } from "../redux/slices/lineVisibilitySlice";
@@ -17,47 +16,54 @@ const determinePriority = (iconPath, priorityConfig) => {
return 5;
};
const fetchJsonSafely = async (url) => {
try {
const response = await fetch(url);
const text = await response.text(); // Erst als Text lesen
try {
return JSON.parse(text); // Falls es JSON ist, parsen
} catch (error) {
console.error(`❌ Fehler beim Parsen der JSON-Daten von ${url}. Antwort:`, text);
return null; // Falls die Antwort HTML ist, keine JSON-Verarbeitung versuchen
}
} catch (error) {
console.error(`❌ Fehler beim Abrufen der Daten von ${url}:`, error);
return null;
}
};
export const createAndSetDevices = async (systemId, setMarkersFunction, GisSystemStatic, priorityConfig) => {
try {
const response1 = await fetch(config.mapGisStationsStaticDistrictUrl);
const jsonResponse = await response1.json();
let staticDistrictData, statusDistrictData;
const response2 = await fetch(config.mapGisStationsStatusDistrictUrl);
const statusResponse = await response2.json();
if (config.isMockMode()) {
console.log("⚠️ Mock-API: Geräte-Daten geladen");
if (!jsonResponse.Points || !statusResponse.Statis) {
console.error("❌ Fehlende Daten in API-Response!");
staticDistrictData = await fetchJsonSafely("/mockData/gisStationsStaticDistrictMock.json");
statusDistrictData = await fetchJsonSafely("/mockData/gisStationsStatusDistrictMock.json");
} else {
staticDistrictData = await fetchJsonSafely(config.mapGisStationsStaticDistrictUrl);
statusDistrictData = await fetchJsonSafely(config.mapGisStationsStatusDistrictUrl);
}
if (!staticDistrictData?.Points || !statusDistrictData?.Statis) {
console.error("❌ Fehlende oder fehlerhafte Daten in API- oder Mock-Response!");
return;
}
console.log("✅ API-Daten geladen:", jsonResponse.Points.length, "Punkte gefunden.");
const statisMap = new Map(statusDistrictData.Statis.map((s) => [s.IdLD, s]));
// Erstelle eine Map für Statusinformationen
const statisMap = new Map(statusResponse.Statis.map((s) => [s.IdLD, s]));
// Speichere `idLD` und `Active` Werte in Redux
const allLines = jsonResponse.Points.filter((station) => station.System === systemId).map((station) => {
console.log("------------------------");
console.log("station.IdLD: ", station.IdLD);
console.log("station.Active: ", station.Active);
console.log("------------------------");
// Redux: Aktualisiere `idLD` und `Active` Werte
const allLines = staticDistrictData.Points.filter((station) => station.System === systemId).map((station) => {
store.dispatch(updateLineStatus({ idLD: station.IdLD, active: station.Active }));
return {
idLD: station.IdLD,
active: station.Active,
};
return { idLD: station.IdLD, active: station.Active };
});
console.log("🔄 Alle Linien gespeichert:", allLines);
// Filtere nur aktive Stationen für Marker
const activeStations = jsonResponse.Points.filter((station) => station.System === systemId && station.Active === 1);
console.log("🔍 Gefilterte aktive Stationen:", activeStations);
const activeStations = staticDistrictData.Points.filter((station) => station.System === systemId && station.Active === 1);
let markersData = activeStations.map((station) => {
const markersData = activeStations.map((station) => {
const statis = statisMap.get(station.IdLD);
const iconPath = statis ? `img/icons/${statis.Na}-marker-icon-${station.Icon}.png` : `img/icons/marker-icon-${station.Icon}.png`;
@@ -79,11 +85,11 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
marker.bindPopup(`
<div class="bg-white rounded-lg">
<span class="text-lg font-semibold text-gray-900">${station.LD_Name}</span>
<span class="text-md font-bold text-gray-800"> ${station.Device}</span><br>
<span class="text-gray-800"><strong> ${station.Area_Short} </strong>(${station.Area_Name})</span><br>
<span class="text-gray-800"><strong>${station.Location_Short} </strong> (${station.Location_Name})</span>
<span class="text-md font-bold text-gray-800">${station.Device}</span><br>
<span class="text-gray-800"><strong>${station.Area_Short}</strong> (${station.Area_Name})</span><br>
<span class="text-gray-800"><strong>${station.Location_Short}</strong> (${station.Location_Name})</span>
<div class="mt-2">
${statusResponse.Statis.filter((status) => status.IdLD === station.IdLD)
${statusDistrictData.Statis.filter((status) => status.IdLD === station.IdLD)
.reverse()
.map(
(status) => `
@@ -98,23 +104,11 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
</div>
`);
marker.on("mouseover", function () {
this.openPopup();
});
marker.on("mouseout", function () {
this.closePopup();
});
marker.on("contextmenu", function (event) {
if (event && event.preventDefault) event.preventDefault();
this.openPopup();
});
document.addEventListener("mouseout", function (event) {
if (event.relatedTarget === null || event.relatedTarget.nodeName === "BODY") {
enablePolylineEvents(window.polylines, window.lineColors);
}
marker.on("mouseover", () => marker.openPopup());
marker.on("mouseout", () => marker.closePopup());
marker.on("contextmenu", (event) => {
event.preventDefault();
marker.openPopup();
});
if (typeof marker.bounce === "function" && statis) {
@@ -124,8 +118,6 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
return marker;
});
console.log("📌 Marker erstellt:", markersData.length, markersData);
setMarkersFunction(markersData);
} catch (error) {
console.error("❌ Fehler beim Abrufen der Daten in createAndSetDevices.js: ", error);