mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 03:26:17 +00:00
Update hardware.tsx
This commit is contained in:
@@ -40,13 +40,19 @@ const formatMemory = (memoryKB: number | string): string => {
|
|||||||
return `${mb.toFixed(0)} MB`
|
return `${mb.toFixed(0)} MB`
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatClock = (clockString: string): string => {
|
const formatClock = (clockString: string | number): string => {
|
||||||
|
let mhz: number
|
||||||
|
|
||||||
|
if (typeof clockString === "number") {
|
||||||
|
mhz = clockString
|
||||||
|
} else {
|
||||||
// Extract numeric value from string like "1138.179107 MHz"
|
// Extract numeric value from string like "1138.179107 MHz"
|
||||||
const match = clockString.match(/([\d.]+)\s*MHz/i)
|
const match = clockString.match(/([\d.]+)\s*MHz/i)
|
||||||
if (!match) return clockString
|
if (!match) return clockString
|
||||||
|
mhz = Number.parseFloat(match[1])
|
||||||
|
}
|
||||||
|
|
||||||
const mhz = Number.parseFloat(match[1])
|
if (isNaN(mhz)) return String(clockString)
|
||||||
if (isNaN(mhz)) return clockString
|
|
||||||
|
|
||||||
// Convert to GHz if >= 1000 MHz
|
// Convert to GHz if >= 1000 MHz
|
||||||
if (mhz >= 1000) {
|
if (mhz >= 1000) {
|
||||||
@@ -110,13 +116,10 @@ export default function Hardware() {
|
|||||||
|
|
||||||
if (!fullSlot) return
|
if (!fullSlot) return
|
||||||
|
|
||||||
let abortController = new AbortController()
|
const 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`
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
|
|||||||
Reference in New Issue
Block a user