fix: nur Daten abrufen, wenn 'Daten laden' button geklickt wird
This commit is contained in:
@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
|
|||||||
NEXT_PUBLIC_EXPORT_STATIC=false
|
NEXT_PUBLIC_EXPORT_STATIC=false
|
||||||
NEXT_PUBLIC_USE_CGI=false
|
NEXT_PUBLIC_USE_CGI=false
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.6.676
|
NEXT_PUBLIC_APP_VERSION=1.6.677
|
||||||
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)
|
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
|
|||||||
NEXT_PUBLIC_EXPORT_STATIC=true
|
NEXT_PUBLIC_EXPORT_STATIC=true
|
||||||
NEXT_PUBLIC_USE_CGI=true
|
NEXT_PUBLIC_USE_CGI=true
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.6.676
|
NEXT_PUBLIC_APP_VERSION=1.6.677
|
||||||
NEXT_PUBLIC_CPL_MODE=production
|
NEXT_PUBLIC_CPL_MODE=production
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
## [1.6.677] – 2025-08-01
|
||||||
|
|
||||||
|
- fix: link in console
|
||||||
|
|
||||||
|
---
|
||||||
## [1.6.676] – 2025-08-01
|
## [1.6.676] – 2025-08-01
|
||||||
|
|
||||||
- fix: richtige Link in system fetch service
|
- fix: richtige Link in system fetch service
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ export const DetailModal = ({
|
|||||||
datasets: [],
|
datasets: [],
|
||||||
});
|
});
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [shouldUpdateChart, setShouldUpdateChart] = useState(false);
|
||||||
const vonDatum = useSelector(
|
const vonDatum = useSelector(
|
||||||
(state: RootState) => state.kabelueberwachungChartSlice.vonDatum
|
(state: RootState) => state.kabelueberwachungChartSlice.vonDatum
|
||||||
);
|
);
|
||||||
@@ -197,6 +198,13 @@ export const DetailModal = ({
|
|||||||
// API-Request beim Klick auf "Daten laden"
|
// API-Request beim Klick auf "Daten laden"
|
||||||
const handleFetchData = () => {
|
const handleFetchData = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
|
// Clear previous chart data
|
||||||
|
setChartData({ datasets: [] });
|
||||||
|
|
||||||
|
// Flag setzen, dass Chart nach Datenempfang aktualisiert werden soll
|
||||||
|
setShouldUpdateChart(true);
|
||||||
|
|
||||||
switch (selectedKey) {
|
switch (selectedKey) {
|
||||||
case "+5V":
|
case "+5V":
|
||||||
dispatch(getSystemspannung5VplusThunk(zeitraum));
|
dispatch(getSystemspannung5VplusThunk(zeitraum));
|
||||||
@@ -233,12 +241,6 @@ export const DetailModal = ({
|
|||||||
chartRef.current.resetZoom();
|
chartRef.current.resetZoom();
|
||||||
}
|
}
|
||||||
}, [zeitraum]);
|
}, [zeitraum]);
|
||||||
// beim start soll der Chart einmal aufgerufen wird, also einmal der Button "Daten laden" geklickt werden
|
|
||||||
useEffect(() => {
|
|
||||||
if (isOpen && selectedKey) {
|
|
||||||
handleFetchData();
|
|
||||||
}
|
|
||||||
}, [isOpen, selectedKey]);
|
|
||||||
|
|
||||||
// Chart.js animation complete callback to set isLoading false
|
// Chart.js animation complete callback to set isLoading false
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -257,6 +259,40 @@ export const DetailModal = ({
|
|||||||
}
|
}
|
||||||
}, [chartData, isLoading]);
|
}, [chartData, isLoading]);
|
||||||
|
|
||||||
|
// Update chart data when Redux data changes (only after button click)
|
||||||
|
useEffect(() => {
|
||||||
|
if (shouldUpdateChart && reduxData && reduxData.length > 0) {
|
||||||
|
console.log("Redux data for chart:", reduxData);
|
||||||
|
|
||||||
|
// Convert Redux data to Chart.js format
|
||||||
|
const chartDataPoints = reduxData.map((entry) => ({
|
||||||
|
x: new Date(entry.t).getTime(),
|
||||||
|
y: entry.m || entry.a || entry.i || 0, // Use current value, max, min, or 0
|
||||||
|
}));
|
||||||
|
|
||||||
|
const newChartData = {
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: selectedKey || "Messwerte",
|
||||||
|
data: chartDataPoints,
|
||||||
|
borderColor: "#00AEEF", // littwin-blue
|
||||||
|
backgroundColor: "rgba(0, 174, 239, 0.2)", // littwin-blue mit Transparenz
|
||||||
|
tension: 0.1,
|
||||||
|
fill: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("Chart data points:", chartDataPoints);
|
||||||
|
setChartData(newChartData);
|
||||||
|
setShouldUpdateChart(false); // Reset flag
|
||||||
|
} else if (shouldUpdateChart && (!reduxData || reduxData.length === 0)) {
|
||||||
|
console.log("No Redux data available");
|
||||||
|
setChartData({ datasets: [] });
|
||||||
|
setShouldUpdateChart(false); // Reset flag
|
||||||
|
}
|
||||||
|
}, [reduxData, selectedKey, shouldUpdateChart]);
|
||||||
|
|
||||||
if (!isOpen || !selectedKey) return null;
|
if (!isOpen || !selectedKey) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.676",
|
"version": "1.6.677",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.676",
|
"version": "1.6.677",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/roboto": "^5.1.0",
|
"@fontsource/roboto": "^5.1.0",
|
||||||
"@headlessui/react": "^2.2.4",
|
"@headlessui/react": "^2.2.4",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.676",
|
"version": "1.6.677",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user