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 8444863aea2942e850e9d0f6259543e1968b40f3..7cd63c07dbd919dcc4e2f5fc332d13907eb4a000 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
@@ -277,6 +277,12 @@
:backfill-item="backfillItem"
:pre-node="preNode">
+
+
@@ -310,6 +316,7 @@
import mSelectInput from './_source/selectInput'
import mTimeoutAlarm from './_source/timeoutAlarm'
import mWorkerGroups from './_source/workerGroups'
+ import mPreTasks from './tasks/pre_tasks'
import clickoutside from '@/module/util/clickoutside'
import disabledState from '@/module/mixin/disabledState'
import { isNameExDag, rtBantpl } from './../plugIn/util'
@@ -369,7 +376,11 @@
value: 'failed',
label: `${i18n.$t('failed')}`
}
- ]
+ ],
+ // preTasks
+ preTaskIdsInWorkflow: [],
+ preTasksToAdd: [], // pre-taskIds to add, used in jsplumb connects
+ preTasksToDelete: [], // pre-taskIds to delete, used in jsplumb connects
}
},
/**
@@ -393,6 +404,14 @@
_onDependent (o) {
this.dependence = Object.assign(this.dependence, {}, o)
},
+ /**
+ * Pre-tasks in workflow
+ */
+ _onPreTasks (o) {
+ this.preTaskIdsInWorkflow = o.preTasks
+ this.preTasksToAdd = o.preTasksToAdd
+ this.preTasksToDelete = o.preTasksToDelete
+ },
/**
* cache dependent
*/
@@ -543,6 +562,43 @@
if (!this.$refs[this.taskType]._verification()) {
return
}
+ // Verify preTasks and update dag-things
+ if (this.$refs['PRE_TASK']) {
+ if (!this.$refs['PRE_TASK']._verification()) {
+ return
+ }
+ else {
+ // Sync data-targetarr
+ $(`#${this.id}`).attr(
+ 'data-targetarr', this.preTaskIdsInWorkflow ? this.preTaskIdsInWorkflow.join(',') : '')
+
+ // Update JSP connections
+ let plumbIns = JSP.JspInstance
+ var targetId = this.id
+
+ // Update new connections
+ this.preTasksToAdd.map(sourceId => {
+ plumbIns.connect({
+ source: sourceId,
+ target: targetId,
+ type: 'basic',
+ paintStyle: { strokeWidth: 2, stroke: '#2d8cf0' },
+ HoverPaintStyle: {stroke: '#ccc', strokeWidth: 3}
+ })
+ })
+
+ // Update remove connections
+ let currentConnects = plumbIns.getAllConnections()
+ let len = currentConnects.length
+ for (let i = 0; i < len; i++) {
+ if (this.preTasksToDelete.indexOf(currentConnects[i].sourceId) > -1 && currentConnects[i].targetId == targetId) {
+ plumbIns.deleteConnection(currentConnects[i])
+ i -= 1
+ len -= 1
+ }
+ }
+ }
+ }
$(`#${this.id}`).find('span').text(this.name)
this.conditionResult.successNode[0] = this.successBranch
@@ -684,6 +740,16 @@
}
this.cacheBackfillItem = JSON.parse(JSON.stringify(o))
this.isContentBox = true
+
+ // Init value of preTask selector
+ let preTaskIds = $(`#${this.id}`).attr('data-targetarr')
+ if (!_.isEmpty(this.backfillItem)) {
+ if (preTaskIds && preTaskIds.length) {
+ this.backfillItem.preTasks = preTaskIds.split(',')
+ } else {
+ this.backfillItem.preTasks = []
+ }
+ }
},
mounted () {
let self = this
@@ -745,7 +811,8 @@
mSelectInput,
mTimeoutAlarm,
mPriority,
- mWorkerGroups
+ mWorkerGroups,
+ mPreTasks,
}
}
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/pre_tasks.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/pre_tasks.vue
new file mode 100644
index 0000000000000000000000000000000000000000..adf889e9589036dc4964bd40670c12c0b3484f9e
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/pre_tasks.vue
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+
+
+
+ {{$t('Pre tasks')}}
+
+
+
+
+
+
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 e1ecedc9aebf39df6f3a8f37a6ef19fabe66b71a..07dfb7c5a76665786f1558fe361ca3bd05819b3f 100755
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
@@ -642,5 +642,6 @@ export default {
'Related items': 'Related items',
'Project name is required': 'Project name is required',
'Batch move': 'Batch move',
- Version: 'Version'
+ Version: 'Version',
+ 'Pre tasks': 'Pre tasks',
}
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 f69142d3b538e74a0d12a6b6e7eeea575037766d..e3f2562f6fa619dec4152ec814ca0e0c6608c555 100755
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
@@ -642,5 +642,6 @@ export default {
'Related items': '关联项目',
'Project name is required': '项目名称必填',
'Batch move': '批量移动',
- Version: '版本'
+ Version: '版本',
+ 'Pre tasks': '前置任务',
}