From ceb28a75d068fe35d32bbb6a7f033a6556a18eae Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 3 Oct 2023 20:57:24 +0800 Subject: [PATCH] feat: add --- src/client/components/UpDownCounter.tsx | 22 ++++++++++++++++ src/client/pages/Servers.tsx | 35 +++++++++---------------- 2 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 src/client/components/UpDownCounter.tsx diff --git a/src/client/components/UpDownCounter.tsx b/src/client/components/UpDownCounter.tsx new file mode 100644 index 0000000..b76277d --- /dev/null +++ b/src/client/components/UpDownCounter.tsx @@ -0,0 +1,22 @@ +import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons'; +import React from 'react'; + +interface Props { + up: string; + down: string; +} +export const UpDownCounter: React.FC = React.memo((props) => { + return ( +
+
+ + {props.up} +
+
+ + {props.down} +
+
+ ); +}); +UpDownCounter.displayName = 'UpDownCounter'; diff --git a/src/client/pages/Servers.tsx b/src/client/pages/Servers.tsx index 720bc1a..b1cb785 100644 --- a/src/client/pages/Servers.tsx +++ b/src/client/pages/Servers.tsx @@ -6,6 +6,7 @@ import { ServerStatusInfo } from '../../types'; import { useSocketSubscribe } from '../api/socketio'; import { filesize } from 'filesize'; import prettyMilliseconds from 'pretty-ms'; +import { UpDownCounter } from '../components/UpDownCounter'; export const Servers: React.FC = React.memo(() => { const [isModalOpen, setIsModalOpen] = useState(false); @@ -49,20 +50,6 @@ export const Servers: React.FC = React.memo(() => { }); Servers.displayName = 'Servers'; -interface ServerInfoRecordType { - status: 'online' | 'offline'; - nodeName: string; - type: string; // KVM | Hyper-V - location: string; - uptime: number; // second - load: number; - network: string; - traffic: string; - cpu: string; - ram: string; - hdd: string; -} - export const ServerList: React.FC = React.memo(() => { const serverMap = useSocketSubscribe>( 'onServerStatusUpdate', @@ -71,8 +58,6 @@ export const ServerList: React.FC = React.memo(() => { const dataSource = Object.values(serverMap); - console.log('dataSource', dataSource); - const columns = useMemo((): ColumnsType => { return [ { @@ -109,18 +94,24 @@ export const ServerList: React.FC = React.memo(() => { key: 'nework', title: 'Network', render: (_, record) => { - return `${filesize(record.payload.network_in)} | ${filesize( - record.payload.network_out - )}`; + return ( + + ); }, }, { key: 'traffic', title: 'Traffic', render: (_, record) => { - return `${filesize(record.payload.network_rx)}/s | ${filesize( - record.payload.network_tx - )}/s`; + return ( + + ); }, }, {