From 04b29d9e841f4ab8e3cd57080f24bbab3a44b19d Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 10:13:05 +0300 Subject: [PATCH 1/5] Implement memory health card --- src/components/DeviceMemoryHealth.tsx | 70 +++++++++++++++++++++++++++ src/components/LandingPage.tsx | 2 + 2 files changed, 72 insertions(+) create mode 100644 src/components/DeviceMemoryHealth.tsx diff --git a/src/components/DeviceMemoryHealth.tsx b/src/components/DeviceMemoryHealth.tsx new file mode 100644 index 00000000..b5857e22 --- /dev/null +++ b/src/components/DeviceMemoryHealth.tsx @@ -0,0 +1,70 @@ +import StandartLineChart from './StandardLineChart' +import ShadowBox from './ShadowBox' +import IconText from './IconText' +import { Paragraph, Separator, XStack, YStack } from 'tamagui' + +type DataPoint = { + x: number + y: number +} + +type ChartData = { + id: string + color: string + data: DataPoint[] +} + +type DeviceMemoryProps = { + load: number[] +} +const DeviceMemory: React.FC = ({ load }) => { + const chartData: ChartData[] = [ + { + id: 'cpu', + color: '#8DC6BC', + data: load.map((yValue, index: number) => ({ + x: index + 1, + y: yValue, + })), + }, + ] + const currentLoad = + chartData[0].data.length > 0 ? chartData[0].data[chartData[0].data.length - 1].y : 0 + + const message = currentLoad < 80 ? 'Good' : 'Poor' + + return ( + + + +
+ +
+ + + Memory + + + {currentLoad} GB + + +
+ + + + {message} + + {/* This is additional text */} + +
+
+ ) +} + +export default DeviceMemory diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index d6bc3dc6..25286f31 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -1,6 +1,7 @@ import LayoutComponent from './LayoutComponent' import './LandingPage.css' import QuickStartBar from './QuickStartBar' +import DeviceMemory from './DeviceMemoryHealth' function LandingPage() { return ( @@ -95,6 +96,7 @@ function Content() { Discover Nodes + ) } From caf44695565481877f7e74c1ae13d4fc8ebd7c14 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 14:16:20 +0300 Subject: [PATCH 2/5] Add maxMemory argument --- src/components/DeviceMemoryHealth.tsx | 9 ++++++--- src/components/LandingPage.tsx | 2 +- src/components/StandardLineChart.tsx | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/DeviceMemoryHealth.tsx b/src/components/DeviceMemoryHealth.tsx index b5857e22..c1cd0f22 100644 --- a/src/components/DeviceMemoryHealth.tsx +++ b/src/components/DeviceMemoryHealth.tsx @@ -12,20 +12,23 @@ type ChartData = { id: string color: string data: DataPoint[] + maxMemory?: number } type DeviceMemoryProps = { - load: number[] + currentMemory: number[] + maxMemory?: number } -const DeviceMemory: React.FC = ({ load }) => { +const DeviceMemory = ({ currentMemory, maxMemory }: DeviceMemoryProps) => { const chartData: ChartData[] = [ { id: 'cpu', color: '#8DC6BC', - data: load.map((yValue, index: number) => ({ + data: currentMemory.map((yValue, index: number) => ({ x: index + 1, y: yValue, })), + maxMemory: maxMemory, }, ] const currentLoad = diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index 25286f31..dd750b00 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -96,7 +96,7 @@ function Content() { Discover Nodes - + ) } diff --git a/src/components/StandardLineChart.tsx b/src/components/StandardLineChart.tsx index 43aee4ee..5662bee6 100644 --- a/src/components/StandardLineChart.tsx +++ b/src/components/StandardLineChart.tsx @@ -7,12 +7,15 @@ interface DataPoint { interface ChartData { id: string data: DataPoint[] + maxMemory?: number } interface StandartLineChartProps { data: ChartData[] } const StandartLineChart = ({ data }: StandartLineChartProps) => { + const maxMemory = data[0].maxMemory || 'auto' + return ( { xScale={{ type: 'linear', min: 0, max: data[0].data.length }} yScale={{ type: 'linear', - min: 'auto', - max: 'auto', + min: 0, + max: maxMemory, stacked: true, reverse: false, }} From eed7a6d447eeedbc3795be75231768a4d6541c14 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 14:20:11 +0300 Subject: [PATCH 3/5] Remove imports --- src/components/LandingPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index dd750b00..d6bc3dc6 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -1,7 +1,6 @@ import LayoutComponent from './LayoutComponent' import './LandingPage.css' import QuickStartBar from './QuickStartBar' -import DeviceMemory from './DeviceMemoryHealth' function LandingPage() { return ( @@ -96,7 +95,6 @@ function Content() { Discover Nodes - ) } From 6b052c9b170853f38dc07506fec319212fcb239d Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 11 Aug 2023 14:29:06 +0300 Subject: [PATCH 4/5] tweaks --- src/components/DeviceMemoryHealth.tsx | 4 ++-- src/components/LandingPage.tsx | 2 ++ src/components/StandardLineChart.tsx | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/DeviceMemoryHealth.tsx b/src/components/DeviceMemoryHealth.tsx index c1cd0f22..cbc410ed 100644 --- a/src/components/DeviceMemoryHealth.tsx +++ b/src/components/DeviceMemoryHealth.tsx @@ -12,7 +12,7 @@ type ChartData = { id: string color: string data: DataPoint[] - maxMemory?: number + maxValue?: number } type DeviceMemoryProps = { @@ -28,7 +28,7 @@ const DeviceMemory = ({ currentMemory, maxMemory }: DeviceMemoryProps) => { x: index + 1, y: yValue, })), - maxMemory: maxMemory, + maxValue: maxMemory, }, ] const currentLoad = diff --git a/src/components/LandingPage.tsx b/src/components/LandingPage.tsx index d6bc3dc6..19003acf 100644 --- a/src/components/LandingPage.tsx +++ b/src/components/LandingPage.tsx @@ -1,6 +1,7 @@ import LayoutComponent from './LayoutComponent' import './LandingPage.css' import QuickStartBar from './QuickStartBar' +import DeviceMemory from './DeviceMemoryHealth' function LandingPage() { return ( @@ -14,6 +15,7 @@ function LandingPage() { function Content() { return (
+
diff --git a/src/components/StandardLineChart.tsx b/src/components/StandardLineChart.tsx index 5662bee6..4f3efe1b 100644 --- a/src/components/StandardLineChart.tsx +++ b/src/components/StandardLineChart.tsx @@ -7,14 +7,14 @@ interface DataPoint { interface ChartData { id: string data: DataPoint[] - maxMemory?: number + maxValue?: number } interface StandartLineChartProps { data: ChartData[] } const StandartLineChart = ({ data }: StandartLineChartProps) => { - const maxMemory = data[0].maxMemory || 'auto' + const maxMemory = data[0].maxValue || 'auto' return ( Date: Fri, 11 Aug 2023 14:52:28 +0300 Subject: [PATCH 5/5] Use status shadow box --- src/components/DeviceMemoryHealth.tsx | 5 +++-- src/components/DeviceNetworkHealth.tsx | 5 +++-- src/components/LandingPage.tsx | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/DeviceMemoryHealth.tsx b/src/components/DeviceMemoryHealth.tsx index cbc410ed..c9e3e916 100644 --- a/src/components/DeviceMemoryHealth.tsx +++ b/src/components/DeviceMemoryHealth.tsx @@ -1,7 +1,8 @@ import StandartLineChart from './StandardLineChart' -import ShadowBox from './ShadowBox' + import IconText from './IconText' import { Paragraph, Separator, XStack, YStack } from 'tamagui' +import { Shadow as ShadowBox } from '@status-im/components' type DataPoint = { x: number @@ -37,7 +38,7 @@ const DeviceMemory = ({ currentMemory, maxMemory }: DeviceMemoryProps) => { const message = currentLoad < 80 ? 'Good' : 'Poor' return ( - + +