letzte Zustand 03.04.2025
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
} from "../../../../../redux/slices/tdrChartSlice";
|
||||
import { resetBrushRange } from "../../../../../redux/slices/brushSlice";
|
||||
import { fetchTDMDataBySlotThunk } from "../../../../../redux/thunks/fetchTDMListBySlotThunk";
|
||||
import { useLoopChartLoader } from "./LoopMeasurementChart/LoopChartActionBar";
|
||||
|
||||
interface ChartSwitcherProps {
|
||||
isOpen: boolean;
|
||||
@@ -75,6 +76,24 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({
|
||||
}, [dispatch]);
|
||||
*/
|
||||
//-------------------------------------
|
||||
const { loadLoopChartData } = useLoopChartLoader();
|
||||
useEffect(() => {
|
||||
if (isOpen && activeMode === "Schleife") {
|
||||
loadLoopChartData();
|
||||
}
|
||||
}, [isOpen, activeMode]);
|
||||
//-------------------------------------
|
||||
const slotNumber = useSelector(
|
||||
(state: RootState) => state.kabelueberwachungChartSlice.slotNumber
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && activeMode === "Schleife" && slotNumber !== null) {
|
||||
loadLoopChartData();
|
||||
}
|
||||
}, [isOpen, activeMode, slotNumber]);
|
||||
|
||||
//-----------------------------------------
|
||||
return (
|
||||
<ReactModal
|
||||
isOpen={isOpen}
|
||||
|
||||
@@ -15,7 +15,72 @@ import {
|
||||
} from "../../../../../../redux/slices/kabelueberwachungChartSlice";
|
||||
import { setBrushRange } from "../../../../../../redux/slices/brushSlice";
|
||||
import { setChartTitle } from "../../../../../../redux/slices/loopChartTypeSlice";
|
||||
//-----------------------------------------------------------------------------------useLoopChartLoader
|
||||
export const useLoopChartLoader = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { vonDatum, bisDatum, selectedMode, selectedSlotType, slotNumber } =
|
||||
useSelector((state: RootState) => state.kabelueberwachungChartSlice);
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
const [year, month, day] = dateString.split("-");
|
||||
return `${year};${month};${day}`;
|
||||
};
|
||||
|
||||
const getApiUrl = (
|
||||
mode: "DIA0" | "DIA1" | "DIA2",
|
||||
type: number,
|
||||
slotNumber: number
|
||||
) => {
|
||||
const typeFolder =
|
||||
type === 3 ? "isolationswiderstand" : "schleifenwiderstand";
|
||||
return `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate(
|
||||
vonDatum
|
||||
)};${formatDate(bisDatum)};${slotNumber};${type};`;
|
||||
};
|
||||
|
||||
const loadLoopChartData = async () => {
|
||||
const type = selectedSlotType === "schleifenwiderstand" ? 4 : 3;
|
||||
if (slotNumber === null) return;
|
||||
|
||||
dispatch(setLoading(true));
|
||||
dispatch(setChartOpen(false));
|
||||
dispatch(setLoopMeasurementCurveChartData([]));
|
||||
dispatch(setFullScreen(false));
|
||||
|
||||
const startTime = Date.now();
|
||||
const MIN_LOADING_TIME_MS = 1000;
|
||||
|
||||
try {
|
||||
const apiUrl = getApiUrl(selectedMode, type, slotNumber);
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
const waitTime = Math.max(
|
||||
0,
|
||||
MIN_LOADING_TIME_MS - (Date.now() - startTime)
|
||||
);
|
||||
await new Promise((res) => setTimeout(res, waitTime));
|
||||
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
dispatch(setLoopMeasurementCurveChartData(data));
|
||||
dispatch(setChartOpen(true));
|
||||
} else {
|
||||
dispatch(setLoopMeasurementCurveChartData([]));
|
||||
dispatch(setChartOpen(false));
|
||||
alert("⚠️ Keine Daten im gewählten Zeitraum.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("❌ Fehler beim Laden:", err);
|
||||
alert("❌ Fehler beim Laden.");
|
||||
} finally {
|
||||
dispatch(setLoading(false));
|
||||
}
|
||||
};
|
||||
|
||||
return { loadLoopChartData };
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------LoopChartActionBar
|
||||
const LoopChartActionBar: React.FC = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||
|
||||
*/
|
||||
const webVersion = "1.6.212";
|
||||
const webVersion = "1.6.213";
|
||||
export default webVersion;
|
||||
|
||||
Reference in New Issue
Block a user