fix: update allChildren after stop or start

This commit is contained in:
jialin
2025-05-28 14:41:35 +08:00
parent 034a54bf4b
commit f53fe042a9
7 changed files with 10 additions and 24 deletions
@@ -41,7 +41,6 @@ const TableRow: React.FC<
} = props; } = props;
const tableContext: any = React.useContext<{ const tableContext: any = React.useContext<{
allChildren?: any[]; allChildren?: any[];
allSubChildren?: any[];
setDisableExpand?: (record: any) => boolean; setDisableExpand?: (record: any) => boolean;
}>(TableContext); }>(TableContext);
const { setChunkRequest } = useSetChunkRequest(); const { setChunkRequest } = useSetChunkRequest();
+1 -1
View File
@@ -55,7 +55,7 @@ export default function useTableFetch<ListItem>(
const { setChunkRequest } = useSetChunkRequest(); const { setChunkRequest } = useSetChunkRequest();
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({ const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
events: ['UPDATE', 'DELETE'], events: ['UPDATE', 'DELETE', 'INSERT'],
dataList: dataSource.dataList, dataList: dataSource.dataList,
setDataList(list, opts?: any) { setDataList(list, opts?: any) {
setDataSource((pre) => { setDataSource((pre) => {
@@ -478,9 +478,6 @@ const Models: React.FC<ModelsProps> = ({
await handleStartModel(row); await handleStartModel(row);
message.success(intl.formatMessage({ id: 'common.message.success' })); message.success(intl.formatMessage({ id: 'common.message.success' }));
updateExpandedRowKeys([row.id, ...expandedRowKeys]); updateExpandedRowKeys([row.id, ...expandedRowKeys]);
setTimeout(() => {
handleSearch?.();
}, 150);
} }
if (val === 'api') { if (val === 'api') {
@@ -496,9 +493,6 @@ const Models: React.FC<ModelsProps> = ({
name: row.name, name: row.name,
async onOk() { async onOk() {
await handleStopModel(row); await handleStopModel(row);
setTimeout(() => {
handleSearch?.();
}, 150);
} }
}); });
} }
@@ -85,16 +85,14 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
const handleOnValuesChange = _.debounce((data: any) => { const handleOnValuesChange = _.debounce((data: any) => {
const formdata = form.getFieldsValue?.(); const formdata = form.getFieldsValue?.();
console.log('handleOnValuesChange:', formdata);
let alldata = {}; let alldata = {};
if (formdata.scheduleType === 'manual') { if (formdata.scheduleType === 'manual') {
alldata = { alldata = {
..._.omit(formdata, ['worker_selector']), ..._.omit(formdata, ['worker_selector']),
env: formdata.env || originFormData.current?.env || null, env: formdata.env || originFormData.current?.env || null,
gpu_selector: gpu_selector: formdata.gpu_selector
formdata.gpu_selector?.gpu_ids?.length > 0
? originFormData.current?.gpu_selector
: null
}; };
} else { } else {
alldata = { alldata = {
+1 -10
View File
@@ -202,14 +202,7 @@ export const useGenerateModelFileOptions = () => {
Object.entries(worker).filter(([key]) => workerFields.has(key)) Object.entries(worker).filter(([key]) => workerFields.has(key))
) )
})); }));
// extract a list from the result, and the structure is like:
// [
// {
// label: 'worker_name/child_label',
// value: 'child_value',
// ...other child properties
// }
// ]
const childrenList = result.reduce((acc: any[], cur) => { const childrenList = result.reduce((acc: any[], cur) => {
if (cur.children) { if (cur.children) {
const list = cur.children.map((child: any) => ({ const list = cur.children.map((child: any) => ({
@@ -223,8 +216,6 @@ export const useGenerateModelFileOptions = () => {
}, []); }, []);
return childrenList; return childrenList;
// return result;
}; };
return { return {
+5 -1
View File
@@ -252,10 +252,14 @@ const Models: React.FC = () => {
}); });
}, [fetchData, createModelsChunkRequest, createModelsInstanceChunkRequest]); }, [fetchData, createModelsChunkRequest, createModelsInstanceChunkRequest]);
const handleOnStop = useCallback((ids: number[]) => { const handleOnStop = useCallback(async (ids: number[]) => {
cacheInsDataListRef.current = cacheInsDataListRef.current.filter( cacheInsDataListRef.current = cacheInsDataListRef.current.filter(
(item: any) => !ids.includes(item.model_id) (item: any) => !ids.includes(item.model_id)
); );
await new Promise((resolve) => {
setTimeout(resolve, 300);
});
setModelInstances(cacheInsDataListRef.current);
}, []); }, []);
const handleSearch = useCallback(async () => { const handleSearch = useCallback(async () => {
@@ -602,7 +602,7 @@ const ModelFiles = () => {
{ {
title: intl.formatMessage({ id: 'resources.modelfiles.size' }), title: intl.formatMessage({ id: 'resources.modelfiles.size' }),
dataIndex: 'size', dataIndex: 'size',
width: 100, width: 110,
align: 'right', align: 'right',
ellipsis: { ellipsis: {
showTitle: false showTitle: false