Skip to content

Commit 0020efd

Browse files
authored
Merge pull request #52 from CS3219-AY2425S1/Collab-UI
Update Collab Space UI and Update timers
2 parents 5b050df + ae6bdfe commit 0020efd

File tree

13 files changed

+113
-104
lines changed

13 files changed

+113
-104
lines changed

Backend/MatchingService/app.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const express = require('express');
22
const cors = require("cors");
33
const dotenv = require("dotenv");
4-
const matchmakingRouter = require("./controllers/matchmaking");
54
const { consumeQueue, consumeDLQ } = require('./rabbitmq/subscriber');
65
const { setupRabbitMQ } = require('./rabbitmq/setup');
76

@@ -13,8 +12,6 @@ app.use(express.json());
1312
app.use(express.urlencoded({ extended: true }));
1413
app.options("*", cors());
1514

16-
app.use('/api/match', matchmakingRouter);
17-
1815
// TODO: Start consuming RabbitMQ queues
1916

2017
setupRabbitMQ().then(() => {

Backend/MatchingService/controllers/matchmaking.js

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

Backend/MatchingService/rabbitmq/setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function setupRabbitMQ() {
4646
await channel.assertQueue(queueName, {
4747
durable: true,
4848
arguments: {
49-
'x-message-ttl': 10000, // TTL for messages in the queue
49+
'x-message-ttl': 30000, // TTL for messages in the queue
5050
'x-dead-letter-exchange': dead_letter_exchange_name // Bind to dead-letter exchange
5151
}
5252
});

Backend/MatchingService/rabbitmq/subscriber.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function matchUsers(channel, msg, userId, difficulty, category) {
9191
notifyMatch(channel, matchedUsers, category, difficulty);
9292
return true;
9393
}
94-
}, 5000); // 5-second delay
94+
}, 15000); // 15-second delay
9595
}
9696

9797
return false;
@@ -288,7 +288,7 @@ async function consumeQueue() {
288288
const timeoutId = setTimeout(async () => {
289289
const categorykey = "any." + category
290290
await rejectMessage(channel, msg, userData);
291-
}, 10000); // 10 seconds delay
291+
}, 30000); // 30 seconds delay
292292

293293
timeoutMap[userId] = timeoutId;
294294
}

Frontend/src/components/collab/Chat.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ const Chat = ({ currentUser, messages, sendMessage }) => {
2121
}, [messages]);
2222

