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, }); diff --git a/controllers/workspace/socketChat.ts b/controllers/workspace/socketChat.ts index d451318..f419d79 100644 --- a/controllers/workspace/socketChat.ts +++ b/controllers/workspace/socketChat.ts @@ -44,7 +44,8 @@ const socketChat = (socket: Socket) => { room, }); await chat.save(); - socket.broadcast.to(room).emit('sendMessage', { ...chat }); + socket.to(room).emit('sendMessage', { ...chat }); + socket.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; } diff --git a/controllers/workspace/socketKanban.ts b/controllers/workspace/socketKanban.ts index 89def25..a6fa393 100644 --- a/controllers/workspace/socketKanban.ts +++ b/controllers/workspace/socketKanban.ts @@ -19,13 +19,14 @@ 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') .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; @@ -33,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, @@ -49,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 }; }; @@ -66,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))); }); @@ -101,7 +77,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({ @@ -116,11 +92,10 @@ const socketKanban = async (socket: Socket) => { groupingPart: foundPart, }); await created.save(); - console.log(socket.id); 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({ @@ -136,15 +111,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, @@ -172,7 +147,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({ @@ -193,12 +168,13 @@ 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), (found.startDate = task.startDate), (found.endDate = task.endDate), + (found.taskColor = task.taskColor), (found.assignees = JSON.stringify(task.assignees)), await found.save(); } @@ -207,7 +183,6 @@ const socketKanban = async (socket: Socket) => { id: userId, }, }); - const foundChecklist = await Checklists.find({ where: { nowTask: found, @@ -239,11 +214,13 @@ 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 }); }); - // TODO: πŸ’š/kanban#deleteTaskBox - + // TODO: πŸ’š/kanban#deleteTaskBox - task box μ‚­μ œ socket.on('deleteTaskBox', async ({ targetListIndex, part }) => { console.log('πŸ’š/kanban#deleteTaskBox-'); const foundPart = await Parts.findOne({ @@ -280,12 +257,27 @@ 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 } }); - console.log(targetIndex, targetListIndex); - console.log(foundBox); - const foundTask = await Tasks.findOne({ where: { index: targetIndex, groupingBox: foundBox } }); - console.log(foundTask); + 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, + }, + }); + // console.log(foundTask); await foundTask?.remove(); //μ•žλ‹ΉκΈ°λŠ” 둜직 const foundBoxes = await Task_boxes.find({ @@ -331,7 +323,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) { @@ -357,7 +349,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 }); }); @@ -398,12 +390,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; @@ -412,10 +404,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 { //λ°•μŠ€μ΄λ™ + ν…ŒμŠ€ν¬μ΄λ™ @@ -439,7 +431,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) { @@ -453,28 +445,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;