import { FC } from 'react'; import { useTranslation } from 'react-i18next'; import { makeStyles } from '@material-ui/core'; import Progress from './Progress'; import { getByteString } from '../../utils/Format'; import { DataProgressProps, DataSectionProps, DataCardProps } from './Types'; const getStyles = makeStyles(() => ({ root: { backgroundColor: '#F6F6F6', borderTopRightRadius: '8px', borderBottomRightRadius: '8px', height: '100%', padding: '20px 16px', boxSizing: 'border-box', }, title: { display: 'flex', justifyContent: 'space-between', }, content: { color: '#010E29', fontSize: '20px', fontWeight: 600, lineHeight: '36px', }, desc: { color: '#82838E', fontSize: '14px', lineHeight: '36px', marginLeft: "8px", }, rootName: { color: '#82838E', fontSize: '20px', lineHeight: '24px', }, childName: { color: '#06AFF2', fontSize: '20px', lineHeight: '24px', }, ip: { color: '#010E29', fontSize: '16px', lineHeight: '24px', }, sectionRoot: { borderSpacing: '0 1px', display: 'table', marginTop: '24px', width: '100%' }, sectionRow: { display: 'table-row', }, sectionHeaderCell: { display: 'table-cell', color: '#82838E', fontSize: '12px', lineHeight: '24px', padding: '8px 16px', textTransform: 'uppercase', width: '50%', }, sectionCell: { backgroundColor: 'white', color: '#010E29', display: 'table-cell', fontSize: '14px', lineHeight: '24px', padding: '12px 16px', textTransform: 'capitalize', verticalAlign: 'middle', width: '50%', }, progressTitle: { fontSize: '14px', color: '#010E29', lineHeight: '24px', display: 'flex', justifyContent: 'space-between', } })); const DataSection: FC = (props) => { const classes = getStyles(); const { titles, contents } = props; return (
{titles.map((titleEntry) =>
{titleEntry}
)}
{contents.map((contentEntry) => { return (
{contentEntry.label}
{contentEntry.value}
) })}
); } const DataProgress: FC = ({ percent = 0, desc = '' }) => { const classes = getStyles(); return (
{`${Number(percent * 100).toFixed(2)}%`} {desc}
) }; const DataCard: FC> = (props) => { const classes = getStyles(); const { t } = useTranslation('systemView'); const { t: commonTrans } = useTranslation(); const capacityTrans: { [key in string]: string } = commonTrans('capacity'); const { node, extend } = props; const hardwareTitle = [t('hardwareTitle'), t('valueTitle')]; const hardwareContent = []; const infos = node?.infos?.hardware_infos || {}; const { cpu_core_count: cpu = 0, cpu_core_usage: cpuUsage = 0, memory = 1, memory_usage: memoryUsage = 0, disk = 1, disk_usage: diskUsage = 0, } = infos; if (extend) { hardwareContent.push({ label: t('thCPUCount'), value: cpu }); hardwareContent.push({ label: t('thCPUUsage'), value: }); hardwareContent.push({ label: t('thMemUsage'), value: }); hardwareContent.push({ label: t('thDiskUsage'), value: }); } const systemTitle = [t('systemTitle'), t('valueTitle')]; const systemContent = []; const sysInfos = node?.infos?.system_info || {}; const { system_version: version, deploy_mode: mode = '', created_time: create = '', updated_time: update = '', } = sysInfos; systemContent.push({ label: t('thVersion'), value: version }); systemContent.push({ label: t('thDeployMode'), value: mode }); systemContent.push({ label: t('thCreateTime'), value: create }); systemContent.push({ label: t('thUpdateTime'), value: update }); return (
Milvus / {node?.infos?.name}
{`${t('thIP')}:${infos?.ip || ''}`}
{extend && }
); }; export default DataCard;