UI Bug fixes and initial windows support

This commit is contained in:
Jaret Burkett
2025-02-24 08:15:22 -07:00
parent f0fbd8bb53
commit 093f14ac19
10 changed files with 88 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { GPUApiResponse } from '@/types';
import Loading from '@/components/Loading';
import GPUWidget from '@/components/GPUWidget';
@@ -8,10 +8,15 @@ const GpuMonitor: React.FC = () => {
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const [lastUpdated, setLastUpdated] = useState<Date | null>(null);
const isFetchingGpuRef = useRef(false);
useEffect(() => {
const fetchGpuInfo = async () => {
try {
if (isFetchingGpuRef.current) {
return;
}
isFetchingGpuRef.current = true;
const response = await fetch('/api/gpu');
if (!response.ok) {
@@ -25,6 +30,7 @@ const GpuMonitor: React.FC = () => {
} catch (err) {
setError(`Failed to fetch GPU data: ${err instanceof Error ? err.message : String(err)}`);
} finally {
isFetchingGpuRef.current = false;
setLoading(false);
}
};

View File

@@ -98,8 +98,8 @@ export default function GPUWidget({ gpu }: GPUWidgetProps) {
<div>
<p className="text-xs text-gray-400">Power Draw</p>
<p className="text-sm text-gray-200">
{gpu.power.draw.toFixed(1)}W
<span className="text-gray-400 text-xs"> / {gpu.power.limit.toFixed(1)}W</span>
{gpu.power.draw?.toFixed(1)}W
<span className="text-gray-400 text-xs"> / {gpu.power.limit?.toFixed(1) || " ? "}W</span>
</p>
</div>
</div>