You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ch...@apache.org on 2020/03/23 08:44:28 UTC
[incubator-dolphinscheduler] branch dev-resource-tree updated:
Filter UDF resources
This is an automated email from the ASF dual-hosted git repository.
chenxingchun pushed a commit to branch dev-resource-tree
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev-resource-tree by this push:
new 0a9e4af Filter UDF resources
new c6022f5 Merge pull request #2283 from break60/dev-resource-tree
0a9e4af is described below
commit 0a9e4af57a92ff7c0f565c01e75f04c4b6e6a47b
Author: break60 <79...@qq.com>
AuthorDate: Mon Mar 23 16:37:59 2020 +0800
Filter UDF resources
---
.../pages/udf/pages/function/_source/createUdf.vue | 43 +++++++++++++++++++++-
.../js/module/components/fileUpdate/udfUpdate.vue | 17 +++++++--
.../src/js/module/i18n/locale/en_US.js | 2 +
.../src/js/module/i18n/locale/zh_CN.js | 2 +
4 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/resource/pages/udf/pages/function/_source/createUdf.vue b/dolphinscheduler-ui/src/js/conf/home/pages/resource/pages/udf/pages/function/_source/createUdf.vue
index 9805434..ec4e091 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/resource/pages/udf/pages/function/_source/createUdf.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/resource/pages/udf/pages/function/_source/createUdf.vue
@@ -15,7 +15,7 @@
* limitations under the License.
*/
<template>
- <m-popup :ok-text="item ? $t('Edit') : $t('Submit')" :nameText="item ? $t('Edit UDF Function') : $t('Create UDF Function')" @ok="_ok" ref="popup">
+ <m-popup style="width:800px" :ok-text="item ? $t('Edit') : $t('Submit')" :nameText="item ? $t('Edit UDF Function') : $t('Create UDF Function')" @ok="_ok" ref="popup">
<template slot="content">
<div class="udf-create-model">
<m-list-box-f>
@@ -72,16 +72,25 @@
<m-list-box-f>
<template slot="name"><strong>*</strong>{{$t('UDF Resources')}}</template>
<template slot="content">
- <treeselect style="width:260px;float:left;" v-model="resourceId" :disable-branch-nodes="true" :options="udfResourceList" :disabled="isUpdate" :normalizer="normalizer" :placeholder="$t('Please select resources')">
+ <treeselect style="width:535px;float:left;" v-model="resourceId" :disable-branch-nodes="true" :options="udfResourceList" :disabled="isUpdate" :normalizer="normalizer" :placeholder="$t('Please select UDF resources directory')">
<div slot="value-label" slot-scope="{ node }">{{ node.raw.fullName }}</div>
</treeselect>
<x-button type="primary" @click="_toggleUpdate" :disabled="upDisabled">{{$t('Upload Resources')}}</x-button>
</template>
</m-list-box-f>
<m-list-box-f v-if="isUpdate">
+ <template slot="name"><strong>*</strong>{{$t('UDF resources directory')}}</template>
+ <template slot="content">
+ <treeselect style="width:535px;float:left;" v-model="pid" @select="selTree" :options="udfResourceDirList" :normalizer="normalizer" :placeholder="$t('Please select UDF resources directory')">
+ <div slot="value-label" slot-scope="{ node }">{{ node.raw.fullName }}</div>
+ </treeselect>
+ </template>
+ </m-list-box-f>
+ <m-list-box-f v-if="isUpdate">
<template slot="name"> </template>
<template slot="content">
<m-udf-update
+ ref="assignment"
@on-update-present="_onUpdatePresent"
@on-update="_onUpdate">
</m-udf-update>
@@ -123,6 +132,7 @@
database: '',
description: '',
resourceId: null,
+ pid: null,
udfResourceList: [],
isUpdate: false,
upDisabled: false,
@@ -189,6 +199,10 @@
// disabled update
this.upDisabled = true
},
+ // selTree
+ selTree(node) {
+ this.$refs.assignment.receivedValue(node.pid,node.name)
+ },
/**
* get udf resources
*/
@@ -196,12 +210,37 @@
return new Promise((resolve, reject) => {
this.store.dispatch('resource/getResourcesList', { type: 'UDF' }).then(res => {
let item = res.data
+ this.filterEmptyDirectory(item)
+ item = this.filterEmptyDirectory(item)
+ let item1 = _.cloneDeep(res.data)
this.diGuiTree(item)
+
+ this.diGuiTree(this.filterJarFile(item1))
this.udfResourceList = item
+ this.udfResourceDirList = item1
resolve()
})
})
},
+ // filterEmptyDirectory
+ filterEmptyDirectory(array) {
+ for (const item of array) {
+ if (item.children.length>0) {
+ this.filterJarFile(item.children)
+ }
+ }
+ return array.filter(n => ((/\.jar$/.test(n.name) && n.children.length==0) || (!/\.jar$/.test(n.name) && n.children.length>0)))
+ },
+ // filterJarFile
+ filterJarFile (array) {
+ for (const item of array) {
+ if (item.children) {
+ item.children = this.filterJarFile(item.children)
+ }
+ }
+ return array.filter(n => !/\.jar$/.test(n.name))
+ },
+ // diGuiTree
diGuiTree(item) { // Recursive convenience tree structure
item.forEach(item => {
item.children === '' || item.children === undefined || item.children === null || item.children.length === 0?
diff --git a/dolphinscheduler-ui/src/js/module/components/fileUpdate/udfUpdate.vue b/dolphinscheduler-ui/src/js/module/components/fileUpdate/udfUpdate.vue
index cbf1aed..7c852c5 100644
--- a/dolphinscheduler-ui/src/js/module/components/fileUpdate/udfUpdate.vue
+++ b/dolphinscheduler-ui/src/js/module/components/fileUpdate/udfUpdate.vue
@@ -25,7 +25,7 @@
size="small"
v-model="udfName"
:disabled="progress !== 0"
- style="width: 268px"
+ style="width: 535px"
:placeholder="$t('Please enter resource name')"
autocomplete="off">
</x-input>
@@ -66,7 +66,9 @@
udfDesc: '',
file: '',
progress: 0,
- spinnerLoading: false
+ spinnerLoading: false,
+ pid: null,
+ currentDir: ''
}
},
props: {
@@ -77,6 +79,10 @@
* validation
*/
_validation () {
+ if (!this.currentDir) {
+ this.$message.warning(`${i18n.$t('Please select UDF resources directory')}`)
+ return false
+ }
if (!this.udfName) {
this.$message.warning(`${i18n.$t('Please enter file name')}`)
return false
@@ -100,12 +106,17 @@
})
})
},
+ receivedValue(pid,name) {
+ this.pid = pid
+ this.currentDir = name
+ },
_formDataUpdate () {
let self = this
let formData = new FormData()
formData.append('file', this.file)
formData.append('type', 'UDF')
- formData.append('pid', 155)
+ formData.append('pid', this.pid)
+ formData.append('currentDir', this.currentDir)
formData.append('name', this.udfName)
formData.append('description', this.udfDesc)
this.spinnerLoading = true
diff --git a/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js b/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
index a2ea708..b679a52 100644
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
@@ -182,6 +182,8 @@ export default {
'Authorize': 'Authorize',
'File resources': 'File resources',
'UDF resources': 'UDF resources',
+ 'UDF resources directory' : 'UDF resources directory',
+ 'Please select UDF resources directory': 'Please select UDF resources directory',
'Upload File Size': 'Upload File size cannot exceed 1g',
'Edit alarm group': 'Edit alarm group',
'Create alarm group': 'Create alarm group',
diff --git a/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js b/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
index 66a6437..86422ec 100644
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
@@ -184,6 +184,8 @@ export default {
'Authorize': '授权',
'File resources': '文件资源',
'UDF resources': 'UDF资源',
+ 'UDF resources directory': 'UDF资源目录',
+ 'Please select UDF resources directory': '请选择UDF资源目录',
'Edit alarm group': '编辑告警组',
'Create alarm group': '创建告警组',
'Group Name': '组名称',