feat(striker-ui): add host list item in host management
This commit is contained in:
parent
1d08f747c6
commit
19f819ec61
56
striker-ui/components/ManageHost/HostListItem.tsx
Normal file
56
striker-ui/components/ManageHost/HostListItem.tsx
Normal 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;
|
@ -1,4 +1,4 @@
|
||||
import HostListItem from './HostListItem';
|
||||
import ManageHost from './ManageHost';
|
||||
import PrepareHostForm from './PrepareHostForm';
|
||||
|
||||
export { ManageHost, PrepareHostForm };
|
||||
export { ManageHost, HostListItem };
|
||||
|
2
striker-ui/types/APIAnvil.d.ts
vendored
2
striker-ui/types/APIAnvil.d.ts
vendored
@ -87,7 +87,7 @@ type AnvilStatusHost = {
|
||||
host_uuid: string;
|
||||
maintenance_mode: boolean;
|
||||
server_count: number;
|
||||
state: 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online';
|
||||
state: APIHostStatus;
|
||||
state_message: string;
|
||||
state_percent: number;
|
||||
};
|
||||
|
11
striker-ui/types/APIHost.d.ts
vendored
11
striker-ui/types/APIHost.d.ts
vendored
@ -28,8 +28,18 @@ type APIHostConnectionOverviewList = {
|
||||
|
||||
type APIHostInstallTarget = 'enabled' | 'disabled';
|
||||
|
||||
type APIHostStatus = 'offline' | 'booted' | 'crmd' | 'in_ccm' | 'online';
|
||||
|
||||
type APIHostIPMI = {
|
||||
command: string;
|
||||
ip: string;
|
||||
password: string;
|
||||
username: string;
|
||||
};
|
||||
|
||||
type APIHostOverview = {
|
||||
hostName: string;
|
||||
hostStatus: APIHostStatus;
|
||||
hostType: string;
|
||||
hostUUID: string;
|
||||
shortHostName: string;
|
||||
@ -60,6 +70,7 @@ type APIHostDetail = APIHostOverview & {
|
||||
gateway?: string;
|
||||
gatewayInterface?: string;
|
||||
installTarget?: APIHostInstallTarget;
|
||||
ipmi?: APIHostIPMI;
|
||||
networks?: APIHostNetworkList;
|
||||
organization?: string;
|
||||
prefix?: string;
|
||||
|
6
striker-ui/types/ManageHost.d.ts
vendored
6
striker-ui/types/ManageHost.d.ts
vendored
@ -36,3 +36,9 @@ type PreapreHostFormProps = {
|
||||
host: InquireHostResponse;
|
||||
tools: CrudListFormTools;
|
||||
};
|
||||
|
||||
/** HostListItem */
|
||||
|
||||
type HostListItemProps = {
|
||||
data: APIHostOverview;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user