2323
return (
24-
<Accordion defaultActiveKey="0" className='mt-3' onSelect={(eventKey) => setIsAccordionOpen(eventKey === "0")}>
24+
<Accordion defaultActiveKey="0" className='mt-3' onSelect={(eventKey) => setIsAccordionOpen(eventKey === "0")} style={{ height: '100%' }}>
2525
<Accordion.Item eventKey="0">
2626
<Accordion.Header>
2727
Chat
2828
</Accordion.Header>
29-
<Accordion.Body>
29+
<Accordion.Body style={{ display: 'flex', flexDirection: 'column'}}>
3030
<div
3131
ref={chatContainerRef}
3232
style={{
33-
maxHeight: '300px',
33+
minHeight: '33vh',
34+
maxHeight: '33vh',
35+
flex: 1,
3436
overflowY: 'auto',
3537
marginBottom: '1rem',
3638
}}
@@ -68,19 +70,20 @@ const Chat = ({ currentUser, messages, sendMessage }) => {
6870
</ListGroup>
6971
</div>
7072
{isAccordionOpen && ( // Only show message input when accordion is open
71-
<Form onSubmit={(e) => { e.preventDefault(); handleSend(); }}>
72-
<Form.Group controlId="messageInput">
73+
<Form onSubmit={(e) => { e.preventDefault(); handleSend(); }} style={{ display: 'flex', alignItems: 'center' }}>
74+
<Form.Group controlId="messageInput" style={{ flex: 1, marginRight: '10px' }}> {/* Makes input take available space */}
7375
<Form.Control
7476
type="text"
7577
placeholder="Type a message..."
7678
value={text}
7779
onChange={(e) => setText(e.target.value)}
7880
/>
7981
</Form.Group>
80-
<Button variant="primary" type="submit" className="mt-2">
82+
<Button variant="primary" type="submit">
8183
Send
8284
</Button>
8385
</Form>
86+
8487
)}
8588
</Accordion.Body>
8689
</Accordion.Item>

Frontend/src/components/collab/CodeSpace.jsx

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,58 @@ import { Container, Stack, Spinner } from 'react-bootstrap'
55
const CodeSpace = ({ handleEditorChange, loading, code, language, output, isError }) => {
66
return (
77

8-
<Stack gap={3} className='h-100'>
8+
<Stack gap={3} className='h-100' style={{ height: '100vh' }}>
9+
{/* Editor Section (60% of viewport) */}
10+
<div style={{ borderRadius: '0.5rem', overflow: 'hidden', height: '60vh' }}>
911
<Editor
10-
height='400px'
12+
height="100%" // Make the editor fill the container
1113
defaultLanguage="python"
1214
language={language}
1315
value={code}
1416
onChange={handleEditorChange}
15-
theme='vs-dark'
17+
theme="vs-dark"
18+
options={{
19+
fontSize: 14 // Set font size here, adjust as needed
20+
}}
1621
/>
17-
<Container style={{ height: '225px', border: '1px solid #ccc', borderRadius: '0.5rem', padding: '1rem', backgroundColor: '#f8f9fa', padding: '20px'}}>
18-
<h4>Output</h4>
19-
{loading ? (
20-
<div className="d-flex justify-content-center align-items-center" style={{ height: '100%' }}>
22+
</div>
23+
24+
{/* Output Section (40% of viewport) */}
25+
<Container
26+
style={{
27+
height: '30vh', // Occupies 40% of viewport height
28+
border: '1px solid #ccc',
29+
borderRadius: '0.5rem',
30+
padding: '1rem',
31+
backgroundColor: '#f8f9fa',
32+
}}
33+
>
34+
<p>Output</p>
35+
{loading ? (
36+
<div className="d-flex justify-content-center align-items-center" style={{ height: '100%' }}>
2137
<Spinner animation="border" variant="primary" />
2238
<span className="ms-1">Running...</span>
23-
</div>
24-
): (
25-
<div style={{ height: '150px', maxHeight: '150px', overflowY: 'auto', fontFamily: 'monospace', whiteSpace: 'pre-wrap', border: '1px solid rgba(0, 0, 0, 0.2)', borderRadius: '0.5rem'}}>
39+
</div>
40+
) : (
41+
<div
42+
style={{
43+
height: '90%',
44+
overflowY: 'auto',
45+
fontFamily: 'monospace',
46+
whiteSpace: 'pre-wrap',
47+
border: '1px solid rgba(0, 0, 0, 0.2)',
48+
borderRadius: '0.5rem',
49+
paddingLeft: '5px',
50+
paddingLeft: '10px',
51+
fontSize: '16'
52+
}}
53+
>
2654
<p style={{ color: isError ? 'red' : '#212529' }}>{output}</p>
27-
</div>
28-
)}
29-
</Container>
30-
</Stack>
55+
</div>
56+
)}
57+
</Container>
58+
</Stack>
59+
3160

3261
)
3362
}

Frontend/src/components/collab/CollabNavigationBar.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ const CollabNavigationBar = ({ handleExit, users, handleCodeRun, setLanguage, la
2626

2727
{/* Run Code and Exit Buttons in Center */}
2828
<Nav className='mx-auto'>
29-
<Button onClick={handleCodeRun}>Run Code</Button>
29+
<Button
30+
onClick={handleCodeRun}
31+
style={{ backgroundColor: '#28a745', color: '#fff', border: 'none' }}
32+
>
33+
Run Code
34+
</Button>
3035
<Button variant="danger" className="ms-2" onClick={handleExit}>Exit</Button>
3136
</Nav>
3237

Frontend/src/components/collab/CollaborationSpace.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ const CollaborationSpace = () => {
284284

285285
return (
286286

287-
<div style={{ textAlign: 'center', height: '100vh', overflow: 'hidden' }}>
287+
<div style={{ height: '100vh', overflow: 'hidden' }}>
288288
{showAccessDeniedToast ? (
289-
<ToastContainer className="p-3" position="top-center" style={{ zIndex: 1 }}>
289+
<ToastContainer className="p-3" position="top-center" style={{ zIndex: 1, textAlign: 'center' }}>
290290
<Toast
291291
onClose={handleCloseToast}
292292
show={showAccessDeniedToast}
@@ -311,19 +311,22 @@ const CollaborationSpace = () => {
311311
</Toast>
312312
))}
313313
</ToastContainer>
314-
<CollabNavigationBar handleExit={handleExit} handleCodeRun={handleCodeRun} users={users} setLanguage={setLanguage} language={language}/>
315-
<Container fluid style={{ marginTop: '20px', height: 'calc(100vh - 60px)', display: 'flex', overflow: 'hidden' }}>
314+
<CollabNavigationBar handleExit={handleExit} handleCodeRun={handleCodeRun} users={users} setLanguage={setLanguage} language={language} userLangChange={handleLanguageChange}/>
315+
<Container fluid style={{ marginTop: '10px', height: 'calc(100vh - 60px)', display: 'flex', overflow: 'hidden' }}>
316316
<Row style={{ flexGrow: 1, width: '100%', height: '100%', overflow: 'hidden' }}>
317-
<Col md={6} style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
318-
<CodeSpace handleEditorChange={handleEditorChange} loading={outputLoading} code={code} language={language} output={output}/>
317+
<Col md={6} style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden', marginTop: '5px'}}>
318+
<CodeSpace handleEditorChange={handleEditorChange} loading={outputLoading} code={code} language={language} output={output} isError={isError}/>
319319
</Col>
320320
<Col md={6} style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
321-
<div style={{ flex: '60%', display: 'flex', overflow: 'hidden' }}>
322-
<QuestionDisplay question={question}/>
321+
<div style={{ flex: 2, display: 'flex', overflow: 'hidden', width:'100%', minHeight:'0vh', marginTop:'5px'}}>
322+
<QuestionDisplay question={question} style={{width:'100%'}}/>
323323
</div>
324-
<div style={{ flex: '40%', overflow: 'hidden' }}>
325-
<Chat currentUser={username} messages={messages} sendMessage={sendMessage}/>
324+
325+
<div style={{ flex: 2, height:'100%', marginBottom: '38px', maxHeight:'50vh'}}>
326+
<Chat currentUser={userId} messages={messages} sendMessage={sendMessage}/>
327+
326328
</div>
329+
327330
</Col>
328331
</Row>
329332
</Container>

Frontend/src/components/collab/QuestionDisplay.jsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from 'react';
2-
import { Card } from 'react-bootstrap';
2+
import { Card, Col} from 'react-bootstrap';
33
import { getQuestionsByCategory } from '../../services/questions';
44

55
const QuestionDisplay = ({ question }) => {
@@ -12,13 +12,14 @@ const QuestionDisplay = ({ question }) => {
1212
}
1313

1414
return (
15-
<Card>
16-
<Card.Header>{question ? `${question.title} (${question.complexity})` : "Loading..."}</Card.Header>
17-
<Card.Body style={{textAlign: 'left'}}>
18-
<p>{question ? question.category.join(", ") : "Loading question description..."}</p>
19-
<p>{question ? question.description : "Loading question description..."}</p>
20-
</Card.Body>
21-
</Card>
15+
<Card style={{ width: '100%' }}>
16+
<Card.Header>{question ? <strong>{question.title} ({question.complexity})</strong> : "Loading..."}</Card.Header>
17+
<Card.Body style={{ textAlign: 'left' }}>
18+
<p>{question ? "Category: " + question.category.join(", ") : "Loading question description..."}</p>
19+
<p> Description:</p>
20+
<p>{question ? question.description : "Loading question description..."}</p>
21+
</Card.Body>
22+
</Card>
2223
);
2324
};
2425

Frontend/src/components/matching/CriteriaDisplay.jsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ const capitalizeFirstLetter = (difficulty) => {
2525

2626
const CriteriaDisplay = ({ difficulty, category }) => {
2727
return (
28-
<Card className="mt-3" style={{ width: '20rem' }}>
29-
<Card.Body>
30-
<Card.Title>Selected Criteria</Card.Title>
31-
<Card.Text>
32-
<span>
33-
Difficulty: <Badge bg={getBadgeVariant(difficulty ? difficulty : "Not Selected" )}>{capitalizeFirstLetter(difficulty ? difficulty : "Not Selected")}</Badge>
34-
<br></br>
35-
Category: <strong>{capitalizeFirstLetter(category ? category : "Not Selected")}</strong>
36-
</span>
37-
</Card.Text>
38-
</Card.Body>
39-
</Card>
28+
<Card className="mt-3 mx-auto" style={{ maxWidth: '100%', width: '90%', minWidth: '200px' }}>
29+
<Card.Body>
30+
<Card.Title>Selected Criteria</Card.Title>
31+
<Card.Text>
32+
<span>
33+
Difficulty: <Badge bg={getBadgeVariant(difficulty ? difficulty : "Not Selected")}>
34+
{capitalizeFirstLetter(difficulty ? difficulty : "Not Selected")}
35+
</Badge>
36+
<br />
37+
Category: <strong>{capitalizeFirstLetter(category ? category : "Not Selected")}</strong>
38+
</span>
39+
</Card.Text>
40+
</Card.Body>
41+
</Card>
4042
)
4143
};
4244

0 commit comments

Comments
 (0)