Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Collab Page (CS3219-AY2425S1#52)
* Wrap delete questions in single API call * Add new POST `questions/delete` endpoint * Update question service README * Update frontend to use new endpoint * Ensure question table is responsive to fit smaller viewports * Fix question README * Fix comments * Update return type of getQuestionByID * Revert "Update return type of getQuestionByID" This reverts commit cb11b5a. * Update return type of getQuestionByID * Set up layout for question box and editor * Add codemirror * Update layout styling * Update chip colours to match difficulty * Update question-box to fetch question through API call * Update to set cursor position * Fix styling issue Previously, the content of the question-box gets cut off when the panel is resized to a very small size * Add confirm dialog box for submit and forfeit buttons * Added Collaboration Services Features * Remove controller and add client1 and client2 to test websocket * Able to update database * Integrate collab service * Containerize collaboration service and enhance structure - Added a README.md to document the collaboration service. - Added a Dockerfile and docker-compose configuration to containerize the collaboration service. - Moved project files into appropriate directories for better structure and organization. - Updated helper.ts with improvements and new helper methods. - Refactored code to use the helper methods in helper.ts for consistency and reusability. - Removed unused tests.html file (will develop a new testing approach for HTML files in the future). * Added MongoDB URI configuration for Collaboration Service database - Updated .env.sample to include MONGO_URI for MongoDB Atlas. - Modified mongodbservice.ts to use MONGO_URI for database connection. - Updated docker-compose.yml to pass MONGO_URI as an environment variable for the collaboration service. * Updated README.md for improved clarity and documentation - Clarified MongoDB URI usage and environment variable setup. - Improved explanation of collaboration service setup and configuration. * Fix formatting issues * Fix button placement * Add code formatter * Add icons to buttons * Randomise user's color in codemirror * Fix formatting issues * Update MongoDB Atlas URI, config.json, and file organization - Updated MongoDB Atlas URI in .env to ensure proper connection. - Modified config.json to compile JavaScript files in addition to TypeScript. - Refactored naming and file locations of helper.ts and utility.js. * Update configurations on MongoDB - changing URI * Adding new files and changing file structure * Add Read from Question to Create Room, Update Question Service URL and Axios call - Updated `QUESTION_SERVICE_URL` in the `.env` file to use `question` as the service hostname (matching the Docker service name). - Refactored `createRoomWithQuestion` in `roomController` to correctly append `/questions/search` to the base URL. - Ensured the correct retrieval of question data using Axios, resolving the `ENOTFOUND` error in the Docker environment. * Initialize ydocs and create room collections - Updated MongoDB service to initialize ydocs. - Modified MongoDB service to create room collections using room_id. - Enhanced API to retrieve room details by user_id (have not tested yet) * Update message production and add logging - Updated producer to send messages to the collab-created queue. - Added logging to track message production and consumption in the queue. * Separate WebSocket and HTTP services into different ports and update room retrieval API - Configured WebSocket service to run on port 8084 (collaboration) and HTTP API service on port 8087 (rooms). - Updated API to retrieve a list of room IDs based on the user ID instead of full room details. - Modified Docker Compose file to reflect the new service port structure for collaboration and room services. - Added logging for room consumer initialisation to ensure proper service startup. * Update ESLint configurations for collaboration and refactor code * Enhance collaboration microservice with improved error handling and new APIs - Updated methods to properly handle success and error messages - Refined try-catch implementations - Added room_status field for room creation (true for on, false for off) - Updated API to retrieve only active room IDs (status: true) - Created new API to close rooms (sets status to false and removes Yjs documents from DB) * Update README.md * Add collaboration-db to Docker Compose and update MongoDB URIs - Added collaboration-db service to Docker Compose YAML - Updated mongoURI in question service - Updated mongoURI in collaboration service - Modified environment sample files in root and collaboration service * Add package.json and package-lock.json * Update broker.ts, consumer.ts in both collab and matching - broker.ts: Update the getChannel - consumer.ts in collab: Add channel.nack(msg) - consumer.ts in matching: Add debug message * Fix collab package.json * Fix collab service running the wrong file in development mode * Fix env variables * Choose environment DB URI instead of defaulting to cloud if available * Add broker env variable for match * Handle COLLAB_CREATED status Ensure COLLAB_CREATED status triggers success UI. URL redirection has not been handled. * Add API call * Add URL redirection from matching to collab * Update question retrieval * Update yjs roomId to match the passed roomId * Add guard for collab page * Fix roomId retrieval issue * Fix styling issue caused by nav bar * Add 2s delay on match found * Fix linting * Tidy up codes * Add API to update user isForfeit status - Implement new API for updating the isForfeit status of users in a room. - Modify existing APIs to align with the isForfeit status functionality. - Update README.md for both root and collaboration services to reflect changes. * Update room closing functionality and documentation - Modified `compose.yml` and environment sample files. - Updated `README.md` to include details on room closure. - Enhanced room close functionality to return success if the room is already closed. * Add functionality to submit button * Update websocket initialisation - Include param, which contains userId, when initialising * Update collab guard * Fix bug - roomId initialisation was not done on init, which caused the roomId to be undefined when initialising websocket * Add forfeit functionality * Fix bug - The user who accepted first would get stuck and not retrieve COLLAB_CREATED status as the polling was unsubscribed prematurely * Fix error - Uninitialised question was causing error in console logs as the question title is being retrieved before it's even initialised * - Update README.md - Change posiiton of initRoomId * Enhance environment configuration and collaboration service - Updated environment sample files for both root and collaboration services. - Added collaboration guard in `websocketservice.ts` to improve security. - Revised `README.md` to include new details and instructions. * Added collaboration guard in `websocketservice.ts` to improve security. * Fix eslint at websocketservice.ts * Fix linting * Add citation for utility.js in Collaboration Service * Collab: Centralize env variables * Fix linting * Remove packages The collaboration service has many unused packages. Let's remove them * Adjust Dockerfile * Minor Fix Based On Comments: - .env.sample: Remove the port numbers - compose.yml: Remove the ports to not exposed it, and remove the env as well - README.md: Change the collaboration and room service to under Port 8084 - default.conf: Change the collaboration-api to be 8084 - config.ts: Change to one PORT instead of two PORTS - index.ts: Change to one PORT instead of two PORTS - README.md in Collaboration Service: Update the documentation to use one port only - consumer.ts in Match Service: Remove the debug code * Fix bugs * Update submit logic Submit now keep tracks the number of user connected to the session. If the other user is not connected (log out or forfeit), only 1 user is required for the submission to go through. * Minor Fix Based On Comments: - README.md: Update port from 8087 to 8084Z - roomController.ts: Update the helper methods - webSocketService.ts: Update the helper methods - helper.ts: Seperate the helper methods for HTTPS and WebSocket * Update forfeit warning message Forfeit warning message now depends on the number of remaining users that have access to the session. * Minor Fix Based On Comments: - broker.ts: Adapt the broker.ts from Match Service - consumer.ts: Update consumer.ts with new broker.ts - producer.ts: Update producer.ts with new broker.ts * Minor Fixes Based On Comments: - types.ts: Contains interface for User and Room - mongodbService.ts: Update method for new types - roomController.ts: Update method for new types and remove any * Minor Fixes Based On Comments: - types.ts: Contains interface for User and Room - mongodbService.ts: Update method for new types - roomController.ts: Update method for new types and remove any * Update submit Submit will now show a warning message if the user attempts to submit while the other user is disconnected * Minor Additional Details Based On Comments (Added a new queue to handle error if the room is not created) - queues.ts: A new queue called COLLAB_CREATE_FAILED (if room is not created successfully) - consumer.ts: Update method to handle if room is not created successfully * Add notification on forfeit Previously, when user2 forfeits, user1 is not notified. Now, user1 will be able to tell if user2 forfeits * Major Fix Based On Comments (Using JWT Token) - compose.yml: Added JWT Token to Collaboration Service - .env.sample: Added JWT Token to Collaboration Service - package.json: Added jsonwebtoken and mongoose - README.md: Updated the API Calls to include JWT, and added details on handling room not created for Queue - app.ts: Added verifyAccessToken - config.ts: Added JWT Token to Collaboration Service - roomController.ts: Change from retrieving user_id to use JWT Token to retrieve the user_id instead - types.ts: Change room_id from string to Object_id - express.d.ts: Declare Request User - jwt.ts: Added JWT functionality - request.ts: Added types for Request User - roomRoutes.ts: Update routes - mongodbService.ts: Update method based on types.ts * Testing Fix * Change path from /start to /collab * Remove prettier-standalone library * Fix Issues On The WebSocketService.ts * Fix using ESLINT * Remove params from editor.component.ts * Fixed Based On Comments: - compose.dev.yml: Add port 8084 - compose.yml: Remove port 8084 - api.config.ts: Change to api gateway - editor.component.ts: Change the websocketurl - default.conf: Add the proxy - package.json: Add --files to solves issue on dev - index.ts: Edit the file sequence * Minor Fix On Collaboration Service: - Use Linting to fix - webSocketService.ts: Add new checks - editor.component.ts: Parse userid in the params * Fix linting * Update api calls to match new endpoint * Remove the duplicate createYJSDocument method * Fix unexpected end of array error This error seems to be due to YJS attempting to read strings sent by the collab service. Let's keep the websocket channel purely for YJS-related changes. * Remove wscat * Adjust Collab to use only 8084 * Simplify websocket path routing * Match: Nuke update route * Question: Consume MatchFoundEvent and produce QuestionFoundEvent, MatchFailedEvent * Collab: Consume QuestionFoundEvent instead * Frontend: Obtain question from collab * Match: Consume MatchFailedEvent * Frontend: Delay first match request status poll The finding match component could poll the status of the previous match request before the matchId updating to the new match request. Let's create a delay before the first poll to prevent this.` * Ensure question awaits broker * Use accessToken for websockets * Fix minor logger typos * Collab: Protect routes Ensure that a user cannot query for rooms not belonging to them * Ensure all services restart --------- Co-authored-by: Samuel Lim <samuelim01@gmail.com> Co-authored-by: KhoonSun47 <justforwks@gmail.com> Co-authored-by: Yek Khoon Sun <133077437+KhoonSun47@users.noreply.github.com>
- Loading branch information