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

Add overview button to admin page of projects #384

Merged
merged 7 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
AronBuzogany marked this conversation as resolved.
Show resolved Hide resolved
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