Skip to content

Commit 8b9760f

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 55b714f + 9e01c55 commit 8b9760f

File tree

5 files changed

+72
-94
lines changed

5 files changed

+72
-94
lines changed

src/main/java/com/example/dto/MouseDTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
public class MouseDTO {
77

88
String name;
9+
String type;
910
int x;
1011
int y;
1112
}

src/main/java/com/example/service/NodeServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ public void DeleteNodeByIdAndUser(Long nodeId, User user) {
8080
// nodeId 로 node 찾기
8181
Node findNode = findNodeById(nodeId);
8282

83-
imageService.deleteS3Image(findNode.getImageURL());
8483

8584
// node 생성자 인지 확인
86-
if (!findNode.getUser().equals(user)) {
85+
if (!projectUserService.checkProjectUserExists(findNode.getProject(), user)) {
8786
throw new GeneralException(ErrorStatus.NODE_INVALID_USER);
8887
}
8988
else {
89+
imageService.deleteS3Image(findNode.getImageURL());
90+
9091
Node parentNode = findNode.getParentNode();
9192
// 부모노드가 있는 경우
9293
if (parentNode!=null) {

src/main/resources/static/css/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ body, html {
5050
border-radius: 50%; /* 원형으로 만들기 */
5151
pointer-events: none; /* 클릭 이벤트 차단 */
5252
z-index: 1000; /* 다른 요소 위에 표시 */
53+
transition: transform 0.1s linear;
5354
}
5455
.cursor span {
5556
position: relative;

src/main/resources/static/index.html

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ <h3>Sign-Up</h3>
10211021
// 노드의 위치를 새로운 좌표로 업데이트
10221022
nodeElement.style.left = `${nodeData.x}px`;
10231023
nodeElement.style.top = `${nodeData.y}px`;
1024+
1025+
// 선 업데이트
1026+
updateLine(nodeElement);
10241027
} else {
10251028
console.error(`Node with ID ${nodeData.nodeId} not found.`);
10261029
}
@@ -1029,25 +1032,35 @@ <h3>Sign-Up</h3>
10291032
// WebSocket을 통해 마우스 좌표 수신
10301033
stompClient.subscribe(`/topic/mouse/${projectId}`, function (message) {
10311034
const mouseData = JSON.parse(message.body);
1032-
const { name, x, y } = mouseData;
1033-
1034-
// 커서 요소가 이미 존재하는지 확인
1035-
if (!userCursors[name]) {
1036-
// 커서 요소 생성
1037-
const cursorElement = document.createElement('div');
1038-
cursorElement.className = 'cursor';
1039-
cursorElement.style.position = 'absolute';
1040-
cursorElement.innerHTML = `<span>${name}</span>`;
1041-
document.body.appendChild(cursorElement);
1042-
1043-
// 사용자 커서 저장
1044-
userCursors[name] = cursorElement;
1035+
1036+
if (mouseData.type === "disconnect") {
1037+
const { name } = mouseData; // mouseData에서 name 가져오기
1038+
if (userCursors[name]) {
1039+
userCursors[name].remove(); // DOM 요소 삭제
1040+
delete userCursors[name]; // userCursors에서 제거
1041+
}
10451042
}
1043+
else{
1044+
const { name, x, y } = mouseData;
1045+
1046+
// 커서 요소가 이미 존재하는지 확인
1047+
if (!userCursors[name]) {
1048+
// 커서 요소 생성
1049+
const cursorElement = document.createElement('div');
1050+
cursorElement.className = 'cursor';
1051+
cursorElement.style.position = 'absolute';
1052+
cursorElement.innerHTML = `<span>${name}</span>`;
1053+
document.body.appendChild(cursorElement);
1054+
1055+
// 사용자 커서 저장
1056+
userCursors[name] = cursorElement;
1057+
}
10461058

1047-
// 커서 위치 업데이트
1048-
const cursorElement = userCursors[name];
1049-
cursorElement.style.left = `${x}px`;
1050-
cursorElement.style.top = `${y}px`;
1059+
// 커서 위치 업데이트
1060+
const cursorElement = userCursors[name];
1061+
cursorElement.style.left = `${x}px`;
1062+
cursorElement.style.top = `${y}px`;
1063+
}
10511064
});
10521065

10531066
// 노드 삭제 이벤트 구독
@@ -1063,7 +1076,10 @@ <h3>Sign-Up</h3>
10631076
}
10641077

10651078
if(document.getElementById(`node-${nodeID}`)){
1066-
deleteNode(nodeID); // 해당 노드를 삭제하는 함수 호출
1079+
document.getElementById(`node-${nodeID}`)?.remove();
1080+
document.getElementById(`path-${nodeID}`)?.remove();
1081+
upadteNodeCheck();
1082+
console.log("Node deleted successfully.");
10671083
}
10681084
});
10691085

@@ -1076,12 +1092,44 @@ <h3>Sign-Up</h3>
10761092
const mouseData = {
10771093
name: currentUserName, // 사용자 이름 추가
10781094
x: event.clientX + window.scrollX,
1079-
y: event.clientY + window.scrollY
1095+
y: event.clientY + window.scrollY,
1096+
type: "connect"
10801097
};
10811098
stompClient.send(`/app/mouse/${CurrentProjectId}`, {}, JSON.stringify(mouseData));
10821099
}
10831100
});
10841101

1102+
document.addEventListener("visibilitychange", function () {
1103+
if (document.visibilityState === "hidden") {
1104+
// 사용자가 페이지를 벗어남
1105+
const mouseData = {
1106+
type: "disconnect",
1107+
name: currentUserName,
1108+
projectId: CurrentProjectId,
1109+
};
1110+
stompClient.send(`/app/mouse/${CurrentProjectId}`, {}, JSON.stringify(mouseData));
1111+
} else if (document.visibilityState === "visible") {
1112+
// 사용자가 페이지로 돌아옴
1113+
const mouseData = {
1114+
type: "connect", // 재접속 메시지
1115+
name: currentUserName,
1116+
x: window.scrollX,
1117+
y: window.scrollY,
1118+
projectId: CurrentProjectId,
1119+
};
1120+
stompClient.send(`/app/mouse/${CurrentProjectId}`, {}, JSON.stringify(mouseData));
1121+
}
1122+
});
1123+
1124+
window.addEventListener("beforeunload", function () {
1125+
const mouseData = {
1126+
type: "disconnect",
1127+
name: currentUserName,
1128+
projectId: CurrentProjectId,
1129+
};
1130+
stompClient.send(`/app/mouse/${CurrentProjectId}`, {}, JSON.stringify(mouseData));
1131+
});
1132+
10851133
//드래그 가능한 기능을 추가하는 함수 - nodeForm에 대해 적용되어있음
10861134
function makeDraggable(element) {
10871135
let offsetX, offsetY;

src/main/resources/static/login.html

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)