Browse Source
* [Feature][UI] Create a dynamic task component canvas. * [Feature][UI] Create a dynamic task component canvas. * [Feature][UI] Create a dynamic task component canvas. * [Feature][UI] Create a dynamic task component canvas. * [Feature][UI] Create a dynamic task component canvas.3.2.0-release
19 changed files with 593 additions and 10 deletions
@ -0,0 +1,34 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
.container { |
||||
height: 100%; |
||||
width: 100%; |
||||
} |
||||
|
||||
.dag-container { |
||||
height: 100%; |
||||
width: 100%; |
||||
} |
||||
|
||||
.minimap { |
||||
position: absolute; |
||||
right: 20px; |
||||
bottom: 20px; |
||||
border: dashed 1px #e4e4e4; |
||||
z-index: 9000; |
||||
} |
@ -0,0 +1,96 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { defineComponent, ref, onMounted } from 'vue' |
||||
import { Graph } from '@antv/x6' |
||||
import { useDagResize } from './use-dag-resize' |
||||
import { useDagGraph } from './use-dag-graph' |
||||
import { useDagNode } from './use-dag-node' |
||||
import { useDagEdge } from './use-dag-edge' |
||||
import { DagNodeName, DagEdgeName } from './dag-setting' |
||||
import styles from './dag-canvas.module.scss' |
||||
|
||||
const DagCanvas = defineComponent({ |
||||
name: 'DagCanvas', |
||||
emits: ['drop'], |
||||
setup(props, context) { |
||||
const container = ref() |
||||
const dagContainer = ref() |
||||
const minimapContainer = ref() |
||||
const graph = ref<Graph>() |
||||
|
||||
if (graph.value) { |
||||
useDagResize(dagContainer.value, graph.value) |
||||
} |
||||
|
||||
const initGraph = () => { |
||||
graph.value = useDagGraph(container.value, minimapContainer.value) |
||||
} |
||||
|
||||
const registerNode = () => { |
||||
Graph.unregisterNode(DagNodeName) |
||||
Graph.registerNode(DagNodeName, useDagNode()) |
||||
} |
||||
|
||||
const registerEdge = () => { |
||||
Graph.unregisterEdge(DagEdgeName) |
||||
Graph.registerEdge( |
||||
DagEdgeName, |
||||
useDagEdge(), |
||||
true |
||||
) |
||||
} |
||||
|
||||
const handlePreventDefault = (e: DragEvent) => { |
||||
e.preventDefault() |
||||
} |
||||
|
||||
const handleDrop = (e: DragEvent) => { |
||||
context.emit('drop', e) |
||||
} |
||||
|
||||
onMounted(() => { |
||||
initGraph() |
||||
registerNode() |
||||
registerEdge() |
||||
}) |
||||
|
||||
return { |
||||
container, |
||||
'dag-container': dagContainer, |
||||
minimapContainer, |
||||
handlePreventDefault, |
||||
handleDrop |
||||
} |
||||
}, |
||||
render() { |
||||
return( |
||||
<> |
||||
<div ref='container' class={styles.container} |
||||
onDrop={this.handleDrop} |
||||
onDragenter={this.handlePreventDefault} |
||||
onDragover={this.handlePreventDefault} |
||||
onDragleave={this.handlePreventDefault}> |
||||
<div ref='dag-container' class={styles['dag-container']}/> |
||||
</div> |
||||
<div ref='minimapContainer' class={styles.minimap}/> |
||||
</> |
||||
) |
||||
} |
||||
}) |
||||
|
||||
export { DagCanvas } |
@ -0,0 +1,23 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
.dag-node { |
||||
cursor: pointer; |
||||
height: 20px; |
||||
width: 100px; |
||||
border: 1px solid #1890ff; |
||||
} |
@ -0,0 +1,33 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { defineComponent } from 'vue' |
||||
import styles from './dag-node.module.scss' |
||||
|
||||
const DagNode = defineComponent({ |
||||
name: 'DagNode', |
||||
setup() { |
||||
|
||||
}, |
||||
render() { |
||||
return ( |
||||
<div class={styles['dag-node']}>1111</div> |
||||
) |
||||
} |
||||
}) |
||||
|
||||
export { DagNode } |
@ -0,0 +1,21 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
export const DagNodeName = 'dag-node' |
||||
export const DagEdgeName = 'dag-edge' |
||||
export const NodeWidth = '200' |
||||
export const NodeHeight = '50' |
@ -0,0 +1,23 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
.task-item { |
||||
cursor: pointer; |
||||
height: 20px; |
||||
width: 100px; |
||||
border: 1px solid #1890ff; |
||||
} |
@ -0,0 +1,58 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { defineComponent, onMounted, toRefs } from 'vue' |
||||
import { useSidebar } from './use-sidebar' |
||||
import styles from './dag-sidebar.module.scss' |
||||
|
||||
const DagSidebar = defineComponent({ |
||||
name: 'DagSidebar', |
||||
emits: ['Dragend'], |
||||
setup(props, context) { |
||||
const { variables, getTaskList } = useSidebar() |
||||
|
||||
const handleDragend = (e: DragEvent, task: any) => { |
||||
context.emit('Dragend', e, task) |
||||
} |
||||
|
||||
onMounted(() => { |
||||
getTaskList() |
||||
}) |
||||
|
||||
return { |
||||
...toRefs(variables), |
||||
handleDragend |
||||
} |
||||
}, |
||||
render() { |
||||
return ( |
||||
<div> |
||||
{ |
||||
this.taskList.map(task => { |
||||
return ( |
||||
<div class={styles['task-item']} draggable='true' onDragend={(e: DragEvent) => this.handleDragend(e, task)}> |
||||
{task} |
||||
</div> |
||||
) |
||||
}) |
||||
} |
||||
</div> |
||||
) |
||||
} |
||||
}) |
||||
|
||||
export { DagSidebar } |
@ -0,0 +1,21 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
.workflow-dag { |
||||
display: flex; |
||||
height: 100%; |
||||
} |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { defineComponent } from 'vue' |
||||
import { DagSidebar } from './dag-sidebar' |
||||
import { DagCanvas } from './dag-canvas' |
||||
import styles from './index.module.scss' |
||||
|
||||
const DynamicDag = defineComponent({ |
||||
name: 'DynamicDag', |
||||
setup() { |
||||
const handelDragend = () => { |
||||
//console.log(e, task)
|
||||
//if (readonly.value) {
|
||||
// e.preventDefault()
|
||||
// return
|
||||
//}
|
||||
//dragged.value = {
|
||||
// x: e.offsetX,
|
||||
// y: e.offsetY,
|
||||
// type: task
|
||||
//}
|
||||
} |
||||
|
||||
return { |
||||
handelDragend |
||||
} |
||||
}, |
||||
render() { |
||||
return ( |
||||
<div class={styles['workflow-dag']}> |
||||
<DagSidebar onDragend={this.handelDragend} /> |
||||
<DagCanvas /> |
||||
</div> |
||||
) |
||||
} |
||||
}) |
||||
|
||||
export { DynamicDag } |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
export function useDagEdge() { |
||||
return { |
||||
attrs: { |
||||
line: { |
||||
stroke: '#666', |
||||
strokeWidth: 0.5 |
||||
} |
||||
}, |
||||
router: { |
||||
name: 'orth' |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { Graph } from '@antv/x6' |
||||
|
||||
export function useDagGraph(container: any, minimapContainer: any) { |
||||
return new Graph({ |
||||
container, |
||||
scroller: true, |
||||
grid: { |
||||
size: 10, |
||||
visible: true |
||||
}, |
||||
minimap: { |
||||
enabled: true, |
||||
width: 200, |
||||
height: 120, |
||||
container: minimapContainer |
||||
} |
||||
}) |
||||
} |
@ -0,0 +1,22 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
export function useDagNode() { |
||||
return { |
||||
inherit: 'rect' |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { debounce } from 'lodash' |
||||
import { useResizeObserver } from '@vueuse/core' |
||||
import { Graph } from '@antv/x6' |
||||
|
||||
export function useDagResize(dagContainer: any, graph: Graph) { |
||||
const resize = debounce(() => { |
||||
if (dagContainer) { |
||||
const w = dagContainer.offsetWidth |
||||
const h = dagContainer.offsetHeight |
||||
graph.resize(w, h) |
||||
} |
||||
}, 200) |
||||
|
||||
useResizeObserver(dagContainer, resize) |
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
import { reactive } from 'vue' |
||||
|
||||
export function useSidebar() { |
||||
const variables = reactive({ |
||||
taskList: [] |
||||
}) |
||||
|
||||
const getTaskList = () => { |
||||
variables.taskList = ['shell'] as any |
||||
} |
||||
|
||||
return { variables, getTaskList } |
||||
} |
@ -0,0 +1,40 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
export const useTaskForm = { |
||||
locales: { |
||||
zh_CN: { |
||||
node_name: '节点名称', |
||||
node_name_tips: '节点名称不能为空' |
||||
}, |
||||
en_US: { |
||||
node_name: 'Node Name', |
||||
node_name_tips: 'Node name cannot be empty' |
||||
} |
||||
}, |
||||
items: [ |
||||
{ |
||||
label: 'node_name', |
||||
type: 'input', |
||||
field: '', |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
message: 'node_name_tips' |
||||
} |
||||
} |
||||
] |
||||
} |
Loading…
Reference in new issue