@@ -583,7 +606,10 @@
backfillRefresh: true,
// whether this is a new Task
isNewCreate: true,
- tasksTypeList: Object.keys(tasksType)
+ tasksTypeList: Object.keys(tasksType),
+ // processCode
+ processCode: undefined,
+ processDefinition: null
}
},
provide () {
@@ -609,7 +635,7 @@
},
inject: ['dagChart'],
methods: {
- ...mapActions('dag', ['getTaskInstanceList']),
+ ...mapActions('dag', ['getTaskInstanceList', 'getProcessDefinition']),
helpUrlEnable (typekey) {
const type = tasksType[typekey]
if (!type) return false
@@ -850,10 +876,16 @@
if (!this.$refs[this.nodeData.taskType]._verification()) {
return
}
- // set preTask
- if (this.$refs.preTasks) {
- this.$refs.preTasks.setPreNodes()
+ // set dag preTask
+ if (this.dagChart && this.$refs.preTasks) {
+ this.$refs.preTasks.setDagPreNodes()
}
+
+ // set edge label
+ if (this.dagChart) {
+ this._setEdgeLabel()
+ }
+
this.successBranch && (this.conditionResult.successNode[0] = this.successBranch)
this.failedBranch && (this.conditionResult.failedNode[0] = this.failedBranch)
this.$emit('addTaskInfo', {
@@ -882,11 +914,12 @@
taskGroupId: this.taskGroupId,
taskGroupPriority: this.taskGroupPriority
},
- fromThis: this
+ fromThis: this,
+ ...(this.fromTaskDefinition ? {
+ prevTasks: this.$refs.preTasks ? this.$refs.preTasks.preTasks : [],
+ processCode: this.processCode
+ } : {})
})
-
- // set edge label
- this._setEdgeLabel()
},
/**
* Sub-workflow selected node echo name
@@ -1005,6 +1038,44 @@
},
changeTaskType (value) {
this.$emit('changeTaskType', value)
+ },
+ calculateRelatedTasks () {
+ if (this.processDefinition && this.taskDefinition) {
+ const relations = this.processDefinition.processTaskRelationList || []
+ const tasks = this.processDefinition.taskDefinitionList || []
+ const tasksMap = {}
+ tasks.forEach(task => {
+ tasksMap[task.code] = task
+ })
+ const taskCode = this.taskDefinition.code
+ const buildTask = (task) => ({
+ code: task.code,
+ name: task.name,
+ type: task.taskType
+ })
+ // Downstream tasks
+ const postTasks = relations
+ .filter(relation => relation.preTaskCode === taskCode)
+ .map(relation => buildTask(tasksMap[relation.postTaskCode]))
+
+ // Upstream tasks
+ const prevTasks = relations
+ .filter(relation => relation.postTaskCode === taskCode && relation.preTaskCode !== 0)
+ .map(relation => buildTask(tasksMap[relation.preTaskCode]))
+
+ this.postTasks = postTasks
+ this.prevTasks = prevTasks
+ }
+ },
+ getProcessDetails () {
+ this.getProcessDefinition(this.processCode).then(res => {
+ this.processDefinition = res
+ this.calculateRelatedTasks()
+ })
+ },
+ changeProcessCode (code) {
+ this.processCode = code
+ this.getProcessDetails()
}
},
created () {
@@ -1046,6 +1117,11 @@
this.postTasks = postNodes.map(buildTask)
this.prevTasks = prevNodes.map(buildTask)
}
+
+ if (this.fromTaskDefinition && this.taskDefinition) {
+ this.processCode = this.taskDefinition.processCode
+ this.getProcessDetails()
+ }
},
mounted () {
let self = this
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
index cc976966fd..5ffd2c8c03 100644
--- 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
@@ -53,7 +53,11 @@
code: {
type: Number,
default: 0
- }
+ },
+ processDefinition: {
+ type: Object
+ },
+ prevTasks: Array
},
data () {
return {
@@ -61,20 +65,45 @@
preTasks: []
}
},
- mounted () {
- const canvas = this.getDagCanvasRef()
- const edges = canvas.getEdges()
- this.preTasks = canvas.getPrevNodes(this.code).map(node => node.id)
- this.options = this.tasks.filter((task) => {
- // The current node cannot be used as the prev node
- if (task.code === this.code) return false
- if (this.preTasks.includes(task.code)) return true
- // The number of edges start with CONDITIONS task cannot be greater than 2
- if (task.taskType === 'CONDITIONS') {
- return edges.filter((e) => e.sourceId === task.code).length < 2
+ watch: {
+ processDefinition (def) {
+ if (def) {
+ this.preTasks = []
+ const relations = def.processTaskRelationList
+ this.options = def.taskDefinitionList.filter((task) => {
+ // The current node cannot be used as the prev node
+ if (task.code === this.code) return false
+ // The number of edges start with CONDITIONS task cannot be greater than 2
+ if (task.taskType === 'CONDITIONS') {
+ return relations.filter((e) => e.preTaskCode === task.code).length < 2
+ }
+ return true
+ })
+ }
+ },
+ prevTasks (prevTasks) {
+ if (prevTasks) {
+ this.preTasks = prevTasks.map(task => task.code)
}
- return true
- })
+ }
+ },
+ mounted () {
+ // Called by dag
+ if (this.dagChart) {
+ const canvas = this.getDagCanvasRef()
+ const edges = canvas.getEdges()
+ this.preTasks = canvas.getPrevNodes(this.code).map(node => node.id)
+ this.options = this.tasks.filter((task) => {
+ // The current node cannot be used as the prev node
+ if (task.code === this.code) return false
+ if (this.preTasks.includes(task.code)) return true
+ // The number of edges start with CONDITIONS task cannot be greater than 2
+ if (task.taskType === 'CONDITIONS') {
+ return edges.filter((e) => e.sourceId === task.code).length < 2
+ }
+ return true
+ })
+ }
},
computed: {
...mapState('dag', ['tasks'])
@@ -89,7 +118,7 @@
return canvas
}
},
- setPreNodes () {
+ setDagPreNodes () {
const canvas = this.getDagCanvasRef()
canvas.setPreNodes(this.code, this.preTasks, true)
}
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
index bca4b47134..36d24560f9 100644
--- 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
@@ -23,61 +23,106 @@
style="width: 100%"
@selection-change="select"
>
-
- {{ scope.row.name }}
+ {{ scope.row.taskName }}
-
+
+
+
+ :label="$t('Task Type')"
+ prop="taskType"
+ min-width="135"
+ >
+
- {{ 'V' + scope.row.version }}
+ {{ "V" + scope.row.taskVersion }}
+
+
+
+
+ {{ task.taskName }}
+
+ {{ task.taskName }}
+
+
+
+
+
+
+ {{ task.taskName }}
+
+
+
+ {{
+ $t("and {n} more", {
+ n: scope.row.upstreamTasks.length - 3,
+ })
+ }}
+
+
+
-
+
+
+
- {{ scope.row.createTime | formatDate }}
+ {{ scope.row.taskCreateTime | formatDate }}
- {{ scope.row.updateTime | formateDate }}
+ {{ scope.row.taskUpdateTime | formateDate }}
-
-
- {{ scope.row.description | filterNull }}
-
-
-
+
+
+
+
+
+
-
+
-
-
+ :disabled="
+ scope.row.processDefinitionCode &&
+ scope.row.processReleaseState === 'ONLINE'
+ "
+ @click="showDeleteModal(scope.row)"
+ >
+
+
+
+
@@ -127,7 +207,6 @@
-
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskDeleteModal.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskDeleteModal.vue
new file mode 100644
index 0000000000..9d90ad5b68
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskDeleteModal.vue
@@ -0,0 +1,91 @@
+/*
+ * 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("Delete task {taskName} from process {processName}?", {
+ processName: taskRow.processDefinitionName,
+ taskName: taskRow.taskName,
+ })
+ }}
+ {{
+ $t("Delete task completely")
+ }}
+
+
+ {{
+ $t("Delete {taskName}?", {
+ taskName: taskRow.taskName,
+ })
+ }}
+
+
+
+
+
+
+
+
+
+
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskMoveModel.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskMoveModel.vue
new file mode 100644
index 0000000000..23c9c2e9a4
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/taskMoveModel.vue
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+
+
+
+
+
+
+ {{ process.name }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/versions.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/versions.vue
new file mode 100644
index 0000000000..9b0974122a
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskDefinition/_source/versions.vue
@@ -0,0 +1,253 @@
+/*
+* 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.
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ V{{ scope.row.version }}
+ {{ $t("Current Version") }}
+ V{{ scope.row.version }}
+
+ -
+
+
+
+
+
+ {{ scope.row.updateTime | formatDate }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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
index 50a8b0a7f4..a09f16f4ea 100644
--- 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
@@ -18,12 +18,61 @@
-
+
{{ $t("Create task") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -32,7 +81,10 @@
:tasksList="tasksList"
@on-update="_onUpdate"
@editTask="editTask"
+ @showDeleteModal="showDeleteModal"
+ @showMoveModal="showMoveModal"
@viewTaskDetail="viewTaskDetail"
+ @viewTaskVersions="viewTaskVersions"
>
+
+
+
@@ -297,5 +503,40 @@
.taskGroupBtn {
width: 300px;
}
+
+ ::v-deep .table-box {
+ table {
+ tr {
+ th:first-child,
+ td:first-child {
+ text-align: left;
+ padding-left: 20px;
+ }
+ td:first-child span {
+ text-align: left;
+ }
+ }
+ td,
+ th.is-leaf {
+ padding-left: 10px;
+ }
+ }
+ .pre-task-tag {
+ margin-right: 10px;
+ max-width: 100px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .upstream-tasks {
+ display: flex;
+ flex-wrap: wrap;
+ }
+ }
+
+ ::v-deep .el-dialog__header {
+ .el-dialog__headerbtn {
+ right: 20px;
+ }
+ }
}
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 6341d78a9e..64a83b21c5 100644
--- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
+++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
@@ -24,7 +24,7 @@ const convertLocations = (locationStr) => {
if (!locationStr) return locations
try {
locations = JSON.parse(locationStr)
- } catch (error) {}
+ } catch (error) { }
return Array.isArray(locations) ? locations : null
}
@@ -870,7 +870,7 @@ export default {
*/
deleteTaskDefinition ({ state }, payload) {
return new Promise((resolve, reject) => {
- io.delete(`projects/${state.projectCode}/task-definition/${payload.code}`, payload, res => {
+ io.delete(`projects/${state.projectCode}/task-definition/${payload.taskCode}`, res => {
resolve(res)
}).catch(e => {
reject(e)
@@ -891,15 +891,143 @@ export default {
})
})
},
- updateTaskDefinition ({ state }, taskDefinition) {
+ /**
+ * Save Task Definition with upstreams
+ * @param {Object} taskDefinition
+ * @param {number[]} prevTasks
+ * @param {number} processDefinitionCode
+ */
+ saveTaskDefinitionWithUpstreams ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.post(`projects/${state.projectCode}/task-definition/save-single`, {
+ taskDefinitionJsonObj: JSON.stringify(payload.taskDefinition),
+ upstreamCodes: payload.prevTasks.join(','),
+ processDefinitionCode: payload.processDefinitionCode
+ }, res => {
+ resolve(res)
+ }).catch(e => {
+ reject(e)
+ })
+ })
+ },
+ /**
+ *
+ * @param {Object} taskDefinition
+ * @param {number[]} taskDefinition
+ * @returns
+ */
+ updateTaskDefinition ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.put(`projects/${state.projectCode}/task-definition/${payload.taskDefinition.code}/with-upstream`, {
+ taskDefinitionJsonObj: JSON.stringify(payload.taskDefinition),
+ upstreamCodes: payload.prevTasks.join(',')
+ }, res => {
+ resolve(res)
+ }).catch(e => {
+ reject(e)
+ })
+ })
+ },
+ /**
+ * Query taskDefinition by code
+ * @param {*} param0
+ */
+ getTaskDefinition ({ state }, taskDefinitionCode) {
+ return new Promise((resolve, reject) => {
+ io.get(`projects/${state.projectCode}/task-definition/${taskDefinitionCode}`, res => {
+ resolve(res.data)
+ }).catch(e => {
+ reject(e)
+ })
+ })
+ },
+ /**
+ * Get process definition detail
+ * @param {numbetr} code
+ */
+ getProcessDefinition ({ state }, code) {
+ return new Promise((resolve, reject) => {
+ io.get(`projects/${state.projectCode}/process-definition/${code}`, res => {
+ resolve(res.data)
+ }).catch(res => {
+ reject(res)
+ })
+ })
+ },
+ /**
+ * Move task
+ */
+ moveTaskToProcess ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.post(`projects/${state.projectCode}/process-task-relation/move`, {
+ processDefinitionCode: payload.processDefinitionCode,
+ targetProcessDefinitionCode: payload.targetProcessDefinitionCode,
+ taskCode: payload.taskCode
+ }, res => {
+ resolve(res)
+ }).catch(e => {
+ reject(e)
+ })
+ })
+ },
+ /**
+ * Delete relation
+ */
+ deleteRelation ({ state }, payload) {
return new Promise((resolve, reject) => {
- io.put(`projects/${state.projectCode}/task-definition/${taskDefinition.code}`, {
- taskDefinitionJsonObj: JSON.stringify(taskDefinition)
+ io.delete(`projects/${state.projectCode}/process-task-relation/${payload.taskCode}`, {
+ processDefinitionCode: payload.processDefinitionCode
}, res => {
resolve(res)
}).catch(e => {
reject(e)
})
})
+ },
+ /**
+ * Query task versions
+ * @param {number} taskCode
+ * @param {number} pageNo
+ * @param {number} pageSize
+ */
+ getTaskVersions ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.get(`projects/${state.projectCode}/task-definition/${payload.taskCode}/versions`, {
+ pageNo: payload.pageNo,
+ pageSize: payload.pageSize
+ }, res => {
+ resolve(res.data)
+ }).catch(res => {
+ reject(res)
+ })
+ })
+ },
+ /**
+ * Switch task version
+ * @param {number} taskCode
+ * @param {number} version
+ */
+ switchTaskVersion ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.get(`projects/${state.projectCode}/task-definition/${payload.taskCode}/versions/${payload.version}`, res => {
+ resolve(res)
+ }).catch(res => {
+ reject(res)
+ })
+ })
+ },
+ /**
+ * Delete task version
+ * @param {number} taskCode
+ * @param {number} version
+ */
+ deleteTaskVersion ({ state }, payload) {
+ return new Promise((resolve, reject) => {
+ io.delete(`projects/${state.projectCode}/task-definition/${payload.taskCode}/versions/${payload.version}`, 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 4f11dc5386..4ffd030fd0 100644
--- a/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue
+++ b/dolphinscheduler-ui/src/js/module/components/conditions/conditions.vue
@@ -42,24 +42,6 @@
>
-
-
-
-
-
-
@@ -67,40 +49,24 @@