From 9ba2e08ccc370c231ed0869be97a85ffaf470e59 Mon Sep 17 00:00:00 2001 From: pacholoamit Date: Sun, 13 Oct 2024 15:11:38 +0800 Subject: [PATCH] feat: Add memory and swap information to system widget --- src/components/system-information-widget.tsx | 56 ++++++++++++++++--- src/features/metrics/pages/dashboard.page.tsx | 11 ++-- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/components/system-information-widget.tsx b/src/components/system-information-widget.tsx index 1e37cee7..9c10ff70 100644 --- a/src/components/system-information-widget.tsx +++ b/src/components/system-information-widget.tsx @@ -1,20 +1,62 @@ import { useShallow } from "zustand/react/shallow"; +import Card from "@/components/card"; import useGlobalCpuSelectors from "@/features/metrics/stores/global-cpu.store"; +import useMemorySelectors from "@/features/metrics/stores/memory.store"; +import useSwapSelectors from "@/features/metrics/stores/swap.store"; import useSystemStoreSelectors from "@/features/metrics/stores/system.store"; -import { Group, Title } from "@mantine/core"; +import formatBytes from "@/features/metrics/utils/format-bytes"; +import { Grid, Group, Text, Title } from "@mantine/core"; const SystemInformationWidget: React.FC = () => { const info = useSystemStoreSelectors(useShallow((state) => state.info)); const cpuBrand = useGlobalCpuSelectors(useShallow((state) => state.latest.brand)); + const memory = useMemorySelectors.use.latest().total; + const swap = useSwapSelectors.use.latest().total; + return ( - - CPU: {cpuBrand} - CPU cores: {info.coreCount} - OS: {info.os} - Kernel: {info.kernelVersion} - + + + + + CPU + + {cpuBrand} + + + + OS + + {info.os} + + + + CPU cores + + {info.coreCount} + + + + + Kernel + + {info.kernelVersion} + + + + Memory + + {formatBytes(memory)} + + + + Swap + + {formatBytes(swap)} + + + ); }; diff --git a/src/features/metrics/pages/dashboard.page.tsx b/src/features/metrics/pages/dashboard.page.tsx index bced9e32..f2029413 100644 --- a/src/features/metrics/pages/dashboard.page.tsx +++ b/src/features/metrics/pages/dashboard.page.tsx @@ -64,10 +64,10 @@ const CpuSection = () => { const NetworksSection = () => { return ( <> - + - + @@ -92,9 +92,12 @@ const DashboardPage = () => { const hostname = useSystemStoreSelectors(useShallow((state) => state.info.hostname)); const greeting = useRandomGreeting(hostname); return ( - }> + - + + + + {/* */}