Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the title #76

Merged
merged 24 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8de1d42
save work
hongjun2002 Nov 13, 2023
a8f26e4
Merge branch 'develop' of https://github.com/Shaurya0108/CSProject in…
hongjun2002 Nov 13, 2023
df2c39e
return 10 most recent session IDs when logged in
hongjun2002 Nov 13, 2023
bb51179
Merge branch 'develop' of https://github.com/Shaurya0108/CSProject in…
hongjun2002 Nov 13, 2023
022d8e1
Merge pull request #63 from Shaurya0108/feat/session-patch
xavierlmendez Nov 13, 2023
b18ada3
Frontend calls server instead of model directly
hongjun2002 Nov 17, 2023
d967e6b
the response renders the code and latex responses now
Shaurya0108 Nov 18, 2023
8716c95
modal styling
jesusjimenez32 Nov 18, 2023
6fc9985
.env variable name change
hongjun2002 Nov 18, 2023
bb211c3
Merge pull request #66 from Shaurya0108/charles-patch
xavierlmendez Nov 18, 2023
346d1fc
generates session id based on UserId + Timestamp
hongjun2002 Nov 18, 2023
0efa907
stores sessionId in sessionStorage
hongjun2002 Nov 18, 2023
8a3f8f4
Modal for all buttons
jesusjimenez32 Nov 18, 2023
19362ad
deleted unecessary routes
jesusjimenez32 Nov 18, 2023
73a483b
modal is now in front of everything when opened
jesusjimenez32 Nov 18, 2023
76e1500
Merge pull request #68 from Shaurya0108/64-fix-the-code-output-from-t…
xavierlmendez Nov 20, 2023
cddb7ac
Merge pull request #69 from Shaurya0108/charles-patch
xavierlmendez Nov 20, 2023
9360e2f
Contact TA button added
jesusjimenez32 Nov 22, 2023
d5a0f48
can only create new session if least one query
hongjun2002 Nov 27, 2023
6233098
Merge pull request #72 from Shaurya0108/charles-patch
xavierlmendez Nov 29, 2023
f5f3f70
Merge pull request #71 from Shaurya0108/TACountactButton
xavierlmendez Nov 30, 2023
41707eb
save changes
hongjun2002 Dec 1, 2023
e8cfe89
Merge pull request #73 from Shaurya0108/charles-session-patch
hongjun2002 Dec 1, 2023
c2002d9
Merge pull request #74 from Shaurya0108/develop
xavierlmendez Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 161 additions & 19 deletions FrontEnd/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@
font-size: 20px;
}

/* .navbar-cap-1 {
margin: 0;
font-size: 40px;
margin-top: 30px;
width: fit-content;
margin-left: auto;
margin-right: auto;
}

.navbar-cap-2 {
margin: 0;
font-size: 20px;
margin-top: 30px;
width: fit-content;
margin-left: auto;
margin-right: auto;
} */

.hidden {
display: none;
}
Expand Down Expand Up @@ -121,5 +103,165 @@
}

.rotate {
transform: rotate(90deg);
transform: rotate(360deg);
}

/* Dropdown Menu styles for buttons */
.dropdown-menubutton, .dropdown-settingsbutton {
position: absolute;
top: 85%; /* Position it below the settings button */
background-color: #D9D9D9;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
z-index: 20; /* Make sure it's above other elements */
width: 150px;
overflow: hidden; /* Ensures the border-radius clips the content */
}

.dropdown-menubutton{
left: 0;
}

.dropdown-settingsbutton{
right: 0;
}

.nav .dropdown-menubutton {
margin-left: 2rem; /* Margin */
}

.nav .dropdown-settingsbutton {
margin-right: 2rem; /* Margin */
}

/* Style for each item in the dropdown menu */
.dropdown-menubutton a, .dropdown-settingsbutton a {
display: block;
background-color: #808080;
color: white;
border-radius: 15px;
top: 10px;
width: calc(100% - 20px);
padding: 5px;
margin: 5px 10px;
text-decoration: none;
transition: #154734 0.2s;
text-align: center;
font-weight: bold;
box-sizing: border-box;
}

/* Remove border from the last item */
.dropdown-menubutton a:last-child, .dropdown-settingsbutton a:last-child {
border-bottom: none;
}

/* Hover effect for each item */
.dropdown-menubutton a:hover, .dropdown-settingsbutton a:hover {
background-color: #154734;
}

.modal-backdrop {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 2000;
}

.modal {
background-color: #D9D9D9;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
width: 60%;
height: 60%;
overflow-y: auto;
position: relative;
}

.modal-header {
display: flex;
justify-content: center;
align-items: center;
}

.modal-title {
display: inline-block;
width: 150px;
background-color: #154734;
color: white;
border-radius: 15px;
padding: 5px;
margin: 10px 0;
text-align: center;
font-weight: bold;
box-sizing: border-box;
}

.modal-content {
color: black;
font-weight: bold;
}

.close-button {
position: absolute;
/* padding: 20px 20px; */
top: 10px;
right: 30px;
border: none;
background: none;
font-size: 30px;
font-weight: bold;
cursor: pointer;
color: #808080;
}

.close-button:hover {
color: #154734;
}

.modal-textarea {
flex-grow: 1;
overflow-y: auto;
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
color:black;
border: 1px solid #808080;
resize: none;
}

