mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update hardware.tsx
This commit is contained in:
@@ -74,8 +74,13 @@ export default function Hardware() {
|
|||||||
|
|
||||||
if (!fullSlot) return
|
if (!fullSlot) return
|
||||||
|
|
||||||
|
let abortController = new AbortController()
|
||||||
|
|
||||||
const fetchRealtimeData = async () => {
|
const fetchRealtimeData = async () => {
|
||||||
try {
|
try {
|
||||||
|
// Create a new AbortController for each fetch
|
||||||
|
abortController = new AbortController()
|
||||||
|
|
||||||
const apiUrl = `http://${window.location.hostname}:8008/api/gpu/${fullSlot}/realtime`
|
const apiUrl = `http://${window.location.hostname}:8008/api/gpu/${fullSlot}/realtime`
|
||||||
console.log("[v0] Fetching GPU realtime data from:", apiUrl)
|
console.log("[v0] Fetching GPU realtime data from:", apiUrl)
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ export default function Hardware() {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
signal: AbortSignal.timeout(10000),
|
signal: abortController.signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -99,7 +104,10 @@ export default function Hardware() {
|
|||||||
setRealtimeGPUData(data)
|
setRealtimeGPUData(data)
|
||||||
setDetailsLoading(false)
|
setDetailsLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[v0] Error fetching GPU realtime data:", error)
|
// Only log non-abort errors
|
||||||
|
if (error instanceof Error && error.name !== "AbortError") {
|
||||||
|
console.error("[v0] Error fetching GPU realtime data:", error)
|
||||||
|
}
|
||||||
setRealtimeGPUData({ has_monitoring_tool: false })
|
setRealtimeGPUData({ has_monitoring_tool: false })
|
||||||
setDetailsLoading(false)
|
setDetailsLoading(false)
|
||||||
}
|
}
|
||||||
@@ -111,7 +119,10 @@ export default function Hardware() {
|
|||||||
// Poll every 3 seconds
|
// Poll every 3 seconds
|
||||||
const interval = setInterval(fetchRealtimeData, 3000)
|
const interval = setInterval(fetchRealtimeData, 3000)
|
||||||
|
|
||||||
return () => clearInterval(interval)
|
return () => {
|
||||||
|
clearInterval(interval)
|
||||||
|
abortController.abort()
|
||||||
|
}
|
||||||
}, [selectedGPU])
|
}, [selectedGPU])
|
||||||
|
|
||||||
const handleGPUClick = async (gpu: GPU) => {
|
const handleGPUClick = async (gpu: GPU) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user