Nach Betriebsferien einmal sichern
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.602
|
NEXT_PUBLIC_APP_VERSION=1.6.604
|
||||||
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.602
|
NEXT_PUBLIC_APP_VERSION=1.6.604
|
||||||
NEXT_PUBLIC_CPL_MODE=production
|
NEXT_PUBLIC_CPL_MODE=production
|
||||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
|||||||
|
## [1.6.604] – 2025-07-21
|
||||||
|
|
||||||
|
- feat(analogInputs): automatisches Laden der Chart-Daten bei Tabellenklick via Redux
|
||||||
|
|
||||||
|
- analogInputsHistorySlice um `autoLoad` erweitert, um automatisches Laden zu triggern
|
||||||
|
- handleSelect in AnalogInputsTable dispatcht jetzt `setAutoLoad(true)`
|
||||||
|
- AnalogInputsChart lauscht auf `autoLoad` + `selectedId` und lädt Daten automatisch
|
||||||
|
- `autoLoad` wird nach dem Laden wieder auf false zurückgesetzt
|
||||||
|
|
||||||
|
---
|
||||||
|
## [1.6.603] – 2025-07-21
|
||||||
|
|
||||||
|
- feat(analogInputs): automatisches Laden der Chart-Daten bei Tabellenklick via Redux
|
||||||
|
|
||||||
|
- analogInputsHistorySlice um `autoLoad` erweitert, um automatisches Laden zu triggern
|
||||||
|
- handleSelect in AnalogInputsTable dispatcht jetzt `setAutoLoad(true)`
|
||||||
|
- AnalogInputsChart lauscht auf `autoLoad` + `selectedId` und lädt Daten automatisch
|
||||||
|
- `autoLoad` wird nach dem Laden wieder auf false zurückgesetzt
|
||||||
|
|
||||||
|
---
|
||||||
## [1.6.602] – 2025-07-15
|
## [1.6.602] – 2025-07-15
|
||||||
|
|
||||||
- feat(analogInputs): automatisches Laden der Chart-Daten bei Tabellenklick via Redux
|
- feat(analogInputs): automatisches Laden der Chart-Daten bei Tabellenklick via Redux
|
||||||
|
|||||||
@@ -3,20 +3,17 @@ import React, { useEffect } from "react";
|
|||||||
import DatePicker from "react-datepicker";
|
import DatePicker from "react-datepicker";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { RootState } from "@/redux/store";
|
import { RootState } from "@/redux/store";
|
||||||
import {
|
import { setVonDatum, setBisDatum } from "@/redux/slices/dateRangePickerSlice";
|
||||||
setVonDatum,
|
|
||||||
setBisDatum,
|
|
||||||
} from "@/redux/slices/kabelueberwachungChartSlice";
|
|
||||||
import "react-datepicker/dist/react-datepicker.css";
|
import "react-datepicker/dist/react-datepicker.css";
|
||||||
|
|
||||||
const DateRangePicker: React.FC = () => {
|
const DateRangePicker: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const reduxVonDatum = useSelector(
|
const reduxVonDatum = useSelector(
|
||||||
(state: RootState) => state.kabelueberwachungChartSlice.vonDatum
|
(state: RootState) => state.dateRangePicker.vonDatum
|
||||||
);
|
);
|
||||||
const reduxBisDatum = useSelector(
|
const reduxBisDatum = useSelector(
|
||||||
(state: RootState) => state.kabelueberwachungChartSlice.bisDatum
|
(state: RootState) => state.dateRangePicker.bisDatum
|
||||||
);
|
);
|
||||||
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|||||||
@@ -45,12 +45,91 @@ type AnalogInputHistoryPoint = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function AnalogInputsChart() {
|
export default function AnalogInputsChart() {
|
||||||
|
useEffect(() => {
|
||||||
|
const loadZoomPlugin = async () => {
|
||||||
|
const zoomPlugin = (await import("chartjs-plugin-zoom")).default;
|
||||||
|
if (!ChartJS.registry.plugins.get("zoom")) {
|
||||||
|
ChartJS.register(zoomPlugin);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadZoomPlugin();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const chartRef = useRef<any>(null);
|
const chartRef = useRef<any>(null);
|
||||||
|
|
||||||
const { zeitraum, vonDatum, bisDatum, data, autoLoad, selectedId } =
|
const { zeitraum, vonDatum, bisDatum, data, autoLoad, selectedId } =
|
||||||
useSelector((state: RootState) => state.analogInputsHistory);
|
useSelector((state: RootState) => state.analogInputsHistory);
|
||||||
|
const selectedAnalogInput = useSelector(
|
||||||
|
(state: RootState) => state.selectedAnalogInput
|
||||||
|
);
|
||||||
|
// ✅ Button-Klick → Fetch auslösen
|
||||||
|
const handleFetchData = () => {
|
||||||
|
if (!selectedAnalogInput?.id) return;
|
||||||
|
|
||||||
|
// Sicherstellen, dass die neuesten Werte aus dem DateRangePicker verwendet werden
|
||||||
|
const latestVonDatum = vonDatum || new Date().toISOString().slice(0, 10);
|
||||||
|
const latestBisDatum = bisDatum || new Date().toISOString().slice(0, 10);
|
||||||
|
|
||||||
|
dispatch(
|
||||||
|
getAnalogInputsHistoryThunk({
|
||||||
|
eingang: selectedAnalogInput.id,
|
||||||
|
zeitraum,
|
||||||
|
vonDatum: latestVonDatum,
|
||||||
|
bisDatum: latestBisDatum,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (chartRef.current) {
|
||||||
|
const chart = chartRef.current;
|
||||||
|
|
||||||
|
// Aktualisiere die X-Achse basierend auf den neuesten Werten
|
||||||
|
chart.options.scales.x.min = new Date(latestVonDatum).getTime();
|
||||||
|
chart.options.scales.x.max = new Date(latestBisDatum).getTime();
|
||||||
|
|
||||||
|
// Aktualisiere die Daten des Diagramms
|
||||||
|
const chartKey = selectedAnalogInput?.id ? String(selectedAnalogInput.id + 99) : null;
|
||||||
|
const inputData = chartKey ? data[chartKey] ?? [] : [];
|
||||||
|
const filteredData = inputData.filter((point) => {
|
||||||
|
const date = new Date(point.t);
|
||||||
|
const from = new Date(latestVonDatum);
|
||||||
|
const to = new Date(latestBisDatum);
|
||||||
|
return (!from || date >= from) && (!to || date <= to);
|
||||||
|
});
|
||||||
|
|
||||||
|
chart.data.datasets = [
|
||||||
|
{
|
||||||
|
label: selectedAnalogInput?.label
|
||||||
|
? `Messwerteingang ${selectedAnalogInput.label}`
|
||||||
|
: "Messwerte",
|
||||||
|
data: filteredData.map((point) => ({ x: point.t, y: point.m })),
|
||||||
|
fill: false,
|
||||||
|
borderColor: getColor("littwin-blue"),
|
||||||
|
backgroundColor: "rgba(59,130,246,0.3)",
|
||||||
|
borderWidth: 2,
|
||||||
|
pointRadius: 0,
|
||||||
|
tension: 0.1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Erzwinge ein vollständiges Redraw des Diagramms
|
||||||
|
chart.update("none");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ✅ Filtere Daten aus Redux
|
||||||
|
const chartKey = selectedAnalogInput?.id
|
||||||
|
? String(selectedAnalogInput.id + 99)
|
||||||
|
: null;
|
||||||
|
const inputData = chartKey ? data[chartKey] ?? [] : [];
|
||||||
|
// ✅ Zeitbereich anwenden (nur Anzeige gefiltert)
|
||||||
|
const filteredData = inputData.filter((point) => {
|
||||||
|
const date = new Date(point.t);
|
||||||
|
const from = vonDatum ? new Date(vonDatum) : null;
|
||||||
|
const to = bisDatum ? new Date(bisDatum) : null;
|
||||||
|
|
||||||
|
return (!from || date >= from) && (!to || date <= to);
|
||||||
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const vor30Tagen = new Date(today);
|
const vor30Tagen = new Date(today);
|
||||||
@@ -73,15 +152,29 @@ export default function AnalogInputsChart() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dataKey = selectedId ? String(selectedId + 99) : null;
|
const dataKey = selectedId ? String(selectedId + 99) : null;
|
||||||
|
let filteredPoints: AnalogInputHistoryPoint[] = [];
|
||||||
|
if (dataKey && data[dataKey]) {
|
||||||
|
const fromDate = vonDatum ? new Date(vonDatum) : null;
|
||||||
|
const toDate = bisDatum ? new Date(bisDatum) : null;
|
||||||
|
|
||||||
|
filteredPoints = data[dataKey].filter((p: AnalogInputHistoryPoint) => {
|
||||||
|
const pointDate = new Date(p.t);
|
||||||
|
return (
|
||||||
|
(!fromDate || pointDate >= fromDate) && (!toDate || pointDate <= toDate)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
const chartData = {
|
const chartData = {
|
||||||
datasets:
|
datasets:
|
||||||
dataKey && data[dataKey]
|
filteredPoints.length > 0
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: `Messwerteingang ${selectedId}`,
|
label: selectedAnalogInput?.label
|
||||||
data: data[dataKey].map((p: AnalogInputHistoryPoint) => ({
|
? `Messwerteingang ${selectedAnalogInput.label}`
|
||||||
x: new Date(p.t),
|
: "Messwerte",
|
||||||
y: p.m,
|
data: filteredData.map((point) => ({
|
||||||
|
x: point.t,
|
||||||
|
y: point.m,
|
||||||
})),
|
})),
|
||||||
fill: false,
|
fill: false,
|
||||||
borderColor: getColor("littwin-blue"),
|
borderColor: getColor("littwin-blue"),
|
||||||
@@ -94,36 +187,63 @@ export default function AnalogInputsChart() {
|
|||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartOptions: ChartOptions<"line"> = {
|
const chartOptions = {
|
||||||
responsive: true,
|
responsive: true,
|
||||||
plugins: {
|
plugins: {
|
||||||
legend: { position: "top" },
|
legend: { position: "top" as const },
|
||||||
title: { display: true, text: "Verlauf" },
|
|
||||||
tooltip: {
|
tooltip: {
|
||||||
mode: "index",
|
mode: "index" as const,
|
||||||
intersect: false,
|
intersect: false,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: (ctx) => `Messwert: ${ctx.parsed.y}`,
|
label: function (context: any) {
|
||||||
title: (items) =>
|
return `Messwert: ${context.parsed.y}`;
|
||||||
`Zeitpunkt: ${new Date(items[0].parsed.x).toLocaleString("de-DE")}`,
|
},
|
||||||
|
title: function (tooltipItems: any[]) {
|
||||||
|
const date = tooltipItems[0].parsed.x;
|
||||||
|
return `Zeitpunkt: ${new Date(date).toLocaleString("de-DE")}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: selectedAnalogInput?.label
|
||||||
|
? `Verlauf: ${selectedAnalogInput.label}`
|
||||||
|
: "Messwert-Verlauf",
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
pan: { enabled: true, mode: "x" as const },
|
||||||
|
zoom: { wheel: { enabled: true }, pinch: { enabled: true }, mode: "x" as const },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
type: "time",
|
type: "time" as const,
|
||||||
time: {
|
time: {
|
||||||
unit: "day",
|
unit: "day" as const,
|
||||||
tooltipFormat: "dd.MM.yyyy HH:mm",
|
tooltipFormat: "dd.MM.yyyy HH:mm",
|
||||||
displayFormats: { day: "dd.MM.yyyy" },
|
displayFormats: {
|
||||||
|
day: "dd.MM.yyyy",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
adapters: { date: { locale: de } },
|
adapters: { date: { locale: de } },
|
||||||
title: { display: true, text: "Zeit" },
|
title: { display: true, text: "Zeit" },
|
||||||
|
// ✅ Hier definieren wir den sichtbaren Bereich dynamisch
|
||||||
|
min: vonDatum ? new Date(vonDatum).getTime() : undefined,
|
||||||
|
max: bisDatum ? new Date(bisDatum).getTime() : undefined,
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: `Messwert ${selectedAnalogInput?.unit || ""}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
y: { title: { display: true, text: "Messwert" } },
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// ✅ DateRangePicker Event → Redux-Datum setzen (aber KEIN Fetch!)
|
||||||
|
const handleDateChange = (from: string, to: string) => {
|
||||||
|
dispatch(setVonDatum(from));
|
||||||
|
dispatch(setBisDatum(to));
|
||||||
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (autoLoad && selectedId) {
|
if (autoLoad && selectedId) {
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -137,6 +257,7 @@ export default function AnalogInputsChart() {
|
|||||||
dispatch(setAutoLoad(false)); // ✅ zurücksetzen, sonst endlose Schleife
|
dispatch(setAutoLoad(false)); // ✅ zurücksetzen, sonst endlose Schleife
|
||||||
}
|
}
|
||||||
}, [autoLoad, selectedId, dispatch, zeitraum, vonDatum, bisDatum]);
|
}, [autoLoad, selectedId, dispatch, zeitraum, vonDatum, bisDatum]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<div className="flex flex-wrap items-center gap-4 mb-2">
|
<div className="flex flex-wrap items-center gap-4 mb-2">
|
||||||
@@ -173,7 +294,7 @@ export default function AnalogInputsChart() {
|
|||||||
</Listbox>
|
</Listbox>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleFetchChartData}
|
onClick={handleFetchData}
|
||||||
className="px-4 py-1 bg-littwin-blue text-white rounded text-sm"
|
className="px-4 py-1 bg-littwin-blue text-white rounded text-sm"
|
||||||
>
|
>
|
||||||
Daten laden
|
Daten laden
|
||||||
|
|||||||
@@ -19,3 +19,4 @@
|
|||||||

|

|
||||||
Zeit bis Ende August
|
Zeit bis Ende August
|
||||||
- [ ] TODO: Überall Littwin-Blau und ausgewählt und grau wie bei Navigation bei Mouse over
|
- [ ] TODO: Überall Littwin-Blau und ausgewählt und grau wie bei Navigation bei Mouse over
|
||||||
|
- [ ] TODO: Messwerteingänge Diagrammme /Messkurven
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.602",
|
"version": "1.6.604",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.602",
|
"version": "1.6.604",
|
||||||
"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.602",
|
"version": "1.6.604",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
32
redux/slices/dateRangePickerSlice.ts
Normal file
32
redux/slices/dateRangePickerSlice.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
interface DateRangePickerState {
|
||||||
|
vonDatum: string | null;
|
||||||
|
bisDatum: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: DateRangePickerState = {
|
||||||
|
vonDatum: null,
|
||||||
|
bisDatum: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateRangePickerSlice = createSlice({
|
||||||
|
name: "dateRangePicker",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setVonDatum(state, action: PayloadAction<string>) {
|
||||||
|
state.vonDatum = action.payload;
|
||||||
|
},
|
||||||
|
setBisDatum(state, action: PayloadAction<string>) {
|
||||||
|
state.bisDatum = action.payload;
|
||||||
|
},
|
||||||
|
resetDateRange(state) {
|
||||||
|
state.vonDatum = null;
|
||||||
|
state.bisDatum = null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { setVonDatum, setBisDatum, resetDateRange } =
|
||||||
|
dateRangePickerSlice.actions;
|
||||||
|
export default dateRangePickerSlice.reducer;
|
||||||
@@ -38,6 +38,7 @@ import { combineReducers } from "@reduxjs/toolkit";
|
|||||||
import { useDispatch, useSelector, TypedUseSelectorHook } from "react-redux";
|
import { useDispatch, useSelector, TypedUseSelectorHook } from "react-redux";
|
||||||
import systemChartReducer from "./slices/systemChartSlice";
|
import systemChartReducer from "./slices/systemChartSlice";
|
||||||
import analogInputsUiReducer from "./slices/analogInputs/analogInputsUiSlice";
|
import analogInputsUiReducer from "./slices/analogInputs/analogInputsUiSlice";
|
||||||
|
import dateRangePickerReducer from "./slices/dateRangePickerSlice";
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
systemspannung5Vplus: systemspannung5VplusReducer,
|
systemspannung5Vplus: systemspannung5VplusReducer,
|
||||||
@@ -76,6 +77,7 @@ const rootReducer = combineReducers({
|
|||||||
analogInputsHistory: analogInputsHistoryReducer,
|
analogInputsHistory: analogInputsHistoryReducer,
|
||||||
selectedAnalogInput: selectedAnalogInputReducer,
|
selectedAnalogInput: selectedAnalogInputReducer,
|
||||||
analogInputsUi: analogInputsUiReducer,
|
analogInputsUi: analogInputsUiReducer,
|
||||||
|
dateRangePicker: dateRangePickerReducer,
|
||||||
});
|
});
|
||||||
// ⬆️ Alle deine Imports und combineReducers bleiben so wie du sie geschrieben hast ...
|
// ⬆️ Alle deine Imports und combineReducers bleiben so wie du sie geschrieben hast ...
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ export const getAnalogInputsHistoryThunk = createAsyncThunk(
|
|||||||
thunkAPI
|
thunkAPI
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetchAnalogInputsHistory(eingang, zeitraum);
|
const response = await fetchAnalogInputsHistory(
|
||||||
|
eingang,
|
||||||
|
zeitraum,
|
||||||
|
vonDatum,
|
||||||
|
bisDatum
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
eingang,
|
eingang,
|
||||||
|
|||||||
@@ -4,11 +4,16 @@ import { AnalogInputsHistoryEntry } from "@/redux/slices/analogInputs/analogInpu
|
|||||||
|
|
||||||
export async function fetchAnalogInputsHistory(
|
export async function fetchAnalogInputsHistory(
|
||||||
eingang: number,
|
eingang: number,
|
||||||
zeitraum: string
|
zeitraum: string,
|
||||||
|
vonDatum?: string,
|
||||||
|
bisDatum?: string
|
||||||
): Promise<{ daten: AnalogInputsHistoryEntry[] }> {
|
): Promise<{ daten: AnalogInputsHistoryEntry[] }> {
|
||||||
const res = await fetch(
|
const url =
|
||||||
`/api/cpl/getAnalogInputsHistory?eingang=${eingang}&zeitraum=${zeitraum}`
|
`/api/cpl/getAnalogInputsHistory?eingang=${eingang}&zeitraum=${zeitraum}` +
|
||||||
);
|
(vonDatum ? `&von=${vonDatum}` : "") +
|
||||||
|
(bisDatum ? `&bis=${bisDatum}` : "");
|
||||||
|
|
||||||
|
const res = await fetch(url);
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error("Serverantwort war nicht erfolgreich");
|
throw new Error("Serverantwort war nicht erfolgreich");
|
||||||
|
|||||||
55
src/components/AnalogInputsChart.tsx
Normal file
55
src/components/AnalogInputsChart.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Chart } from "some-chart-library"; // Replace with actual chart library import
|
||||||
|
|
||||||
|
const AnalogInputsChart = () => {
|
||||||
|
const [startDate, setStartDate] = useState("2025-06-27");
|
||||||
|
const [endDate, setEndDate] = useState("2025-07-01");
|
||||||
|
const [chartData, setChartData] = useState([]);
|
||||||
|
|
||||||
|
const fetchData = async () => {
|
||||||
|
// Replace with actual API call or data fetching logic
|
||||||
|
const response = await fetch(`/api/data?start=${startDate}&end=${endDate}`);
|
||||||
|
const data = await response.json();
|
||||||
|
setChartData(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchData(); // Fetch data initially
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLoadData = () => {
|
||||||
|
fetchData(); // Fetch data when button is clicked
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<label>Von</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={startDate}
|
||||||
|
onChange={(e) => setStartDate(e.target.value)}
|
||||||
|
/>
|
||||||
|
<label>Bis</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={endDate}
|
||||||
|
onChange={(e) => setEndDate(e.target.value)}
|
||||||
|
/>
|
||||||
|
<button onClick={handleLoadData}>Daten laden</button>
|
||||||
|
</div>
|
||||||
|
<Chart
|
||||||
|
data={chartData}
|
||||||
|
xAxis={{
|
||||||
|
type: "datetime",
|
||||||
|
title: "Zeit",
|
||||||
|
}}
|
||||||
|
yAxis={{
|
||||||
|
title: "Messwert V",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AnalogInputsChart;
|
||||||
Reference in New Issue
Block a user