lastTDR in CPL Verzeichnis

This commit is contained in:
ISA
2024-10-25 06:40:49 +02:00
parent 85bc6f86de
commit f085787053
85 changed files with 383943 additions and 165 deletions

View File

@@ -1,31 +1,33 @@
// components/Header.jsx
"use client";
"use client"; // components/Header.jsx
import React, { useEffect, useState } from "react";
import Image from "next/image";
import "bootstrap-icons/font/bootstrap-icons.css";
import { loadWindowVariables } from "../utils/loadWindowVariables"; // Importiere die Funktion
import { loadWindowVariables } from "../utils/loadWindowVariables";
import SettingsModal from "./modales/SettingsModal";
function Header() {
const [isClient, setIsClient] = useState(false);
const [stationsname, setStationsname] = useState("Lädt..."); // Platzhalter
const [stationsname, setStationsname] = useState("Lädt...");
const [cplStatus, setCplStatus] = useState("Lädt...");
const [showSettingsModal, setShowSettingsModal] = useState(false);
// Boolean-Flag, um sicherzustellen, dass der console.log nur einmal ausgeführt wird
const [logOnce, setLogOnce] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
const handleSettingsClick = () => {
setShowSettingsModal(true); // Öffne das Modal
setShowSettingsModal(true);
};
const handleCloseSettingsModal = () => {
setShowSettingsModal(false); // Schließe das Modal
setShowSettingsModal(false);
};
const handleLogout = () => {
window.location.href = "/offline.html"; // Öffnet offline.html
window.location.href = "/offline.html";
};
useEffect(() => {
@@ -46,93 +48,93 @@ function Header() {
});
}
}, [isClient]);
useEffect(() => {
if (typeof window !== "undefined") {
console.log("Systemvariablen geladen:", {
// last20Messages.acp
last20Messages: window.last20Messages,
// System.acp Variablen
deviceName: window.deviceName,
mac1: window.mac1,
mac2: window.mac2,
ip: window.ip,
subnet: window.subnet,
gateway: window.gateway,
datetime: window.datetime,
// de.acp Variablen
de: window.de,
counter: window.counter,
flutter: window.flutter,
// kueConfig.acp Variablen
kueOnline: window.kueOnline,
kueID: window.kueID,
//kueIso: window.kueIso, von SERVICE/kueConfig.acp also von window.kueIso
// kuedetail.acp Variablen
kueValid: window.kueValid,
kueAlarm1: window.kueAlarm1,
kueAlarm2: window.kueAlarm2,
kueRes: window.kueRes,
kueCableBreak: window.kueCableBreak,
kueGroundFault: window.kueGroundFault,
kueLimit1: window.kueLimit1,
kueLimit2Low: window.kueLimit2Low,
kueLimit2High: window.kueLimit2High,
kueDelay1: window.kueDelay1,
kueLoopInterval: window.kueLoopInterval,
kueVersion: window.kueVersion,
tdrAtten: window.tdrAtten,
tdrPulse: window.tdrPulse,
tdrSpeed: window.tdrSpeed,
tdrAmp: window.tdrAmp,
tdrTrigger: window.tdrTrigger,
tdrLocation: window.tdrLocation,
tdrActive: window.tdrActive,
kueOverflow: window.kueOverflow,
kue100V: window.kue100V,
kueResidence: window.kueResidence,
tdrLastMeasurement: window.tdrLastMeasurement,
kueBooting: window.kueBooting,
appVersion: window.appVersion,
});
}
}, []);
useEffect(() => {
if (isClient) {
if (isClient && !logOnce) {
const files = [
"de.acp",
"kueConfig.acp",
"de.js",
"kueConfig.js",
"kueData.js",
"kueDetailTdr.acp",
"Start.acp",
"System.acp",
"kueDetailTdr.js",
"Start.js",
"System.js",
];
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production"; // Fallback auf 'production'
const environment = process.env.NEXT_PUBLIC_NODE_ENV || "production";
let filesLoadedCount = 0; // Zähle die Anzahl der erfolgreich geladenen Dateien
files.forEach((file) => {
const script = document.createElement("script");
if (environment === "production") {
script.src = `/CPL?/CPL/SERVICE/${file}`; // Produktions-Pfad
script.src = `/CPL?/CPL/SERVICE/${file}`;
} else {
script.src = `/mockData/SERVICE/${file}`; // Entwicklungs-Pfad
script.src = `/mockData/SERVICE/${file}`;
}
script.async = true;
script.onload = () => console.log(`${file} wurde erfolgreich geladen.`);
script.onload = () => {
console.log(`${file} wurde erfolgreich geladen.`);
filesLoadedCount++;
// Wenn alle Dateien geladen sind und der logOnce noch false ist, führe den log aus
if (filesLoadedCount === files.length && !logOnce) {
console.log("Systemvariablen geladen:", {
last20Messages: window.last20Messages,
deviceName: window.deviceName,
mac1: window.mac1,
mac2: window.mac2,
ip: window.ip,
subnet: window.subnet,
gateway: window.gateway,
datetime: window.datetime,
de: window.de,
counter: window.counter,
flutter: window.flutter,
kueOnline: window.kueOnline,
kueID: window.kueID,
kueValid: window.kueValid,
kueAlarm1: window.kueAlarm1,
kueAlarm2: window.kueAlarm2,
kueRes: window.kueRes,
kueCableBreak: window.kueCableBreak,
kueGroundFault: window.kueGroundFault,
kueLimit1: window.kueLimit1,
kueLimit2Low: window.kueLimit2Low,
kueLimit2High: window.kueLimit2High,
kueDelay1: window.kueDelay1,
kueLoopInterval: window.kueLoopInterval,
kueVersion: window.kueVersion,
tdrAtten: window.tdrAtten,
tdrPulse: window.tdrPulse,
tdrSpeed: window.tdrSpeed,
tdrAmp: window.tdrAmp,
tdrTrigger: window.tdrTrigger,
tdrLocation: window.tdrLocation,
tdrActive: window.tdrActive,
kueOverflow: window.kueOverflow,
kue100V: window.kue100V,
kueResidence: window.kueResidence,
tdrLastMeasurement: window.tdrLastMeasurement,
kueBooting: window.kueBooting,
appVersion: window.appVersion,
});
setLogOnce(true); // Setze das Flag auf true, damit der log nicht erneut ausgeführt wird
}
};
script.onerror = (error) =>
console.error(`Fehler beim Laden von ${file}:`, error);
document.head.appendChild(script);
});
}
}, [isClient]);
}, [isClient, logOnce]);
useEffect(() => {
console.log("Environment:", process.env.NEXT_PUBLIC_NODE_ENV); // Logge die Umgebungsvariable
console.log("Environment:", process.env.NEXT_PUBLIC_NODE_ENV);
}, []);
if (!isClient) return null; // Rendere die Komponente nicht, bis sie clientseitig ausgeführt wird
if (!isClient) return null;
return (
<header className="bg-gray-300 flex justify-between items-center w-full h-28 relative text-black">
@@ -148,7 +150,6 @@ function Header() {
</div>
<div className="w-64 flex-shrink-0 h-full mt-24 "></div>
{/* CPL Status und Stationsname */}
<div className="flex items-start space-x-4 w-full">
<div className="flex flex-col text-left pl-8">
<h2 className="text-base">Stationsname</h2>

View File

@@ -114,7 +114,7 @@ function KueModal({ showModal, onClose, slot, onModulNameChange }) {
// Falls Änderungen vorhanden sind, die fetch-Requests auslösen
if (Object.keys(changes).length > 0) {
let url = `/cpl?/SERVICE/kueDetail.HTML&slot=${slot}`;
let url = `/cpl?/CPL/SERVICE/kueDetail.HTML&slot=${slot}`;
Object.keys(changes).forEach((paramKey) => {
url += `&${paramKey}${slot}=${encodeURIComponent(changes[paramKey])}`;
@@ -142,7 +142,7 @@ function KueModal({ showModal, onClose, slot, onModulNameChange }) {
};
const handleDisplayEinschalten = () => {
const url = `/CPL?/Service/kueDetail.HTML&KSD${slot}=1`;
const url = `/CPL?/CPL/Service/kueDetail.HTML&KSD${slot}=1`;
fetch(url, { method: "GET" })
.then((response) => {
if (response.ok) {

View File

@@ -54,7 +54,7 @@ function Kue705FO({
const slot = slotIndex;
//const fileData = `../cpl?lastTDR/slot${slot}.json`; // TDR-Daten je nach Slot laden
if (environment === "production") {
fileData = `CPL?/SERVICE/lastTDR/slot${slot}.json`; // Produktions-Pfad
fileData = `/CPL?/CPL/lastTDR/slot${slot}.json`; // Produktions-Pfad
} else {
fileData = `/mockData/lastTDR/slot${slot}.json`; // Mock-Daten-Pfad für Entwicklung
}
@@ -75,7 +75,7 @@ function Kue705FO({
const slot = slotIndex;
//const fileData = `../cpl?4000values/slot${slot}.json`; // Schleifenmessdaten je nach Slot laden
if (environment === "production") {
fileData = `CPL?/SERVICE/4000values/slot${slot}.json`; // Produktions-Pfad
fileData = `/CPL?/CPL/4000values/slot${slot}.json`; // Produktions-Pfad
} else {
fileData = `/mockData/4000values/slot${slot}.json`; // Mock-Daten-Pfad für Entwicklung
}
@@ -375,9 +375,9 @@ function Kue705FO({
<span className="text-white text-[18px]"></span>
</button>
<div className="absolute bottom-[5px] left-1/2 transform -translate-x-1/2">
<div className="top-[220px] left-[10px] text-black text-[10px]">
<p>{currentDisplayValue}</p>
<div className="absolute bottom-[5px] left-1/2 transform -translate-x-1/2 w-[100px] flex justify-center items-center">
<div className="text-center text-black text-[10px]">
<p>{currentDisplayValue + " KOhm"}</p>
</div>
</div>
</div>