import SvgIcon from '@/components/svg-icon'; import { useFetchSystemStatus } from '@/hooks/user-setting-hooks'; import { ISystemStatus, Minio } from '@/interfaces/database/userSetting'; import { Badge, Card, Flex, Spin, Typography } from 'antd'; import classNames from 'classnames'; import lowerCase from 'lodash/lowerCase'; import upperFirst from 'lodash/upperFirst'; import { useEffect } from 'react'; import { toFixed } from '@/utils/common-util'; import styles from './index.less'; const { Text } = Typography; enum Status { 'green' = 'success', 'red' = 'error', 'yellow' = 'warning', } const TitleMap = { es: 'Elasticsearch', minio: 'MinIO Object Storage', redis: 'Redis', mysql: 'Mysql', }; const SystemInfo = () => { const { systemStatus, fetchSystemStatus, loading: statusLoading, } = useFetchSystemStatus(); useEffect(() => { fetchSystemStatus(); }, [fetchSystemStatus]); return (
{Object.keys(systemStatus).map((key) => { const info = systemStatus[key as keyof ISystemStatus]; return ( {TitleMap[key as keyof typeof TitleMap]} } key={key} > {Object.keys(info) .filter((x) => x !== 'status') .map((x) => { return ( {upperFirst(lowerCase(x))}: {toFixed(info[x as keyof Minio]) as any} {x === 'elapsed' && ' ms'} ); })} ); })}
); }; export default SystemInfo;