-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(widget): 🎉 update usages widget logic
- Loading branch information
1 parent
f96d9c9
commit c608d39
Showing
11 changed files
with
108 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ReactElement, useEffect, useState } from "react"; | ||
import useMain from "../../hooks/useMain"; | ||
import { BsGpuCard } from "react-icons/bs"; | ||
import { IGPUDeviceUsage } from "../../interfaces/instanceInferfaces"; | ||
|
||
export default function GPUChart(): ReactElement { | ||
const { pagesState } = useMain(); | ||
|
||
const [gpuData, setGpuData] = useState<IGPUDeviceUsage[] | undefined>([]); | ||
|
||
useEffect(() => { | ||
setGpuData(pagesState?.instance?.cloudInstanceResource?.gpuDeviceUsage); | ||
}, [pagesState?.instance?.cloudInstanceResource?.gpuDeviceUsage]); | ||
|
||
return ( | ||
<div className="flex flex-col items-center gap-3"> | ||
{gpuData?.map((data, index) => { | ||
return ( | ||
<div key={index} className="flex items-center gap-4 text-sm"> | ||
<div className="flex gap-2"> | ||
<BsGpuCard size={22} className="text-layer-secondary-600" /> | ||
<p>{data?.device}</p> | ||
</div> | ||
<div className="flex flex-col text-[0.66rem]"> | ||
<div> | ||
<p> | ||
{(Number(data?.memoryUsed) / 1024)?.toFixed(1) || 0.1} /{" "} | ||
{( | ||
(Number(data?.memoryFree) + Number(data?.memoryUsed)) / | ||
1024 | ||
).toFixed(1)} | ||
GB - {data?.temp}°C | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
<span className="text-[0.66rem]"> | ||
GPU ( | ||
{gpuData?.reduce((acc, curr) => { | ||
return ( | ||
acc + (Number(curr?.memoryFree) + Number(curr?.memoryUsed)) / 1024 | ||
); | ||
}, 0)} | ||
) | ||
</span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters