From 7c4fbc3988f4732a16b0874f6f3710bc10f94486 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 25 Jun 2025 07:21:05 +0200 Subject: [PATCH] refactor: Komponenten-Hooks strukturiert und in passende UI-Unterverzeichnisse verschoben MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useLineData.js → components/gisPolylines/tooltip/ - useLayerVisibility.js → components/mapLayersControlPanel/hooks/ - useAreaMarkersLayer.js → components/area/hooks/ - useDynamicDeviceLayers.js → components/devices/hooks/ - useDataUpdater.js & useMapComponentState.js → components/hooks/ 💡 Ziel: Alle UI-bezogenen Hooks an logische Stellen verschoben, um Wartbarkeit zu verbessern. 🔍 Vorteil: Schnellere Navigation bei UI-Fehlern oder Layout-Anpassungen. --- .env.development | 2 +- .env.production | 2 +- .../area/hooks}/useAreaMarkersLayer.js | 0 .../devices/hooks}/useDynamicDeviceLayers.js | 4 +- .../gisPolylines/tooltip}/useLineData.js | 52 ++++++++++++++----- {hooks => components/hooks}/useDataUpdater.js | 10 ++-- .../hooks}/useMapComponentState.js | 0 components/mainComponent/MapComponent.js | 10 ++-- .../hooks}/useLayerVisibility.js | 0 package-lock.json | 4 +- package.json | 2 +- 11 files changed, 55 insertions(+), 31 deletions(-) rename {hooks => components/area/hooks}/useAreaMarkersLayer.js (100%) rename {hooks => components/devices/hooks}/useDynamicDeviceLayers.js (96%) rename {hooks => components/gisPolylines/tooltip}/useLineData.js (60%) rename {hooks => components/hooks}/useDataUpdater.js (67%) rename {hooks => components/hooks}/useMapComponentState.js (100%) rename {hooks => components/mapLayersControlPanel/hooks}/useLayerVisibility.js (100%) diff --git a/.env.development b/.env.development index 2d7bcf5c6..f1eadb417 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.295 +NEXT_PUBLIC_APP_VERSION=1.1.296 diff --git a/.env.production b/.env.production index 7140d4291..0ab757789 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.295 \ No newline at end of file +NEXT_PUBLIC_APP_VERSION=1.1.296 \ No newline at end of file diff --git a/hooks/useAreaMarkersLayer.js b/components/area/hooks/useAreaMarkersLayer.js similarity index 100% rename from hooks/useAreaMarkersLayer.js rename to components/area/hooks/useAreaMarkersLayer.js diff --git a/hooks/useDynamicDeviceLayers.js b/components/devices/hooks/useDynamicDeviceLayers.js similarity index 96% rename from hooks/useDynamicDeviceLayers.js rename to components/devices/hooks/useDynamicDeviceLayers.js index bfd501d45..8b4198b06 100644 --- a/hooks/useDynamicDeviceLayers.js +++ b/components/devices/hooks/useDynamicDeviceLayers.js @@ -1,8 +1,8 @@ // /hooks/layers/useDynamicDeviceLayers.js import { useEffect, useRef, useState } from "react"; import L from "leaflet"; -import { createAndSetDevices } from "../utils/devices/createAndSetDevices"; -import { checkOverlappingMarkers } from "../utils/mapUtils"; +import { createAndSetDevices } from "@/utils/devices/createAndSetDevices"; +import { checkOverlappingMarkers } from "@/utils/mapUtils"; import plusRoundIcon from "@/components/icons/devices/overlapping/PlusRoundIcon"; import { useSelector } from "react-redux"; import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice.js"; diff --git a/hooks/useLineData.js b/components/gisPolylines/tooltip/useLineData.js similarity index 60% rename from hooks/useLineData.js rename to components/gisPolylines/tooltip/useLineData.js index d1c7534e2..6c5471357 100644 --- a/hooks/useLineData.js +++ b/components/gisPolylines/tooltip/useLineData.js @@ -1,15 +1,15 @@ // hooks/useLineData.js //fix v1.0.8.1 import { useEffect, useState } from "react"; import { useSelector, useDispatch } from "react-redux"; -import { selectGisLinesStatusFromWebservice } from "../redux/slices/webservice/gisLinesStatusSlice"; -import { fetchGisLinesThunk } from "../redux/thunks/database/polylines/fetchGisLinesThunk"; -import { fetchGisLinesStatusThunk } from "../redux/thunks/webservice/fetchGisLinesStatusThunk"; +import { selectGisLinesStatusFromWebservice } from "@/redux/slices/webservice/gisLinesStatusSlice"; +import { fetchGisLinesThunk } from "@/redux/thunks/database/polylines/fetchGisLinesThunk"; +import { fetchGisLinesStatusThunk } from "@/../redux/thunks/webservice/fetchGisLinesStatusThunk"; const useLineData = () => { const dispatch = useDispatch(); const { data: statisData } = useSelector(selectGisLinesStatusFromWebservice); - const linesData = useSelector((state) => state.gisLinesFromDatabase.data); + const linesData = useSelector(state => state.gisLinesFromDatabase.data); const [lineColors, setLineColors] = useState({}); const [tooltipContents, setTooltipContents] = useState({}); @@ -27,7 +27,7 @@ const useLineData = () => { const sortedStatis = [...statisData].sort((a, b) => a.Level - b.Level); - sortedStatis.forEach((statis) => { + sortedStatis.forEach(statis => { const key = `${statis.IdLD}-${statis.Modul}`; if (!valueMap[key]) { valueMap[key] = { @@ -37,7 +37,11 @@ const useLineData = () => { }; } - if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) { + if ( + statis.DpName.endsWith("_Messwert") && + statis.Value !== "True" && + !valueMap[key].messwert + ) { valueMap[key].messwert = statis.Value; } @@ -48,37 +52,57 @@ const useLineData = () => { if (statis.Message && statis.Message !== "?") { valueMap[key].messages.push({ message: statis.Message, - prioColor: statis.PrioColor && statis.PrioColor !== "#ffffff" ? statis.PrioColor : "green", + prioColor: + statis.PrioColor && statis.PrioColor !== "#ffffff" ? statis.PrioColor : "green", }); } }); - sortedStatis.forEach((statis) => { + sortedStatis.forEach(statis => { const key = `${statis.IdLD}-${statis.Modul}`; - const matchingLine = linesData.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul); + const matchingLine = linesData.find( + item => item.idLD === statis.IdLD && item.idModul === statis.Modul + ); if (matchingLine) { const values = valueMap[key]; - const messageDisplay = values.messages.map((msg) => `${msg.message}
`).join(""); + const messageDisplay = values.messages + .map( + msg => + `${msg.message}
` + ) + .join(""); colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green"; newTooltipContents[key] = `
- ${statis.ModulName || "Unknown"} + ${ + statis.ModulName || "Unknown" + }
${statis.ModulTyp || "N/A"}
Slot: ${statis.Modul || "N/A"}
- Station: ${matchingLine.name || "N/A"} + Station: ${ + matchingLine.name || "N/A" + }
${messageDisplay}

