IP kommt von window und nicht von.env.local, weil in CHIPTOOL kann die IP eingestellt werden
This commit is contained in:
@@ -14,7 +14,8 @@ import { Icon } from "@iconify/react";
|
||||
|
||||
function Dashboard() {
|
||||
//const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
const apiUrl = `https://${window.ip}:443`;
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
|
||||
const [last20Messages, setLast20Messages] = useState([]);
|
||||
const [kueOnline, setkueOnline] = useState([]);
|
||||
const [ip, setIp] = useState("");
|
||||
@@ -24,28 +25,42 @@ function Dashboard() {
|
||||
const [error, setError] = useState(null);
|
||||
const [kueCableBreak, setKueCableBreak] = useState([]);
|
||||
const [appVersion, setAppVersion] = useState("");
|
||||
const [apiUrl, setApiUrl] = useState("");
|
||||
/* useEffect(() => {
|
||||
setIsClient(true);
|
||||
if (typeof window !== "undefined") {
|
||||
setApiUrl(`https://${window.ip}:443`);
|
||||
}
|
||||
}, []); */
|
||||
|
||||
/* if (!isClient) {
|
||||
return null; // or a loading spinner
|
||||
} */
|
||||
//const apiUrl = `https://${ip}:443`;
|
||||
useEffect(() => {
|
||||
loadWindowVariables(apiUrl)
|
||||
.then(() => {
|
||||
if (window.last20Messages) {
|
||||
const parsedMessages = parseMessages(window.last20Messages);
|
||||
setLast20Messages(parsedMessages);
|
||||
setIp(window.ip);
|
||||
setSubnet(window.subnet);
|
||||
setGateway(window.gateway);
|
||||
setAppVersion(window.appVersion);
|
||||
} else {
|
||||
console.error("Konnte last20Messages nicht finden.");
|
||||
setError("Konnte last20Messages nicht finden.");
|
||||
}
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler beim Laden des Skripts:", error);
|
||||
setError(error);
|
||||
setLoading(false);
|
||||
});
|
||||
if (typeof window !== "undefined") {
|
||||
loadWindowVariables(apiUrl)
|
||||
.then(() => {
|
||||
if (window.last20Messages) {
|
||||
const parsedMessages = parseMessages(window.last20Messages);
|
||||
setLast20Messages(parsedMessages);
|
||||
setIp(window.ip);
|
||||
setSubnet(window.subnet);
|
||||
setGateway(window.gateway);
|
||||
setAppVersion(window.appVersion);
|
||||
setApiUrl(`https://${window.ip}:443`);
|
||||
} else {
|
||||
console.error("Konnte last20Messages nicht finden.");
|
||||
setError("Konnte last20Messages nicht finden.");
|
||||
}
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler beim Laden des Skripts:", error);
|
||||
setError(error);
|
||||
setLoading(false);
|
||||
});
|
||||
}
|
||||
}, [apiUrl]);
|
||||
useEffect(() => {
|
||||
loadWindowVariables(apiUrl)
|
||||
|
||||
@@ -4,7 +4,9 @@ import Kue705FO from "../../components/modules/Kue705FO";
|
||||
|
||||
function Kabelueberwachung() {
|
||||
//const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
const apiUrl = `https://${window.ip}:443`;
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
const [apiUrl, setApiUrl] = useState("");
|
||||
|
||||
const [activeRack, setActiveRack] = useState(1); // Track the active rack
|
||||
const [kueIso, setKueIso] = useState([]); // State to store isolation values
|
||||
const [kueName, setKueName] = useState([]); // State to store the KUE names
|
||||
@@ -16,7 +18,15 @@ function Kabelueberwachung() {
|
||||
const changeRack = (rack) => {
|
||||
setActiveRack(rack);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setIsClient(true);
|
||||
if (typeof window !== "undefined") {
|
||||
setApiUrl(`https://${window.ip}:443`);
|
||||
}
|
||||
}, []);
|
||||
/* if (!isClient) {
|
||||
return null; // or a loading spinner
|
||||
}*/
|
||||
// Load the external JavaScript file and fetch the isolation values
|
||||
useEffect(() => {
|
||||
if (window.kueIso && Array.isArray(window.kueIso)) {
|
||||
|
||||
Reference in New Issue
Block a user