docs: Zusatzfunktionen (Kai, 25.06.2025) in TODO.md ergänzt
This commit is contained in:
@@ -44,7 +44,8 @@ function AppContent({
|
||||
}): JSX.Element {
|
||||
const dispatch = useAppDispatch();
|
||||
const [sessionExpired, setSessionExpired] = useState(false);
|
||||
|
||||
const mode = "DIA0"; // oder aus Router oder Session
|
||||
const type = 0; // Beispiel: 0 für "loop", 1 für "iso" (bitte ggf. anpassen)
|
||||
useEffect(() => {
|
||||
let intervalId: NodeJS.Timeout;
|
||||
const pathname = window.location.pathname;
|
||||
@@ -71,11 +72,19 @@ function AppContent({
|
||||
} else if (pathname.includes("tdrRef")) {
|
||||
dispatch(getAllTDRReferenceChartThunk());
|
||||
} else if (pathname.includes("tdrSlot")) {
|
||||
dispatch(getReferenceCurveBySlotThunk());
|
||||
dispatch(getReferenceCurveBySlotThunk(1));
|
||||
} else if (pathname.includes("tdrId")) {
|
||||
dispatch(getTDRChartDataByIdThunk());
|
||||
dispatch(getTDRChartDataByIdThunk(1));
|
||||
} else if (pathname.includes("loopChart")) {
|
||||
dispatch(getLoopChartDataThunk());
|
||||
dispatch(
|
||||
getLoopChartDataThunk({
|
||||
mode,
|
||||
type,
|
||||
slotNumber: 1, // Beispielwert, ggf. anpassen
|
||||
vonDatum: new Date().toISOString().split("T")[0], // Beispiel: heutiges Datum
|
||||
bisDatum: new Date().toISOString().split("T")[0], // Beispiel: heutiges Datum
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
}
|
||||
|
||||
if (mode === "jsSimulatedProd") {
|
||||
const analogInputsScript = fs.readFileSync(
|
||||
"mocks/device-cgi-simulator/SERVICE/analogInputsMockData.js",
|
||||
"utf-8"
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"mocks/device-cgi-simulator/SERVICE/analogInputsMockData.json"
|
||||
);
|
||||
res.setHeader("Content-Type", "application/javascript");
|
||||
res.status(200).send(analogInputsScript);
|
||||
const jsonContent = fs.readFileSync(filePath, "utf-8");
|
||||
const data = JSON.parse(jsonContent);
|
||||
res.status(200).json(data);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export default function handler(req, res) {
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { slot } = req.query;
|
||||
setTimeout(() => {
|
||||
res
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// pages/api/cpl/tdrMessungStartenMockHandler.ts
|
||||
export default function handler(req, res) {
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { slot } = req.query;
|
||||
setTimeout(() => {
|
||||
res.status(200).json({ message: `TDR simuliert für Slot ${slot}` });
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
export default function handler(req, res) {
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method !== "POST") {
|
||||
return res.status(405).json({ message: "Nur POST erlaubt" });
|
||||
}
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
// /pages/api/cpl/updateKueSettingsDataAPIHandler.ts
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
let { key, value, slot } = req.query;
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { key, value, slot } = req.query;
|
||||
|
||||
if (!key || slot === undefined) {
|
||||
return res.status(400).json({ error: "Missing key or slot parameter." });
|
||||
if (
|
||||
typeof key !== "string" ||
|
||||
typeof value !== "string" ||
|
||||
typeof slot !== "string"
|
||||
) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Missing or invalid key, value, or slot parameter." });
|
||||
}
|
||||
|
||||
const mockFilePath = path.join(
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const updates = req.body?.updates;
|
||||
|
||||
if (!Array.isArray(updates) || updates.length === 0) {
|
||||
@@ -34,7 +38,7 @@ export default async function handler(req, res) {
|
||||
.map((v) => (v === "" ? "0" : v))
|
||||
.slice(0, 32);
|
||||
|
||||
values[Number(slot)] = Number(value);
|
||||
values[Number(slot)] = String(Number(value));
|
||||
|
||||
const newLine = `var ${key} = [\n ${values.join(", ")}\n];`;
|
||||
fileContent = fileContent.replace(regex, newLine);
|
||||
|
||||
@@ -10,10 +10,10 @@ import { getKueDataThunk } from "../redux/thunks/getKueDataThunk";
|
||||
function Kabelueberwachung() {
|
||||
const dispatch: AppDispatch = useDispatch();
|
||||
const searchParams = useSearchParams(); // URL-Parameter holen
|
||||
const initialRack = parseInt(searchParams.get("rack")) || 1; // Rack-Nummer aus URL oder 1
|
||||
const initialRack = parseInt(searchParams.get("rack") ?? "1") || 1; // Rack-Nummer aus URL oder 1
|
||||
|
||||
const [activeRack, setActiveRack] = useState(initialRack); // Nutze initialRack als Startwert
|
||||
const [alarmStatus, setAlarmStatus] = useState([]); // Alarmstatus
|
||||
const [alarmStatus, setAlarmStatus] = useState<boolean[]>([]); // Alarmstatus
|
||||
|
||||
// Redux-Variablen aus dem Store abrufen
|
||||
const {
|
||||
@@ -25,21 +25,23 @@ function Kabelueberwachung() {
|
||||
kueResidence,
|
||||
kueCableBreak,
|
||||
kueGroundFault,
|
||||
} = useSelector((state) => state.kueDataSlice);
|
||||
} = useSelector((state: RootState) => state.kueDataSlice);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// 🚀 **TDR-Daten bereits in Redux abrufen**
|
||||
// Redux-Variablen abrufen
|
||||
const tdrData = useSelector((state) => state.tdrChartSlice.data);
|
||||
const loading = useSelector((state) => state.tdrChartSlice.loading);
|
||||
const error = useSelector((state) => state.tdrChartSlice.error);
|
||||
const tdrData = useSelector((state: RootState) => state.tdrChartSlice.data);
|
||||
const loading = useSelector(
|
||||
(state: RootState) => state.tdrChartSlice.loading
|
||||
);
|
||||
const error = useSelector((state: RootState) => state.tdrChartSlice.error);
|
||||
//----------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Alarmstatus basierend auf Redux-Variablen berechnen
|
||||
const updateAlarmStatus = () => {
|
||||
const updatedAlarmStatus = kueIso.map((_, index) => {
|
||||
return (
|
||||
return !!(
|
||||
(kueAlarm1 && kueAlarm1[index]) ||
|
||||
(kueAlarm2 && kueAlarm2[index]) ||
|
||||
(kueCableBreak && kueCableBreak[index]) ||
|
||||
@@ -66,7 +68,8 @@ function Kabelueberwachung() {
|
||||
}));
|
||||
//console.log("Alle Module:", allModules);
|
||||
|
||||
const racks = {
|
||||
type RackKey = "rack1" | "rack2" | "rack3" | "rack4";
|
||||
const racks: Record<RackKey, typeof allModules> = {
|
||||
rack1: allModules.slice(0, 8),
|
||||
rack2: allModules.slice(8, 16),
|
||||
rack3: allModules.slice(16, 24),
|
||||
@@ -92,7 +95,11 @@ function Kabelueberwachung() {
|
||||
); */
|
||||
|
||||
// Funktion zum Wechseln des Racks
|
||||
const changeRack = (rack) => {
|
||||
interface ChangeRackFn {
|
||||
(rack: number): void;
|
||||
}
|
||||
|
||||
const changeRack: ChangeRackFn = (rack) => {
|
||||
setActiveRack(rack);
|
||||
console.log(`Aktives Rack geändert zu: ${rack}`);
|
||||
};
|
||||
@@ -144,23 +151,22 @@ function Kabelueberwachung() {
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-row space-x-8 xl:space-x-0 2xl:space-x-8 qhd:space-x-16 ml-[5%] mt-[5%]">
|
||||
{racks[`rack${activeRack}`].map((slot, index) => {
|
||||
const slotIndex = index + (activeRack - 1) * 8;
|
||||
return (
|
||||
<div key={index} className="flex">
|
||||
<Kue705FO
|
||||
isolationswert={slot.isolationswert}
|
||||
schleifenwiderstand={slot.schleifenwiderstand}
|
||||
modulName={slot.modulName}
|
||||
kueOnline={slot.kueOnlineStatus}
|
||||
alarmStatus={slot.alarmStatus}
|
||||
slotIndex={slotIndex}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{racks[`rack${activeRack}` as RackKey].map((slot, index) => {
|
||||
const slotIndex = index + (activeRack - 1) * 8;
|
||||
return (
|
||||
<div key={index} className="flex">
|
||||
<Kue705FO
|
||||
isolationswert={slot.isolationswert}
|
||||
schleifenwiderstand={slot.schleifenwiderstand}
|
||||
modulName={slot.modulName}
|
||||
kueOnline={slot.kueOnlineStatus}
|
||||
alarmStatus={slot.alarmStatus}
|
||||
slotIndex={slotIndex}
|
||||
tdrLocation={[]} // TODO: Replace with actual tdrLocation data if available
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user