- ${values.messwert ? `Messwert: ${values.messwert}
` : ""} - ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""} + ${ + values.messwert + ? `Messwert: ${values.messwert}
` + : "" + } + ${ + values.schleifenwert + ? `Schleifenwert: ${values.schleifenwert}` + : "" + }
`; } diff --git a/hooks/useDataUpdater.js b/components/hooks/useDataUpdater.js similarity index 67% rename from hooks/useDataUpdater.js rename to components/hooks/useDataUpdater.js index 45b193214..c31898bfc 100644 --- a/hooks/useDataUpdater.js +++ b/components/hooks/useDataUpdater.js @@ -4,11 +4,11 @@ import { useDispatch } from "react-redux"; // import type { AppDispatch } from "../redux/store"; // ✅ Thunks aus korrektem Pfad importieren -import { fetchGisLinesStatusThunk } from "../redux/thunks/webservice/fetchGisLinesStatusThunk"; -import { fetchGisStationsMeasurementsThunk } from "../redux/thunks/webservice/fetchGisStationsMeasurementsThunk"; -import { fetchGisStationsStaticDistrictThunk } from "../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk"; -import { fetchGisStationsStatusDistrictThunk } from "../redux/thunks/webservice/fetchGisStationsStatusDistrictThunk"; -import { fetchGisSystemStaticThunk } from "../redux/thunks/webservice/fetchGisSystemStaticThunk"; +import { fetchGisLinesStatusThunk } from "@/redux/thunks/webservice/fetchGisLinesStatusThunk"; +import { fetchGisStationsMeasurementsThunk } from "@/redux/thunks/webservice/fetchGisStationsMeasurementsThunk"; +import { fetchGisStationsStaticDistrictThunk } from "@/redux/thunks/webservice/fetchGisStationsStaticDistrictThunk"; +import { fetchGisStationsStatusDistrictThunk } from "@/redux/thunks/webservice/fetchGisStationsStatusDistrictThunk"; +import { fetchGisSystemStaticThunk } from "@/redux/thunks/webservice/fetchGisSystemStaticThunk"; const REFRESH_INTERVAL = parseInt(process.env.NEXT_PUBLIC_REFRESH_INTERVAL || "10000"); diff --git a/hooks/useMapComponentState.js b/components/hooks/useMapComponentState.js similarity index 100% rename from hooks/useMapComponentState.js rename to components/hooks/useMapComponentState.js diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 122ec057b..0d3a3a8a3 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -13,11 +13,11 @@ import plusRoundIcon from "../icons/devices/overlapping/PlusRoundIcon.js"; import { restoreMapSettings, checkOverlappingMarkers } from "../../utils/mapUtils.js"; import addItemsToMapContextMenu from "@/components/contextmenu/useMapContextMenu.js"; -import useAreaMarkersLayer from "@/hooks/useAreaMarkersLayer.js"; +import useAreaMarkersLayer from "@/components/area/hooks/useAreaMarkersLayer.js"; import { setupPolylines } from "@/utils/polylines/setupPolylines.js"; import { setupPOIs } from "@/utils/setupPOIs.js"; -import useLineData from "@/hooks/useLineData.js"; -import { useMapComponentState } from "@/hooks/useMapComponentState.js"; +import useLineData from "@/components/gisPolylines/tooltip/useLineData.js"; +import { useMapComponentState } from "@/components/hooks/useMapComponentState.js"; import CoordinatePopup from "@/components/contextmenu/CoordinatePopup.js"; //----------Ui Widgets---------------- import MapLayersControlPanel from "@/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js"; @@ -74,9 +74,9 @@ import { fetchPoiIconsDataThunk } from "@/redux/thunks/database/pois/fetchPoiIco import { fetchPoiTypThunk } from "@/redux/thunks/database/pois/fetchPoiTypThunk.js"; import { updateAreaThunk } from "@/redux/thunks/database/area/updateAreaThunk"; -import useDynamicDeviceLayers from "@/hooks/useDynamicDeviceLayers.js"; +import useDynamicDeviceLayers from "@/components/devices/hooks/useDynamicDeviceLayers.js"; -import useDataUpdater from "@/hooks/useDataUpdater"; +import useDataUpdater from "@/components/hooks/useDataUpdater.js"; import { cleanupPolylinesForMemory } from "@/utils/polylines/cleanupPolylinesForMemory"; import { cleanupMarkers } from "@/utils/common/cleanupMarkers"; import { monitorHeapAndReload } from "@/utils/common/monitorMemory"; diff --git a/hooks/useLayerVisibility.js b/components/mapLayersControlPanel/hooks/useLayerVisibility.js similarity index 100% rename from hooks/useLayerVisibility.js rename to components/mapLayersControlPanel/hooks/useLayerVisibility.js diff --git a/package-lock.json b/package-lock.json index bde24df4f..8c4672df4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.295", + "version": "1.1.296", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.295", + "version": "1.1.296", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 10f21ee54..b500bda66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.295", + "version": "1.1.296", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0",