fix: CGI-API-Aufruf in Produktionsumgebung per fetch statt location.href
- CGI-Endpunkte der CPL-Hardware werden jetzt per fetch im Hintergrund aufgerufen - Kein Tab-Wechsel oder Seitenreload mehr bei "Speichern" - Entwicklung nutzt weiterhin Next.js API-Routen - Nutzer erhält einheitliches Feedback per alert
This commit is contained in:
@@ -4,3 +4,5 @@ NEXT_PUBLIC_ENCRYPTION_IV=1
|
||||
NEXT_PUBLIC_USE_MOCK_BACKEND_TDR_START=true
|
||||
NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
|
||||
NEXT_PUBLIC_EXPORT_STATIC=false
|
||||
NEXT_PUBLIC_USE_CGI=false
|
||||
|
||||
|
||||
@@ -2,4 +2,5 @@ NEXT_PUBLIC_NODE_ENV=production
|
||||
NEXT_PUBLIC_ENCRYPTION_KEY=1
|
||||
NEXT_PUBLIC_ENCRYPTION_IV=1
|
||||
NEXT_PUBLIC_CPL_API_PATH=/CPL
|
||||
NEXT_PUBLIC_EXPORT_STATIC=true
|
||||
NEXT_PUBLIC_EXPORT_STATIC=true
|
||||
NEXT_PUBLIC_USE_CGI=true
|
||||
|
||||
@@ -95,7 +95,7 @@ var win_kueVersion = [
|
||||
];
|
||||
|
||||
//Modulname in Komponente und auf der Anzeige
|
||||
var win_kueID = [ "FTZ_4", "B23", "Kabel 3", "Kabel 4", "Kabel 5", "Kabel 6", "FTZ4562", "Kabel 8", "12344", "Kabel 10", "Kabel 11", "Kabel 12", "Kabel 13", "Kabel 14", "Kabel 15", "H56-77", "Kabel 17", "Kabel 18", "Kabel 19", "Kabel 20", "Kabel 21", "Kabel 22", "Kabel 23", "Kabel 24", "Kabel 25", "Kabel 26", "Kabel 27", "Kabel 28", "Kabel 29", "Kabel 30", "Kabel 31", "Kabel 32", ];;;
|
||||
var win_kueID = [ "FTZ_5", "B23", "Kabel 3", "Kabel 4", "Kabel 5", "Kabel 6", "FTZ4562", "Kabel 8", "12344", "Kabel 10", "Kabel 11", "Kabel 12", "Kabel 13", "Kabel 14", "Kabel 15", "H56-77", "Kabel 17", "Kabel 18", "Kabel 19", "Kabel 20", "Kabel 21", "Kabel 22", "Kabel 23", "Kabel 24", "Kabel 25", "Kabel 26", "Kabel 27", "Kabel 28", "Kabel 29", "Kabel 30", "Kabel 31", "Kabel 32", ];;;;
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ interface HandleSaveParams {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
// Vergleich: robust für Zahlen und Strings
|
||||
const isDifferent = (a: any, b: any): boolean => {
|
||||
const aNum = Number(a);
|
||||
const bNum = Number(b);
|
||||
@@ -49,7 +50,7 @@ const handleSave = async ({
|
||||
const changesForFile: Record<string, any> = {};
|
||||
|
||||
if (isDifferent(ids[slot], originalValues.kueID[slot])) {
|
||||
changesForFile.win_kueID = ids[slot];
|
||||
changesForFile.KID = ids[slot];
|
||||
}
|
||||
if (
|
||||
isDifferent(
|
||||
@@ -57,10 +58,10 @@ const handleSave = async ({
|
||||
originalValues.isolationsgrenzwerte[slot]
|
||||
)
|
||||
) {
|
||||
changesForFile.win_kueLimit1 = isolationsgrenzwerte[slot];
|
||||
changesForFile.KL_ = isolationsgrenzwerte[slot];
|
||||
}
|
||||
if (isDifferent(verzoegerung[slot], originalValues.verzoegerung[slot])) {
|
||||
changesForFile.win_kueDelay1 = verzoegerung[slot];
|
||||
changesForFile.KD_ = verzoegerung[slot];
|
||||
}
|
||||
if (
|
||||
isDifferent(
|
||||
@@ -68,7 +69,7 @@ const handleSave = async ({
|
||||
originalValues.untereSchleifenGrenzwerte[slot]
|
||||
)
|
||||
) {
|
||||
changesForFile.win_kueLimit2Low = untereSchleifenGrenzwerte[slot];
|
||||
changesForFile.KR_ = untereSchleifenGrenzwerte[slot];
|
||||
}
|
||||
if (
|
||||
isDifferent(
|
||||
@@ -76,7 +77,7 @@ const handleSave = async ({
|
||||
originalValues.obereSchleifenGrenzwerte[slot]
|
||||
)
|
||||
) {
|
||||
changesForFile.win_kueLimit2High = obereSchleifenGrenzwerte[slot];
|
||||
changesForFile.KRO_ = obereSchleifenGrenzwerte[slot];
|
||||
}
|
||||
if (
|
||||
isDifferent(
|
||||
@@ -84,19 +85,22 @@ const handleSave = async ({
|
||||
originalValues.schleifenintervall[slot]
|
||||
)
|
||||
) {
|
||||
changesForFile.win_kueLoopInterval = schleifenintervall[slot];
|
||||
changesForFile.KRI = schleifenintervall[slot];
|
||||
}
|
||||
|
||||
if (Object.keys(changesForFile).length > 0) {
|
||||
const isDev = window.location.hostname === "localhost";
|
||||
const isProd = !isDev;
|
||||
|
||||
if (isDev) {
|
||||
// Entwicklung: interne Next.js API
|
||||
for (const [key, value] of Object.entries(changesForFile)) {
|
||||
const params = new URLSearchParams({
|
||||
key,
|
||||
key: `win_kue${key}`,
|
||||
value: String(value),
|
||||
slot: String(slot),
|
||||
});
|
||||
|
||||
const response = await fetch(
|
||||
`/api/cpl/updateKueDataAPIHandler?${params.toString()}`
|
||||
);
|
||||
@@ -105,9 +109,35 @@ const handleSave = async ({
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
alert("✅ Daten erfolgreich gespeichert!");
|
||||
}
|
||||
|
||||
alert("✅ Daten erfolgreich gespeichert!");
|
||||
if (isProd) {
|
||||
// Produktion: echte CPL-Hardware CGI-Aufruf
|
||||
const cgiParams = Object.entries(changesForFile)
|
||||
.map(([key, value]) => `${key}${slot}=${encodeURIComponent(value)}`)
|
||||
.join(";");
|
||||
const url = `/CPL?KUEdetail.ACP&${cgiParams}`;
|
||||
|
||||
console.log("📡 Sende an CPL (CGI) →", url);
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
alert("❌ Fehler beim Senden an die CPL-Hardware");
|
||||
return;
|
||||
}
|
||||
|
||||
alert("✅ Daten erfolgreich an die CPL-Hardware gesendet!");
|
||||
} catch (error) {
|
||||
console.error("❌ Netzwerkfehler beim CPL-Aufruf:", error);
|
||||
alert("❌ Netzwerkfehler beim Senden an die CPL-Hardware");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Redux und UI aktualisieren
|
||||
onModulNameChange(ids[slot]);
|
||||
|
||||
dispatch(
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||
|
||||
*/
|
||||
const webVersion = "1.6.248";
|
||||
const webVersion = "1.6.249";
|
||||
export default webVersion;
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"clean": "rimraf .next out",
|
||||
"build": "npm run clean && cross-env EXPORT_STATIC=true next build && next export",
|
||||
"build": "npm run clean && cross-env EXPORT_STATIC=true next build",
|
||||
"postbuild": "copy LICENSE_ICONIFY.txt out\\LICENSE_ICONIFY.txt",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"test": "jest",
|
||||
"prepare": "husky install",
|
||||
"export": "cross-env EXPORT_STATIC=true next build && next export"
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource/roboto": "^5.1.0",
|
||||
|
||||
Reference in New Issue
Block a user