From 3bd5a7c2537d20b8cb84c028e9dbdad6f77c3680 Mon Sep 17 00:00:00 2001 From: Josue Date: Wed, 17 Mar 2021 12:36:48 -0400 Subject: [PATCH] refactor: use pretty-bytes for formatting --- striker-ui/components/Memory.tsx | 42 ++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/striker-ui/components/Memory.tsx b/striker-ui/components/Memory.tsx index 07661ea1..e975e324 100644 --- a/striker-ui/components/Memory.tsx +++ b/striker-ui/components/Memory.tsx @@ -1,26 +1,54 @@ import { Grid } from '@material-ui/core'; +import * as prettyBytes from 'pretty-bytes'; import Panel from './Panel'; import AllocationBar from './AllocationBar'; import { HeaderText, BodyText } from './Text'; +import PeriodicFetch from '../lib/fetchers/periodicFetch'; + +const Memory = ({ uuid }: { uuid: string }): JSX.Element => { + const { data, isLoading } = PeriodicFetch( + `${process.env.NEXT_PUBLIC_API_URL}/anvils/get_memory?anvil_uuid=`, + uuid, + ); + + const memoryData = isLoading || !data ? { total: 0, free: 0 } : data; -const Memory = (): JSX.Element => { return ( - - + + - + - + - - + +