From 016e1a927dbf74ec48668b65927c3f430d3eaada Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 25 Jun 2025 08:43:26 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20Tooltip-Generierung=20f=C3=BCr=20Li?= =?UTF-8?q?nien=20ausgelagert=20und=20Anzeige=20von=20Stationsnamen=20(LD?= =?UTF-8?q?=5FName)=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `generateLineTooltipContent` in eigene Datei extrahiert - `useLineData` angepasst, um Stationen aus `gisStationsStaticDistrict` zu übergeben - Anzeige der Station im Tooltip nun über `LD_Name` statt `matchingLine.name` - Bugfix: "Station: N/A" wird nun korrekt angezeigt --- .env.development | 2 +- .env.production | 2 +- .../tooltip/generateLineTooltipContent.js | 15 ++++++++++----- components/gisPolylines/tooltip/useLineData.js | 11 +++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.env.development b/.env.development index 9aa05bfb3..474ed1088 100644 --- a/.env.development +++ b/.env.development @@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=true NEXT_PUBLIC_BASE_PATH=/talas5 # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.297 +NEXT_PUBLIC_APP_VERSION=1.1.298 diff --git a/.env.production b/.env.production index 748e94ec2..8e6f7b310 100644 --- a/.env.production +++ b/.env.production @@ -26,4 +26,4 @@ NEXT_PUBLIC_BASE_PATH=/talas5 # Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH= # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.297 \ No newline at end of file +NEXT_PUBLIC_APP_VERSION=1.1.298 \ No newline at end of file diff --git a/components/gisPolylines/tooltip/generateLineTooltipContent.js b/components/gisPolylines/tooltip/generateLineTooltipContent.js index aa3033779..ee2f4ee58 100644 --- a/components/gisPolylines/tooltip/generateLineTooltipContent.js +++ b/components/gisPolylines/tooltip/generateLineTooltipContent.js @@ -1,4 +1,9 @@ -export function generateLineTooltipContent(statis, matchingLine, values) { +// /components/gisPolylines/tooltip/generateLineTooltipContent.js +// KEIN useSelector hier! +export function generateLineTooltipContent(statis, matchingLine, values, stations) { + const station = stations.find(s => s.IdLD === statis.IdLD); + const stationName = station?.LD_Name || "N/A"; + const messageDisplay = values.messages .map( msg => @@ -14,12 +19,12 @@ export function generateLineTooltipContent(statis, matchingLine, values) { ${statis.ModulName || "Unknown"}
${statis.ModulTyp || "N/A"}
Slot: ${statis.Modul || "N/A"}
- Station: ${ - matchingLine.name || "N/A" - }
+ Station: ${stationName} +
${messageDisplay} -

+ +
${ values.messwert ? `Messwert: ${values.messwert}
` diff --git a/components/gisPolylines/tooltip/useLineData.js b/components/gisPolylines/tooltip/useLineData.js index 1f1e787c5..aba50d591 100644 --- a/components/gisPolylines/tooltip/useLineData.js +++ b/components/gisPolylines/tooltip/useLineData.js @@ -5,6 +5,7 @@ import { selectGisLinesStatusFromWebservice } from "@/redux/slices/webservice/gi import { fetchGisLinesThunk } from "@/redux/thunks/database/polylines/fetchGisLinesThunk"; import { fetchGisLinesStatusThunk } from "@/../redux/thunks/webservice/fetchGisLinesStatusThunk"; import { generateLineTooltipContent } from "./generateLineTooltipContent"; +import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice"; const useLineData = () => { const dispatch = useDispatch(); @@ -13,6 +14,7 @@ const useLineData = () => { const linesData = useSelector(state => state.gisLinesFromDatabase.data); const [lineColors, setLineColors] = useState({}); const [tooltipContents, setTooltipContents] = useState({}); + const stations = useSelector(selectGisStationsStaticDistrict)?.Points ?? []; useEffect(() => { dispatch(fetchGisLinesThunk()); @@ -70,13 +72,18 @@ const useLineData = () => { colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green"; - newTooltipContents[key] = generateLineTooltipContent(statis, matchingLine, values); + newTooltipContents[key] = generateLineTooltipContent( + statis, + matchingLine, + values, + stations + ); } }); setLineColors(colorsByModule); setTooltipContents(newTooltipContents); - }, [statisData, linesData]); + }, [statisData, linesData, stations]); return { lineColors, tooltipContents }; }; diff --git a/package-lock.json b/package-lock.json index 333ce296f..6736f13d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.297", + "version": "1.1.298", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.297", + "version": "1.1.298", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 0eaf2fbb1..fbdf960c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.297", + "version": "1.1.298", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0",