fix: submit form data error
This commit is contained in:
@@ -13,7 +13,7 @@ interface CompatibilityAlertProps {
|
|||||||
show: boolean;
|
show: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
isHtml?: boolean;
|
isHtml?: boolean;
|
||||||
type: 'danger' | 'warning' | 'transition' | 'info';
|
type?: 'danger' | 'warning' | 'transition';
|
||||||
message: string | string[];
|
message: string | string[];
|
||||||
};
|
};
|
||||||
contentStyle?: React.CSSProperties;
|
contentStyle?: React.CSSProperties;
|
||||||
|
|||||||
@@ -159,7 +159,9 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
const generateGPUIds = (data: FormData) => {
|
const generateGPUIds = (data: FormData) => {
|
||||||
const gpu_ids = _.get(data, 'gpu_selector.gpu_ids', []);
|
const gpu_ids = _.get(data, 'gpu_selector.gpu_ids', []);
|
||||||
if (!gpu_ids.length) {
|
if (!gpu_ids.length) {
|
||||||
return {};
|
return {
|
||||||
|
gpu_selector: null
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = _.reduce(
|
const result = _.reduce(
|
||||||
@@ -175,14 +177,11 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result.length) {
|
return {
|
||||||
return {
|
gpu_selector: {
|
||||||
gpu_selector: {
|
gpu_ids: result
|
||||||
gpu_ids: result
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOk = async (formdata: FormData) => {
|
const handleOk = async (formdata: FormData) => {
|
||||||
@@ -198,6 +197,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
...gpuSelector
|
...gpuSelector
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('allValues--------', allValues);
|
||||||
|
|
||||||
onOk(allValues);
|
onOk(allValues);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import styled from 'styled-components';
|
|||||||
import { queryCatalogItemSpec } from '../apis';
|
import { queryCatalogItemSpec } from '../apis';
|
||||||
import {
|
import {
|
||||||
backendOptionsMap,
|
backendOptionsMap,
|
||||||
excludeFields,
|
|
||||||
modelCategoriesMap,
|
modelCategoriesMap,
|
||||||
sourceOptions
|
sourceOptions
|
||||||
} from '../config';
|
} from '../config';
|
||||||
@@ -83,6 +82,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
handleShowCompatibleAlert,
|
handleShowCompatibleAlert,
|
||||||
setWarningStatus,
|
setWarningStatus,
|
||||||
handleEvaluate,
|
handleEvaluate,
|
||||||
|
generateGPUIds,
|
||||||
|
handleOnValuesChange,
|
||||||
warningStatus
|
warningStatus
|
||||||
} = useCheckCompatibility();
|
} = useCheckCompatibility();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -275,14 +276,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnValuesChange = async (changedValues: any, allValues: any) => {
|
const onValuesChange = async (changedValues: any, allValues: any) => {
|
||||||
const keys = Object.keys(changedValues);
|
handleOnValuesChange?.({
|
||||||
const isExcludeField = keys.some((key) => excludeFields.includes(key));
|
changedValues,
|
||||||
if (!isExcludeField) {
|
allValues: generateSubmitData(allValues),
|
||||||
const values = form.current?.form.getFieldsValue?.();
|
source: props.source
|
||||||
const data = generateSubmitData(values);
|
});
|
||||||
handleCheckCompatibility(data);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBackendChange = (backend: string) => {
|
const handleBackendChange = (backend: string) => {
|
||||||
@@ -561,7 +560,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
gpuOptions={gpuOptions}
|
gpuOptions={gpuOptions}
|
||||||
onBackendChange={handleBackendChange}
|
onBackendChange={handleBackendChange}
|
||||||
onSourceChange={handleSourceChange}
|
onSourceChange={handleSourceChange}
|
||||||
onValuesChange={handleOnValuesChange}
|
onValuesChange={onValuesChange}
|
||||||
></DataForm>
|
></DataForm>
|
||||||
</>
|
</>
|
||||||
</ColumnWrapper>
|
</ColumnWrapper>
|
||||||
|
|||||||
@@ -115,16 +115,16 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOnOk = async (allValues: FormData) => {
|
const handleOnOk = async (allValues: FormData) => {
|
||||||
|
const result = getSourceRepoConfigValue(props.source, allValues).values;
|
||||||
if (submitAnyway.current) {
|
if (submitAnyway.current) {
|
||||||
onOk(allValues);
|
onOk(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = getSourceRepoConfigValue(props.source, allValues);
|
const evalutionData = await handleEvaluate(result);
|
||||||
const evalutionData = await handleEvaluate(result.values);
|
|
||||||
handleShowCompatibleAlert?.(evalutionData);
|
handleShowCompatibleAlert?.(evalutionData);
|
||||||
if (evalutionData?.compatible) {
|
if (evalutionData?.compatible) {
|
||||||
onOk(allValues);
|
onOk(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -309,12 +309,6 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
handleSelectModelFile(sortList[0]);
|
handleSelectModelFile(sortList[0]);
|
||||||
setDataSource({ fileList: sortList, loading: false });
|
setDataSource({ fileList: sortList, loading: false });
|
||||||
|
|
||||||
// if (timer.current) {
|
|
||||||
// clearTimeout(timer.current);
|
|
||||||
// }
|
|
||||||
// timer.current = setTimeout(() => {
|
|
||||||
// handleEvaluate(sortList);
|
|
||||||
// }, 200);
|
|
||||||
handleEvaluate(sortList);
|
handleEvaluate(sortList);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setDataSource({ fileList: [], loading: false });
|
setDataSource({ fileList: [], loading: false });
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
InstanceRealtimeLogStatus,
|
InstanceRealtimeLogStatus,
|
||||||
backendOptionsMap,
|
backendOptionsMap,
|
||||||
getSourceRepoConfigValue,
|
|
||||||
modelCategories,
|
modelCategories,
|
||||||
modelCategoriesMap,
|
modelCategoriesMap,
|
||||||
modelSourceMap
|
modelSourceMap
|
||||||
@@ -261,14 +260,8 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
const handleModalOk = useCallback(
|
const handleModalOk = useCallback(
|
||||||
async (data: FormData) => {
|
async (data: FormData) => {
|
||||||
try {
|
try {
|
||||||
const result = getSourceRepoConfigValue(
|
|
||||||
currentData.current?.source,
|
|
||||||
data
|
|
||||||
);
|
|
||||||
await updateModel({
|
await updateModel({
|
||||||
data: {
|
data,
|
||||||
...result.values
|
|
||||||
},
|
|
||||||
id: currentData.current?.id as number
|
id: currentData.current?.id as number
|
||||||
});
|
});
|
||||||
setOpenAddModal(false);
|
setOpenAddModal(false);
|
||||||
@@ -299,12 +292,8 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
try {
|
try {
|
||||||
console.log('data:', data, openDeployModal);
|
console.log('data:', data, openDeployModal);
|
||||||
|
|
||||||
const result = getSourceRepoConfigValue(openDeployModal.source, data);
|
|
||||||
|
|
||||||
const modelData = await createModel({
|
const modelData = await createModel({
|
||||||
data: {
|
data
|
||||||
...result.values
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setOpenDeployModal({
|
setOpenDeployModal({
|
||||||
...openDeployModal,
|
...openDeployModal,
|
||||||
|
|||||||
@@ -293,7 +293,8 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
form.submit?.();
|
form.submit?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOk = async (formdata: FormData) => {
|
const handleOk = async (data: FormData) => {
|
||||||
|
const formdata = getSourceRepoConfigValue(data.source, data).values;
|
||||||
let obj = {};
|
let obj = {};
|
||||||
let submitData = {} as FormData;
|
let submitData = {} as FormData;
|
||||||
if (
|
if (
|
||||||
@@ -306,23 +307,16 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
cpu_offloading: false
|
cpu_offloading: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (formdata.scheduleType === 'manual') {
|
|
||||||
const gpuSelector = generateGPUIds(formdata);
|
submitData = {
|
||||||
submitData = {
|
..._.omit(formdata, ['scheduleType']),
|
||||||
..._.omit(formdata, ['scheduleType']),
|
categories: formdata.categories ? [formdata.categories] : [],
|
||||||
categories: formdata.categories ? [formdata.categories] : [],
|
worker_selector: null,
|
||||||
worker_selector: null,
|
...obj,
|
||||||
...obj,
|
...(formdata.scheduleType === 'manual'
|
||||||
...gpuSelector
|
? generateGPUIds(formdata)
|
||||||
};
|
: { gpu_selector: null })
|
||||||
} else {
|
};
|
||||||
submitData = {
|
|
||||||
..._.omit(formdata, ['scheduleType']),
|
|
||||||
categories: formdata.categories ? [formdata.categories] : [],
|
|
||||||
gpu_selector: null,
|
|
||||||
...obj
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (submitAnyway.current) {
|
if (submitAnyway.current) {
|
||||||
onOk(submitData);
|
onOk(submitData);
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ export const useCheckCompatibility = () => {
|
|||||||
const [warningStatus, setWarningStatus] = useState<{
|
const [warningStatus, setWarningStatus] = useState<{
|
||||||
show: boolean;
|
show: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
type?: 'transition' | 'warning' | 'error';
|
type?: 'transition' | 'warning' | 'danger';
|
||||||
message: string | string[];
|
message: string | string[];
|
||||||
}>({
|
}>({
|
||||||
show: false,
|
show: false,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { createModel } from '@/pages/llmodels/apis';
|
|||||||
import DeployModal from '@/pages/llmodels/components/deploy-modal';
|
import DeployModal from '@/pages/llmodels/components/deploy-modal';
|
||||||
import {
|
import {
|
||||||
backendOptionsMap,
|
backendOptionsMap,
|
||||||
getSourceRepoConfigValue,
|
|
||||||
modelSourceMap,
|
modelSourceMap,
|
||||||
setSourceRepoConfigValue
|
setSourceRepoConfigValue
|
||||||
} from '@/pages/llmodels/config';
|
} from '@/pages/llmodels/config';
|
||||||
@@ -393,11 +392,8 @@ const ModelFiles = () => {
|
|||||||
|
|
||||||
const handleCreateModel = async (data: any) => {
|
const handleCreateModel = async (data: any) => {
|
||||||
try {
|
try {
|
||||||
const result = getSourceRepoConfigValue(openDeployModal.source, data);
|
|
||||||
const modelData = await createModel({
|
const modelData = await createModel({
|
||||||
data: {
|
data
|
||||||
...result.values
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setOpenDeployModal({
|
setOpenDeployModal({
|
||||||
...openDeployModal,
|
...openDeployModal,
|
||||||
|
|||||||
Reference in New Issue
Block a user