fix(striker-ui): add servers to subnodes, revise node summary layout

main
Tsu-ba-me 1 year ago
parent 352f63a849
commit f4a1ab5a0b
  1. 88
      striker-ui/components/Anvils/AnvilSummary.tsx
  2. 2
      striker-ui/components/Anvils/AnvilSummaryList.tsx
  3. 2
      striker-ui/lib/api_converters/toAnvilDetail.ts
  4. 2
      striker-ui/types/APIAnvil.d.ts

@ -1,4 +1,4 @@
import { Grid, gridClasses, typographyClasses } from '@mui/material'; import { Grid, gridClasses } from '@mui/material';
import { dSizeStr } from 'format-data-size'; import { dSizeStr } from 'format-data-size';
import { FC, ReactNode, useMemo } from 'react'; import { FC, ReactNode, useMemo } from 'react';
@ -9,6 +9,7 @@ import {
toAnvilMemoryCalcable, toAnvilMemoryCalcable,
toAnvilSharedStorageOverview, toAnvilSharedStorageOverview,
} from '../../lib/api_converters'; } from '../../lib/api_converters';
import Divider from '../Divider';
import FlexBox from '../FlexBox'; import FlexBox from '../FlexBox';
import Spinner from '../Spinner'; import Spinner from '../Spinner';
import StackBar from '../Bars/StackBar'; import StackBar from '../Bars/StackBar';
@ -87,39 +88,63 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
const hostsSummary = useMemo( const hostsSummary = useMemo(
() => () =>
anvil && ( anvil && (
<FlexBox <Grid
spacing={0} alignItems="center"
columns={4}
container
sx={{ sx={{
[`& > .${typographyClasses.root}:first-child`]: { [`& > .${gridClasses.item}:nth-child(-n + 4)`]: {
marginBottom: '-.6em', marginBottom: '-.6em',
}, },
}} }}
> >
{Object.values(anvil.hosts).map<ReactNode>((host) => { {Object.values(anvil.hosts).map<ReactNode>((host) => {
const { name, state, stateProgress, uuid } = host; const { name, serverCount, state, stateProgress, uuid } = host;
const stateColour: string = MAP_TO_HOST_STATE_COLOUR[state] ?? GREY; const stateColour: string = MAP_TO_HOST_STATE_COLOUR[state] ?? GREY;
let stateValue: string = state; let stateValue: string = state;
let servers: ReactNode;
if (!['offline', 'online'].includes(state)) { if (['offline', 'online'].includes(state)) {
servers = (
<BodyText variant="caption" whiteSpace="nowrap">
Servers{' '}
<InlineMonoText sx={{ paddingRight: 0 }}>
{serverCount}
</InlineMonoText>
</BodyText>
);
} else {
stateValue = `${stateProgress}%`; stateValue = `${stateProgress}%`;
} }
return ( return [
<BodyText <Grid item key={`${uuid}-state-label`} xs={1}>
key={`anvil-summary-host-${uuid}`} <BodyText variant="caption" whiteSpace="nowrap">
variant="caption" {name}
whiteSpace="nowrap" </BodyText>
> </Grid>,
{name}{' '} <Grid item key={`${uuid}-state`} xs={1}>
<InlineMonoText inheritColour color={stateColour}> <MonoText inheritColour color={stateColour}>
{stateValue} {stateValue}
</InlineMonoText> </MonoText>
</BodyText> </Grid>,
); <Grid item key={`${uuid}-divider`} xs={1}>
<Divider sx={{ marginBottom: '-.2em' }} />
</Grid>,
<Grid
display="flex"
item
justifyContent="flex-end"
key={`${uuid}-server-count`}
xs={1}
>
{servers}
</Grid>,
];
})} })}
</FlexBox> </Grid>
), ),
[anvil], [anvil],
); );
@ -128,22 +153,27 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
() => () =>
cpu && cpu &&
cpuSubnodes && ( cpuSubnodes && (
<FlexBox row> <FlexBox row spacing=".5em">
<FlexBox spacing={0}> <FlexBox spacing={0}>
<BodyText variant="caption" whiteSpace="nowrap"> <BodyText variant="caption" whiteSpace="nowrap">
Vendor <InlineMonoText>{cpuSubnodes[0].vendor}</InlineMonoText> Vendor{' '}
<InlineMonoText sx={{ paddingRight: 0 }}>
{cpuSubnodes[0].vendor}
</InlineMonoText>
</BodyText> </BodyText>
</FlexBox> </FlexBox>
<Divider sx={{ flexGrow: 1 }} />
<Grid <Grid
alignItems="center"
columns={2} columns={2}
container container
minWidth="calc(0% + 4em)" minWidth="calc(0% + 3.2em)"
sx={{ sx={{
[`& > .${gridClasses.item}:nth-child(-n + 2)`]: { [`& > .${gridClasses.item}:nth-child(-n + 2)`]: {
marginBottom: '-.6em', marginBottom: '-.6em',
}, },
}} }}
width="calc(0% + 4em)" width="calc(0% + 3.2em)"
> >
<Grid item xs={1}> <Grid item xs={1}>
<BodyText variant="caption">Cores</BodyText> <BodyText variant="caption">Cores</BodyText>
@ -238,44 +268,44 @@ const AnvilSummary: FC<AnvilSummaryProps> = (props) => {
) : ( ) : (
<Grid <Grid
alignItems="center" alignItems="center"
columns={3} columns={4}
container container
sx={{ sx={{
[`& > .${gridClasses.item}:nth-child(odd)`]: { [`& > .${gridClasses.item}:nth-child(odd)`]: {
alignItems: 'center', alignItems: 'center',
display: 'flex', display: 'flex',
height: '2.5em', height: '2.2em',
}, },
}} }}
> >
<Grid item xs={1}> <Grid item xs={1}>
<BodyText>Node</BodyText> <BodyText>Node</BodyText>
</Grid> </Grid>
<Grid item xs={2}> <Grid item xs={3}>
{anvilSummary} {anvilSummary}
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<BodyText>Subnodes</BodyText> <BodyText>Subnodes</BodyText>
</Grid> </Grid>
<Grid item xs={2}> <Grid item xs={3}>
{hostsSummary} {hostsSummary}
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<BodyText>CPU</BodyText> <BodyText>CPU</BodyText>
</Grid> </Grid>
<Grid item xs={2}> <Grid item xs={3}>
{cpuSummary} {cpuSummary}
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<BodyText>Memory</BodyText> <BodyText>Memory</BodyText>
</Grid> </Grid>
<Grid item xs={2}> <Grid item xs={3}>
{memorySummary} {memorySummary}
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<BodyText>Storage</BodyText> <BodyText>Storage</BodyText>
</Grid> </Grid>
<Grid item xs={2}> <Grid item xs={3}>
{storeSummary} {storeSummary}
</Grid> </Grid>
</Grid> </Grid>

@ -36,7 +36,7 @@ const AnvilSummaryList: FC = () => {
previous[key] = { previous[key] = {
children: ( children: (
<InnerPanel> <InnerPanel width="22em">
<InnerPanelHeader> <InnerPanelHeader>
<BodyText <BodyText
overflow="hidden" overflow="hidden"

@ -11,6 +11,7 @@ const toAnvilDetail = (data: AnvilListItem): APIAnvilDetail => {
host_name: hostName, host_name: hostName,
host_uuid: hostUuid, host_uuid: hostUuid,
maintenance_mode: maintenance, maintenance_mode: maintenance,
server_count: serverCount,
state, state,
state_percent: stateProgress, state_percent: stateProgress,
} = current; } = current;
@ -18,6 +19,7 @@ const toAnvilDetail = (data: AnvilListItem): APIAnvilDetail => {
previous[hostUuid] = { previous[hostUuid] = {
name: hostName, name: hostName,
maintenance, maintenance,
serverCount,
state, state,
stateProgress, stateProgress,
uuid: hostUuid, uuid: hostUuid,

@ -86,6 +86,7 @@ type AnvilStatusHost = {
host_name: string; host_name: string;
host_uuid: string; host_uuid: string;
maintenance_mode: boolean; maintenance_mode: boolean;
server_count: number;
state: 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online'; state: 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online';
state_message: string; state_message: string;
state_percent: number; state_percent: number;
@ -134,6 +135,7 @@ type APIAnvilDetail = {
[uuid: string]: { [uuid: string]: {
maintenance: boolean; maintenance: boolean;
name: string; name: string;
serverCount: number;
state: AnvilStatusHost['state']; state: AnvilStatusHost['state'];
stateProgress: number; stateProgress: number;
uuid: string; uuid: string;

Loading…
Cancel
Save