.modal-send-button {
padding: 5px;
background-color: #808080;
font-weight: bold;
color: white;
border: none;
border-radius: 15px;
cursor: pointer;
display: block;
background-color: #808080;
color: white;
margin: 5px 10px;
text-align: center;
box-sizing: border-box;
transition: #154734 0.2s;
width: 130px;
}

.modal-send-button:hover {
background-color: #154734;
}

.modal-content-container {
display: flex;
flex-direction: column;
height: 90%;
}
4 changes: 0 additions & 4 deletions FrontEnd/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import './App.css'
import {Routes, Route} from 'react-router-dom';
import Login from './Login';
import Home from './Home'
import Settings from './Settings'
import Menu from './Menu'


export default function App() {
Expand All @@ -12,8 +10,6 @@ export default function App() {
<Routes>
<Route path="/home" element={<Home/>} />
<Route path="/" element={<Login/>} />
<Route path="/settings" element={<Settings/>}/>
<Route path="/menu" element={<Menu/>}/>
</Routes>
);
}
23 changes: 22 additions & 1 deletion FrontEnd/src/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ export default function Login() {
const [password, setPassword] = useState('');


async function generateSessionId() {
try {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow',
credentials: 'include'
};
const response = await fetch(import.meta.env.VITE_SERVER_ENDPOINT + "/chatBot/newSessionId", requestOptions)
const data = await response.json();
return data.res;
} catch (error) {
return "Sorry, there was an issue getting the response.";
}
}

async function authorizeUser() {
try {
const credentials = JSON.stringify({
Expand All @@ -31,9 +50,11 @@ export default function Login() {
credentials: 'include'
};

const response = await fetch("http://18.189.195.246:443/auth/login", requestOptions);
const response = await fetch(import.meta.env.VITE_SERVER_ENDPOINT + "/auth/login", requestOptions);

if (response.ok) {
const newSessionId = await generateSessionId(); // Generates a unique session ID
window.sessionStorage.setItem("currentSessionId", newSessionId);
navigator('/home');
} else {
alert('Invalid Credentials');
Expand Down
89 changes: 89 additions & 0 deletions FrontEnd/src/components/MenuButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React, { useState, useRef, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import MenuIcon from "../icons/MenuIcon.svg";
import Modal from './Modal';

export default function MenuButton() {
const [isModalVisible, setIsModalVisible] = useState(false);
const [modalContent, setModalContent] = useState(null);
const [isMenuDropdownOpen, setIsMenuDropdownOpen] = useState(false);
const [isMenuIconRotated, setIsMenuIconRotated] = useState(false);
const dropdownRef = useRef(null);
const navigate = useNavigate();
/* For Modal Title */
const [modalTitle, setModalTitle] = useState("");

const toggleMenuDropdown = () => {
setIsMenuDropdownOpen(!isMenuDropdownOpen);
setIsMenuIconRotated(!isMenuIconRotated);
};

const handleSyllabusClick = () => {
//Edit src
setModalContent(<iframe src="https://github.com/jesusjimenez32/PDF/blob/c8aeddbcff0dc05596c846d76ea8683c9050ce5a/CS%204485%20-%20FA2023%20-%20Syllabus.pdf" style={{ width: '100%', height: '100%' }} />);
setModalTitle("Syllabus");
setIsModalVisible(true);
};

const handleHomeworkClick = () => {
//Edit src
setModalContent(<iframe src="https://github.com/jesusjimenez32/PDF/blob/c8aeddbcff0dc05596c846d76ea8683c9050ce5a/CS%204485%20-%20FA2023%20-%20Syllabus.pdf" style={{ width: '100%', height: '100%' }} />);
setModalTitle("Homework");
setIsModalVisible(true);
};

const handleContactTAClick = () => {
setModalContent(
<div className="modal-content-container">
<textarea placeholder="Type your message here" className="modal-textarea"></textarea>
<button className="modal-send-button">Send</button>
</div>
);
setModalTitle("Contact TA");
setIsModalVisible(true);
};

// Clear modal content when closing
const closeModal = () => {
setIsModalVisible(false);
setModalContent(null);
};

useEffect(() => {
function handleClickOutside(event) {
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
setIsMenuDropdownOpen(false);
}
}

if (isMenuDropdownOpen) {
document.addEventListener('mousedown', handleClickOutside);
}

return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [isMenuDropdownOpen]);

return (
<>
<button className="menu-button" onClick={toggleMenuDropdown}>
<img src={MenuIcon} alt="Menu Icon" className={`menu-icon ${isMenuIconRotated ? 'rotate' : ''}`} />
</button>
{isMenuDropdownOpen && (
<div ref={dropdownRef} className="dropdown-menubutton absolute left-0 top-20 mt-5 py-2 w-48 bg-white rounded-md shadow-xl z-50">
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleSyllabusClick}>Syllabus</a>
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleHomeworkClick}>Homework</a>
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleContactTAClick}>Contact TA</a>
</div>
)}
<Modal
isVisible={isModalVisible}
onClose={closeModal}
title={modalTitle}
>
{modalContent}
</Modal>
</>
);
}
20 changes: 20 additions & 0 deletions FrontEnd/src/components/Modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';

const Modal = ({ isVisible, onClose, title, children }) => {
if (!isVisible) return null;

return (
<div className="modal-backdrop">
<div className="modal">
<button className="close-button" onClick={onClose}>×</button>
<div className="modal-header">
<h2 className="modal-title">{title}</h2>
</div>
{children}
</div>
</div>
);
};


export default Modal;
Loading