Fix: Always show vonDatum and bisDatum in fetch URL for analog inputs chart
- Ensure local date state is never empty by falling back to default date if Redux is empty - Prevent missing date values in fetch URL after multiple dropdown or button interactions - Improves reliability of
This commit is contained in:
@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
|
||||
NEXT_PUBLIC_EXPORT_STATIC=false
|
||||
NEXT_PUBLIC_USE_CGI=false
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.629
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.630
|
||||
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_USE_CGI=true
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.629
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.630
|
||||
NEXT_PUBLIC_CPL_MODE=production
|
||||
@@ -1,3 +1,12 @@
|
||||
## [1.6.630] – 2025-07-22
|
||||
|
||||
- Fix: Preserve chart state during zoom, pan, and date changes
|
||||
|
||||
- Added React.useMemo to memoize chartData and chartOptions to prevent unnecessary re-renders.
|
||||
- Ensured chart zoom and pan states are maintained during interactions.
|
||||
- Improved performance and user experience by avoiding chart
|
||||
|
||||
---
|
||||
## [1.6.629] – 2025-07-22
|
||||
|
||||
- Fix: Preserve chart state during zoom, pan, and date changes
|
||||
|
||||
@@ -70,15 +70,28 @@ export default function AnalogInputsChart() {
|
||||
(state: RootState) => state.dateRangePicker.bisDatum
|
||||
);
|
||||
|
||||
// Hilfsfunktion für Default-Datum
|
||||
const getDefaultDate = (type: "from" | "to") => {
|
||||
const today = new Date();
|
||||
if (type === "to") return today.toISOString().slice(0, 10);
|
||||
const fromDateObj = new Date(today);
|
||||
fromDateObj.setDate(today.getDate() - 30);
|
||||
return fromDateObj.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
// ✅ Lokale States für Picker + Zeitraum
|
||||
const [localVonDatum, setLocalVonDatum] = React.useState(vonDatumRedux || "");
|
||||
const [localBisDatum, setLocalBisDatum] = React.useState(bisDatumRedux || "");
|
||||
const [localVonDatum, setLocalVonDatum] = React.useState(
|
||||
vonDatumRedux || getDefaultDate("from")
|
||||
);
|
||||
const [localBisDatum, setLocalBisDatum] = React.useState(
|
||||
bisDatumRedux || getDefaultDate("to")
|
||||
);
|
||||
const [localZeitraum, setLocalZeitraum] = React.useState(zeitraum);
|
||||
|
||||
// Synchronisiere lokale Werte mit Redux (z.B. nach AutoLoad Reset)
|
||||
useEffect(() => {
|
||||
setLocalVonDatum(vonDatumRedux || "");
|
||||
setLocalBisDatum(bisDatumRedux || "");
|
||||
setLocalVonDatum(vonDatumRedux || getDefaultDate("from"));
|
||||
setLocalBisDatum(bisDatumRedux || getDefaultDate("to"));
|
||||
setLocalZeitraum(zeitraum);
|
||||
}, [vonDatumRedux, bisDatumRedux, zeitraum]);
|
||||
|
||||
@@ -105,24 +118,41 @@ export default function AnalogInputsChart() {
|
||||
const handleFetchData = () => {
|
||||
if (!selectedAnalogInput?.id) return;
|
||||
|
||||
// Fallback auf Redux-Werte, falls lokale Werte leer sind
|
||||
const from = localVonDatum || vonDatumRedux || "";
|
||||
const to = localBisDatum || bisDatumRedux || "";
|
||||
|
||||
// Redux aktualisieren
|
||||
dispatch(setVonDatum(localVonDatum));
|
||||
dispatch(setBisDatum(localBisDatum));
|
||||
dispatch(setVonDatum(from));
|
||||
dispatch(setBisDatum(to));
|
||||
dispatch(setZeitraum(localZeitraum));
|
||||
|
||||
// Debug anzeigen
|
||||
console.log(
|
||||
"Fetch-URL:",
|
||||
`/api/cpl/getAnalogInputsHistory?eingang=${selectedAnalogInput.id}&zeitraum=${localZeitraum}&von=${localVonDatum}&bis=${localBisDatum}`
|
||||
);
|
||||
// Umgebung erkennen und URL generieren
|
||||
const isDev =
|
||||
window.location.hostname === "localhost" ||
|
||||
window.location.hostname === "127.0.0.1";
|
||||
let fetchUrl = "";
|
||||
if (isDev) {
|
||||
fetchUrl = `/api/cpl/getAnalogInputsHistory?eingang=${selectedAnalogInput.id}&zeitraum=${localZeitraum}&von=${from}&bis=${to}`;
|
||||
} else {
|
||||
// Produktion: CPL-Webserver direkt abfragen
|
||||
const [vonJahr, vonMonat, vonTag] = from.split("-");
|
||||
const [bisJahr, bisMonat, bisTag] = to.split("-");
|
||||
const aeEingang = 100 + (selectedAnalogInput.id - 1);
|
||||
let diaType = "DIA1";
|
||||
if (localZeitraum === "DIA0") diaType = "DIA0";
|
||||
if (localZeitraum === "DIA2") diaType = "DIA2";
|
||||
fetchUrl = `${window.location.origin}/CPL?seite.ACP&${diaType}=${vonJahr};${vonMonat};${vonTag};${bisJahr};${bisMonat};${bisTag};${aeEingang};1`;
|
||||
}
|
||||
console.log("Fetch-URL:", fetchUrl);
|
||||
|
||||
// Thunk-Fetch mit neuen Werten
|
||||
dispatch(
|
||||
getAnalogInputsHistoryThunk({
|
||||
eingang: selectedAnalogInput.id,
|
||||
zeitraum: localZeitraum,
|
||||
vonDatum: localVonDatum,
|
||||
bisDatum: localBisDatum,
|
||||
vonDatum: from,
|
||||
bisDatum: to,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.629",
|
||||
"version": "1.6.630",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.629",
|
||||
"version": "1.6.630",
|
||||
"dependencies": {
|
||||
"@fontsource/roboto": "^5.1.0",
|
||||
"@headlessui/react": "^2.2.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.629",
|
||||
"version": "1.6.630",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
Reference in New Issue
Block a user