selectedChartData slice erstellt
This commit is contained in:
@@ -1,36 +1,49 @@
|
||||
// /services/fetchSystemSettings.ts
|
||||
|
||||
export const fetchSystemSettings = async () => {
|
||||
if (typeof window === "undefined") return null;
|
||||
try {
|
||||
if (typeof window === "undefined") return null;
|
||||
|
||||
// ✅ System.js nur bei Bedarf nachladen (Pfad abhängig von Umgebung)
|
||||
const scriptSrc =
|
||||
process.env.NODE_ENV === "production"
|
||||
? "/CPL?/CPL/SERVICE/System.js"
|
||||
: "/CPLmockData/SERVICE/System.js";
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
script.src = "/CPLmockData/SERVICE/System.js"; // ggf. anpassen
|
||||
script.async = true;
|
||||
script.onload = () => resolve();
|
||||
script.onerror = () => reject("❌ Fehler beim Laden von System.js");
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
script.src = scriptSrc;
|
||||
script.async = true;
|
||||
script.onload = () => resolve();
|
||||
script.onerror = () => reject("❌ Fehler beim Laden von System.js");
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
const {
|
||||
win_deviceName,
|
||||
win_mac1,
|
||||
win_ip,
|
||||
win_subnet,
|
||||
win_gateway,
|
||||
win_cplInternalTimestamp,
|
||||
win_ntp1,
|
||||
win_ntp2,
|
||||
win_ntp3,
|
||||
win_ntpTimezone,
|
||||
win_ntpActive,
|
||||
win_appVersion,
|
||||
} = window as any;
|
||||
|
||||
const win = window as any;
|
||||
|
||||
return {
|
||||
deviceName: win.win_deviceName || "",
|
||||
mac1: win.win_mac1 || "",
|
||||
ip: win.win_ip || "",
|
||||
subnet: win.win_subnet || "",
|
||||
gateway: win.win_gateway || "",
|
||||
cplInternalTimestamp: win.win_cplInternalTimestamp || "",
|
||||
ntp1: win.win_ntp1 || "",
|
||||
ntp2: win.win_ntp2 || "",
|
||||
ntp3: win.win_ntp3 || "",
|
||||
ntpTimezone: win.win_ntpTimezone || "",
|
||||
ntpActive: win.win_ntpActive || false,
|
||||
};
|
||||
return {
|
||||
deviceName: win_deviceName,
|
||||
mac1: win_mac1,
|
||||
ip: win_ip,
|
||||
subnet: win_subnet,
|
||||
gateway: win_gateway,
|
||||
cplInternalTimestamp: win_cplInternalTimestamp,
|
||||
ntp1: win_ntp1,
|
||||
ntp2: win_ntp2,
|
||||
ntp3: win_ntp3,
|
||||
ntpTimezone: win_ntpTimezone,
|
||||
ntpActive: win_ntpActive === "1",
|
||||
appVersion: win_appVersion, // ✅ jetzt korrekt
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Laden der Systemdaten:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user