fix(striker-ui): correct NIC name sort, correct NIC state display

main
Tsu-ba-me 2 years ago
parent 29cd0d2c2f
commit fe8eaa44e3
  1. 11
      striker-ui/lib/sumstring.ts
  2. 17
      striker-ui/pages/init/index.tsx

@ -0,0 +1,11 @@
const sumstring = (value: string): number => {
let sum = 0;
for (let index = 0; index < value.length; index += 1) {
sum += value.codePointAt(index) || 0;
}
return sum;
};
export default sumstring;

@ -12,11 +12,12 @@ import {
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; import API_BASE_URL from '../../lib/consts/API_BASE_URL';
import { TEXT } from '../../lib/consts/DEFAULT_THEME'; import { TEXT } from '../../lib/consts/DEFAULT_THEME';
import Decorator from '../../components/Decorator';
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 sumstring from '../../lib/sumstring';
import { BodyText, BodyTextProps, HeaderText } from '../../components/Text'; import { BodyText, BodyTextProps, HeaderText } from '../../components/Text';
import Decorator from '../../components/Decorator';
const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [ const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [
{ {
@ -84,6 +85,7 @@ const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [
<DataGridCellText text={value} /> <DataGridCellText text={value} />
</MUIBox> </MUIBox>
), ),
sortComparator: (v1, v2) => sumstring(v1) - sumstring(v2),
}, },
{ {
field: 'networkInterfaceMACAddress', field: 'networkInterfaceMACAddress',
@ -91,6 +93,19 @@ const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [
headerName: 'MAC', headerName: 'MAC',
renderCell: ({ value }) => <DataGridCellText monospaced text={value} />, renderCell: ({ value }) => <DataGridCellText monospaced text={value} />,
}, },
{
field: 'networkInterfaceState',
headerName: 'State',
renderCell: ({ value }) => {
const state = String(value);
return (
<DataGridCellText
text={`${state.charAt(0).toUpperCase()}${state.substring(1)}`}
/>
);
},
},
{ {
field: 'networkInterfaceSpeed', field: 'networkInterfaceSpeed',
flex: 1, flex: 1,

Loading…
Cancel
Save