feat: add download instance log button

This commit is contained in:
jialin
2025-02-27 18:03:28 +08:00
parent 4b73457f7f
commit 8464e0ea3f
8 changed files with 201 additions and 35 deletions
@@ -10,6 +10,7 @@ import {
} from '@/pages/resources/config/types';
import {
DeleteOutlined,
DownloadOutlined,
HddFilled,
InfoCircleOutlined,
ThunderboltFilled
@@ -48,6 +49,18 @@ const childActionList = [
],
icon: <IconFont type="icon-logs" />
},
{
label: 'common.button.downloadLog',
key: 'download',
status: [
InstanceStatusMap.Initializing,
InstanceStatusMap.Running,
InstanceStatusMap.Error,
InstanceStatusMap.Starting,
InstanceStatusMap.Downloading
],
icon: <DownloadOutlined />
},
{
label: 'common.button.delrecreate',
key: 'delete',
@@ -60,7 +73,7 @@ const childActionList = [
const setChildActionList = (item: ModelInstanceListItem) => {
return _.filter(childActionList, (action: any) => {
if (action.key === 'viewlog') {
if (action.key === 'viewlog' || action.key === 'download') {
return action.status.includes(item.state);
}
return true;
+9 -1
View File
@@ -10,6 +10,7 @@ import { SealColumnProps } from '@/components/seal-table/types';
import { PageAction } from '@/config';
import HotKeys from '@/config/hotkeys';
import useBodyScroll from '@/hooks/use-body-scroll';
import useDownloadStream from '@/hooks/use-download-stream';
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
import useTableRowSelection from '@/hooks/use-table-row-selection';
import useTableSort from '@/hooks/use-table-sort';
@@ -181,6 +182,7 @@ const Models: React.FC<ModelsProps> = ({
loadend,
total
}) => {
const { downloadStream } = useDownloadStream();
const { getGPUList, generateFormValues, gpuDeviceList } =
useGenerateFormEditInitialValues();
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
@@ -440,7 +442,7 @@ const Models: React.FC<ModelsProps> = ({
restoreScrollHeight();
} catch (error) {}
},
[currentData]
[handleSearch]
);
const handleModalCancel = useCallback(() => {
@@ -652,6 +654,12 @@ const Models: React.FC<ModelsProps> = ({
if (val === 'viewlog') {
handleViewLogs(row);
}
if (val === 'download') {
downloadStream({
url: `${MODEL_INSTANCE_API}/${row.id}/logs`,
filename: row.name
});
}
},
[handleViewLogs, handleDeleteInstace]
);