From ed48023abb9de313dcbba6869b35f460e4ca00ab Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 18 Jun 2024 14:59:35 +0200 Subject: [PATCH] add: You can switch in /config/config.js linesColorApi or GisLinesStatus , locally or remotely API-Endpoint-Function from Webservice --- components/MapComponent.js | 7 ++++--- config/config.js | 7 ++++++- pages/api/linesColorApi.js | 42 +++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index a0e625fd9..f759eed7f 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -219,6 +219,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const mapGisStationsMeasurementsUrl = config.mapGisStationsMeasurementsUrl; const mapGisSystemStaticUrl = config.mapGisSystemStaticUrl; const mapDataIconUrl = config.mapDataIconUrl; + const webserviceGisLinesStatusUrl = config.webserviceGisLinesStatusUrl; const openVersionInfoModal = () => { setShowVersionInfoModal(true); @@ -2085,11 +2086,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { useEffect(() => { const fetchLinesColor = async () => { try { - const response = await fetch("/api/linesColorApi"); + const response = await fetch(webserviceGisLinesStatusUrl); const data = await response.json(); const colorsByModule = {}; - data.linesColor.Statis.forEach((item) => { - colorsByModule[item.IdModul] = item.Co; + data.Statis.forEach((item) => { + colorsByModule[item.Modul] = item.PrioColor; }); setLineColors(colorsByModule); } catch (error) { diff --git a/config/config.js b/config/config.js index d38803d40..8b4725ba4 100644 --- a/config/config.js +++ b/config/config.js @@ -11,7 +11,8 @@ let mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, - mapDataIconUrl; + mapDataIconUrl, + webserviceGisLinesStatusUrl; // Prüfen, ob das Code im Browser ausgeführt wird if (typeof window !== "undefined") { @@ -36,6 +37,9 @@ if (typeof window !== "undefined") { mapGisSystemStaticUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${c}&idUser=${user}`; mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`; + //webserviceGisLinesStatusUrl = `http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${c}`; + webserviceGisLinesStatusUrl = `http://localhost:3000/api/linesColorApi`; + //http://10.10.0.13/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=12&idUser=484 /* mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict`; @@ -61,4 +65,5 @@ export { mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, mapDataIconUrl, + webserviceGisLinesStatusUrl, }; diff --git a/pages/api/linesColorApi.js b/pages/api/linesColorApi.js index 53b924638..33ddb46a4 100644 --- a/pages/api/linesColorApi.js +++ b/pages/api/linesColorApi.js @@ -2,7 +2,7 @@ // http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict export default function handler(req, res) { - const linesColor = { + /* const linesColor = { Statis: [ { IdModul: 1, @@ -32,6 +32,46 @@ export default function handler(req, res) { Icon: 0, }, ], + }; */ + const linesColor = { + Statis: [ + { + IdLD: 25440, + Modul: 1, + DpName: "KUE01_Ausfall", + ModulName: "42 Wippershain Sender", + ModulTyp: "nicht vorhanden", + Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend", + Level: 4, + PrioColor: "#FF00FF", + PrioName: "system", + Value: "?", + }, + { + IdLD: 25440, + Modul: 3, + DpName: "KUE03_Ausfall", + ModulName: "42 Solz Sender", + ModulTyp: "nicht vorhanden", + Message: "KÜG 03: 42 Solz Sender Messwerkausfall kommend", + Level: 4, + PrioColor: "#FF00FF", + PrioName: "system", + Value: "?", + }, + { + IdLD: 25440, + Modul: 4, + DpName: "KUE04_Ausfall", + ModulName: "42/13 Bad Hersfeld Gaswerk", + ModulTyp: "Kü705-FO", + Message: "KÜG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend", + Level: 4, + PrioColor: "#FF00FF", + PrioName: "system", + Value: "?", + }, + ], }; res.status(200).json({ linesColor });