-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
650d7aa
commit c55b4ef
Showing
9 changed files
with
192 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Elysia } from "elysia"; | ||
import { t } from "elysia"; | ||
import { getAcademicYearId } from "../../controllers"; | ||
|
||
const PYTHON_SERVER_URL = "http://localhost:5000"; | ||
|
||
const app = new Elysia({ prefix: "/generateTT" }) | ||
.get( | ||
"/department/:id", | ||
async ({ params }) => { | ||
const { id } = params; | ||
const academicYearId = await getAcademicYearId("department", id); | ||
return await fetch(`${PYTHON_SERVER_URL}/generate/department/${id}/${academicYearId}`); | ||
}, | ||
{ | ||
detail: { | ||
summary: "Generate division timetable", | ||
tags: ["Generate Timetable"], | ||
}, | ||
params: t.Object({ | ||
id: t.Numeric(), | ||
}), | ||
}, | ||
) | ||
.get( | ||
"/loading", | ||
async ({ body }) => { | ||
return await fetch(`${PYTHON_SERVER_URL}/loading`); | ||
}, | ||
{ | ||
detail: { | ||
summary: "Get loading status", | ||
tags: ["Generate Timetable"], | ||
}, | ||
}, | ||
); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Button } from "@mui/material"; | ||
import { SelectedValuesContext } from "../../context/SelectedValuesContext"; | ||
import React, { useContext } from "react"; | ||
import api from "../.."; | ||
import { TimetableDataContext } from "../../context/TimetableDataContext"; | ||
import { TimetableResponse } from "../../../backend/api/routes/responseTypes"; | ||
import { edenFetch } from "../fetchAndSet"; | ||
|
||
export default function Generate() { | ||
const { selectedValues } = useContext(SelectedValuesContext); | ||
const { setTimetable, setAvailable } = useContext(TimetableDataContext); | ||
const handleClick = () => { | ||
const divisionId = selectedValues.division.value; | ||
const departmentId = selectedValues.department.value; | ||
if (!divisionId || !departmentId) return; | ||
edenFetch(api.generateTT.department({ id: departmentId }).get()).then((data) => { | ||
console.log(data); | ||
api.divisions({ id: divisionId }) | ||
.timetable.get() | ||
.then(({ data, error }) => { | ||
if (error) return console.log(error); | ||
setTimetable(data ?? ({} as TimetableResponse)); | ||
setAvailable(true); | ||
}); | ||
}) | ||
}; | ||
return ( | ||
<Button variant="contained" sx={{ height: "3rem" }} onClick={handleClick}> | ||
Generate New | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
import { styled } from "@mui/material/styles"; | ||
import Button from "@mui/material/Button"; | ||
import CloudUploadIcon from "@mui/icons-material/CloudUpload"; | ||
|
||
const VisuallyHiddenInput = styled("input")({ | ||
clip: "rect(0 0 0 0)", | ||
clipPath: "inset(50%)", | ||
height: 1, | ||
overflow: "hidden", | ||
position: "absolute", | ||
bottom: 0, | ||
left: 0, | ||
whiteSpace: "nowrap", | ||
width: 1, | ||
}); | ||
|
||
export default function InputFileUpload() { | ||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files?.[0] ?? null; | ||
if (file === null) return; | ||
const formData = new FormData(); | ||
formData.append("file", file); | ||
formData.append("academicYearId", "1"); | ||
fetch("http://localhost:3000/csv/batchAndSubdivisions", { | ||
method: "POST", | ||
body: formData, | ||
}); | ||
}; | ||
return ( | ||
<Button | ||
component="label" | ||
role={undefined} | ||
variant="contained" | ||
tabIndex={-1} | ||
startIcon={<CloudUploadIcon />} | ||
sx={{margin: "0.5rem"}} | ||
> | ||
Batch And Subdivision Upload | ||
<VisuallyHiddenInput type="file" accept=".csv" onChange={handleFileChange} /> | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react"; | ||
import { styled } from "@mui/material/styles"; | ||
import Button from "@mui/material/Button"; | ||
import CloudUploadIcon from "@mui/icons-material/CloudUpload"; | ||
|
||
const VisuallyHiddenInput = styled("input")({ | ||
clip: "rect(0 0 0 0)", | ||
clipPath: "inset(50%)", | ||
height: 1, | ||
overflow: "hidden", | ||
position: "absolute", | ||
bottom: 0, | ||
left: 0, | ||
whiteSpace: "nowrap", | ||
width: 1, | ||
}); | ||
|
||
export default function InputFileUpload() { | ||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files?.[0] ?? null; | ||
if (file === null) return; | ||
const formData = new FormData(); | ||
formData.append("file", file); | ||
formData.append("academicYearId", "1"); | ||
fetch("http://localhost:3000/csv/classrooms", { | ||
method: "POST", | ||
body: formData, | ||
}); | ||
}; | ||
return ( | ||
<Button | ||
component="label" | ||
role={undefined} | ||
variant="contained" | ||
tabIndex={-1} | ||
startIcon={<CloudUploadIcon />} | ||
sx={{margin: "0.5rem"}} | ||
|
||
> | ||
Classroom Upload | ||
<VisuallyHiddenInput type="file" accept=".csv" onChange={handleFileChange} /> | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters