feat(striker-ui): add host list item in host management

This commit is contained in:
Tsu-ba-me 2024-04-05 18:25:10 -04:00
parent 1d08f747c6
commit 19f819ec61
5 changed files with 76 additions and 3 deletions

View File

@ -0,0 +1,56 @@
import { FC } from 'react';
import Decorator, { Colours } from '../Decorator';
import Divider from '../Divider';
import FlexBox from '../FlexBox';
import { BodyText, MonoText } from '../Text';
const MAP_TO_DECORATOR_COLOUR: Record<string, Colours> = {
online: 'ok',
offline: 'off',
};
const MAP_TO_HOST_TYPE_DISPLAY: Record<string, string> = {
dr: 'DR',
node: 'Subnode',
};
const HostListItem: FC<HostListItemProps> = (props) => {
const { data } = props;
const { hostName, hostStatus, hostType, shortHostName } = data;
return (
<FlexBox row spacing=".5em">
<Decorator
colour={MAP_TO_DECORATOR_COLOUR[hostStatus] ?? 'warning'}
sx={{
alignSelf: 'stretch',
height: 'auto',
}}
/>
<FlexBox flexGrow={1} spacing={0}>
<FlexBox sm="row" spacing=".5em">
<BodyText>{MAP_TO_HOST_TYPE_DISPLAY[hostType]}</BodyText>
<MonoText whiteSpace="nowrap">{shortHostName}</MonoText>
<Divider
orientation="vertical"
sx={{
alignSelf: 'stretch',
height: 'auto',
}}
/>
<MonoText
sx={{ display: { xs: 'none', sm: 'flex' } }}
whiteSpace="nowrap"
>
{hostName}
</MonoText>
</FlexBox>
<BodyText>{hostStatus}</BodyText>
</FlexBox>
</FlexBox>
);
};
export default HostListItem;

View File

@ -1,4 +1,4 @@
import HostListItem from './HostListItem';
import ManageHost from './ManageHost'; import ManageHost from './ManageHost';
import PrepareHostForm from './PrepareHostForm';
export { ManageHost, PrepareHostForm }; export { ManageHost, HostListItem };

View File

@ -87,7 +87,7 @@ type AnvilStatusHost = {
host_uuid: string; host_uuid: string;
maintenance_mode: boolean; maintenance_mode: boolean;
server_count: number; server_count: number;
state: 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online'; state: APIHostStatus;
state_message: string; state_message: string;
state_percent: number; state_percent: number;
}; };

View File

@ -28,8 +28,18 @@ type APIHostConnectionOverviewList = {
type APIHostInstallTarget = 'enabled' | 'disabled'; type APIHostInstallTarget = 'enabled' | 'disabled';
type APIHostStatus = 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online';
type APIHostIPMI = {
command: string;
ip: string;
password: string;
username: string;
};
type APIHostOverview = { type APIHostOverview = {
hostName: string; hostName: string;
hostStatus: APIHostStatus;
hostType: string; hostType: string;
hostUUID: string; hostUUID: string;
shortHostName: string; shortHostName: string;
@ -60,6 +70,7 @@ type APIHostDetail = APIHostOverview & {
gateway?: string; gateway?: string;
gatewayInterface?: string; gatewayInterface?: string;
installTarget?: APIHostInstallTarget; installTarget?: APIHostInstallTarget;
ipmi?: APIHostIPMI;
networks?: APIHostNetworkList; networks?: APIHostNetworkList;
organization?: string; organization?: string;
prefix?: string; prefix?: string;

View File

@ -36,3 +36,9 @@ type PreapreHostFormProps = {
host: InquireHostResponse; host: InquireHostResponse;
tools: CrudListFormTools; tools: CrudListFormTools;
}; };
/** HostListItem */
type HostListItemProps = {
data: APIHostOverview;
};