Wangyizhi1 commented on a change in pull request #6239: URL: https://github.com/apache/dolphinscheduler/pull/6239#discussion_r716386432
########## File path: dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/taskTable.vue ########## @@ -0,0 +1,905 @@ +/* + * 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. + */ +<template> + <div class="dag-canvas"> + <dag-taskbar @on-drag-start="onDragStart" /> + <div + class="dag-container" + ref="container" + @dragenter.prevent + @dragover.prevent + @dragleave.prevent + @drop.stop.prevent="onDrop" + > + <div ref="paper" class="paper"></div> + <div ref="minimap" class="minimap" style="opacity: 0"></div> + <context-menu ref="contextMenu" /> + </div> + </div> +</template> + +<script> + import _ from 'lodash' + import { Graph, DataUri } from '@antv/x6' + import dagTaskbar from './taskbar.vue' + import contextMenu from './contextMenu.vue' + import { + NODE_PROPS, + EDGE_PROPS, + PORT_PROPS, + X6_NODE_NAME, + X6_PORT_OUT_NAME, + X6_PORT_IN_NAME, + X6_EDGE_NAME, + NODE_HIGHLIGHT_PROPS, + PORT_HIGHLIGHT_PROPS, + EDGE_HIGHLIGHT_PROPS, + NODE_STATUS_MARKUP + } from './x6-helper' + import { DagreLayout } from '@antv/layout' + import { tasksType, tasksState } from '../config' + import { mapActions, mapMutations, mapState } from 'vuex' + import nodeStatus from './nodeStatus' + + export default { + name: 'dag-canvas', + data () { + return { + graph: null, + // Used to calculate the context menu location + originalScrollPosition: { + left: 0, + top: 0 + }, + editable: true, + dragging: { + // Distance from the mouse to the top-left corner of the dragging element + x: 0, + y: 0, + type: '' + } + } + }, + provide () { + return { + dagCanvas: this + } + }, + inject: ['dagChart'], + components: { + dagTaskbar, + contextMenu + }, + computed: { + ...mapState('dag', [ + 'tasks' + ]) + }, + mounted () { + this.$nextTick(() => { + document.querySelector('.x6-graph-scroller').style.opacity = 0 + const div = document.createElement('div') + div.className = 'task-table' + div.style.cssText = 'position: absolute; top: 0; bottom: 0; left: 0; right: 0' + const targetDiv = document.querySelector('.dag-container') + targetDiv.appendChild(div) + }) + }, + methods: { + ...mapActions('dag', ['genTaskCodeList']), + ...mapMutations('dag', ['removeTask']), + /** + * Recalculate the paper width and height + */ + paperResize () { + const w = this.$el.offsetWidth + const h = this.$el.offsetHeight + this.graph.resize(w, h) + }, + /** + * Init graph + * This will be called in the dag-chart mounted event + * @param {boolean} uneditable + */ + graphInit (editable) { + const self = this Review comment: Does this page need an ``@antv/x6`` graph? I think most of the code in this file is useless, such as: ``graphInit``, ``registerX6Shape``,``bindGraphEvent``, ``downloadPNG`` and so on... ---- 创建任务定义应该不需要使用DAG吧?所以我理解是不是大部分和图表相关的方法都可以删除? 这里基于``dag/_source/canvas/canvas.vue``修改反而复杂,为何不重新写一个呢? -- 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]
