Skip to content

Commit

Permalink
feat: fix intersecting node error
Browse files Browse the repository at this point in the history
  • Loading branch information
FacerAin committed Aug 4, 2023
1 parent 3172c1f commit ee41d45
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 17 deletions.
14 changes: 12 additions & 2 deletions src/components/aws/ALB.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -14,10 +15,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/AutoScalingGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -14,10 +15,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/EC2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -19,10 +20,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/NATGateway.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -14,10 +15,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/PrivateSubnet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -19,10 +20,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/PublicSubnet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -19,10 +20,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
3 changes: 1 addition & 2 deletions src/components/aws/ResourceNodeCommon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useNode, useVueFlow } from '@vue-flow/core';
const { node } = useNode();
const { removeNodes, getIntersectingNodes, onNodeDragStop, findNode } =
useVueFlow();
const { removeNodes } = useVueFlow();
/**
* 삭제 버튼 클릭 핸들러
Expand Down
14 changes: 12 additions & 2 deletions src/components/aws/SecurityGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ResourceNodeCommon from './ResourceNodeCommon.vue';
import { useVueFlow, useNode } from '@vue-flow/core';
const { getIntersectingNodes, findNode, onNodeDragStop } = useVueFlow();
const { getIntersectingNodes, findNode, onNodeDragStop, updateNodeInternals } =
useVueFlow();
const { node } = useNode();
onNodeDragStop((nodeDragEvent) => {
Expand All @@ -17,10 +18,19 @@ onNodeDragStop((nodeDragEvent) => {
.map((e) => e);
const parentId = filteredNodes[filteredNodes.length - 1]?.id;
const parentNode = findNode(parentId);
if (parentId && findNode(parentId).parentNode != node.id) {
if (parentId && parentNode.parentNode != node.id) {
//노드에 새로운 부모 노드가 생겼을 때 좌표 값이 부모 노드 기준으로 바뀌는 현상 보정
if (!node.parentNode) {
node.position = {
x: node.position.x - parentNode.position.x,
y: node.position.y - parentNode.position.y,
};
}
node.parentNode = parentId;
node.expandParent = true;
updateNodeInternals([node.id]);
}
}
});
Expand Down
1 change: 0 additions & 1 deletion src/components/node/NodePlane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function onDragOver(event) {
event.dataTransfer.dropEffect = 'move';
}
}
onConnect((params) => addEdges(params));
function onDrop(event) {
Expand Down

0 comments on commit ee41d45

Please sign in to comment.