fix(striker-ui): change NIC table render

main
Tsu-ba-me 2 years ago
parent b663d10196
commit 29cd0d2c2f
  1. 3
      striker-ui/components/Text/index.tsx
  2. 44
      striker-ui/pages/init/index.tsx

@ -1,5 +1,6 @@
import BodyText from './BodyText'; import BodyText, { BodyTextProps } from './BodyText';
import HeaderText from './HeaderText'; import HeaderText from './HeaderText';
import Monospace from './Monospace'; import Monospace from './Monospace';
export type { BodyTextProps };
export { BodyText, HeaderText, Monospace }; export { BodyText, HeaderText, Monospace };

@ -15,7 +15,8 @@ import { TEXT } from '../../lib/consts/DEFAULT_THEME';
import { Panel, PanelHeader } from '../../components/Panels'; import { Panel, PanelHeader } from '../../components/Panels';
import periodicFetch from '../../lib/fetchers/periodicFetch'; import periodicFetch from '../../lib/fetchers/periodicFetch';
import Spinner from '../../components/Spinner'; import Spinner from '../../components/Spinner';
import { HeaderText } from '../../components/Text'; import { BodyText, BodyTextProps, HeaderText } from '../../components/Text';
import Decorator from '../../components/Decorator';
const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [ const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [
{ {
@ -52,33 +53,56 @@ const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [
}, },
]; ];
const DataGridCellText: FC<BodyTextProps> = ({
...dataGridCellTextRestProps
}) => (
<BodyText
{...{
variant: 'body2',
...dataGridCellTextRestProps,
}}
/>
);
const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [ const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [
{
field: 'networkInterfaceMACAddress',
flex: 1,
headerName: 'MAC',
},
{ {
field: 'networkInterfaceName', field: 'networkInterfaceName',
flex: 1, flex: 1,
headerName: 'Name', headerName: 'Name',
renderCell: ({ row: { networkInterfaceState } = {}, value }) => (
<MUIBox
sx={{
display: 'flex',
flexDirection: 'row',
'& > :not(:first-child)': { marginLeft: '.5em' },
}}
>
<Decorator
colour={networkInterfaceState === 'up' ? 'ok' : 'warning'}
sx={{ height: 'auto' }}
/>
<DataGridCellText text={value} />
</MUIBox>
),
}, },
{ {
field: 'networkInterfaceState', field: 'networkInterfaceMACAddress',
flex: 1, flex: 1,
headerName: 'State', headerName: 'MAC',
renderCell: ({ value }) => <DataGridCellText monospaced text={value} />,
}, },
{ {
field: 'networkInterfaceSpeed', field: 'networkInterfaceSpeed',
flex: 1, flex: 1,
headerName: 'Speed', headerName: 'Speed',
type: 'number', renderCell: ({ value }) => (
<DataGridCellText text={`${parseFloat(value).toLocaleString()} Mbps`} />
),
}, },
{ {
field: 'networkInterfaceOrder', field: 'networkInterfaceOrder',
flex: 1, flex: 1,
headerName: 'Order', headerName: 'Order',
type: 'number',
}, },
]; ];

Loading…
Cancel
Save