feat(iso): DateRangePicker-Zeitraum bei "Daten laden" anwenden

This commit is contained in:
ISA
2025-08-12 09:33:25 +02:00
parent e4b56faf75
commit 8af8e14878
8 changed files with 64 additions and 34 deletions

View File

@@ -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.692
NEXT_PUBLIC_APP_VERSION=1.6.694
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)

View File

@@ -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.692
NEXT_PUBLIC_APP_VERSION=1.6.694
NEXT_PUBLIC_CPL_MODE=production

View File

@@ -1,3 +1,13 @@
## [1.6.694] 2025-08-12
- feat: RSL starten in Dev mode 15 Sek. und in prod. 120 Sek.
---
## [1.6.693] 2025-08-12
- feat: RSL starten in Dev mode 15 Sek. und in prod. 120 Sek.
---
## [1.6.692] 2025-08-12
- PlayWright Test

View File

@@ -11,6 +11,7 @@ import {
setLoading,
} from "@/redux/slices/kabelueberwachungChartSlice";
import { setBrushRange } from "@/redux/slices/brushSlice";
import { getMessagesThunk } from "@/redux/thunks/getMessagesThunk";
import { Listbox } from "@headlessui/react";
//-----------------------------------------------------------------------------------useIsoChartLoader
@@ -174,22 +175,31 @@ const IsoChartActionBar: React.FC = () => {
const { vonDatum, bisDatum, selectedMode, slotNumber, chartTitle } =
useSelector((state: RootState) => state.kabelueberwachungChartSlice);
// Aus DateRangePicker-Slice kommen die Werte, die der User im UI wählt
const { vonDatum: pickerVonDatum, bisDatum: pickerBisDatum } = useSelector(
(state: RootState) => state.dateRangePicker
);
const formatDate = (dateString: string) => {
const [year, month, day] = dateString.split("-");
return `${year};${month};${day}`;
};
const getApiUrl = (mode: "DIA0" | "DIA1" | "DIA2", slotNumber: number) => {
const getApiUrl = (
mode: "DIA0" | "DIA1" | "DIA2",
slotNumber: number,
fromDate: string,
toDate: string
) => {
const type = 3; // Fest auf Isolationswiderstand gesetzt
const typeFolder = "isolationswiderstand";
const baseUrl =
process.env.NODE_ENV === "development"
? `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}`
? `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${fromDate}&bisDatum=${toDate}`
: `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate(
vonDatum
)};${formatDate(bisDatum)};${slotNumber};${type};`;
fromDate
)};${formatDate(toDate)};${slotNumber};${type};`;
console.log("baseUrl", baseUrl);
return baseUrl;
@@ -200,8 +210,26 @@ const IsoChartActionBar: React.FC = () => {
alert("⚠️ Bitte zuerst einen KÜ auswählen!");
return;
}
// Wenn Meldungen-Ansicht aktiv ist, dann Meldungen laden
if (chartTitle === "Meldungen") {
try {
dispatch(setLoading(true));
const fromDate = pickerVonDatum ?? vonDatum;
const toDate = pickerBisDatum ?? bisDatum;
await dispatch(getMessagesThunk({ fromDate, toDate })).unwrap();
} catch (err) {
console.error("❌ Fehler beim Laden der Meldungen:", err);
alert("❌ Fehler beim Laden der Meldungen.");
} finally {
dispatch(setLoading(false));
}
return;
}
const apiUrl = getApiUrl(selectedMode, slotNumber);
// Messkurve (ISO) laden
const fromDate = pickerVonDatum ?? vonDatum;
const toDate = pickerBisDatum ?? bisDatum;
const apiUrl = getApiUrl(selectedMode, slotNumber, fromDate, toDate);
if (!apiUrl) return;
dispatch(setLoading(true));
@@ -227,8 +255,8 @@ const IsoChartActionBar: React.FC = () => {
console.log("▶️ Lade Isolationswiderstand-Daten für:");
console.log(" Slot:", slotNumber);
console.log(" Modus:", selectedMode);
console.log(" Von:", vonDatum);
console.log(" Bis:", bisDatum);
console.log(" Von:", fromDate);
console.log(" Bis:", toDate);
console.log(" URL:", apiUrl);
console.log(" Daten:", jsonData);
@@ -257,12 +285,8 @@ const IsoChartActionBar: React.FC = () => {
</div>
<div className="flex items-center space-x-2">
{/* DateRangePicker - Platz reservieren, aber ausblenden wenn Meldungen */}
<div
style={{
visibility: chartTitle === "Messkurve" ? "visible" : "hidden",
}}
>
{/* DateRangePicker für beide Ansichten sichtbar, da Meldungen auch datumsabhängig sind */}
<div>
<DateRangePicker />
</div>
@@ -334,12 +358,7 @@ const IsoChartActionBar: React.FC = () => {
{/* Dropdown für Auswahl zwischen "Messkurve" und "Meldungen" - immer anzeigen */}
{/* Dropdown für Auswahl zwischen "Messkurve" und "Meldungen" entfernt */}
{/* Daten laden Button - Platz reservieren, aber ausblenden wenn Meldungen */}
<div
style={{
visibility: chartTitle === "Messkurve" ? "visible" : "hidden",
}}
>
{/* Daten laden Button lädt je nach Ansicht Messkurve oder Meldungen */}
<button
onClick={handleFetchData}
className="px-4 py-1 bg-littwin-blue text-white rounded text-sm"
@@ -348,7 +367,6 @@ const IsoChartActionBar: React.FC = () => {
</button>
</div>
</div>
</div>
);
};

View File

@@ -237,7 +237,7 @@ const IsoChartView: React.FC<IsoChartViewProps> = ({
{chartTitle === "Messkurve" ? (
<IsoMeasurementChart />
) : (
<Report moduleType="ISO" />
<Report moduleType="ISO" autoLoad={false} />
)}
</div>
</div>

View File

@@ -19,9 +19,10 @@ type ModuleType = "ISO" | "TDR" | "RSL" | "KVZ";
interface ReportProps {
moduleType: ModuleType;
autoLoad?: boolean;
}
const Report: React.FC<ReportProps> = ({ moduleType }) => {
const Report: React.FC<ReportProps> = ({ moduleType, autoLoad = true }) => {
const dispatch = useDispatch<AppDispatch>();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -178,12 +179,13 @@ const Report: React.FC<ReportProps> = ({ moduleType }) => {
moduleKeywordMap,
]);
// Automatisches Laden beim Mount und bei Änderungen
// Automatisches Laden beim Mount und bei Änderungen (optional)
useEffect(() => {
if (!autoLoad) return;
if (slotNumber !== null) {
loadMessages();
}
}, [loadMessages, slotNumber]);
}, [loadMessages, slotNumber, autoLoad]);
if (loading) {
return (

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "cpl-v4",
"version": "1.6.692",
"version": "1.6.694",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cpl-v4",
"version": "1.6.692",
"version": "1.6.694",
"dependencies": {
"@fontsource/roboto": "^5.1.0",
"@headlessui/react": "^2.2.4",

View File

@@ -1,6 +1,6 @@
{
"name": "cpl-v4",
"version": "1.6.692",
"version": "1.6.694",
"private": true,
"scripts": {
"dev": "next dev",