feat: in System 5 Volt DIA0, DIA1 und DIA2 in dropdown anzeigen

This commit is contained in:
ISA
2025-07-03 11:13:39 +02:00
parent 09bc64e771
commit 3e7d702ab7
10 changed files with 93 additions and 24 deletions

View File

@@ -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.531 NEXT_PUBLIC_APP_VERSION=1.6.533
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)

View File

@@ -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.531 NEXT_PUBLIC_APP_VERSION=1.6.533
NEXT_PUBLIC_CPL_MODE=production NEXT_PUBLIC_CPL_MODE=production

View File

@@ -1,3 +1,25 @@
## [1.6.533] 2025-07-03
- feat: API für Systemspannung +5V erfolgreich implementiert
- API-Handler `getSystemspannung5VplusHandler.ts` erstellt
- JSON-Daten werden aus dem Verzeichnis `mocks/device-cgi-simulator/chartsData/systemspannung5Vplus/` geladen
- unterstützt die Parameter DIA0, DIA1, DIA2 für unterschiedliche Datenfrequenzen
- Fehlerbehandlung bei ungültigen Typen und fehlenden Dateien eingebaut
- API getestet unter `/api/cpl/getSystemspannung5VplusHandler?typ=DIA0`
---
## [1.6.532] 2025-07-03
- feat: API für Systemspannung +5V erfolgreich implementiert
- API-Handler `getSystemspannung5VplusHandler.ts` erstellt
- JSON-Daten werden aus dem Verzeichnis `mocks/device-cgi-simulator/chartsData/systemspannung5Vplus/` geladen
- unterstützt die Parameter DIA0, DIA1, DIA2 für unterschiedliche Datenfrequenzen
- Fehlerbehandlung bei ungültigen Typen und fehlenden Dateien eingebaut
- API getestet unter `/api/cpl/getSystemspannung5VplusHandler?typ=DIA0`
---
## [1.6.531] 2025-07-03 ## [1.6.531] 2025-07-03
- feat: API für Systemspannung +5V erfolgreich implementiert - feat: API für Systemspannung +5V erfolgreich implementiert

View File

