diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/_source/referenceFromTask.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/_source/referenceFromTask.vue index ef1489cb85d8c41e00d0448b659b79ae1dea86c2..be631908ba2b30e8c0d3f919a11666686da78f4e 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/_source/referenceFromTask.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/_source/referenceFromTask.vue @@ -81,7 +81,7 @@ document.removeEventListener('click', this.outsideClick) }, methods: { - ...mapActions('dag', ['getTaskDefinitions']), + ...mapActions('dag', ['getTaskDefinitionList']), outsideClick (e) { const elem = this.$refs.copyFrom if (!elem.contains(e.target) && this.dropdownVisible) { @@ -99,7 +99,7 @@ } if (this.noMore) return this.loading = true - this.getTaskDefinitions({ + this.getTaskDefinitionsList({ pageNo: this.pageNo, pageSize: this.pageSize, searchVal: this.searchVal, diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue index fcafefc268d7a470e14ae27fff3e03688ac359e1..c5107d38363c5960a5e2664f0fd0c6e22b19418d 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/formModel.vue @@ -46,7 +46,6 @@
- @@ -61,12 +60,34 @@ :disabled="isDetails" :placeholder="$t('Please enter name (required)')" maxlength="100" - @blur="_verifName()" >
+ +
{{ $t("Task Type") }}
+
+ + + + +
+
+
{{ $t("Run flag") }}
@@ -353,13 +374,14 @@ :backfill-item="backfillItem" > - - + +
@@ -415,7 +437,7 @@ :loading="spinnerLoading" @click="ok()" :disabled="isDetails" - >{{ spinnerLoading ? $t("Loading...") : $t("Confirm add") }} + >{{ spinnerLoading ? $t("Loading...") : $t("Confirm") }} @@ -453,6 +475,7 @@ import disabledState from '@/module/mixin/disabledState' import mPriority from '@/module/components/priority/priority' import { findComponentDownward } from '@/module/util/' + import { tasksType } from '@/conf/home/pages/dag/_source/config.js' // import ReferenceFromTask from './_source/referenceFromTask.vue' export default { @@ -524,7 +547,8 @@ // refresh part of the formModel, after set backfillItem outside backfillRefresh: true, // whether this is a new Task - isNewCreate: true + isNewCreate: true, + tasksTypeList: Object.keys(tasksType) } }, provide () { @@ -542,7 +566,8 @@ type: { type: String, default: '' - } + }, + taskDefinition: Object }, inject: ['dagChart'], methods: { @@ -723,6 +748,16 @@ } return true }, + _verifTaskType () { + if (!this.fromTaskDefinition) return true + if (!this.nodeData.taskType) { + this.$message.warning( + `${i18n.$t('Please select a task type (required)')}` + ) + return false + } + return true + }, /** * Global verification procedure */ @@ -731,6 +766,12 @@ if (!this._verifName()) { return } + + // Verify task type + if (!this._verifTaskType()) { + return + } + // verif workGroup if (!this._verifWorkGroup()) { return @@ -777,14 +818,11 @@ timeoutNotifyStrategy: this.timeout.strategy, timeout: this.timeout.interval || 0, delayTime: this.delayTime, - environmentCode: this.environmentCode || -1, - status: this.status, - branch: this.branch + environmentCode: this.environmentCode || -1 }, fromThis: this }) - // set run flag - this._setRunFlag() + // set edge label this._setEdgeLabel() }, @@ -795,10 +833,8 @@ this.name = name }, /** - * set run flag - * TODO + * set edge label by successBranch && failedBranch */ - _setRunFlag () {}, _setEdgeLabel () { if (this.successBranch || this.failedBranch) { const canvas = findComponentDownward(this.dagChart, 'dag-canvas') @@ -892,7 +928,8 @@ } else { this.workerGroup = o.workerGroup } - this.environmentCode = o.environmentCode === -1 ? '' : o.environmentCode + this.environmentCode = + o.environmentCode === -1 ? '' : o.environmentCode this.params = o.params || {} this.dependence = o.dependence || {} this.cacheDependence = o.dependence || {} @@ -901,23 +938,37 @@ } this.cacheBackfillItem = JSON.parse(JSON.stringify(o)) this.isContentBox = true + }, + changeTaskType (value) { + this.$emit('changeTaskType', value) } }, created () { // Backfill data - let taskList = this.store.state.dag.tasks let o = {} - if (taskList.length) { - taskList.forEach((task) => { - if (task.code === this.nodeData.id) { - const backfillItem = this.taskToBackfillItem(task) - o = backfillItem - this.backfillItem = backfillItem - this.isNewCreate = false - } - }) - } this.code = this.nodeData.id + + if (this.fromTaskDefinition) { + if (this.taskDefinition) { + const backfillItem = this.taskToBackfillItem(this.taskDefinition) + o = backfillItem + this.backfillItem = backfillItem + this.isNewCreate = false + } + } else { + let taskList = this.store.state.dag.tasks + if (taskList.length) { + taskList.forEach((task) => { + if (task.code === this.nodeData.id) { + const backfillItem = this.taskToBackfillItem(task) + o = backfillItem + this.backfillItem = backfillItem + this.isNewCreate = false + } + }) + } + } + this.backfill(o) if (this.dagChart) { @@ -958,6 +1009,12 @@ ) } return null + }, + /** + * Open the modal from task definition + */ + fromTaskDefinition () { + return this.type === 'task-definition' } }, components: { @@ -986,7 +1043,7 @@ mWorkerGroups, mRelatedEnvironment, mPreTasks - // ReferenceFromTask + // ReferenceFromTask } } diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/list.vue new file mode 100644 index 0000000000000000000000000000000000000000..bca4b47134bcb91d4a1af381c9bcac9817492ca4 --- /dev/null +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/list.vue @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + + + diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..67aa2b304bb3dcd1c67d3ffe7cf63a57e897decf --- /dev/null +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/index.vue @@ -0,0 +1,307 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + diff --git a/dolphinscheduler-ui/src/js/conf/home/router/index.js b/dolphinscheduler-ui/src/js/conf/home/router/index.js index 2c82a83cc3da44a77096becc0074a3e4fa54a701..8d997afd7458bd3b485e110e79f3cbbe8ab2b2cb 100644 --- a/dolphinscheduler-ui/src/js/conf/home/router/index.js +++ b/dolphinscheduler-ui/src/js/conf/home/router/index.js @@ -207,6 +207,15 @@ const router = new Router({ } }, + { + path: '/projects/:projectCode/task-definition', + name: 'task-definition', + component: resolve => require(['../pages/projects/pages/taskDefinition/index'], resolve), + meta: { + title: `${i18n.$t('Task Definition')}`, + refreshInSwitchedTab: config.refreshInSwitchedTab + } + }, { path: '/projects/:projectCode/task-record', name: 'task-record', diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js index 1a92cc1649011a0cdee1bd66cb430c4aa723627e..fd423fe8ca0e52029b436686c96da94bacc7f798 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -836,7 +836,10 @@ export default { }) }) }, - getTaskDefinitions ({ state }, payload) { + /** + * Query Task Definitions List Paging + */ + getTaskDefinitionsList ({ state }, payload) { return new Promise((resolve, reject) => { io.get(`projects/${state.projectCode}/task-definition`, payload, res => { resolve(res.data) @@ -844,5 +847,42 @@ export default { reject(e) }) }) + }, + /** + * Delete Task Definition by code + */ + deleteTaskDefinition ({ state }, payload) { + return new Promise((resolve, reject) => { + io.delete(`projects/${state.projectCode}/task-definition/${payload.code}`, payload, res => { + resolve(res) + }).catch(e => { + reject(e) + }) + }) + }, + /** + * Save Task Definition + */ + saveTaskDefinition ({ state }, payload) { + return new Promise((resolve, reject) => { + io.post(`projects/${state.projectCode}/task-definition`, { + taskDefinitionJson: JSON.stringify(payload.taskDefinitionJson) + }, res => { + resolve(res) + }).catch(e => { + reject(e) + }) + }) + }, + updateTaskDefinition ({ state }, taskDefinition) { + return new Promise((resolve, reject) => { + io.put(`projects/${state.projectCode}/task-definition/${taskDefinition.code}`, { + taskDefinitionJsonObj: JSON.stringify(taskDefinition) + }, res => { + resolve(res) + }).catch(e => { + reject(e) + }) + }) } } diff --git a/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue b/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue index 59b60f5963acc2563de3a06ef3d183fcb30bb09e..18e2ffbb5ec99d7ad279b6dba605c0b90d716977 100644 --- a/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue +++ b/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue @@ -24,17 +24,42 @@ @@ -42,24 +67,40 @@