diff --git a/striker-ui/lib/sumstring.ts b/striker-ui/lib/sumstring.ts new file mode 100644 index 00000000..3a349374 --- /dev/null +++ b/striker-ui/lib/sumstring.ts @@ -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; diff --git a/striker-ui/pages/init/index.tsx b/striker-ui/pages/init/index.tsx index 4274b6d4..7cc715d4 100644 --- a/striker-ui/pages/init/index.tsx +++ b/striker-ui/pages/init/index.tsx @@ -12,11 +12,12 @@ import { import API_BASE_URL from '../../lib/consts/API_BASE_URL'; import { TEXT } from '../../lib/consts/DEFAULT_THEME'; +import Decorator from '../../components/Decorator'; import { Panel, PanelHeader } from '../../components/Panels'; import periodicFetch from '../../lib/fetchers/periodicFetch'; import Spinner from '../../components/Spinner'; +import sumstring from '../../lib/sumstring'; import { BodyText, BodyTextProps, HeaderText } from '../../components/Text'; -import Decorator from '../../components/Decorator'; const MOCK_NICS: NetworkInterfaceOverviewMetadata[] = [ { @@ -84,6 +85,7 @@ const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [ ), + sortComparator: (v1, v2) => sumstring(v1) - sumstring(v2), }, { field: 'networkInterfaceMACAddress', @@ -91,6 +93,19 @@ const NETWORK_INTERFACE_COLUMNS: MUIDataGridProps['columns'] = [ headerName: 'MAC', renderCell: ({ value }) => , }, + { + field: 'networkInterfaceState', + headerName: 'State', + renderCell: ({ value }) => { + const state = String(value); + + return ( + + ); + }, + }, { field: 'networkInterfaceSpeed', flex: 1,