import useSWR from "swr"; import { FiHardDrive, FiCpu } from "react-icons/fi"; import { FaMemory } from "react-icons/fa"; export default function Resources({ options }) { const { data, error } = useSWR( `/api/widgets/resources?disk=${options.disk}`, { refreshInterval: 1500, } ); if (error) { return
failed to load
; } if (!data) { return ( <> {options.disk && (
- GB free - GB used
)} {options.cpu && (
- Usage - Load
)} {options.memory && (
- GB Used - GB Free
)} ); } if (data.error) { return
; } return ( <> {options.disk && (
{Math.round(data.drive.freeGb)} GB free {Math.round(data.drive.totalGb)} GB used
)} {options.cpu && (
{Math.round(data.cpu.usage)}% Usage {Math.round(data.cpu.load * 100) / 100} Load
)} {options.memory && (
{Math.round((data.memory.usedMemMb / 1024) * 100) / 100} GB Used {Math.round((data.memory.freeMemMb / 1024) * 100) / 100} GB Free
)} ); }