From 7f884a555497a3f2d350a785f586b3091f2c7845 Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Wed, 8 May 2024 14:43:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E8=A1=A8=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B4=E6=8E=A5=E6=9F=A5=E7=9C=8Bhdfs?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9A=84=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/components/common.js | 141 ++++++++++++++++++ .../resources/static/components/tool-tab.js | 132 +--------------- 2 files changed, 142 insertions(+), 131 deletions(-) diff --git a/service-web/src/main/resources/static/components/common.js b/service-web/src/main/resources/static/components/common.js index 3e86ab6..4685923 100644 --- a/service-web/src/main/resources/static/components/common.js +++ b/service-web/src/main/resources/static/components/common.js @@ -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 队列', diff --git a/service-web/src/main/resources/static/components/tool-tab.js b/service-web/src/main/resources/static/components/tool-tab.js index b8c7f8c..5b34491 100644 --- a/service-web/src/main/resources/static/components/tool-tab.js +++ b/service-web/src/main/resources/static/components/tool-tab.js @@ -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: [