chore: batch start/stop models
This commit is contained in:
@@ -45,7 +45,7 @@ import {
|
||||
updateModel
|
||||
} from '../apis';
|
||||
import {
|
||||
InstanceRealLogStatus,
|
||||
InstanceRealtimeLogStatus,
|
||||
getSourceRepoConfigValue,
|
||||
modelCategories,
|
||||
modelCategoriesMap,
|
||||
@@ -472,7 +472,9 @@ const Models: React.FC<ModelsProps> = ({
|
||||
status: row.state,
|
||||
id: row.id,
|
||||
modelId: row.model_id,
|
||||
tail: InstanceRealLogStatus.includes(row.state) ? undefined : PageSize
|
||||
tail: InstanceRealtimeLogStatus.includes(row.state)
|
||||
? undefined
|
||||
: PageSize
|
||||
});
|
||||
setOpenLogModal(true);
|
||||
onViewLogs();
|
||||
@@ -739,6 +741,32 @@ const Models: React.FC<ModelsProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const handleStartBatch = async () => {
|
||||
modalRef.current.show({
|
||||
content: 'models.table.models',
|
||||
title: 'common.title.start.confirm',
|
||||
okText: 'common.button.start',
|
||||
operation: 'common.start.confirm',
|
||||
async onOk() {
|
||||
await handleBatchRequest(rowSelection.selectedRows, handleStartModel);
|
||||
rowSelection.clearSelections();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleStopBatch = async () => {
|
||||
modalRef.current.show({
|
||||
content: 'models.table.models',
|
||||
title: 'common.title.stop.confirm',
|
||||
okText: 'common.button.stop',
|
||||
operation: 'common.stop.confirm',
|
||||
async onOk() {
|
||||
await handleBatchRequest(rowSelection.selectedRows, handleStopModel);
|
||||
rowSelection.clearSelections();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageContainer
|
||||
@@ -820,6 +848,30 @@ const Models: React.FC<ModelsProps> = ({
|
||||
</span>
|
||||
</Button>
|
||||
</Access>
|
||||
<Button
|
||||
icon={<IconFont type="icon-outline-play"></IconFont>}
|
||||
onClick={handleStartBatch}
|
||||
disabled={!rowSelection.selectedRows.length}
|
||||
>
|
||||
<span>
|
||||
{intl?.formatMessage?.({ id: 'common.button.start' })}
|
||||
{rowSelection.selectedRows.length > 0 && (
|
||||
<span>({rowSelection.selectedRows?.length})</span>
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
icon={<IconFont type="icon-stop1"></IconFont>}
|
||||
onClick={handleStopBatch}
|
||||
disabled={!rowSelection.selectedRows.length}
|
||||
>
|
||||
<span>
|
||||
{intl?.formatMessage?.({ id: 'common.button.stop' })}
|
||||
{rowSelection.selectedRows.length > 0 && (
|
||||
<span>({rowSelection.selectedRows?.length})</span>
|
||||
)}
|
||||
</span>
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
></PageTools>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useIntl } from '@umijs/max';
|
||||
import { Modal } from 'antd';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { MODELS_API } from '../apis';
|
||||
import { InstanceRealLogStatus } from '../config';
|
||||
import { InstanceRealtimeLogStatus } from '../config';
|
||||
|
||||
type ViewModalProps = {
|
||||
open: boolean;
|
||||
@@ -35,10 +35,10 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
||||
|
||||
const updateHandler = (list: any) => {
|
||||
const data = list?.find((item: any) => item.data?.id === props.id);
|
||||
// state in InstanceRealLogStatus will not enable scorll load, because it is in the trasisition state
|
||||
// state in InstanceRealtimeLogStatus will not enable scorll load, because it is in the trasisition state
|
||||
if (data) {
|
||||
setEnableScorllLoad(
|
||||
() => !InstanceRealLogStatus.includes(data?.data?.state)
|
||||
() => !InstanceRealtimeLogStatus.includes(data?.data?.state)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user