@@ -180,9 +206,11 @@ const delNode = id => {
class="my-diagram-class"
@dragover="onDragOver"
@dragleave="onDragLeave"
+ @paneScroll="handleZommOnScroll"
>
-
+
+
diff --git a/src/views/createapp/components/workFlowConfig/useLayout.js b/src/views/createapp/components/workFlowConfig/useLayout.js
new file mode 100644
index 0000000000000000000000000000000000000000..1dd933ac0d73c746995c96fa9f3346ace6f44e19
--- /dev/null
+++ b/src/views/createapp/components/workFlowConfig/useLayout.js
@@ -0,0 +1,62 @@
+import dagre from '@dagrejs/dagre';
+import { Position, useVueFlow } from '@vue-flow/core';
+import { ref } from 'vue';
+
+/**
+ * Composable to run the layout algorithm on the graph.
+ * It uses the `dagre` library to calculate the layout of the nodes and edges.
+ *
+ * @see https://github.com/dagrejs/dagre/wiki
+ */
+export function useLayout() {
+ const { findNode } = useVueFlow();
+
+ const graph = ref(new dagre.graphlib.Graph());
+
+ function layout(nodes, edges, direction) {
+ // we create a new graph instance, in case some nodes/edges were removed, otherwise dagre would act as if they were still there
+ const dagreGraph = new dagre.graphlib.Graph();
+
+ graph.value = dagreGraph;
+
+ dagreGraph.setDefaultEdgeLabel(() => ({}));
+
+ const isHorizontal = direction === 'LR';
+ dagreGraph.setGraph({ rankdir: direction });
+
+ for (const node of nodes) {
+ // if you need width+height of nodes for your layout, you can use the dimensions property of the internal node (`GraphNode` type)
+ const graphNode = findNode(node.id);
+
+ if (!graphNode) {
+ console.error(`Node with id ${node.id} not found in the graph`);
+ continue;
+ }
+
+ dagreGraph.setNode(node.id, {
+ width: graphNode.dimensions.width || 150,
+ height: graphNode.dimensions.height || 50,
+ });
+ }
+
+ for (const edge of edges) {
+ dagreGraph.setEdge(edge.source, edge.target);
+ }
+
+ dagre.layout(dagreGraph);
+
+ // set nodes with updated positions
+ return nodes.map(node => {
+ const nodeWithPosition = dagreGraph.node(node.id);
+
+ return {
+ ...node,
+ targetPosition: isHorizontal ? Position.Left : Position.Top,
+ sourcePosition: isHorizontal ? Position.Right : Position.Bottom,
+ position: { x: nodeWithPosition.x, y: nodeWithPosition.y },
+ };
+ });
+ }
+
+ return { graph, layout };
+}
diff --git a/src/views/createapp/components/workFlowStyle.scss b/src/views/createapp/components/workFlowStyle.scss
index 4a5e3afdb6b962a0987e2e8350374758329508b4..258318f5b3321109f8a89a379d2b9442ff3fc6fd 100644
--- a/src/views/createapp/components/workFlowStyle.scss
+++ b/src/views/createapp/components/workFlowStyle.scss
@@ -129,6 +129,20 @@
.vue-flow__minimap {
transform-origin: bottom right;
background-color: var(--o-bg-color-base);
+ bottom: 57px;
+ margin-left: 24px;
+ border-radius: 8px;
+ width: 144px;
+ height: 96px;
+ svg {
+ width: 144px;
+ height: 96px;
+ border-radius: 8px;
+ path {
+ padding: 10px;
+ height: 100px !important;
+ }
+ }
}
.vue-flow__panel.right {