|
|
|
@@ -7,6 +7,8 @@ |
|
|
|
import KFIcon from '@/components/KFIcon'; |
|
|
|
import { DevEditorStatus } from '@/enums'; |
|
|
|
import { useCacheState } from '@/hooks/useCacheState'; |
|
|
|
import { useComputingResource } from '@/hooks/useComputingResource'; |
|
|
|
import { DatasetData, ModelData } from '@/pages/Dataset/config'; |
|
|
|
import { |
|
|
|
deleteEditorReq, |
|
|
|
getEditorListReq, |
|
|
|
@@ -14,6 +16,7 @@ import { |
|
|
|
stopEditorReq, |
|
|
|
} from '@/services/developmentEnvironment'; |
|
|
|
import themes from '@/styles/theme.less'; |
|
|
|
import { parseJsonText } from '@/utils'; |
|
|
|
import { openAntdModal } from '@/utils/modal'; |
|
|
|
import { to } from '@/utils/promise'; |
|
|
|
import SessionStorage from '@/utils/sessionStorage'; |
|
|
|
@@ -42,6 +45,10 @@ export type EditorData = { |
|
|
|
update_by: string; |
|
|
|
create_time: string; |
|
|
|
url: string; |
|
|
|
computing_resource_id: number; |
|
|
|
dataset?: string | DatasetData; |
|
|
|
model?: string | ModelData; |
|
|
|
image?: string; |
|
|
|
}; |
|
|
|
|
|
|
|
function EditorList() { |
|
|
|
@@ -56,6 +63,7 @@ function EditorList() { |
|
|
|
pageSize: 10, |
|
|
|
}, |
|
|
|
); |
|
|
|
const getResourceDescription = useComputingResource()[1]; |
|
|
|
|
|
|
|
// 获取编辑器列表 |
|
|
|
const getEditorList = useCallback(async () => { |
|
|
|
@@ -66,6 +74,10 @@ function EditorList() { |
|
|
|
const [res] = await to(getEditorListReq(params)); |
|
|
|
if (res && res.data) { |
|
|
|
const { content = [], totalElements = 0 } = res.data; |
|
|
|
content.forEach((item: EditorData) => { |
|
|
|
item.dataset = typeof item.dataset === 'string' ? parseJsonText(item.dataset) : null; |
|
|
|
item.model = typeof item.model === 'string' ? parseJsonText(item.model) : null; |
|
|
|
}); |
|
|
|
setTableData(content); |
|
|
|
setTotal(totalElements); |
|
|
|
} |
|
|
|
@@ -102,11 +114,18 @@ function EditorList() { |
|
|
|
|
|
|
|
// 停止编辑器 |
|
|
|
const stopEditor = async (id: number) => { |
|
|
|
const [res] = await to(stopEditorReq(id)); |
|
|
|
if (res) { |
|
|
|
message.success('操作成功'); |
|
|
|
getEditorList(); |
|
|
|
} |
|
|
|
modalConfirm({ |
|
|
|
title: '停止后,该编辑器将不可使用', |
|
|
|
content: '是否确认停止?', |
|
|
|
isDelete: false, |
|
|
|
onOk: async () => { |
|
|
|
const [res] = await to(stopEditorReq(id)); |
|
|
|
if (res) { |
|
|
|
message.success('操作成功'); |
|
|
|
getEditorList(); |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 制作镜像 |
|
|
|
@@ -165,44 +184,72 @@ function EditorList() { |
|
|
|
title: '编辑器名称', |
|
|
|
dataIndex: 'name', |
|
|
|
key: 'name', |
|
|
|
width: '30%', |
|
|
|
render: (text, record) => |
|
|
|
record.url && record.status === DevEditorStatus.Running ? ( |
|
|
|
<a className="kf-table-row-link" onClick={(e) => gotoEditorPage(e, record)}> |
|
|
|
{text} |
|
|
|
</a> |
|
|
|
) : ( |
|
|
|
<span>{text ?? '--'}</span> |
|
|
|
), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '状态', |
|
|
|
dataIndex: 'status', |
|
|
|
key: 'status', |
|
|
|
width: '10%', |
|
|
|
render: EditorStatusCell, |
|
|
|
width: '20%', |
|
|
|
render: (text, record, index) => |
|
|
|
record.url && record.status === DevEditorStatus.Running |
|
|
|
? tableCellRender<EditorData>(true, TableCellValueType.Link, { |
|
|
|
onClick: (record, e) => gotoEditorPage(e, record), |
|
|
|
})(text, record, index) |
|
|
|
: tableCellRender<EditorData>(true, TableCellValueType.Text)(text, record, index), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '资源', |
|
|
|
title: '计算资源', |
|
|
|
dataIndex: 'computing_resource', |
|
|
|
key: 'computing_resource', |
|
|
|
width: '20%', |
|
|
|
width: 100, |
|
|
|
render: tableCellRender(), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '资源规格', |
|
|
|
dataIndex: 'computing_resource_id', |
|
|
|
key: 'computing_resource_id', |
|
|
|
width: '20%', |
|
|
|
render: tableCellRender(true, TableCellValueType.Custom, { |
|
|
|
format: getResourceDescription, |
|
|
|
}), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '数据集', |
|
|
|
dataIndex: ['dataset', 'showValue'], |
|
|
|
key: 'dataset', |
|
|
|
width: '15%', |
|
|
|
render: tableCellRender(true), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '模型', |
|
|
|
dataIndex: ['model', 'showValue'], |
|
|
|
key: 'model', |
|
|
|
width: '15%', |
|
|
|
render: tableCellRender(true), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '镜像', |
|
|
|
dataIndex: ['image'], |
|
|
|
key: 'image', |
|
|
|
width: '15%', |
|
|
|
render: tableCellRender(true), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '创建者', |
|
|
|
dataIndex: 'update_by', |
|
|
|
key: 'update_by', |
|
|
|
width: '20%', |
|
|
|
render: tableCellRender(), |
|
|
|
width: '15%', |
|
|
|
render: tableCellRender(true), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '创建时间', |
|
|
|
dataIndex: 'create_time', |
|
|
|
key: 'create_time', |
|
|
|
width: '20%', |
|
|
|
width: 180, |
|
|
|
render: tableCellRender(false, TableCellValueType.Date), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '状态', |
|
|
|
dataIndex: 'status', |
|
|
|
key: 'status', |
|
|
|
width: 80, |
|
|
|
render: EditorStatusCell, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
dataIndex: 'operation', |
|
|
|
|