This commit is contained in:
Ismail Ali
2025-06-26 22:56:20 +02:00
parent 137839da98
commit b9651a53a9
82 changed files with 7476 additions and 4171 deletions

View File

@@ -9,7 +9,12 @@ import inputIcon from "@iconify/icons-mdi/input";
import loginIcon from "@iconify/icons-mdi/login";
type Props = {
openInputModal: (input: any) => void;
openInputModal: (input: {
id: number;
eingangOffline: boolean;
status: boolean;
label: string;
}) => void;
inputRange: { start: number; end: number };
};

View File

@@ -8,9 +8,10 @@ import settingsIcon from "@iconify/icons-mdi/settings";
import outputIcon from "@iconify/icons-mdi/output";
import switchIcon from "@iconify/icons-ion/switch";
import { setDigitalOutputs } from "@/redux/slices/digitalOutputsSlice";
import type { DigitalOutput } from "@/types/digitalOutput";
interface DigitalOutputsWidgetProps {
openOutputModal: (output: any) => void;
export interface DigitalOutputsWidgetProps {
openOutputModal: (output: DigitalOutput) => void;
}
export default function DigitalOutputsWidget({

View File

@@ -2,13 +2,14 @@
import React, { useState, useEffect } from "react";
import { useSelector } from "react-redux";
import { RootState } from "../../../../redux/store";
import type { DigitalOutput } from "@/types/digitalOutput";
export default function DigitalOutputsModal({
selectedOutput,
closeOutputModal,
isOpen,
}: {
selectedOutput: any;
selectedOutput: DigitalOutput | null;
closeOutputModal: () => void;
isOpen: boolean;
}) {
@@ -18,7 +19,7 @@ export default function DigitalOutputsModal({
const [label, setLabel] = useState("");
const [status, setStatus] = useState(false);
const [timer, setTimer] = useState(0);
const [isSaving, setIsSaving] = useState(false);
const [errorMsg, setErrorMsg] = useState("");
@@ -27,7 +28,7 @@ export default function DigitalOutputsModal({
if (isOpen && selectedOutput) {
setLabel(selectedOutput.label || "");
setStatus(selectedOutput.status || false);
setTimer(0);
setErrorMsg("");
}
}, [isOpen, selectedOutput]);
@@ -84,6 +85,7 @@ export default function DigitalOutputsModal({
}
}
} catch (err) {
console.error("Fehler beim Speichern:", err);
setErrorMsg("❌ Fehler beim Speichern.");
} finally {
setIsSaving(false);

View File

@@ -3,13 +3,12 @@
import React, { useEffect, useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { RootState } from "@/redux/store";
import switchIcon from "@iconify/icons-ion/switch";
import { updateInvert, updateLabel } from "@/redux/slices/digitalInputsSlice";
type InputModalProps = {
selectedInput: {
id: number;
[key: string]: any;
[key: string]: unknown;
} | null;
closeInputModal: () => void;
isOpen: boolean;
@@ -51,8 +50,24 @@ export default function InputModal({
}
}, [reduxInput, isInitialLoad]);
useEffect(() => {
if (isOpen && selectedInput) {
setIsInitialLoad(true);
}
}, [isOpen, selectedInput]);
useEffect(() => {
if (isOpen && selectedInput) {
setIsInitialLoad(true);
}
}, [isOpen, selectedInput]);
if (!isOpen || !selectedInput || !reduxInput) return null;
const handleClose = () => {
closeInputModal();
};
const sendCgiUpdate = async (param: string) => {
const url = `/CPL?/eingaenge.html&${param}`;
//console.log("📡 CGI senden:", url);
@@ -103,7 +118,15 @@ export default function InputModal({
alert("✅ Daten erfolgreich an die CPL-Hardware gesendet!");
} else {
// ENTWICKLUNGSUMGEBUNG (lokale API)
const updates: any = { id };
type Updates = {
id: number;
label?: string;
invert?: number;
timeFilter?: number;
weighting?: number;
zaehlerAktiv?: number;
};
const updates: Updates = { id };
if (label !== reduxInput.label) {
updates.label = label;
dispatch(updateLabel({ id, label }));
@@ -148,21 +171,15 @@ export default function InputModal({
setIsInitialLoad(true);
closeInputModal();
} catch (err: any) {
alert("❌ Fehler beim Speichern: " + err.message);
} catch (err: unknown) {
if (err instanceof Error) {
alert("❌ Fehler beim Speichern: " + err.message);
} else {
alert("❌ Fehler beim Speichern: Unbekannter Fehler");
}
}
};
const handleClose = () => {
setIsInitialLoad(true);
closeInputModal();
};
useEffect(() => {
if (isOpen && selectedInput) {
setIsInitialLoad(true);
}
}, [isOpen, selectedInput]);
return (
<div className="fixed top-0 left-0 w-full h-full bg-black bg-opacity-50 flex justify-center items-center z-50">
<div className="bg-white rounded-lg shadow-lg p-6 w-1/2 max-w-lg">