Skip to content

Commit

Permalink
Merge branch 'frontend' into mainpage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendemeurichy authored Mar 13, 2024
2 parents ff17a56 + 86cb45e commit 660fd3f
Show file tree
Hide file tree
Showing 22 changed files with 855 additions and 154 deletions.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {ListItem, ListItemButton, ListItemText, Divider} from "@mui/material";
import {useNavigate} from "react-router-dom";
import {t} from "i18next";
interface AssignmentListItemSubjectsPageProps {
key: string;
projectName: string;
dueDate?: Date;
submissions: number;
score: number;
isStudent: boolean;
}

/*
* This component is used to display a single assignment in the list of assignments
* @param key: string - the key of the assignment
* @param projectName: string - the name of the project
* @param dueDate: Date - the due date of the project
* @param submissions: number - number of submissions for the project
* @param score: number - assigned score on the project
* @param isStudent: boolean - if the user is a student or a teacher
*/

export function AssignmentListItemSubjectsPage({key,projectName, dueDate, submissions, score, isStudent}:AssignmentListItemSubjectsPageProps) {
const navigate = useNavigate();
const handleProjectClick = () => {
console.log("Project clicked");
navigate(`/${key}`)
}

return (
<>
<ListItem key={projectName} sx={{margin:0}} disablePadding={true}>
<ListItemButton onClick={handleProjectClick} sx={{
width: "100%",
height: 30,
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
paddingX: 1,
paddingY: 3,
borderRadius:2,
}}>
{isStudent?
<>
<ListItemText sx={{maxWidth:100}} primary={projectName}/>
<ListItemText sx={{maxWidth:110}} primary={dueDate? dueDate.toLocaleDateString() : t("no_deadline")}/>
<ListItemText sx={{maxWidth:100}} primary={submissions + " indieningen"}/>
<ListItemText sx={{maxWidth:50}} primary={score + "/20"}/>
</>
:
<>
<ListItemText sx={{maxWidth:100}} primary={projectName}/>
<ListItemText sx={{maxWidth:110}} primary={dueDate? dueDate.toLocaleDateString() : t("no_deadline")}/>
<ListItemText sx={{maxWidth:40}} primary={"edit"}/>
</>
}
</ListItemButton>
</ListItem>
<Divider color={"text.main"}></Divider>
</>
);
}
50 changes: 50 additions & 0 deletions frontend/frontend/src/components/StudentScoreListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {ListItem, ListItemText, Divider, TextField, IconButton} from "@mui/material";
import DownloadIcon from '@mui/icons-material/Download';
import {t} from "i18next";

interface StudentScoreListItemProps {
key: string;
studentName: string;
submissionFiles: string[];
}

/*
* This component is used to display a single assignment in the list of assignments
* @param key: string - the key of the studentOnProject
* @param studentName: string - the name of the student
* @param submissionFiles: string[] - a list of all files submitted by this student
*/

export function StudentScoreListItem({key, studentName, submissionFiles}:StudentScoreListItemProps) {
return (
<>
<ListItem key={studentName} sx={{margin:0}} disablePadding={true}>
<ListItem sx={{
width: "100%",
height: 30,
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
paddingX: 1,
paddingY: 3,
borderRadius:2,
}}>
<>
<ListItemText sx={{maxWidth:100}} primary={studentName}/>
<ListItemText sx={{maxWidth:110}} primary={submissionFiles.length? submissionFiles.length + " indieningen" : "geen indieningen"}/>
<ListItem sx={{maxWidth:100}}>
<TextField hiddenLabel defaultValue="0" variant="filled" size="small" />
<ListItemText sx={{maxWidth:100}} primary="/20"/>
</ListItem>
<ListItem sx={{maxWidth:100}}>
<IconButton edge="end" aria-label="download">
<DownloadIcon />
</IconButton>
</ListItem>
</>
</ListItem>
</ListItem>
<Divider color={"text.main"}></Divider>
</>
);
}
20 changes: 16 additions & 4 deletions frontend/frontend/src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,38 @@ import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";

const english = {
logo: "./src/assets/logo_UGent_EN_RGB_2400_white.png",
logo_blue: "./src/assets/logo_UGent_EN_RGB_2400_color.png",
logo: "/assets/logo_UGent_EN_RGB_2400_white.png",
logo_blue: "/assets/logo_UGent_EN_RGB_2400_color.png",
login: "Log in with your UGent account",
back: "Back",
current_courses: "Current courses",
archived: "Archived",
students: "Students: ",
no_deadline: "No deadline",
add_admin: "Add admin",
submission: "Submission",
error: "Something went wrong.",
assignment: "Assignment:",
filename: "Submitted file:",
restrictions: "Restrictions:",
current_projects: "Current projects",
};
const dutch = {
logo: "./src/assets/logo_UGent_NL_RGB_2400_wit.png",
logo_blue: "./src/assets/logo_UGent_NL_RGB_2400_kleur.png",
logo: "/assets/logo_UGent_NL_RGB_2400_wit.png",
logo_blue: "/assets/logo_UGent_NL_RGB_2400_kleur.png",
login: "Log in met je UGent account",
back: "Terug",
current_courses: "Huidige vakken",
archived: "Gearchiveerd",
students: "Studenten: ",
no_deadline: "Geen deadline",
add_admin: "Voeg admin toe",
submission: "Indiening",
error: "Er is iets misgegaan.",
assignment: "Opgave:",
filename: "Ingediend bestand:",
restrictions: "Restricties:",
current_projects: "Huidige projecten",
};

