refactor: add instance modal
This commit is contained in:
@@ -1,9 +1,32 @@
|
|||||||
import { PageActionType } from '@/config/types';
|
import { PageActionType } from '@/config/types';
|
||||||
import { ModalFooter } from '@gpustack/core-ui';
|
import Separator from '@/pages/llmodels/components/separator';
|
||||||
|
import { ColumnWrapper, GSDrawer, ModalFooter } from '@gpustack/core-ui';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import FormDrawer from '../../../_components/form-drawer';
|
import styled from 'styled-components';
|
||||||
import { FormData, ListItem } from '../config/types';
|
import { FormData, ListItem } from '../config/types';
|
||||||
import GPUServiceInstanceForm from '../forms';
|
import GPUServiceInstanceForm from '../forms';
|
||||||
|
import { TemplateSelector } from '../forms/template-overlay';
|
||||||
|
import InstanceTypeList from './instance-type-list';
|
||||||
|
|
||||||
|
const Container = styled.div`
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ColWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
max-width: 33.33%;
|
||||||
|
min-height: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const FormWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
max-width: 33.33%;
|
||||||
|
min-height: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
type AddModalProps = {
|
type AddModalProps = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -40,33 +63,61 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormDrawer
|
<GSDrawer
|
||||||
title={title}
|
title={title}
|
||||||
open={open}
|
open={open}
|
||||||
onCancel={handleCancel}
|
onClose={handleCancel}
|
||||||
onSubmit={handleSubmit}
|
destroyOnHidden={true}
|
||||||
width={600}
|
closeIcon={false}
|
||||||
push={{ distance: 24 }}
|
mask={{
|
||||||
footer={
|
closable: false
|
||||||
<ModalFooter
|
}}
|
||||||
onOk={handleSubmit}
|
keyboard={false}
|
||||||
onCancel={handleCancel}
|
styles={{
|
||||||
style={{
|
wrapper: { width: 'calc(100vw - 220px)' },
|
||||||
padding: '16px 24px 8px',
|
body: { overflowY: 'hidden' }
|
||||||
display: 'flex',
|
}}
|
||||||
justifyContent: 'flex-end'
|
footer={false}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<GPUServiceInstanceForm
|
<Container>
|
||||||
ref={form}
|
<ColWrapper>
|
||||||
action={action}
|
<ColumnWrapper styles={{ container: { paddingBlock: 0 } }}>
|
||||||
currentData={data}
|
<InstanceTypeList />
|
||||||
onFinish={onFinish}
|
</ColumnWrapper>
|
||||||
open={open}
|
<Separator></Separator>
|
||||||
/>
|
</ColWrapper>
|
||||||
</FormDrawer>
|
<ColWrapper>
|
||||||
|
<ColumnWrapper styles={{ container: { paddingBlock: 0 } }}>
|
||||||
|
<TemplateSelector></TemplateSelector>
|
||||||
|
</ColumnWrapper>
|
||||||
|
<Separator></Separator>
|
||||||
|
</ColWrapper>
|
||||||
|
<FormWrapper>
|
||||||
|
<ColumnWrapper
|
||||||
|
styles={{ container: { paddingBlock: 0 } }}
|
||||||
|
footer={
|
||||||
|
<ModalFooter
|
||||||
|
onOk={handleSubmit}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
style={{
|
||||||
|
padding: '16px 24px 8px',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-end'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<GPUServiceInstanceForm
|
||||||
|
ref={form}
|
||||||
|
action={action}
|
||||||
|
currentData={data}
|
||||||
|
onFinish={onFinish}
|
||||||
|
open={open}
|
||||||
|
/>
|
||||||
|
</ColumnWrapper>
|
||||||
|
</FormWrapper>
|
||||||
|
</Container>
|
||||||
|
</GSDrawer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import { Form } from 'antd';
|
|||||||
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
||||||
import { mockStorageData } from '../../storage/config/mock-data';
|
import { mockStorageData } from '../../storage/config/mock-data';
|
||||||
import { mockTemplateData } from '../../templates/config/mock-data';
|
import { mockTemplateData } from '../../templates/config/mock-data';
|
||||||
|
import TemplateBasicForm from '../../templates/forms/basic';
|
||||||
import { instanceTypeOptions, StorageModeValueMap } from '../config';
|
import { instanceTypeOptions, StorageModeValueMap } from '../config';
|
||||||
import { FormData, ListItem } from '../config/types';
|
import { FormData, ListItem } from '../config/types';
|
||||||
import Basic from './basic';
|
import Basic from './basic';
|
||||||
import InstanceTypeFormItem from './instance-type';
|
import InstanceTypeFormItem from './instance-type';
|
||||||
import StorageVolume from './storage-volume';
|
import StorageVolume from './storage-volume';
|
||||||
import TemplateFormItem from './template';
|
|
||||||
|
|
||||||
interface InstanceFormProps {
|
interface InstanceFormProps {
|
||||||
ref?: any;
|
ref?: any;
|
||||||
@@ -196,7 +196,7 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
|||||||
key: TABKeysMap.TEMPLATE,
|
key: TABKeysMap.TEMPLATE,
|
||||||
label: '实例模板',
|
label: '实例模板',
|
||||||
forceRender: true,
|
forceRender: true,
|
||||||
children: <TemplateFormItem />
|
children: <TemplateBasicForm />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: TABKeysMap.STORAGE,
|
key: TABKeysMap.STORAGE,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
Input as CInput,
|
Input as CInput,
|
||||||
InputNumber as CInputNumber
|
InputNumber as CInputNumber
|
||||||
} from '@gpustack/core-ui';
|
} from '@gpustack/core-ui';
|
||||||
import { Button, Flex, Form, Tag } from 'antd';
|
import { Flex, Form } from 'antd';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { instanceTypeOptions, InstanceTypeStatusValueMap } from '../config';
|
import { instanceTypeOptions, InstanceTypeStatusValueMap } from '../config';
|
||||||
@@ -68,20 +68,15 @@ const InstanceTypePicker: React.FC<InstanceTypePickerProps> = ({
|
|||||||
<AutoTooltip ghost minWidth={20}>
|
<AutoTooltip ghost minWidth={20}>
|
||||||
{selected?.name || '请选择实例类型'}
|
{selected?.name || '请选择实例类型'}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
<Tag
|
{/* <Tag
|
||||||
style={{
|
style={{
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
color: 'var(--ant-color-text-tertiary)'
|
color: 'var(--ant-color-text-tertiary)'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
库存 {selected?.gpu_count}
|
库存 {selected?.gpu_count}
|
||||||
</Tag>
|
</Tag> */}
|
||||||
</Flex>
|
</Flex>
|
||||||
{/* {selected && (
|
|
||||||
<Tag color="success" style={{ margin: 0 }}>
|
|
||||||
可用
|
|
||||||
</Tag>
|
|
||||||
)} */}
|
|
||||||
</SummaryTitle>
|
</SummaryTitle>
|
||||||
<SummaryMeta>
|
<SummaryMeta>
|
||||||
<span>显存 {selected?.vram ?? '-'} GiB</span>
|
<span>显存 {selected?.vram ?? '-'} GiB</span>
|
||||||
@@ -91,7 +86,7 @@ const InstanceTypePicker: React.FC<InstanceTypePickerProps> = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
</SummaryMeta>
|
</SummaryMeta>
|
||||||
</div>
|
</div>
|
||||||
<Button onClick={() => setOpen(true)}>更换</Button>
|
{/* <Button onClick={() => setOpen(true)}>更换</Button> */}
|
||||||
</SelectedCard>
|
</SelectedCard>
|
||||||
<InstanceTypeOverlay
|
<InstanceTypeOverlay
|
||||||
open={open}
|
open={open}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ interface TemplateOverlayProps {
|
|||||||
onCreate?: () => void;
|
onCreate?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TemplateSelector: React.FC<TemplateSelectorProps> = ({
|
export const TemplateSelector: React.FC<TemplateSelectorProps> = ({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
dataList = mockTemplateData
|
dataList = mockTemplateData
|
||||||
|
|||||||
Reference in New Issue
Block a user