@@ -9,28 +9,33 @@ type Props = {
isOpen: boolean; isOpen: boolean;
selectedKey: string | null; selectedKey: string | null;
onClose: () => void; onClose: () => void;
zeitraum: "DIA0" | "DIA1" | "DIA2";
setZeitraum: (typ: "DIA0" | "DIA1" | "DIA2") => void;
}; };
export const DetailModal = ({ isOpen, selectedKey, onClose }: Props) => { export const DetailModal = ({
// Mapping: Welcher Redux-Zweig zu welchem selectedKey gehört isOpen,
selectedKey,
onClose,
zeitraum,
setZeitraum,
}: Props) => {
const typMap: Record<string, "DIA0" | "DIA1" | "DIA2"> = { const typMap: Record<string, "DIA0" | "DIA1" | "DIA2"> = {
"+5V": "DIA1", "+5V": zeitraum,
"+15V": "DIA1", "+15V": zeitraum,
"-15V": "DIA1", "-15V": zeitraum,
"-98V": "DIA1", "-98V": zeitraum,
}; };
const typ = selectedKey ? typMap[selectedKey] : null; const typ = selectedKey ? typMap[selectedKey] : null;
type ReduxDataItem = { t: string; i: number };
// Redux State abrufen
const reduxData = useSelector((state: RootState) => const reduxData = useSelector((state: RootState) =>
typ ? state.systemspannung5Vplus[typ] : [] typ ? (state.systemspannung5Vplus[typ] as ReduxDataItem[]) : []
); );
// Zeitstempel und Werte extrahieren const labels = reduxData.map((e: ReduxDataItem) => e.t);
type DataPoint = { t: string; i: number }; const values = reduxData.map((e: ReduxDataItem) => e.i);
const labels = reduxData.map((e: unknown) => (e as DataPoint).t);
const values = reduxData.map((e: unknown) => (e as DataPoint).i);
const baseOptions = { const baseOptions = {
responsive: true, responsive: true,
@@ -68,9 +73,16 @@ export const DetailModal = ({ isOpen, selectedKey, onClose }: Props) => {
<div className="mb-4"> <div className="mb-4">
<label className="mr-2 font-medium">Zeitraum:</label> <label className="mr-2 font-medium">Zeitraum:</label>
<select className="border px-2 py-1 rounded"> <select
<option>Letzte 24 Stunden</option> className="border px-2 py-1 rounded"
{/* Optional: dynamische Filter */} value={zeitraum}
onChange={(e) =>
setZeitraum(e.target.value as "DIA0" | "DIA1" | "DIA2")
}
>
<option value="DIA0">Alle Messwerte</option>
<option value="DIA1">Stündlich</option>
<option value="DIA2">Täglich</option>
</select> </select>
</div> </div>

View File

@@ -35,8 +35,8 @@ export type HistoryEntry = {
type Props = { type Props = {
history: HistoryEntry[]; history: HistoryEntry[];
zeitraum: "DIA0" | "DIA1" | "DIA2";
}; };
export const SystemCharts = ({ history }: Props) => { export const SystemCharts = ({ history }: Props) => {
const labels = history.map((h) => new Date(h.time).toLocaleTimeString()); const labels = history.map((h) => new Date(h.time).toLocaleTimeString());
const formatValue = (v: number) => v.toFixed(2); const formatValue = (v: number) => v.toFixed(2);

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.531", "version": "1.6.533",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.531", "version": "1.6.533",
"dependencies": { "dependencies": {
"@fontsource/roboto": "^5.1.0", "@fontsource/roboto": "^5.1.0",
"@iconify-icons/ri": "^1.2.10", "@iconify-icons/ri": "^1.2.10",

View File

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

View File

@@ -7,7 +7,7 @@ export default async function handler(
req: NextApiRequest, req: NextApiRequest,
res: NextApiResponse res: NextApiResponse
) { ) {
const { typ = "DIA0" } = req.query; const { typ = "DIA1" } = req.query;
if (!["DIA0", "DIA1", "DIA2"].includes(typ as string)) { if (!["DIA0", "DIA1", "DIA2"].includes(typ as string)) {
return res return res

View File

@@ -8,6 +8,7 @@ import { SystemOverviewGrid } from "@/components/main/system/SystemOverviewGrid"
import { SystemCharts } from "@/components/main/system/SystemCharts"; import { SystemCharts } from "@/components/main/system/SystemCharts";
import { DetailModal } from "@/components/main/system/DetailModal"; import { DetailModal } from "@/components/main/system/DetailModal";
import type { HistoryEntry } from "@/components/main/system/SystemCharts"; import type { HistoryEntry } from "@/components/main/system/SystemCharts";
import { getSystemspannung5VplusThunk } from "@/redux/thunks/getSystemspannung5VplusThunk";
const SystemPage = () => { const SystemPage = () => {
const dispatch = useDispatch<AppDispatch>(); const dispatch = useDispatch<AppDispatch>();
@@ -21,15 +22,21 @@ const SystemPage = () => {
const [selectedKey, setSelectedKey] = useState<string | null>(null); const [selectedKey, setSelectedKey] = useState<string | null>(null);
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [zeitraum, setZeitraum] = useState<"DIA0" | "DIA1" | "DIA2">("DIA1");
useEffect(() => { useEffect(() => {
dispatch(getSystemVoltTempThunk()); dispatch(getSystemVoltTempThunk());
const interval = setInterval(() => { const interval = setInterval(() => {
dispatch(getSystemVoltTempThunk()); dispatch(getSystemVoltTempThunk());
}, 5000); }, 5000);
return () => clearInterval(interval); return () => clearInterval(interval);
}, [dispatch]); }, [dispatch]);
useEffect(() => {
dispatch(getSystemspannung5VplusThunk(zeitraum));
}, [dispatch, zeitraum]);
const handleOpenDetail = (key: string) => { const handleOpenDetail = (key: string) => {
setSelectedKey(key); setSelectedKey(key);
setIsModalOpen(true); setIsModalOpen(true);
@@ -46,11 +53,13 @@ const SystemPage = () => {
System Spannungen & Temperaturen System Spannungen & Temperaturen
</h1> </h1>
<SystemOverviewGrid voltages={voltages} onOpenDetail={handleOpenDetail} /> <SystemOverviewGrid voltages={voltages} onOpenDetail={handleOpenDetail} />
<SystemCharts history={history} /> <SystemCharts history={history} zeitraum={zeitraum} />
<DetailModal <DetailModal
isOpen={isModalOpen} isOpen={isModalOpen}
selectedKey={selectedKey} selectedKey={selectedKey}
onClose={handleCloseDetail} onClose={handleCloseDetail}
zeitraum={zeitraum}
setZeitraum={setZeitraum}
/> />
</div> </div>
); );

View File

@@ -22,7 +22,33 @@ export const fetchKueDataService = async () => {
document.body.appendChild(script); document.body.appendChild(script);
}); });
const win = window as any; const win = window as Window & {
win_kueOnline?: unknown[];
win_kueID?: unknown[];
win_kueName?: unknown[];
win_kuePSTmMinus96V?: unknown[];
win_kueAlarm1?: unknown[];
win_kueAlarm2?: unknown[];
win_kueIso?: unknown[];
win_kueResidence?: unknown[];
win_kueCableBreak?: unknown[];
win_kueGroundFault?: unknown[];
win_kueLimit1?: unknown[];
win_kueLimit2Low?: unknown[];
win_kueDelay1?: unknown[];
win_kueLoopInterval?: unknown[];
win_kueVersion?: unknown[];
win_kueOverflow?: unknown[];
win_tdrAtten?: unknown[];
win_tdrPulse?: unknown[];
win_tdrSpeed?: unknown[];
win_tdrAmp?: unknown[];
win_tdrTrigger?: unknown[];
win_tdrLocation?: unknown[];
win_tdrActive?: unknown[];
win_tdrLast?: unknown[];
win_memoryInterval?: unknown[];
};
return { return {
kueOnline: win.win_kueOnline || [], kueOnline: win.win_kueOnline || [],