fix: edit model config

This commit is contained in:
jialin
2024-09-05 14:53:14 +08:00
parent 55ca15bdc6
commit a6e5ec0a08
2 changed files with 203 additions and 199 deletions
+8 -1
View File
@@ -50,6 +50,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const intl = useIntl(); const intl = useIntl();
const wokerSelector = Form.useWatch('worker_selector', form); const wokerSelector = Form.useWatch('worker_selector', form);
const [scheduleType, setScheduleType] = React.useState('auto');
const handleSumit = () => { const handleSumit = () => {
form.submit(); form.submit();
@@ -251,6 +252,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
min={0} min={0}
></SealInput.Number> ></SealInput.Number>
</Form.Item> </Form.Item>
{scheduleType === 'auto' && (
<Form.Item<FormData> name="placement_strategy"> <Form.Item<FormData> name="placement_strategy">
<SealSelect <SealSelect
label={intl.formatMessage({ label={intl.formatMessage({
@@ -292,6 +294,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
} }
></SealSelect> ></SealSelect>
</Form.Item> </Form.Item>
)}
<div style={{ marginBottom: 24 }}> <div style={{ marginBottom: 24 }}>
<FormItemWrapper noWrapperStyle> <FormItemWrapper noWrapperStyle>
<Form.Item<FormData> <Form.Item<FormData>
@@ -309,6 +312,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
</Form.Item> </Form.Item>
</FormItemWrapper> </FormItemWrapper>
</div> </div>
{scheduleType === 'auto' && (
<div style={{ marginBottom: 24 }}> <div style={{ marginBottom: 24 }}>
<FormItemWrapper noWrapperStyle> <FormItemWrapper noWrapperStyle>
<Form.Item<FormData> <Form.Item<FormData>
@@ -326,6 +330,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
</Form.Item> </Form.Item>
</FormItemWrapper> </FormItemWrapper>
</div> </div>
)}
{scheduleType === 'auto' && (
<Form.Item<FormData> name="worker_selector"> <Form.Item<FormData> name="worker_selector">
<LabelSelector <LabelSelector
label={intl.formatMessage({ label={intl.formatMessage({
@@ -342,6 +348,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
} }
></LabelSelector> ></LabelSelector>
</Form.Item> </Form.Item>
)}
</> </>
); );
return [ return [
@@ -355,7 +362,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
children children
} }
]; ];
}, []); }, [scheduleType]);
useEffect(() => { useEffect(() => {
handleOnSelectModel(); handleOnSelectModel();
+11 -14
View File
@@ -11,7 +11,7 @@ import { RightOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Checkbox, Collapse, Form, Modal, Typography } from 'antd'; import { Checkbox, Collapse, Form, Modal, Typography } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import { memo, useCallback, useEffect, useMemo, useState } from 'react'; import { memo, useCallback, useEffect, useState } from 'react';
import SimpleBar from 'simplebar-react'; import SimpleBar from 'simplebar-react';
import 'simplebar-react/dist/simplebar.min.css'; import 'simplebar-react/dist/simplebar.min.css';
import { queryHuggingfaceModelFiles, queryHuggingfaceModels } from '../apis'; import { queryHuggingfaceModelFiles, queryHuggingfaceModels } from '../apis';
@@ -287,8 +287,15 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
form.submit(); form.submit();
}; };
const collapseItems = useMemo(() => { const collapseItems = [
const children = ( {
key: '1',
label: (
<span style={{ fontWeight: 'var(--font-weight-medium)' }}>
{intl.formatMessage({ id: 'resources.form.advanced' })}
</span>
),
children: (
<> <>
<Form.Item<FormData> <Form.Item<FormData>
name="replicas" name="replicas"
@@ -407,19 +414,9 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
></LabelSelector> ></LabelSelector>
</Form.Item> </Form.Item>
</> </>
); )
return [
{
key: '1',
label: (
<span style={{ fontWeight: 'var(--font-weight-medium)' }}>
{intl.formatMessage({ id: 'resources.form.advanced' })}
</span>
),
children
} }
]; ];
}, []);
return ( return (
<Modal <Modal