Skip to content

Commit

Permalink
Add overview button to admin page of projects (#384)
Browse files Browse the repository at this point in the history
* changes bekijken

* beaucoup

* edit title and description functionality

* linter :nerd:

* frontend linter

---------

Co-authored-by: Siebe Vlietinck <71773032+Vucis@users.noreply.github.com>
  • Loading branch information
Gerwoud and Vucis authored May 23, 2024
1 parent fe979f5 commit 37606d4
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 64 deletions.
4 changes: 3 additions & 1 deletion backend/project/endpoints/projects/endpoint_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
help='Projects visibility for students',
location="form"
)
parser.add_argument("archived", type=bool, help='Projects', location="form")
parser.add_argument("archived", type=str, help='Projects', location="form")
parser.add_argument(
"regex_expressions",
type=str,
Expand Down Expand Up @@ -61,6 +61,8 @@ def parse_project_params():
)
)
result_dict[key] = new_deadlines
elif "archived" == key:
result_dict[key] = value == "true"
else:
result_dict[key] = value

Expand Down
8 changes: 5 additions & 3 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"cancel": "Cancel",
"create": "Create",
"activeCourses": "Active Courses",
"archivedCourses":"Archived Courses"
"archivedCourses":"Archived Courses"
},
"courseForm": {
"courseName": "Course Name",
Expand All @@ -72,7 +72,9 @@
"running": "Running",
"submitTime": "Time submitted",
"status": "Status"
}
},
"projectOverview": "Overview",
"archive": "Archive"
},
"time": {
"yearsAgo": "years ago",
Expand Down Expand Up @@ -149,4 +151,4 @@
"no_projects": "There are no projects here.",
"new_project": "New Project"
}
}
}
4 changes: 3 additions & 1 deletion frontend/public/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@
"running": "Aan het uitvoeren",
"submitTime": "Indientijd",
"status": "Status"
}
},
"projectOverview": "Overzicht",
"archive": "Archiveer"
},
"time": {
"yearsAgo": "jaren geleden",
Expand Down
43 changes: 43 additions & 0 deletions frontend/src/components/DeadlineView/DeadlineGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow} from "@mui/material";
import {Deadline} from "../../types/deadline.ts";
import {useTranslation} from "react-i18next";

interface Props {
deadlines: Deadline[];
minWidth: number
}

/**
* @returns grid that displays deadlines in a grid
*/
export default function DeadlineGrid({deadlines, minWidth}: Props) {

const { t } = useTranslation('translation', { keyPrefix: 'projectForm' });

return (
<TableContainer component={Paper}>
<Table sx={{ minWidth: minWidth }}>
<TableHead>
<TableRow>
<TableCell sx={{ fontWeight: 'bold' }}>{t("deadline")}</TableCell>
<TableCell sx={{ fontWeight: 'bold' }} align="right">{t("description")}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{deadlines.length === 0 ? ( // Check if deadlines is empty
<TableRow>
<TableCell colSpan={2} align="center">{t("noDeadlinesPlaceholder")}</TableCell>
</TableRow>
) : (
deadlines.map((deadline, index) => (
<TableRow key={index} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">{deadline.deadline}</TableCell>
<TableCell align="right">{deadline.description}</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</TableContainer>
)
}
26 changes: 2 additions & 24 deletions frontend/src/components/ProjectForm/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import AdvancedRegex from "./AdvancedRegex.tsx";
import RunnerSelecter from "./RunnerSelecter.tsx";
import { authenticatedFetch } from "../../utils/authenticated-fetch.ts";
import i18next from "i18next";
import DeadlineGrid from "../DeadlineView/DeadlineGrid.tsx";

interface Course {
course_id: string;
Expand Down Expand Up @@ -332,30 +333,7 @@ export default function ProjectForm() {
deadlines={[]}
onChange={(deadlines: Deadline[]) => handleDeadlineChange(deadlines)}
editable={true} />
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }}>
<TableHead>
<TableRow>
<TableCell sx={{ fontWeight: 'bold' }}>{t("deadline")}</TableCell>
<TableCell sx={{ fontWeight: 'bold' }} align="right">{t("description")}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{deadlines.length === 0 ? ( // Check if deadlines is empty
<TableRow>
<TableCell colSpan={2} align="center">{t("noDeadlinesPlaceholder")}</TableCell>
</TableRow>
) : (
deadlines.map((deadline, index) => (
<TableRow key={index} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">{deadline.deadline}</TableCell>
<TableCell align="right">{deadline.description}</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</TableContainer>
<DeadlineGrid deadlines={deadlines} minWidth={650} />
</Grid>
<Grid item>
<Stack direction="row" style={{display: "flex", alignItems:"center"}}>
Expand Down
Loading

0 comments on commit 37606d4

Please sign in to comment.