Skip to content

Commit

Permalink
Small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
usserwoutV2 committed May 13, 2024
1 parent fe2a39d commit e20a17b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 59 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/common/saveDockerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const saveDockerForm = async (form:FormInstance, initialDockerValues: DockerForm
return API.POST(ApiRoutes.PROJECT_TESTS, { body: data, pathValues: {id: projectId}})
}

if(data.dockerImage === null || data.dockerImage.length === 0 ) {
if(data.dockerImage == null || data.dockerImage.length === 0 ) {
// We do a delete
console.log("DELETE", data);
return API.DELETE(ApiRoutes.PROJECT_TESTS, { pathValues: {id: projectId} })
Expand Down
1 change: 0 additions & 1 deletion frontend/src/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"structureFailed": "Structure tests failed",
"passed": "Passed",
"uploadDirectory": "Upload directory",
"submission": "Submission",
"notSubmitted": "Not submitted",
"submitSuccess": "Submission successful",
"submissionTime": "Submission time",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/index/components/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ProjectCard: FC<{ courseId?: number }> = ({ courseId }) => {
}}
>
<ProjectTable
ignoreColumns={courseId == undefined ? ["course"] : []}
ignoreColumns={["course"] }
projects={projects}
/>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/project/components/SubmissionTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SubmissionTab: FC<{ projectId: number; courseId: number }> = ({ projectId,
return () => {
ignore = true
}
}, [projectId,courseId,API])
}, [projectId,courseId])



Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/project/components/SubmissionsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SubmissionsTab = () => {
return () => {
ignore = true
}
}, [API,projectId])
}, [projectId])

const handleDownloadSubmissions = () => {
// TODO: implement this!
Expand Down
80 changes: 30 additions & 50 deletions frontend/src/pages/submission/components/SubmissionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ import {ApiRoutes} from "../../../@types/requests"
import {ArrowLeftOutlined} from "@ant-design/icons"
import {useNavigate} from "react-router-dom"
import "@fontsource/jetbrains-mono"
import {useEffect, useState} from "react"
import apiCall from "../../../util/apiFetch"

export type SubmissionType = GET_Responses[ApiRoutes.SUBMISSION]

const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission}) => {
const {token} = theme.useToken()
const {t} = useTranslation()
const [structureFeedback, setStructureFeedback] = useState<string | null>(null)
const [dockerFeedback, setDockerFeedback] = useState<string | null>(null)
const navigate = useNavigate()
useEffect(() => {
if (!submission.dockerAccepted) apiCall.get(submission.dockerFeedbackUrl).then((res) => setDockerFeedback(res.data ? res.data : ""))
if (!submission.structureAccepted) apiCall.get(submission.structureFeedbackUrl).then((res) => setStructureFeedback(res.data ? res.data : ""))
}, [submission.dockerFeedbackUrl, submission.structureFeedbackUrl])

const downloadSubmission = async () => {
try {
Expand Down Expand Up @@ -49,6 +42,7 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission})
}
}

const feedback = "TODO: feedback"
return (
<Card
styles={{
Expand Down Expand Up @@ -94,27 +88,20 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission})
<Typography.Text
type={submission.structureAccepted ? "success" : "danger"}>{submission.structureAccepted ? t("submission.status.accepted") : t("submission.status.failed")}</Typography.Text>
{submission.structureAccepted ? null : (
<div>
{structureFeedback === null ? (
<Spin/>
) : (
<Input.TextArea
readOnly
value={structureFeedback}
style={{
width: "100%",
overflowX: "auto",
overflowY: "auto",
resize: "none",
fontFamily: "Jetbrains Mono",
marginTop: 8
}}
rows={4}
autoSize={{minRows: 4, maxRows: 8}}
/>
)}
</div>
)}
<div>
{submission.structureFeedback === null ? (
<Spin />
) : (
<Input.TextArea
readOnly
value={submission.structureFeedback}
style={{ width: "100%", overflowX: "auto", overflowY: "auto", resize: "none", fontFamily: "Jetbrains Mono", marginTop: 8 }}
rows={4}
autoSize={{ minRows: 4, maxRows: 8 }}
/>
)}
</div>
)}
</li>
</ul>

Expand All @@ -124,28 +111,21 @@ const SubmissionCard: React.FC<{ submission: SubmissionType }> = ({submission})
<li>
<Typography.Text
type={submission.dockerAccepted ? "success" : "danger"}>{submission.dockerAccepted ? t("submission.status.accepted") : t("submission.status.failed")}</Typography.Text>
{submission.dockerAccepted ? null : (
<div>
{dockerFeedback === null ? (
<Spin/>
) : (
<Input.TextArea
readOnly
value={dockerFeedback}
style={{
width: "100%",
overflowX: "auto",
overflowY: "auto",
resize: "none",
fontFamily: "Jetbrains Mono",
marginTop: 8
}}
rows={4}
autoSize={{minRows: 4, maxRows: 16}}
/>
)}
</div>
)}
{submission.dockerAccepted ? null : (
<div>
{submission.dockerFeedback === null ? (
<Spin />
) : (
<Input.TextArea
readOnly
value={feedback}
style={{ width: "100%", overflowX: "auto", overflowY: "auto", resize: "none", fontFamily: "Jetbrains Mono", marginTop: 8 }}
rows={4}
autoSize={{ minRows: 4, maxRows: 16 }}
/>
)}
</div>
)}
</li>
</ul>
</Card>
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/pages/submit/Submit.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {Affix, Button, Card, Col, Form, Row, Typography} from "antd"
import {Button, Card, Col, Form, Row} from "antd"
import {useTranslation} from "react-i18next"
import SubmitForm from "./components/SubmitForm"
import SubmitStructure from "./components/SubmitStructure"
import {useNavigate, useParams} from "react-router-dom"
import React, {useState, useRef} from 'react';
import {useState} from 'react';
import apiCall from "../../util/apiFetch";
import {ApiRoutes} from "../../@types/requests.d";
import JSZip from 'jszip';
import { Popconfirm, message } from 'antd';
import { message } from 'antd';
import {AppRoutes} from "../../@types/routes";
import submission from "../submission/Submission";

const Submit = () => {
const {t} = useTranslation()
Expand Down

0 comments on commit e20a17b

Please sign in to comment.