Skip to content

Commit cb6f82f

Browse files
Merge pull request #332 from boostcampwm-2024/bug-fe-#331
노드맵 초기화 로직 초기화
2 parents 40dff0e + 485beca commit cb6f82f

File tree

7 files changed

+110
-288
lines changed

7 files changed

+110
-288
lines changed

apps/backend/src/app.module.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,15 @@ import { AuthModule } from './auth/auth.module';
2020
import { UserModule } from './user/user.module';
2121
import { WorkspaceModule } from './workspace/workspace.module';
2222
import { RoleModule } from './role/role.module';
23-
import { RedisService } from './redis/redis.service';
24-
import { RedisModule } from './redis/redis.module';
25-
import { ScheduleModule } from '@nestjs/schedule';
26-
import { TasksService } from './tasks/tasks.service';
2723

2824
@Module({
2925
imports: [
30-
ScheduleModule.forRoot(),
3126
ServeStaticModule.forRoot({
3227
rootPath: path.join(__dirname, '..', '..', 'frontend', 'dist'),
3328
}),
3429
ConfigModule.forRoot({
3530
isGlobal: true,
36-
envFilePath: '/app/.env', // * docker 내부 디렉터리 기준
31+
envFilePath: path.join(__dirname, '..', '.env'), // * nest 디렉터리 기준
3732
}),
3833
TypeOrmModule.forRootAsync({
3934
imports: [ConfigModule],
@@ -61,9 +56,8 @@ import { TasksService } from './tasks/tasks.service';
6156
UserModule,
6257
WorkspaceModule,
6358
RoleModule,
64-
RedisModule,
6559
],
6660
controllers: [AppController],
67-
providers: [AppService, RedisService, TasksService],
61+
providers: [AppService],
6862
})
6963
export class AppModule {}

apps/frontend/src/features/canvas/model/calculateHandles.ts

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,34 @@
1-
import { Position, Node, XYPosition } from "@xyflow/react";
1+
import { Position, Node } from "@xyflow/react";
22

3-
const getAbsolutePosition = (node: Node, nodes: Node[]): XYPosition => {
4-
if (!node.parentId) {
5-
return node.position;
6-
}
7-
8-
const parentNode = nodes.find((n) => n.id === node.parentId);
9-
if (!parentNode) {
10-
return node.position;
11-
}
12-
13-
const parentPosition: XYPosition = getAbsolutePosition(parentNode, nodes);
14-
return {
15-
x: parentPosition.x + node.position.x,
16-
y: parentPosition.y + node.position.y,
17-
};
18-
};
19-
20-
export const getHandlePosition = (
21-
node: Node,
22-
handleId: Position,
23-
nodes: Node[],
24-
) => {
3+
export const getHandlePosition = (node: Node, handleId: Position) => {
254
const nodeElement = document.querySelector(`[data-id="${node.id}"]`);
265
const nodeRect = nodeElement!.getBoundingClientRect();
276
const nodeWidth = nodeRect.width;
287
const nodeHeight = nodeRect.height;
298

30-
const absolutePosition = getAbsolutePosition(node, nodes);
31-
329
const positions = {
3310
[Position.Left]: {
34-
x: absolutePosition.x,
35-
y: absolutePosition.y + nodeHeight / 2,
11+
x: node.position.x,
12+
y: node.position.y + nodeHeight / 2,
3613
},
3714
[Position.Right]: {
38-
x: absolutePosition.x + nodeWidth,
39-
y: absolutePosition.y + nodeHeight / 2,
15+
x: node.position.x + nodeWidth,
16+
y: node.position.y + nodeHeight / 2,
4017
},
4118
[Position.Top]: {
42-
x: absolutePosition.x + nodeWidth / 2,
43-
y: absolutePosition.y,
19+
x: node.position.x + nodeWidth / 2,
20+
y: node.position.y,
4421
},
4522
[Position.Bottom]: {
46-
x: absolutePosition.x + nodeWidth / 2,
47-
y: absolutePosition.y + nodeHeight,
23+
x: node.position.x + nodeWidth / 2,
24+
y: node.position.y + nodeHeight,
4825
},
4926
};
5027

5128
return positions[handleId];
5229
};
5330

54-
export const calculateBestHandles = (
55-
sourceNode: Node,
56-
targetNode: Node,
57-
nodes: Node[],
58-
) => {
31+
export const calculateBestHandles = (sourceNode: Node, targetNode: Node) => {
5932
const handlePositions = [
6033
Position.Left,
6134
Position.Right,
@@ -69,9 +42,9 @@ export const calculateBestHandles = (
6942
};
7043

7144
handlePositions.forEach((sourceHandle) => {
72-
const sourcePosition = getHandlePosition(sourceNode, sourceHandle, nodes);
45+
const sourcePosition = getHandlePosition(sourceNode, sourceHandle);
7346
handlePositions.forEach((targetHandle) => {
74-
const targetPosition = getHandlePosition(targetNode, targetHandle, nodes);
47+
const targetPosition = getHandlePosition(targetNode, targetHandle);
7548
const distance = Math.hypot(
7649
sourcePosition.x - targetPosition.x,
7750
sourcePosition.y - targetPosition.y,

0 commit comments

Comments
 (0)