|
|
|
@@ -44,14 +44,14 @@ const convertMirrorToTreeData = (list: MirrorData[]): TreeDataNode[] => { |
|
|
|
})); |
|
|
|
}; |
|
|
|
|
|
|
|
// 数据集版本列表转为树形结构 |
|
|
|
const convertDatasetVersionToTreeData = ( |
|
|
|
// 数据集、模型版本列表转为树形结构 |
|
|
|
const convertResourceVersionToTreeData = ( |
|
|
|
parentId: string, |
|
|
|
info: ResourceData, |
|
|
|
list: ResourceVersionData[], |
|
|
|
): TreeDataNode[] => { |
|
|
|
return list.map((item: ResourceVersionData) => ({ |
|
|
|
...pick(info, ['id', 'name', 'owner', 'identifier']), |
|
|
|
...pick(info, ['id', 'name', 'owner', 'identifier', 'is_public']), |
|
|
|
version: item.name, |
|
|
|
title: item.name, |
|
|
|
key: `${parentId}-${item.name}`, |
|
|
|
@@ -85,6 +85,7 @@ interface SelectorTypeInfo { |
|
|
|
readonly buttontTitle: string; // 按钮 title |
|
|
|
} |
|
|
|
|
|
|
|
// 数据集选择 |
|
|
|
export class DatasetSelector implements SelectorTypeInfo { |
|
|
|
readonly name = '数据集'; |
|
|
|
readonly modalIcon = datasetImg; |
|
|
|
@@ -114,14 +115,14 @@ export class DatasetSelector implements SelectorTypeInfo { |
|
|
|
const res = await getDatasetVersionList(pick(parentNode, ['owner', 'identifier'])); |
|
|
|
if (res && res.data) { |
|
|
|
const list = res.data; |
|
|
|
return convertDatasetVersionToTreeData(parentKey, parentNode, list); |
|
|
|
return convertResourceVersionToTreeData(parentKey, parentNode, list); |
|
|
|
} else { |
|
|
|
return Promise.reject('获取数据集版本列表失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async getFiles(_parentKey: string, parentNode: ResourceData & ResourceVersionData) { |
|
|
|
const params = pick(parentNode, ['owner', 'identifier', 'id', 'name', 'version']); |
|
|
|
const params = pick(parentNode, ['owner', 'identifier', 'id', 'name', 'version', 'is_public']); |
|
|
|
const res = await getDatasetInfo(params); |
|
|
|
if (res && res.data) { |
|
|
|
const path = res.data.relative_paths || ''; |
|
|
|
@@ -136,6 +137,7 @@ export class DatasetSelector implements SelectorTypeInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 模型选择 |
|
|
|
export class ModelSelector implements SelectorTypeInfo { |
|
|
|
readonly name = '模型'; |
|
|
|
readonly modalIcon = modelImg; |
|
|
|
@@ -165,14 +167,14 @@ export class ModelSelector implements SelectorTypeInfo { |
|
|
|
const res = await getModelVersionList(pick(parentNode, ['owner', 'identifier'])); |
|
|
|
if (res && res.data) { |
|
|
|
const list = res.data; |
|
|
|
return convertDatasetVersionToTreeData(key, parentNode, list); |
|
|
|
return convertResourceVersionToTreeData(key, parentNode, list); |
|
|
|
} else { |
|
|
|
return Promise.reject('获取模型版本列表失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async getFiles(_parentKey: string, parentNode: ResourceData & ResourceVersionData) { |
|
|
|
const params = pick(parentNode, ['owner', 'identifier', 'id', 'name', 'version']); |
|
|
|
const params = pick(parentNode, ['owner', 'identifier', 'id', 'name', 'version', 'is_public']); |
|
|
|
const res = await getModelInfo(params); |
|
|
|
if (res && res.data) { |
|
|
|
const path = res.data.relative_paths || ''; |
|
|
|
@@ -187,6 +189,7 @@ export class ModelSelector implements SelectorTypeInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 镜像选择 |
|
|
|
export class MirrorSelector implements SelectorTypeInfo { |
|
|
|
readonly name = '镜像'; |
|
|
|
readonly modalIcon = mirrorImg; |
|
|
|
|