Fix: Messkurven-Modal (ISO/RSL) lädt Kurve automatisch, setzt Dropdown & DateRangePicker korrekt zurück
- Dropdown für Messkurven (ISO/RSL) wird beim Öffnen auf 'Alle Messwerte' (DIA0) gesetzt - Messkurve wird beim Öffnen des Modals automatisch geladen - Beim Schließen werden vonDatum, bisDatum, Dropdown und DateRangePicker zurückgesetzt - Gleiches Verhalten für ISO- und RSL/Loop-Modal
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
"use client";
|
||||
// /components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, {
|
||||
useEffect,
|
||||
useState,
|
||||
forwardRef,
|
||||
useImperativeHandle,
|
||||
} from "react";
|
||||
import { useAppDispatch } from "@/redux/store";
|
||||
import { getMessagesThunk } from "@/redux/thunks/getMessagesThunk";
|
||||
import { RSL_DURATION_SECONDS, NODE_ENV } from "@/utils/env";
|
||||
@@ -94,7 +99,7 @@ export const useLoopChartLoader = () => {
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------LoopChartActionBar
|
||||
const LoopChartActionBar: React.FC = () => {
|
||||
const LoopChartActionBar = forwardRef((_props, ref) => {
|
||||
const dispatch = useAppDispatch();
|
||||
// RSL Progress State – Dauer konfigurierbar über NEXT_PUBLIC_RSL_DURATION_SECONDS
|
||||
const TOTAL_DURATION = RSL_DURATION_SECONDS;
|
||||
@@ -272,6 +277,10 @@ const LoopChartActionBar: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
handleFetchData,
|
||||
}));
|
||||
|
||||
return (
|
||||
<div className="flex justify-between p-1 bg-gray-100 rounded-lg ">
|
||||
<div className="flex items-center">
|
||||
@@ -393,6 +402,7 @@ const LoopChartActionBar: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
LoopChartActionBar.displayName = "LoopChartActionBar";
|
||||
export default LoopChartActionBar;
|
||||
|
||||
@@ -6,6 +6,7 @@ import ReactModal from "react-modal";
|
||||
import LoopMeasurementChart from "./LoopMeasurementChart";
|
||||
import Report from "../IsoMeasurementChart/Report";
|
||||
import LoopChartActionBar from "./LoopChartActionBar";
|
||||
import { useRef } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { AppDispatch } from "@/redux/store";
|
||||
import { RootState } from "@/redux/store";
|
||||
@@ -85,6 +86,7 @@ const LoopChartView: React.FC<LoopChartViewProps> = ({
|
||||
};
|
||||
|
||||
// Modal öffnen - RSL spezifische Einstellungen
|
||||
const actionBarRef = useRef<{ handleFetchData: () => void }>(null);
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
const today = new Date();
|
||||
@@ -104,10 +106,13 @@ const LoopChartView: React.FC<LoopChartViewProps> = ({
|
||||
dispatch(setSelectedSlotType("schleifenwiderstand"));
|
||||
dispatch(setSelectedMode("DIA0")); // Set to Alle Messwerte on open
|
||||
|
||||
// Load data for Schleife mode after a small delay to ensure Redux state is updated
|
||||
setTimeout(() => {
|
||||
loadLoopChartData.loadLoopChartData();
|
||||
}, 10);
|
||||
// Automatisch Daten laden wie Button-Klick
|
||||
const timer = setTimeout(() => {
|
||||
actionBarRef.current?.handleFetchData();
|
||||
}, 120);
|
||||
|
||||
// Cleanup timer
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
//ESLint ignore
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -238,7 +243,7 @@ const LoopChartView: React.FC<LoopChartViewProps> = ({
|
||||
</div>
|
||||
</Listbox>
|
||||
</div>
|
||||
<LoopChartActionBar />
|
||||
<LoopChartActionBar ref={actionBarRef} />
|
||||
<div style={{ flex: 1, height: "90%" }}>
|
||||
{chartTitle === "Messkurve" ? (
|
||||
<LoopMeasurementChart />
|
||||
|
||||
Reference in New Issue
Block a user