From 0226b2d6d745bc4a03d2e9081f32442da00d60cb Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 01:46:32 +0900 Subject: [PATCH 1/9] Add #212 sending chat id to writer in sendMessage event --- controllers/workspace/socketChat.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/workspace/socketChat.ts b/controllers/workspace/socketChat.ts index d451318..4096701 100644 --- a/controllers/workspace/socketChat.ts +++ b/controllers/workspace/socketChat.ts @@ -45,6 +45,7 @@ const socketChat = (socket: Socket) => { }); await chat.save(); socket.broadcast.to(room).emit('sendMessage', { ...chat }); + socket.to(socket.id).emit('nowMessageId', { id: chat.id }); } catch (err) { console.log('πŸ’š/chat#sendMessage-err:', err.message); } @@ -135,7 +136,8 @@ const socketChat = (socket: Socket) => { let isEnd = false; let total = chats.length; let start_chat = total - (order + 1) * COUNT_SCROLL; - if (start_chat < 0) { // λ§ˆμ§€λ§‰ chat인지 확인 + if (start_chat < 0) { + // λ§ˆμ§€λ§‰ chat인지 확인 start_chat = 0; isEnd = true; } From f388650961efc7b73d1648f84282e984a9de3eca Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 13:36:21 +0900 Subject: [PATCH 2/9] Fix #212 sending chat id to writer in sendMessage event --- controllers/workspace/socketChat.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/workspace/socketChat.ts b/controllers/workspace/socketChat.ts index 4096701..f419d79 100644 --- a/controllers/workspace/socketChat.ts +++ b/controllers/workspace/socketChat.ts @@ -44,8 +44,8 @@ const socketChat = (socket: Socket) => { room, }); await chat.save(); - socket.broadcast.to(room).emit('sendMessage', { ...chat }); - socket.to(socket.id).emit('nowMessageId', { id: chat.id }); + socket.to(room).emit('sendMessage', { ...chat }); + socket.emit('nowMessageId', { id: chat.id }); } catch (err) { console.log('πŸ’š/chat#sendMessage-err:', err.message); } From 3628b87112d1562554b7488d13f2e9ef24f4b479 Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 13:37:35 +0900 Subject: [PATCH 3/9] Fix console.log for test --- controllers/project/showProject.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/controllers/project/showProject.ts b/controllers/project/showProject.ts index 91a0491..7064f29 100644 --- a/controllers/project/showProject.ts +++ b/controllers/project/showProject.ts @@ -13,7 +13,15 @@ const showProject = async (req: Request, res: Response) => { }, }); if (foundProject) { - console.log('πŸ’›showProject-result: ', foundProject); // test + console.log('πŸ’›showProject-result: ', { + ...foundProject, + members: foundProject.members.map(el => { + return { + id: el.id, + name: el.name, + }; + }), + }); // test res.status(200).json({ ...foundProject, }); From a2bbae56feb82fb096f52871842b7a4c7f20ecfc Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 14:16:56 +0900 Subject: [PATCH 4/9] Add #166 taskColor data to save editTaskItem --- controllers/workspace/socketKanban.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index 89def25..b9b4eb6 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -199,6 +199,7 @@ const socketKanban = async (socket: Socket) => { (found.desc = task.desc), (found.startDate = task.startDate), (found.endDate = task.endDate), + (found.taskColor = task.taskColor), (found.assignees = JSON.stringify(task.assignees)), await found.save(); } From d316cad427cef6df1262007d390eae54b782a002 Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 15:00:17 +0900 Subject: [PATCH 5/9] Add #136 writer data to commemt in sql query syntax --- controllers/workspace/socketKanban.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index b9b4eb6..ac9eabf 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -19,6 +19,7 @@ const structuringData = async (part: string, projectId: number) => { .leftJoinAndSelect('taskBoxesList.tasksList', 'tasksList') .leftJoinAndSelect('tasksList.checklistsList', 'checklistsList') .leftJoinAndSelect('tasksList.commentsList', 'commentsList') + .leftJoinAndSelect('commentsList.writer', 'writer') .orderBy('taskBoxesList.index', 'ASC') .addOrderBy('tasksList.index', 'ASC') .addOrderBy('checklistsList.createdAt', 'ASC') @@ -240,7 +241,9 @@ const socketKanban = async (socket: Socket) => { nowTask: found, }); await created.save(); + console.log(created); } + console.log(task); socket.broadcast.to(part).emit('editTaskItem', { targetIndex, targetListIndex, task }); }); From 508f80a5a6c5520c000575a9fb1821bde77ac82b Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 15:25:01 +0900 Subject: [PATCH 6/9] Fix console.log for test --- controllers/workspace/socketKanban.ts | 39 +++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index ac9eabf..b5cb444 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -24,9 +24,9 @@ const structuringData = async (part: string, projectId: number) => { .addOrderBy('tasksList.index', 'ASC') .addOrderBy('checklistsList.createdAt', 'ASC') .getMany(); - console.log(projects); + // console.log(projects); const partOne = projects[0].partsList[0]; - console.log(partOne); + // console.log(partOne); let taskBox: any[] = []; let taskItems: { [index: string]: any; @@ -50,7 +50,7 @@ const structuringData = async (part: string, projectId: number) => { }); taskBox.push(Object.assign({}, { taskBoxTitle: el.title, tasks, dragging: false })); }); - console.log(taskItems); + // console.log(taskItems); return { taskBox, taskItems }; }; @@ -117,7 +117,6 @@ const socketKanban = async (socket: Socket) => { groupingPart: foundPart, }); await created.save(); - console.log(socket.id); socket.broadcast.to(part).emit('addTaskBox', { taskBoxTitle: title, tasks: [] }); }); @@ -137,15 +136,15 @@ const socketKanban = async (socket: Socket) => { groupingPart: foundPart, }, }); - console.log(foundBox?.tasksList); + // console.log(foundBox?.tasksList); let maxIndex = -1; if (foundBox?.tasksList.length !== 0) { maxIndex = foundBox!.tasksList.reduce((acc, cur) => { return cur.index > acc ? cur.index : acc; }, 0); } - console.log('max', maxIndex); - console.log('TLI', targetListIndex); + // console.log('max', maxIndex); + // console.log('TLI', targetListIndex); const created = await Tasks.create({ index: maxIndex + 1, title: taskTitle, @@ -194,7 +193,7 @@ const socketKanban = async (socket: Socket) => { index: targetIndex, }, }); - console.log('찾음', foundBox, found); + // console.log('찾음', foundBox, found); if (found) { (found.title = task.taskTitle), (found.desc = task.desc), @@ -241,9 +240,9 @@ const socketKanban = async (socket: Socket) => { nowTask: found, }); await created.save(); - console.log(created); + // console.log(created); } - console.log(task); + // console.log(task); socket.broadcast.to(part).emit('editTaskItem', { targetIndex, targetListIndex, task }); }); @@ -286,10 +285,10 @@ const socketKanban = async (socket: Socket) => { console.log('πŸ’š/kanban#deleteTaskItem-'); const foundPart = await Parts.findOne({ where: { name: part, doingProject: foundProject } }); const foundBox = await Task_boxes.findOne({ where: { index: targetListIndex, groupingPart: foundPart } }); - console.log(targetIndex, targetListIndex); - console.log(foundBox); + // console.log(targetIndex, targetListIndex); + // console.log(foundBox); const foundTask = await Tasks.findOne({ where: { index: targetIndex, groupingBox: foundBox } }); - console.log(foundTask); + // console.log(foundTask); await foundTask?.remove(); //μ•žλ‹ΉκΈ°λŠ” 둜직 const foundBoxes = await Task_boxes.find({ @@ -335,7 +334,7 @@ const socketKanban = async (socket: Socket) => { index: 'ASC', }, }); - console.log(foundPart, foundBoxes); + // console.log(foundPart, foundBoxes); if (currentIndex < targetIndex) { foundBoxes.map(el => { if (el.index === currentIndex) { @@ -361,7 +360,7 @@ const socketKanban = async (socket: Socket) => { foundBoxes[currentIndex].index = targetIndex; //μ™Όμͺ½μœΌλ‘œ λ“œλž˜κΉ…ν–ˆμŒ } - console.log(structuringData(part, Number(projectId))); + // console.log(structuringData(part, Number(projectId))); socket.broadcast.to(part).emit('boxMoving', { currentIndex, targetIndex }); // socket.broadcast.emit('boxDragEnd', { targetListIndex: targetIndex, isDragging: false }); }); @@ -402,12 +401,12 @@ const socketKanban = async (socket: Socket) => { }); temp!.index = targetIndex; temp?.save(); - console.log(temp!.index); + // console.log(temp!.index); } else { //상행 let temp: any; boxOne.tasksList.map(el => { - console.log(el.index, currentIndex); + // console.log(el.index, currentIndex); if (el.index === currentIndex) { el.index = -1; temp = el; @@ -416,10 +415,10 @@ const socketKanban = async (socket: Socket) => { el.save(); } }); - console.log(temp); + // console.log(temp); temp!.index = targetIndex; temp?.save(); - console.log(temp!.index); + // console.log(temp!.index); } } else { //λ°•μŠ€μ΄λ™ + ν…ŒμŠ€ν¬μ΄λ™ @@ -443,7 +442,7 @@ const socketKanban = async (socket: Socket) => { el.save(); } }); - console.log(tempTask); + // console.log(tempTask); tempTask!.groupingBox = foundBoxes[targetListIndex]; foundBoxes[targetListIndex].tasksList.map(el => { if (el.index >= targetIndex) { From 79b1c664c33fc72779d11218c88d7bec38955808 Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 15:29:47 +0900 Subject: [PATCH 7/9] Fix indentation according to code style --- controllers/workspace/socketKanban.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index b5cb444..1a7058e 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -208,7 +208,6 @@ const socketKanban = async (socket: Socket) => { id: userId, }, }); - const foundChecklist = await Checklists.find({ where: { nowTask: found, @@ -283,11 +282,26 @@ const socketKanban = async (socket: Socket) => { // TODO: πŸ’š/kanban#deleteTaskItem - task μ‚­μ œ socket.on('deleteTaskItem', async ({ targetIndex, targetListIndex, part }) => { console.log('πŸ’š/kanban#deleteTaskItem-'); - const foundPart = await Parts.findOne({ where: { name: part, doingProject: foundProject } }); - const foundBox = await Task_boxes.findOne({ where: { index: targetListIndex, groupingPart: foundPart } }); + const foundPart = await Parts.findOne({ + where: { + name: part, + doingProject: foundProject, + }, + }); + const foundBox = await Task_boxes.findOne({ + where: { + index: targetListIndex, + groupingPart: foundPart, + }, + }); // console.log(targetIndex, targetListIndex); // console.log(foundBox); - const foundTask = await Tasks.findOne({ where: { index: targetIndex, groupingBox: foundBox } }); + const foundTask = await Tasks.findOne({ + where: { + index: targetIndex, + groupingBox: foundBox, + }, + }); // console.log(foundTask); await foundTask?.remove(); //μ•žλ‹ΉκΈ°λŠ” 둜직 From c368c37607e2ed30b39911e2b6c295c6e1b51f7b Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 15:34:06 +0900 Subject: [PATCH 8/9] Add comment and console.log for info and test --- controllers/workspace/socketKanban.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index 1a7058e..7705acf 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -102,7 +102,7 @@ const socketKanban = async (socket: Socket) => { socket.leave(part); }); - // TODO: πŸ’š/kanban#addTaskBox - + // TODO: πŸ’š/kanban#addTaskBox - task box μΆ”κ°€ socket.on('addTaskBox', async ({ index, title, part }) => { console.log('πŸ’š/kanban#addTaskBox-'); const foundPart = await Parts.findOne({ @@ -120,7 +120,7 @@ const socketKanban = async (socket: Socket) => { socket.broadcast.to(part).emit('addTaskBox', { taskBoxTitle: title, tasks: [] }); }); - // TODO: πŸ’š/kanban#addTaskItem - + // TODO: πŸ’š/kanban#addTaskItem - task μΆ”κ°€ socket.on('addTaskItem', async ({ targetListIndex, part, taskTitle, taskColor }) => { console.log('πŸ’š/kanban#addTaskItem-'); const foundPart = await Parts.findOne({ @@ -172,7 +172,7 @@ const socketKanban = async (socket: Socket) => { }); }); - // TODO: πŸ’š/kanban#editTaskItem - + // TODO: πŸ’š/kanban#editTaskItem - task μˆ˜μ • socket.on('editTaskItem', async ({ task, targetListIndex, targetIndex, part }) => { console.log('πŸ’š/kanban#editTaskItem-', task, targetIndex, targetListIndex, part); const foundPart = await Parts.findOne({ @@ -245,7 +245,7 @@ const socketKanban = async (socket: Socket) => { socket.broadcast.to(part).emit('editTaskItem', { targetIndex, targetListIndex, task }); }); - // TODO: πŸ’š/kanban#deleteTaskBox - + // TODO: πŸ’š/kanban#deleteTaskBox - task box μ‚­μ œ socket.on('deleteTaskBox', async ({ targetListIndex, part }) => { console.log('πŸ’š/kanban#deleteTaskBox-'); const foundPart = await Parts.findOne({ @@ -470,28 +470,29 @@ const socketKanban = async (socket: Socket) => { socket.broadcast.to(part).emit('taskMoving', { targetListIndex, targetIndex, currentIndex, currentListIndex }); }); + // TODO: πŸ’š/kanban#boxDragBlock - dragν•˜κ³  μžˆλŠ” task box block 처리 socket.on('boxDragBlock', ({ part, targetListIndex, isDragging }) => { + console.log('πŸ’š/kanban#boxDragBlock-'); socket.broadcast.to(part).emit('boxDragBlock', { targetListIndex, isDragging }); }); - // socket.on('boxDragEnd', ({ boxTitle, isDragging }) => { - // socket.broadcast.emit('boxDragEnd', { boxTitle, isDragging }); - // }); - + // TODO: πŸ’š/kanban#itemDragStart - item drag μ‹œμž‘ μ•Œλ¦Ό socket.on('itemDragStart', ({ part, targetListIndex, isDragging }) => { + console.log('πŸ’š/kanban#itemDragStart-'); socket.broadcast.to(part).emit('itemDragStart', { targetListIndex, isDragging }); }); + // TODO: πŸ’š/kanban#itemDragEnd - item drag μ’…λ£Œ μ•Œλ¦Ό socket.on('itemDragEnd', ({ part, currentListIndex, targetListIndex, targetIndex, isDragging }) => { + console.log('πŸ’š/kanban#itemDragEnd-'); socket.broadcast.to(part).emit('itemDragEnd', { currentListIndex, targetListIndex, targetIndex, isDragging }); }); + // TODO: πŸ’š/kanban#itemEditBlock - μˆ˜μ •ν•˜κ³  μžˆλŠ” item block 처리 socket.on('itemEditBlock', ({ part, targetListIndex, isDragging }) => { + console.log('πŸ’š/kanban#itemEditBlock-'); socket.broadcast.to(part).emit('itemEditBlock', { targetListIndex, isDragging }); }); - // socket.on('itemEditBlock', ({ targetListIndex, isDragging }) => { - // socket.broadcast.emit('itemEditEnd', { targetListIndex, isDragging }); - // }); }; export default socketKanban; From c17688bffb267fb4edb7f3f31aaa7fff0428b11d Mon Sep 17 00:00:00 2001 From: SongYi Jung Date: Wed, 2 Jun 2021 16:33:45 +0900 Subject: [PATCH 9/9] Remove #174 saving newname part in joinPart so fix already exist error in editKanbanPart --- controllers/workspace/socketKanban.ts | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index 7705acf..a6fa393 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -34,7 +34,7 @@ const structuringData = async (part: string, projectId: number) => { partOne.taskBoxesList.map(el => { let tasks: any[] = []; el.tasksList.map(el => { - console.log('adfadfasdfasgasdgasfdf', el); + // console.log('adfadfasdfasgasdgasfdf', el); tasks.push(Object.keys(taskItems).length); taskItems[Object.keys(taskItems).length] = { taskTitle: el.title, @@ -67,31 +67,6 @@ const socketKanban = async (socket: Socket) => { // TODO: πŸ’š/kanban#joinPart - part μž…μž₯ socket.on('joinPart', async part => { console.log('πŸ’š/kanban#joinPart-', part); - const foundPartOne = await Parts.findOne({ - where: { - doingProject: foundProject, - name: part, - }, - }); - if (!foundPartOne) { - const foundPart = await Parts.find({ - where: { - doingProject: foundProject, - }, - }); - let maxIndex = -1; - if (foundPart.length !== 0) { - maxIndex = foundPart.reduce((acc, cur) => { - return acc.index > cur.index ? acc : cur; - }).index; - } - const created = await Parts.create({ - name: part, - doingProject: foundProject, - index: maxIndex + 1, - }); - created.save(); - } socket.join(part); socket.emit('getKanbanData', await structuringData(part, Number(projectId))); });