Wangyizhi1 commented on a change in pull request #6098:
URL: https://github.com/apache/dolphinscheduler/pull/6098#discussion_r702576830
##########
File path: dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
##########
@@ -15,890 +15,478 @@
* limitations under the License.
*/
<template>
- <div class="clearfix dag-model" >
- <div class="toolbar">
- <div class="title"><span>{{$t('Toolbar')}}</span></div>
- <div class="toolbar-btn">
- <div class="bar-box roundedRect jtk-draggable jtk-droppable
jtk-endpoint-anchor jtk-connected"
- :class="v === dagBarId ? 'active' : ''"
- :id="v"
- :key="v"
- v-for="(item,v) in tasksTypeList"
- @mousedown="_getDagId(v)">
- <div data-toggle="tooltip" :title="item.desc">
- <div class="icos" :class="'icos-' + v" ></div>
- </div>
- </div>
- </div>
- </div>
- <div class="dag-contect">
- <div class="dag-toolbar">
- <div class="assist-btn">
- <el-tooltip :content="$t('View variables')" placement="top"
:enterable="false">
- <span>
- <el-button
- style="vertical-align: middle;"
- type="primary"
- size="mini"
- :disabled="$route.name !== 'projects-instance-details'"
- @click="_toggleView"
- icon="el-icon-c-scale-to-original">
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip :content="$t('Startup parameter')" placement="top"
:enterable="false">
- <span>
- <el-button
- style="vertical-align: middle;"
- type="primary"
- size="mini"
- :disabled="$route.name !== 'projects-instance-details'"
- @click="_toggleParam"
- icon="el-icon-arrow-right">
- </el-button>
- </span>
- </el-tooltip>
- <span class="name">{{name}}</span>
-
- <span v-if="name" class="copy-name" @click="_copyName"
:data-clipboard-text="name"><em class="el-icon-copy-document"
data-container="body" data-toggle="tooltip" :title="$t('Copy name')"
></em></span>
- </div>
- <div class="save-btn">
- <div class="operation" style="vertical-align: middle;">
- <a href="javascript:"
- v-for="(item,$index) in toolOperList"
- :class="_operationClass(item)"
- :id="item.code"
- :key="$index"
- @click="_ckOperation(item,$event)">
- <el-tooltip :content="item.desc" placement="top"
:enterable="false">
- <span><el-button type="text" class="operBtn"
:icon="item.icon"></el-button></span>
- </el-tooltip>
- </a>
- </div>
- <el-tooltip :content="$t('Format DAG')" placement="top"
:enterable="false">
- <span>
- <el-button
- type="primary"
- icon="el-icon-caret-right"
- size="mini"
- v-if="(type === 'instance' || 'definition') && urlParam.id
!=undefined"
- style="vertical-align: middle;"
- @click="dagAutomaticLayout">
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip :content="$t('Refresh DAG status')" placement="top"
:enterable="false">
- <span>
- <el-button
- style="vertical-align: middle;"
- icon="el-icon-refresh"
- type="primary"
- :loading="isRefresh"
- v-if="type === 'instance'"
- @click="!isRefresh && _refresh()"
- size="mini" >
- </el-button>
- </span>
- </el-tooltip>
- <el-button
- v-if="isRtTasks"
- style="vertical-align: middle;"
- type="primary"
- size="mini"
- icon="el-icon-back"
- @click="_rtNodesDag" >
- {{$t('Return_1')}}
- </el-button>
- <span>
- <el-button
- type="primary"
- icon="el-icon-switch-button"
- size="mini"
- v-if="(type === 'instance' || 'definition') "
- style="vertical-align: middle;"
- @click="_closeDAG">
- {{$t('Close')}}
- </el-button>
- </span>
- <el-button
- style="vertical-align: middle;"
- type="primary"
- size="mini"
- :loading="spinnerLoading"
- @click="_saveChart"
- icon="el-icon-document-checked"
- >
- {{spinnerLoading ? 'Loading...' : $t('Save')}}
- </el-button>
- <span>
- <el-button
- style="vertical-align: middle;"
- type="primary"
- size="mini"
- :loading="spinnerLoading"
- @click="_version"
- :disabled="$route.params.id == null"
- icon="el-icon-info">
- {{spinnerLoading ? 'Loading...' : $t('Version Info')}}
- </el-button>
- </span>
- </div>
- </div>
- <div class="scrollbar dag-container">
- <div class="jtk-demo" id="jtk-demo">
- <div class="jtk-demo-canvas canvas-wide statemachine-demo
jtk-surface jtk-surface-nopan jtk-draggable" id="canvas" ></div>
- </div>
- </div>
- <el-drawer
- :visible.sync="drawer"
- size=""
- :with-header="false">
- <m-versions :versionData = versionData :isInstance="type ===
'instance'"
@mVersionSwitchProcessDefinitionVersion="mVersionSwitchProcessDefinitionVersion"
@mVersionGetProcessDefinitionVersionsPage="mVersionGetProcessDefinitionVersionsPage"
@mVersionDeleteProcessDefinitionVersion="mVersionDeleteProcessDefinitionVersion"
@closeVersion="closeVersion"></m-versions>
- </el-drawer>
- <el-drawer
- :visible.sync="nodeDrawer"
- size=""
- :with-header="false">
- <m-form-model v-if="nodeDrawer" :nodeData=nodeData
@seeHistory="seeHistory" @addTaskInfo="addTaskInfo"
@cacheTaskInfo="cacheTaskInfo" @close="close"
@onSubProcess="onSubProcess"></m-form-model>
- </el-drawer>
- <el-drawer
- :visible.sync="lineDrawer"
- size=""
- :wrapperClosable="false"
- :with-header="false">
- <m-form-line-model :lineData = lineData @addLineInfo="addLineInfo"
@cancel="cancel"></m-form-line-model>
- </el-drawer>
- <el-drawer
- :visible.sync="udpDrawer"
- size=""
- :wrapperClosable="false"
- :with-header="false">
- <m-udp></m-udp>
- </el-drawer>
- <el-dialog
- :title="$t('Set the DAG diagram name')"
- :visible.sync="dialogVisible"
- width="auto">
- <m-udp ref="mUdp" @onUdp="onUdpDialog" @close="closeDialog"></m-udp>
- </el-dialog>
- <el-dialog
- :title="$t('Please set the parameters before starting')"
- :visible.sync="startDialog"
- width="auto">
- <m-start :startData= "startData" :startNodeList="startNodeList"
:sourceType="sourceType" @onUpdateStart="onUpdateStart"
@closeStart="closeStart"></m-start>
- </el-dialog>
- </div>
+ <div :class="['dag-chart', fullScreen ? 'full-screen' : '']">
+ <dag-toolbar />
+ <dag-canvas ref="canvas" />
+ <el-drawer
+ :visible.sync="taskDrawer"
+ size=""
+ :with-header="false"
+ :wrapperClosable="false"
+ >
+ <m-form-model
+ v-if="taskDrawer"
+ :nodeData="nodeData"
+ @seeHistory="seeHistory"
+ @addTaskInfo="addTaskInfo"
+ @close="closeTaskDrawer"
+ @onSubProcess="toSubProcess"
+ ></m-form-model>
+ </el-drawer>
+ <el-dialog
+ :title="$t('Set the DAG diagram name')"
+ :visible.sync="saveDialog"
+ width="auto"
+ >
+ <m-udp ref="mUdp" @onUdp="onSave" @close="cancelSave"></m-udp>
+ </el-dialog>
+ <el-dialog
+ :title="$t('Please set the parameters before starting')"
+ :visible.sync="startDialog"
+ width="auto"
+ >
+ <m-start
+ :startData="{ code: definitionCode, name: name }"
+ :startNodeList="startTaskName"
+ :sourceType="'contextmenu'"
+ @onUpdateStart="onUpdateStart"
+ @closeStart="closeStart"
+ ></m-start>
+ </el-dialog>
+ <edge-edit-model ref="edgeEditModel" />
</div>
</template>
+
<script>
- import _ from 'lodash'
- import Dag from './dag'
- import mUdp from './udp/udp'
- import i18n from '@/module/i18n'
- import { jsPlumb } from 'jsplumb'
- import Clipboard from 'clipboard'
- import { allNodesId } from './plugIn/util'
- import { toolOper, tasksType } from './config'
- import mFormModel from './formModel/formModel'
- import mFormLineModel from './formModel/formLineModel'
- import { formatDate } from '@/module/filter/filter'
- import { findComponentDownward } from '@/module/util/'
- import disabledState from '@/module/mixin/disabledState'
+ import { debounce } from 'lodash'
+ import dagToolbar from './canvas/toolbar.vue'
+ import dagCanvas from './canvas/canvas.vue'
+ import mFormModel from '../_source/formModel/formModel.vue'
import { mapActions, mapState, mapMutations } from 'vuex'
- import mStart from '../../projects/pages/definition/pages/list/_source/start'
- import mVersions from
'../../projects/pages/definition/pages/list/_source/versions'
+ import mUdp from '../_source/udp/udp.vue'
+ import mStart from
'../../projects/pages/definition/pages/list/_source/start.vue'
+ import edgeEditModel from './canvas/edgeEditModel.vue'
- let eventModel
+ const DEFAULT_NODE_DATA = {
+ id: null,
+ taskType: '',
+ self: {},
+ preNode: [],
+ rearList: [],
+ instanceId: null
+ }
export default {
name: 'dag-chart',
- data () {
+ components: {
+ dagCanvas,
+ dagToolbar,
+ mFormModel,
+ mUdp,
+ mStart,
+ edgeEditModel
+ },
+ provide () {
return {
- tasksTypeList: tasksType,
- toolOperList: toolOper(this),
- dagBarId: null,
- toolOperCode: '',
- spinnerLoading: false,
- urlParam: {
- id: this.$route.params.id || null
- },
- isRtTasks: false,
- isRefresh: false,
- isLoading: false,
- taskId: null,
- arg: false,
- versionData: {
- processDefinition: {
- id: null,
- version: '',
- releaseState: ''
- },
- processDefinitionVersions: [],
- total: null,
- pageNo: null,
- pageSize: null
- },
- drawer: false,
- nodeData: {
- id: null,
- taskType: '',
- self: {},
- preNode: [],
- rearList: [],
- instanceId: null
- },
- nodeDrawer: false,
- lineData: {
- id: null,
- sourceId: '',
- targetId: ''
- },
- lineDrawer: false,
- udpDrawer: false,
- dialogVisible: false,
- startDialog: false,
- startData: {},
- startNodeList: '',
- sourceType: ''
+ dagChart: this
}
},
- mixins: [disabledState],
props: {
type: String,
releaseState: String
},
- methods: {
- ...mapActions('dag', ['saveDAGchart', 'updateInstance',
'updateDefinition', 'getTaskState', 'switchProcessDefinitionVersion',
'getProcessDefinitionVersionsPage', 'deleteProcessDefinitionVersion']),
- ...mapMutations('dag', ['addTasks', 'cacheTasks', 'resetParams',
'setIsEditDag', 'setName', 'addConnects', 'resetLocalParam']),
- startRunning (item, startNodeList, sourceType) {
- this.startData = item
- this.startNodeList = startNodeList
- this.sourceType = sourceType
- this.startDialog = true
- },
- onUpdateStart () {
- this.startDialog = false
- },
- closeStart () {
- this.startDialog = false
- },
- // DAG automatic layout
- dagAutomaticLayout () {
- if (this.store.state.dag.isEditDag) {
- this.$message.warning(`${i18n.$t('Please save the DAG before
formatting')}`)
- return false
- }
- $('#canvas').html('')
+ data () {
+ return {
+ // full screen mode
+ fullScreen: false,
+ // task config drawer
+ taskDrawer: false,
+ nodeData: { ...DEFAULT_NODE_DATA },
+ saveDialog: false,
+ isLoading: false,
+ definitionCode: 0,
+ startDialog: false,
+ startTaskName: ''
+ }
+ },
+ mounted () {
+ // TODO
+ window._debug = this
- // Destroy round robin
- Dag.init({
- dag: this,
- instance: jsPlumb.getInstance({
- Endpoint: [
- 'Dot', { radius: 1, cssClass: 'dot-style' }
- ],
- Connector: 'Bezier',
- PaintStyle: { lineWidth: 2, stroke: '#456' }, // Connection style
- ConnectionOverlays: [
- [
- 'Arrow',
- {
- location: 1,
- id: 'arrow',
- length: 12,
- foldback: 0.8
- }
- ],
- ['Label', {
- location: 0.5,
- id: 'label'
- }]
- ],
- Container: 'canvas',
- ConnectionsDetachable: true
- })
- })
- if (this.tasks.length) {
- Dag.backfill(true)
- if (this.type === 'instance') {
- this._getTaskState(false).then(res => {})
- }
- } else {
- Dag.create()
- }
- },
+ if (this.type === 'instance') {
+ this.definitionCode = this.$route.query.id
+ } else if (this.type === 'definition') {
+ this.definitionCode = this.$route.params.code
+ }
- init (args) {
- if (this.tasks.length) {
- Dag.backfill(args)
- // Process instances can view status
- if (this.type === 'instance') {
- this._getTaskState(false).then(res => {})
- // Round robin acquisition status
- this.setIntervalP = setInterval(() => {
- this._getTaskState(true).then(res => {})
- }, 90000)
- }
- } else {
- Dag.create()
- }
- },
+ this.resizeDebounceFunc = debounce(this.canvasResize, 200)
+ window.addEventListener('resize', this.resizeDebounceFunc)
+ this.$refs.canvas.graphInit(!this.isDetails)
+
+ this.backfill()
+ },
+ unmounted () {
+ window.removeEventListener('resize', this.resizeDebounceFunc)
+ },
+ computed: {
+ ...mapState('dag', [
+ 'tasks',
+ 'locations',
+ 'connects',
+ 'isEditDag',
+ 'name',
+ 'isDetails',
+ 'projectCode'
+ ])
+ },
+ methods: {
+ ...mapActions('dag', [
+ 'saveDAGchart',
+ 'updateInstance',
+ 'updateDefinition',
+ 'getTaskState',
+ 'getStartCheck',
+ 'genTaskCodeList',
+ 'switchProcessDefinitionVersion',
+ 'getProcessDefinitionVersionsPage',
+ 'deleteProcessDefinitionVersion'
+ ]),
+ ...mapMutations('dag', [
+ 'addTask',
+ 'setTasks',
+ 'setConnects',
+ 'resetParams',
+ 'setIsEditDag',
+ 'setName',
+ 'setLocations',
+ 'resetLocalParam'
+ ]),
/**
- * copy name
+ * Toggle full screen
*/
- _copyName () {
- let clipboard = new Clipboard('.copy-name')
- clipboard.on('success', e => {
- this.$message.success(`${i18n.$t('Copy success')}`)
- // Free memory
- clipboard.destroy()
- })
- clipboard.on('error', e => {
- // Copy is not supported
- this.$message.warning(`${i18n.$t('The browser does not support
automatic copying')}`)
- // Free memory
- clipboard.destroy()
- })
+ canvasResize () {
+ const canvas = this.$refs.canvas
+ canvas && canvas.paperResize()
+ },
+ toggleFullScreen () {
+ this.fullScreen = !this.fullScreen
+ this.$nextTick(this.canvasResize)
},
/**
- * Get state interface
- * @param isReset Whether to manually refresh
+ * Task Drawer
+ * @param {boolean} visible
*/
- _getTaskState (isReset) {
- return new Promise((resolve, reject) => {
- this.getTaskState(this.urlParam.id).then(res => {
- let data = res.list
- let state = res.processInstanceState
- let taskList = res.taskList
- let idArr = allNodesId()
- const titleTpl = (item, desc) => {
- let $item = _.filter(taskList, v => v.name === item.name)[0]
- return `<div style="text-align:
left">${i18n.$t('Name')}:${$item.name}</br>${i18n.$t('State')}:${desc}</br>${i18n.$t('type')}:${$item.taskType}</br>${i18n.$t('host')}:${$item.host
|| '-'}</br>${i18n.$t('Retry
Count')}:${$item.retryTimes}</br>${i18n.$t('Submit
Time')}:${formatDate($item.submitTime)}</br>${i18n.$t('Start
Time')}:${formatDate($item.startTime)}</br>${i18n.$t('End
Time')}:${$item.endTime ? formatDate($item.endTime) : '-'}</br></div>`
- }
-
- // remove tip state dom
- $('.w').find('.state-p').html('')
- const newTask = []
- data.forEach(v1 => {
- idArr.forEach(v2 => {
- if (v2.name === v1.name) {
- let dom = $(`#${v2.id}`)
- let state = dom.find('.state-p')
- let depState = ''
- taskList.forEach(item => {
- if (item.name === v1.name) {
- depState = item.state
- const params = item.taskJson ?
JSON.parse(item.taskJson).params : ''
- let localParam = params.localParams || []
- newTask.push({
- id: v2.id,
- localParam
- })
- }
- })
- dom.attr('data-state-id', v1.stateId)
- dom.attr('data-dependent-result', v1.dependentResult || '')
- dom.attr('data-dependent-depState', depState)
- state.append(`<strong class="${v1.icoUnicode} ${v1.isSpin ?
'as as-spin' : ''}" style="color:${v1.color}" data-toggle="tooltip"
data-html="true" data-container="body"></strong>`)
- state.find('strong').attr('title', titleTpl(v2, v1.desc))
- }
- })
- })
- if (state === 'PAUSE' || state === 'STOP' || state === 'FAILURE'
|| this.state === 'SUCCESS') {
- // Manual refresh does not regain large json
- if (isReset) {
- findComponentDownward(this.$root,
`${this.type}-details`)._reset()
- }
- }
- if (!isReset) {
- this.resetLocalParam(newTask)
- }
- resolve()
- })
- })
+ toggleTaskDrawer (visible) {
+ this.taskDrawer = visible
},
/**
- * Get the action bar id
- * @param item
+ * Set the current node data
*/
- _getDagId (v) {
- // if (this.isDetails) {
- // return
- // }
- this.dagBarId = v
+ setNodeData (nodeData) {
+ this.nodeData = Object.assign(DEFAULT_NODE_DATA, nodeData)
},
/**
- * operating
+ * open form model
+ * @desc Edit task config
+ * @param {number} taskCode
+ * @param {string} taskType
*/
- _ckOperation (item) {
- let is = true
- let code = ''
-
- if (item.disable) {
- return
- }
-
- if (this.toolOperCode === item.code) {
- this.toolOperCode = ''
- code = item.code
- is = false
- } else {
- this.toolOperCode = item.code
- code = this.toolOperCode
- is = true
- }
-
- // event type
- Dag.toolbarEvent({
- item: item,
- code: code,
- is: is
+ openFormModel (taskCode, taskType) {
+ this.setNodeData({
+ id: taskCode,
+ taskType: taskType
})
+ this.toggleTaskDrawer(true)
+ },
+ addTaskInfo ({ item, fromThis }) {
+ this.addTask(item)
+ this.$refs.canvas.setNodeName(item.code, item.name)
+ this.taskDrawer = false
},
- _operationClass (item) {
- return this.toolOperCode === item.code ? 'active' : ''
- // if (item.disable) {
- // return this.toolOperCode === item.code ? 'active' : ''
- // } else {
- // return 'disable'
- // }
+ closeTaskDrawer ({ item, flag, fromThis }) {
+ if (flag) {
+ const canvas = this.$refs.canvas
+ canvas.removeNode(this.nodeData.id)
+ }
+ this.taskDrawer = false
},
/**
- * Storage interface
+ * Save dialog
*/
- _save (sourceType) {
+ toggleSaveDialog (value) {
+ this.saveDialog = value
+ },
+ onSave (sourceType) {
+ this.toggleSaveDialog(false)
return new Promise((resolve, reject) => {
- this.spinnerLoading = true
- // Storage store
- Dag.saveStore().then(res => {
- if (this._verifConditions(res.tasks)) {
- if (this.urlParam.id) {
- /**
- * Edit
- * @param saveInstanceEditDAGChart => Process instance editing
- * @param saveEditDAGChart => Process definition editing
- */
- this[this.type === 'instance' ? 'updateInstance' :
'updateDefinition'](this.urlParam.id).then(res => {
+ this.isLoading = true
+
+ let tasks = this.tasks || []
+ const edges = this.$refs.canvas.getEdges()
+ const nodes = this.$refs.canvas.getNodes()
+
+ const connects = this.buildConnects(edges, tasks)
+
+ this.setConnects(connects)
+
+ const locations = nodes.map(node => {
+ return {
+ taskCode: node.id,
+ x: node.position.x,
+ y: node.position.y
+ }
+ })
+
+ this.setLocations(locations)
+
+ resolve({
+ connects: connects,
+ tasks: tasks,
+ locations: locations
+ })
+ }).then((res) => {
+ if (this._verifConditions(res.tasks)) {
+ const definitionCode = this.definitionCode
+ if (definitionCode) {
+ /**
+ * Edit
+ * @param saveInstanceEditDAGChart => Process instance editing
+ * @param saveEditDAGChart => Process definition editing
+ */
+ return this[
+ this.type === 'instance' ? 'updateInstance' :
'updateDefinition'
+ ](definitionCode)
+ .then((res) => {
// this.$message.success(res.msg)
this.$message({
message: res.msg,
type: 'success',
offset: 80
})
- this.spinnerLoading = false
+ this.isLoading = false
// Jump process definition
if (this.type === 'instance') {
- this.$router.push({ path:
`/projects/${this.projectId}/instance/list/${this.urlParam.id}` })
+ this.$router.push({
+ path:
`/projects/${this.projectCode}/instance/list/${definitionCode}`
+ })
} else {
- this.$router.push({ path:
`/projects/${this.projectId}/definition/list/${this.urlParam.id}` })
+ this.$router.push({
+ path:
`/projects/${this.projectCode}/definition/list/${definitionCode}`
+ })
}
- resolve()
- }).catch(e => {
+ })
+ .catch((e) => {
this.$message.error(e.msg || '')
- this.spinnerLoading = false
- reject(e)
+ this.isLoading = false
})
- } else {
- // New
- this.saveDAGchart().then(res => {
+ } else {
+ // New
+ return this.saveDAGchart()
+ .then((res) => {
this.$message.success(res.msg)
- this.spinnerLoading = false
+ this.isLoading = false
// source
@/conf/home/pages/dag/_source/editAffirmModel/index.js
if (sourceType !== 'affirm') {
// Jump process definition
this.$router.push({ name: 'projects-definition-list' })
}
- resolve()
- }).catch(e => {
+ })
+ .catch((e) => {
this.$message.error(e.msg || '')
this.setName('')
- this.spinnerLoading = false
- reject(e)
+ this.isLoading = false
})
- }
}
- })
+ }
})
},
- _closeDAG () {
- let $name = this.$route.name
- if ($name && $name.indexOf('definition') !== -1) {
- this.$router.push({ name: 'projects-definition-list' })
- } else {
- this.$router.push({ name: 'projects-instance-list' })
- }
- },
_verifConditions (value) {
let tasks = value
let bool = true
- tasks.map(v => {
- if (v.type === 'CONDITIONS' && (v.conditionResult.successNode[0] ===
'' || v.conditionResult.successNode[0] === null ||
v.conditionResult.failedNode[0] === '' || v.conditionResult.failedNode[0] ===
null)) {
+ tasks.map((v) => {
+ if (
+ v.taskType === 'CONDITIONS' &&
+ (v.taskParams.conditionResult.successNode[0] === '' ||
+ v.taskParams.conditionResult.successNode[0] === null ||
+ v.taskParams.conditionResult.failedNode[0] === '' ||
+ v.taskParams.conditionResult.failedNode[0] === null)
+ ) {
bool = false
return false
}
})
if (!bool) {
- this.$message.warning(`${i18n.$t('Successful branch flow and failed
branch flow are required')}`)
- this.spinnerLoading = false
+ this.$message.warning(
+ `${this.$t(
+ 'Successful branch flow and failed branch flow are required'
+ )}`
+ )
+ this.isLoading = false
return false
}
return true
},
- onUdpDialog () {
- this._save()
- this.dialogVisible = false
- },
- closeDialog () {
- this.dialogVisible = false
+ cancelSave () {
+ this.toggleSaveDialog(false)
},
/**
- * Save chart
+ * build graph json
*/
- _saveChart () {
- // Verify node
- if (!this.tasks.length) {
- this.$message.warning(`${i18n.$t('Failed to create node to save')}`)
- return
- }
-
- this.dialogVisible = true
- this.$nextTick(() => {
- this.$refs.mUdp.reloadParam()
+ buildGraphJSON (tasks, locations, connects) {
+ const nodes = []
+ const edges = []
+ tasks.forEach((task) => {
+ const location = locations.find(l => l.taskCode === task.code) || {}
+ const node = this.$refs.canvas.genNodeJSON(
+ task.code,
+ task.taskType,
+ task.name,
+ {
+ x: location.x,
+ y: location.y
+ }
+ )
+ nodes.push(node)
+ })
+ connects.filter(r => !!r.preTaskCode).forEach((c) => {
+ const edge = this.$refs.canvas.genEdgeJSON(
+ c.preTaskCode,
+ c.postTaskCode,
+ c.name
+ )
+ edges.push(edge)
})
+ return {
+ nodes,
+ edges
+ }
},
/**
- * Return to the previous child node
+ * Build connects by edges and tasks
+ * @param {Edge[]} edges
+ * @param {Task[]} tasks
+ * @returns
*/
- _rtNodesDag () {
- let getIds = this.$route.query.subProcessIds
- let idsArr = getIds.split(',')
- let ids = idsArr.slice(0, idsArr.length - 1)
- let id = idsArr[idsArr.length - 1]
- let query = {}
+ buildConnects (edges, tasks) {
+ const preTaskMap = {}
+ const tasksMap = {}
- if (id !== idsArr[0]) {
- query = { subProcessIds: ids.join(',') }
- }
- let $name = this.$route.name.split('-')
- this.$router.push({ path: `/${$name[0]}/${$name[1]}/list/${id}`,
query: query })
+ edges.forEach((edge) => {
+ preTaskMap[edge.targetId] = {
+ sourceId: edge.sourceId,
+ edgeLabel: edge.label || ''
+ }
+ })
+ tasks.forEach(task => {
+ tasksMap[task.code] = task
+ })
+
+ return tasks.map(task => {
+ const preTask = preTaskMap[task.code]
+ return {
+ name: preTask ? preTask.edgeLabel : '',
+ preTaskCode: preTask ? preTask.sourceId : 0,
+ preTaskVersion: preTask ? tasksMap[preTask.sourceId].version : 0,
+ postTaskCode: task.code,
+ postTaskVersion: tasksMap[task.code].version || 0,
+ conditionType: 0,
+ conditionParams: {}
Review comment:
Thank you for your review!
``conditionType`` and ``conditionParams`` are reserved fields and have no
practical meaning at present.
The parameters of the CONDITIONS task are passed in taskDefinitionJson:
```
[{
"code": 703646130176,
"name": "test",
"description": "",
"taskType": "CONDITIONS",
"taskParams": {
"conditionResult": {
"successNode": [
"shell-1"
],
"failedNode": [
"shell-2"
]
}
},
"flag": "YES",
"taskPriority": "MEDIUM",
"workerGroup": "default",
"failRetryTimes": "0",
"failRetryInterval": "1",
"timeoutFlag": "CLOSE",
"timeoutNotifyStrategy": "",
"timeout": 0,
"delayTime": "0"
}, ... ]
```
I will add a comment here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]