i18n.use(initReactI18next).use(LanguageDetector).init({
Expand Down
23 changes: 21 additions & 2 deletions frontend/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,42 @@ import ErrorPage from "./pages/ErrorPage.tsx";

import {MainPage} from "./pages/mainPage/MainPage.tsx";
import {Helmet, HelmetProvider} from "react-helmet-async";

import { SubjectsStudentPage } from "./pages/subjectsPage/SubjectsStudentPage.tsx";
import { SubjectsTeacherPage } from "./pages/subjectsPage/SubjectsTeacherPage.tsx";
import { ProjectScoresPage } from "./pages/scoresPage/ProjectScoresPage.tsx";
import { SubjectsStudentPage } from "./pages/subjects_page/SubjectsStudentPage.tsx";
import { AssignmentStudentPage } from "./pages/assignmentPage/assignmentStudentPage";
import { AssignmentTeacherPage } from "./pages/assignmentPage/assignmentTeacherPage.tsx";
import { GroupsPage } from "./pages/groupsPage/groupsPage.tsx";
import {SubjectsStudentPage} from "./pages/subjects_page/SubjectsStudentPage.tsx";

import {LocalizationProvider} from "@mui/x-date-pickers";
import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs/AdapterDayjs';

import {SubmissionPage} from "./pages/submissionPage/SubmissionPage.tsx";
import {SimpleRequestsPage} from "./pages/simpleRequestsPage/SimpleRequestsPage.tsx";


const router = createBrowserRouter([
{
path: "/",
element: <MainPage />,
errorElement: <ErrorPage />,
},
{
path: "/subjects_student",
path: "/subjects_student/:courseId",
element: <SubjectsStudentPage />,
},
{

path: "/subjects_teacher/:courseId",
element: <SubjectsTeacherPage />,
},
{
path: "/scores",
element: <ProjectScoresPage />,
},

path: "/assignment_student",
element: <AssignmentStudentPage />,
},
Expand All @@ -47,6 +61,11 @@ const router = createBrowserRouter([
},

{

path: "/submission/:project",
element: <SubmissionPage/>,
},
{
path: "/test_requests",
element: <SimpleRequestsPage/>,
}
Expand Down
122 changes: 113 additions & 9 deletions frontend/frontend/src/pages/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,122 @@
import { useRouteError } from "react-router-dom";
import {isRouteErrorResponse, useRouteError} from "react-router-dom";
import {Box, Typography} from "@mui/material";
import {t} from "i18next";

//TODO:: fix a decent error page
export default function ErrorPage() {

const error = useRouteError();
console.error(error);
let errorMessage: string;

if (isRouteErrorResponse(error)) {
// error is type `ErrorResponse`
errorMessage = error.error?.message || error.statusText;
} else if (error instanceof Error) {
errorMessage = error.message;
} else if (typeof error === 'string') {
errorMessage = error;
} else {
console.error(error);
errorMessage = 'Unknown error';
}

return (
<div id="error-page">
<h1>Oops!</h1>
<p>Sorry, an unexpected error has occurred.</p>
<p>
error
</p>
</div>
<>
<Box
position="fixed"
top={0}
left={0}
height="100%"
width="100%"
component="div"
sx={{
backgroundColor: "secondary.main",
alignItems: "center",
justifyContent: "center",
display: "flex",
backgroundSize: "cover",
}}
>
<Box
className="background-image"
component="div"
height="100%"
width="100%"
top={0}
left={0}
sx={{
backgroundImage: `url(/assets/ufo-logo-3375276369.png)`,
opacity: 0.2,
position: "fixed",
backgroundSize: "cover",
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
padding: 0,
margin: 0,
zIndex: -1,
}}
/>
<Box
component="div"
className="contentContainer"
display="flex"
position={"relative"}
flexDirection="column"
alignItems="center"
justifyContent={"center"}
alignSelf={"center"}
maxWidth="60%"
maxHeight="60%"
>
<Box
component="div"
className="upperContainer"
display="flex"
flexDirection="row"
alignItems="center"
justifyContent={"center"}
alignSelf={"center"}
>
<Box
component="img"
src={t("logo_blue")}
alt="logo"
sx={{
maxHeight: "20%",
maxWidth: "30%",
}}
/>
<Box
component="div"
display="flex"
flexDirection="column"
maxWidth={"40%"}
maxHeight={"30%"}

>
<Typography
variant="h4"
sx={{
color: "error.main",
maxWidth: "100%",
maxHeight: "50%",
}}
>
{t("error")}
</Typography>
<Typography variant={"h5"} sx={{
color: "error.main",
maxWidth: "100%",
maxHeight: "50%",
}}>
{errorMessage}
</Typography>
</Box>
</Box>
</Box>
</Box>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function ArchivedProjectsView() {
return (
<>

</>
);
}
Loading

0 comments on commit 660fd3f

Please sign in to comment.