From 0ba0f4a080a08029f222a1dcd89bcf0deac01f1d Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 14 Oct 2023 00:26:31 +0800 Subject: [PATCH] feat: monitor list add upPercent --- src/client/components/monitor/MonitorList.tsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/client/components/monitor/MonitorList.tsx b/src/client/components/monitor/MonitorList.tsx index 6127fe7..8e110fe 100644 --- a/src/client/components/monitor/MonitorList.tsx +++ b/src/client/components/monitor/MonitorList.tsx @@ -27,11 +27,28 @@ export const MonitorList: React.FC = React.memo(() => { return null; }, []); + const [beats, setBeats] = useState< + { + value: number; + createdAt: string; + }[] + >([]); const [selectedMonitorId, setSelectedMonitorId] = useState( initMonitorId ); + const upPercent = useMemo(() => { + let up = 0; + beats.forEach((b) => { + if (b.value >= 0) { + up++; + } + }); + + return parseFloat(((up / beats.length) * 100).toFixed(1)); + }, [beats]); + if (!currentWorkspaceId) { return ; } @@ -59,11 +76,11 @@ export const MonitorList: React.FC = React.memo(() => { } > {/* {monitor.monthOnlineRate * 100}% */} - 80% + {upPercent}%
-
{monitor.name}
+
{monitor.name}
{/*
{monitor.tags.map((tag) => ( {
- +
))}