feat(web): 表详情增加直接查看hdfs目录的入口

This commit is contained in:
v-zhangjc9
2024-05-08 14:43:20 +08:00
parent 23ced7a2e1
commit 7f884a5554
2 changed files with 142 additions and 131 deletions

View File

@@ -656,6 +656,140 @@ function simpleYarnDialog(cluster, title, filterField) {
}
}
function hdfsDialog(hdfsField) {
return {
title: {
type: 'tpl',
tpl: `\${${hdfsField}}`
},
...readOnlyDialogOptions(),
size: 'xl',
body: {
type: 'crud',
api: {
method: 'get',
url: '${base}/hudi/hdfs_list',
data: {
root: `\${${hdfsField}|default:undefined}`,
},
},
deferApi: {
method: 'get',
url: '${base}/hudi/hdfs_list_children',
data: {
root: '${path|default:undefined}',
},
},
...crudCommonOptions(),
perPage: 10,
headerToolbar: [
"reload",
paginationCommonOptions(undefined, 10),
],
footerToolbar: [
paginationCommonOptions(undefined, 10),
],
columns: [
{
name: 'name',
label: '文件名',
className: 'font-mono',
},
{
name: 'group',
label: '组',
width: 70,
},
{
name: 'owner',
label: '用户',
width: 70,
},
{
label: '大小',
width: 90,
type: 'tpl',
tpl: "${sizeText}",
},
{
label: '修改时间',
width: 140,
type: 'tpl',
tpl: "${DATETOSTR(DATE(modifyTime), 'YYYY-MM-DD HH:mm:ss')}",
},
{
type: 'operation',
label: '操作',
width: 160,
fixed: 'right',
buttons: [
{
label: '完整路径',
type: 'action',
level: 'link',
size: 'xs',
actionType: 'copy',
content: '${path}',
tooltip: '复制 ${path}',
},
{
disabledOn: 'folder || size > 1048576',
label: '查看',
type: 'action',
level: 'link',
size: 'xs',
actionType: 'dialog',
dialog: {
title: {
type: 'tpl',
tpl: '文件内容:${path}'
},
size: 'md',
...readOnlyDialogOptions(),
body: {
type: 'service',
api: {
method: 'get',
url: '${base}/hudi/hdfs_read',
data: {
root: '${path|default:undefined}'
}
},
body: {
type: 'textarea',
name: 'text',
readOnly: true,
}
}
}
},
{
disabledOn: 'folder',
label: '下载',
type: 'action',
level: 'link',
size: 'xs',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
script: (context, action, event) => {
let downloadUrl = `${event.data.base}/hudi/hdfs_download?root=${encodeURI(event.data.path)}`
window.open(downloadUrl, '_blank')
},
}
]
}
}
},
]
}
]
}
}
}
function copyField(field, tips = '复制', ignoreLength = 0) {
let tpl = ignoreLength === 0 ? `\${${field}}` : `\${TRUNCATE(${field}, ${ignoreLength})}`
return {
@@ -1336,6 +1470,13 @@ function tableMetaDialog() {
}
}
},
{
type: 'button',
label: '数据目录',
icon: 'fa fa-folder',
actionType: 'dialog',
dialog: hdfsDialog('tableMeta.hudi.targetHdfsPath')
},
{
type: 'button',
label: 'Pulsar 队列',

View File

@@ -80,137 +80,7 @@ function toolTab() {
type: 'submit',
label: '查看',
actionType: 'dialog',
dialog: {
title: {
type: 'tpl',
tpl: '${hdfs}'
},
...readOnlyDialogOptions(),
size: 'xl',
body: {
type: 'crud',
api: {
method: 'get',
url: '${base}/hudi/hdfs_list',
data: {
root: '${hdfs|default:undefined}',
},
},
deferApi: {
method: 'get',
url: '${base}/hudi/hdfs_list_children',
data: {
root: '${path|default:undefined}',
},
},
...crudCommonOptions(),
perPage: 10,
headerToolbar: [
"reload",
paginationCommonOptions(undefined, 10),
],
footerToolbar: [
paginationCommonOptions(undefined, 10),
],
columns: [
{
name: 'name',
label: '文件名',
className: 'font-mono',
},
{
name: 'group',
label: '组',
width: 70,
},
{
name: 'owner',
label: '用户',
width: 70,
},
{
label: '大小',
width: 90,
type: 'tpl',
tpl: "${sizeText}",
},
{
label: '修改时间',
width: 140,
type: 'tpl',
tpl: "${DATETOSTR(DATE(modifyTime), 'YYYY-MM-DD HH:mm:ss')}",
},
{
type: 'operation',
label: '操作',
width: 160,
fixed: 'right',
buttons: [
{
label: '完整路径',
type: 'action',
level: 'link',
size: 'xs',
actionType: 'copy',
content: '${path}',
tooltip: '复制 ${path}',
},
{
disabledOn: 'folder || size > 1048576',
label: '查看',
type: 'action',
level: 'link',
size: 'xs',
actionType: 'dialog',
dialog: {
title: {
type: 'tpl',
tpl: '文件内容:${path}'
},
size: 'md',
...readOnlyDialogOptions(),
body: {
type: 'service',
api: {
method: 'get',
url: '${base}/hudi/hdfs_read',
data: {
root: '${path|default:undefined}'
}
},
body: {
type: 'textarea',
name: 'text',
readOnly: true,
}
}
}
},
{
disabledOn: 'folder',
label: '下载',
type: 'action',
level: 'link',
size: 'xs',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
script: (context, action, event) => {
let downloadUrl = `${event.data.base}/hudi/hdfs_download?root=${encodeURI(event.data.path)}`
window.open(downloadUrl, '_blank')
},
}
]
}
}
},
]
}
]
}
}
dialog: hdfsDialog('hdfs'),
}
],
body: [