mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-25 11:30:08 +00:00
Uptime.tsx Type Error Fix
This commit is contained in:
parent
2f6957a45d
commit
12abe9c0d7
@ -46,20 +46,31 @@ const gridColumns = {
|
|||||||
3: 30
|
3: 30
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface UptimeData {
|
||||||
|
appName: string;
|
||||||
|
appId: number;
|
||||||
|
uptimeSummary: {
|
||||||
|
timestamp: string;
|
||||||
|
missing: boolean;
|
||||||
|
online: boolean | null;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
export default function Uptime() {
|
export default function Uptime() {
|
||||||
const [data, setData] = useState<any[]>([]);
|
const [data, setData] = useState<UptimeData[]>([]);
|
||||||
const [timespan, setTimespan] = useState<1 | 2 | 3>(1);
|
const [timespan, setTimespan] = useState<1 | 2 | 3>(1);
|
||||||
|
|
||||||
const getData = async (selectedTimespan: number) => {
|
const getData = async (selectedTimespan: number) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("/api/applications/uptime", {
|
const response = await axios.post<UptimeData[]>("/api/applications/uptime", {
|
||||||
timespan: selectedTimespan
|
timespan: selectedTimespan
|
||||||
});
|
});
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching data:", error);
|
console.error("Error:", error);
|
||||||
}
|
setData([]); // Setze leeres Array bei Fehlern
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getData(timespan);
|
getData(timespan);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user