From ea6d71a4f54c4c804f599334b72fd5ebe66573d0 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 17 Sep 2025 09:16:04 +0200 Subject: [PATCH] feat: Alarm UI Widget --- .env.development | 2 +- .env.production | 2 +- components/mainComponent/MapComponent.js | 30 ++-- package-lock.json | 4 +- package.json | 2 +- websocketDump/GisStationsStaticDistrict.json | 2 +- websocketDump/GisStationsStatusDistrict.json | 138 +++++++------------ 7 files changed, 73 insertions(+), 107 deletions(-) diff --git a/.env.development b/.env.development index cff8e6582..9caa93f85 100644 --- a/.env.development +++ b/.env.development @@ -23,4 +23,4 @@ NEXT_PUBLIC_USE_MOCKS=true # z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.384 +NEXT_PUBLIC_APP_VERSION=1.1.385 diff --git a/.env.production b/.env.production index 696a6cacf..19d663a32 100644 --- a/.env.production +++ b/.env.production @@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=false # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.384 +NEXT_PUBLIC_APP_VERSION=1.1.385 diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 3bd7b7fa4..f0bdac077 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -133,7 +133,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const poiLayerVisible = useSelector(state => state.poiLayerVisible.visible); const zoomTrigger = useSelector(state => state.zoomTrigger.trigger); const poiReadTrigger = useSelector(state => state.poiReadFromDbTrigger.trigger); - const GisStationsStaticDistrict = useSelector(selectGisStationsStaticDistrict); + // entfernt, da weiter unten dynamisch und mit Fallback deklariert const gisSystemStaticStatus = useSelector(state => state.gisSystemStatic.status); const polylineEventsDisabled = useSelector(state => state.polylineEventsDisabled.disabled); const mapLayersVisibility = useSelector(selectMapLayersState) || {}; @@ -144,25 +144,37 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { selectGisLinesStatusFromWebservice ); - // Alarm Status und Link aus GisStationsStatusDistrict + // Alarm Status und Link dynamisch aus GisStationsStaticDistrict const gisStationsStatusDistrict = useSelector(state => state.gisStationsStatusDistrict.data); - // Unterstützt sowohl Array-Shape (Statis[]) als auch Objekt mit Statis-Array + const GisStationsStaticDistrict = useSelector(selectGisStationsStaticDistrict) || {}; + const pointsArr = GisStationsStaticDistrict.Points || []; let hasActiveAlarm = false; let alarmLink = ""; let alarmText = ""; + let alarmIdLD = null; if (Array.isArray(gisStationsStatusDistrict)) { - const alarmObj = gisStationsStatusDistrict.find(item => item?.Alarm === 1 && item?.AlarmLink); + const alarmObj = gisStationsStatusDistrict.find(item => item?.Alarm === 1); hasActiveAlarm = !!alarmObj; - alarmLink = alarmObj?.AlarmLink || ""; + alarmIdLD = alarmObj?.IdLD; alarmText = alarmObj?.Me || "Alarm aktiv"; } else if (gisStationsStatusDistrict?.Statis) { - const alarmObj = gisStationsStatusDistrict.Statis.find( - item => item?.Alarm === 1 && item?.AlarmLink - ); + const alarmObj = gisStationsStatusDistrict.Statis.find(item => item?.Alarm === 1); hasActiveAlarm = !!alarmObj; - alarmLink = alarmObj?.AlarmLink || ""; + alarmIdLD = alarmObj?.IdLD; alarmText = alarmObj?.Me || "Alarm aktiv"; } + if (hasActiveAlarm && alarmIdLD) { + const staticObj = pointsArr.find(p => p.IdLD === alarmIdLD); + if (staticObj && staticObj.Link) { + // Link kann relativ sein, ggf. mit Host ergänzen + const isAbsolute = + staticObj.Link.startsWith("http://") || staticObj.Link.startsWith("https://"); + alarmLink = isAbsolute + ? staticObj.Link + : //: `${window.location.origin}/talas5/devices/${staticObj.Link}`; + `http://10.10.0.13/talas5/devices/${staticObj.Link}`; // nur zum Testen + } + } const poiIconsData = useSelector(selectPoiIconsData); const poiIconsStatus = useSelector(selectPoiIconsStatus); const poiTypData = useSelector(selectPoiTypData); diff --git a/package-lock.json b/package-lock.json index 248fc30d3..95dd7e932 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.384", + "version": "1.1.385", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.384", + "version": "1.1.385", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 9728ab639..2ab34f38f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.384", + "version": "1.1.385", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/websocketDump/GisStationsStaticDistrict.json b/websocketDump/GisStationsStaticDistrict.json index e94367bc4..f73f29ea2 100644 --- a/websocketDump/GisStationsStaticDistrict.json +++ b/websocketDump/GisStationsStaticDistrict.json @@ -18,7 +18,7 @@ }, { "LD_Name": "GMA-isa-test", - "IdLD": 50981, + "IdLD": 50922, "Device": "Glättemeldeanlage", "Link": "gma.aspx?ver=1&id=50981", "Location_Name": "Littwin", diff --git a/websocketDump/GisStationsStatusDistrict.json b/websocketDump/GisStationsStatusDistrict.json index 09d9ed343..2cf063d4e 100644 --- a/websocketDump/GisStationsStatusDistrict.json +++ b/websocketDump/GisStationsStatusDistrict.json @@ -7,8 +7,7 @@ "Me": "Eingang DE 01 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -18,8 +17,7 @@ "Me": "Eingang DE 31 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -29,8 +27,7 @@ "Me": "Eingang DE 17 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -40,8 +37,7 @@ "Me": "Eingang DE 05 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -51,8 +47,7 @@ "Me": "Eingang DE 20 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -62,8 +57,7 @@ "Me": "Eingang DE 32 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -73,8 +67,7 @@ "Me": "Eingang DE 01 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50977, @@ -84,8 +77,7 @@ "Me": "Station offline", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50977, @@ -95,8 +87,7 @@ "Me": "Eingang DE 01 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -106,8 +97,7 @@ "Me": "Station offline", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50066, @@ -117,8 +107,7 @@ "Me": "CPL offline", "Feld": 5, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50011, @@ -128,8 +117,7 @@ "Me": "CPL offline", "Feld": 16, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50011, @@ -139,8 +127,7 @@ "Me": "Wasserdruck aus", "Feld": 16, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50011, @@ -150,8 +137,7 @@ "Me": "Ein", "Feld": 16, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50011, @@ -161,8 +147,7 @@ "Me": "Digitaleingang 1 ON", "Feld": 16, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50000, @@ -172,8 +157,7 @@ "Me": "Ein", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -183,8 +167,7 @@ "Me": "Station offline", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -194,8 +177,7 @@ "Me": "Eingang DE 32 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -205,8 +187,7 @@ "Me": "KÜG 07: Überspannung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -216,8 +197,7 @@ "Me": "KÜG 08: Überspannung gehend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50977, @@ -227,8 +207,7 @@ "Me": "KÜG 08: Überspannung gehend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -238,8 +217,7 @@ "Me": "KÜG 08: Überspannung gehend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -249,8 +227,7 @@ "Me": "Eingang DE 02 kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -260,8 +237,7 @@ "Me": "KÜG 08: Überspannung gehend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -271,8 +247,7 @@ "Me": "Eingang DE 03 Test Karte kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -282,8 +257,7 @@ "Me": "KÜG 01: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 1, - "AlarmLink": "http://10.10.0.13/talas5/devices/cpl.aspx?ver=35&kue=24&id=50977" + "Alarm": 0 }, { "IdLD": 50922, @@ -293,8 +267,7 @@ "Me": "KÜG 02: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50922, @@ -304,8 +277,7 @@ "Me": "KÜG 03: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50000, @@ -315,8 +287,7 @@ "Me": "über 8V kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -326,8 +297,7 @@ "Me": "KÜG 05: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -337,8 +307,7 @@ "Me": "KÜG 02: Isolationsminderung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50984, @@ -348,8 +317,7 @@ "Me": "KÜG 06: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 1 }, { "IdLD": 50977, @@ -359,8 +327,7 @@ "Me": "KÜG 01: Isolationsminderung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50977, @@ -370,8 +337,7 @@ "Me": "KÜG 06: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50977, @@ -381,8 +347,7 @@ "Me": "KÜG 05: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50976, @@ -392,8 +357,7 @@ "Me": "CPL offline", "Feld": 3, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50976, @@ -403,8 +367,7 @@ "Me": "KÜG 03: Isolationsminderung kommend", "Feld": 3, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -414,8 +377,7 @@ "Me": "KÜG 04: Isolationsminderung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -425,8 +387,7 @@ "Me": "KÜG 02: Isolationsminderung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -436,8 +397,7 @@ "Me": "KÜG 01: Isolationsminderung kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50001, @@ -447,8 +407,7 @@ "Me": "Sammelstörung kommend", "Feld": 5, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -458,8 +417,7 @@ "Me": "KÜG 06: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50975, @@ -469,8 +427,7 @@ "Me": "KÜG 05: Aderbruch kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50963, @@ -480,8 +437,7 @@ "Me": "CPL offline", "Feld": 3, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50063, @@ -491,8 +447,7 @@ "Me": "Digitaleingang 1 EIN", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 }, { "IdLD": 50000, @@ -502,7 +457,6 @@ "Me": "über 10V kommend", "Feld": 4, "Icon": 0, - "Alarm": 0, - "AlarmLink": "" + "Alarm": 0 } ] \ No newline at end of file