From c89e6e1c47c92186e68525c72efe257bcf8fe0f6 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Thu, 10 Aug 2023 15:28:38 +0300 Subject: [PATCH] dynamically set left storage --- src/components/DeviceStorageHealth.tsx | 45 +++++++++++++++----------- src/components/LandingPage.tsx | 4 +-- src/components/StandardGauge.tsx | 26 +++++++-------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/components/DeviceStorageHealth.tsx b/src/components/DeviceStorageHealth.tsx index b8ace279..e65c28d0 100644 --- a/src/components/DeviceStorageHealth.tsx +++ b/src/components/DeviceStorageHealth.tsx @@ -2,24 +2,31 @@ import ShadowBox from './ShadowBox' import IconText from './IconText' import { Paragraph, Separator, XStack, YStack } from 'tamagui' import StandardGauge from './StandardGauge' +interface DeviceStorageHealthProps { + storage: number + maxStorage: number +} +const DeviceStorageHealth: React.FC = ({ storage, maxStorage }) => { + const message = storage < maxStorage ? 'Good' : 'Poor' + const data = (storage: number, maxStorage: number) => { + const used = storage + const free = maxStorage - storage -const DeviceStorageHealth = () => { - const currentLoad = 60 - const message = currentLoad < 80 ? 'Good' : 'Poor' - const data = [ - { - id: 'storage', - label: 'Storage', - value: 55, - color: '#E95460', - }, - { - id: 'storage', - label: 'Storage', - value: 45, - color: '#E7EAEE', - }, - ] + return [ + { + id: 'storage', + label: 'Used', + value: used, + color: '#E95460', + }, + { + id: 'storage', + label: 'Free', + value: free, + color: '#E7EAEE', + }, + ] + } return ( @@ -38,14 +45,14 @@ const DeviceStorageHealth = () => { height: '75px', }} > - + Storage - {currentLoad} GB + {storage} GB diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index 00563d14..426af7cd 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -3,7 +3,7 @@ import './LandingPage.css' import QuickStartBar from './QuickStartBar' import DeviceStorageHealth from './DeviceStorageHealth' import DeviceCPULoad from './DeviceCPULoad' - + function LandingPage() { return ( <> @@ -97,7 +97,7 @@ function Content() { Discover Nodes - + ) diff --git a/src/components/StandardGauge.tsx b/src/components/StandardGauge.tsx index 28b7c8bd..813122fb 100644 --- a/src/components/StandardGauge.tsx +++ b/src/components/StandardGauge.tsx @@ -11,20 +11,18 @@ interface StandardGaugeProps { } const StandardGauge = ({ data }: StandardGaugeProps) => ( - //
- datum.data.color} - fit={false} - activeOuterRadiusOffset={8} - enableArcLinkLabels={false} - arcLinkLabelsColor={{ from: 'color' }} - enableArcLabels={false} - legends={[]} - /> - //
+ datum.data.color} + fit={false} + activeOuterRadiusOffset={8} + enableArcLinkLabels={false} + arcLinkLabelsColor={{ from: 'color' }} + enableArcLabels={false} + legends={[]} + /> ) export default StandardGauge