diff --git a/frontend/src/components/GanttChart.tsx b/frontend/src/components/GanttChart.tsx index 841f411..79765cc 100644 --- a/frontend/src/components/GanttChart.tsx +++ b/frontend/src/components/GanttChart.tsx @@ -3,6 +3,7 @@ import { Id } from "vis-data/declarations/data-interface"; import { DataGroupCollectionType, DataItemCollectionType, DataSet, Timeline } from "vis-timeline/standalone"; import "vis-timeline/styles/vis-timeline-graph2d.min.css"; import "../styles/ganttUnassignable.css"; +import { useAuthContext } from "../security/AuthContext"; import { findCampusSolution, @@ -13,13 +14,15 @@ import { rawDate, toRawDate, } from "../scripts/solutionParsing"; -import { TimetableSolution, Unit } from "../scripts/api"; +import { REMOTE_API_URL, TimetableSolution, Unit } from "../scripts/api"; import { useParams } from "react-router-dom"; import JSZip from "jszip"; import { saveAs } from "file-saver"; +import { Button } from "@mui/material"; export default memo(function GanttChart() { const params = useParams(); + const { authHeader } = useAuthContext(); const timelineRef = useRef(null); const items = useRef(new DataSet()); const groups = useRef(new DataSet()); @@ -58,7 +61,13 @@ export default memo(function GanttChart() { end: "2024-10-19", min: "2024-10-14", max: "2024-10-19", - editable: true, + editable: { + add: false, // add new items by double tapping + updateTime: true, // drag items horizontally + updateGroup: true, // drag items from one group to another + remove: false, // delete an item by tapping the delete button top right + overrideItems: false, // allow these options to override item.editable + }, }; // Initialize the timeline @@ -199,7 +208,7 @@ export default memo(function GanttChart() { "-" + course.replace(/[^a-zA-Z0-9]/g, "_") + ".csv", - csvData + csvData.replace(/\u00A0/g, " ") ); } }) @@ -214,10 +223,11 @@ export default memo(function GanttChart() { const saveData = async () => { try { - const response = await fetch("http://localhost:8080/timetabling/update", { + const response = await fetch(REMOTE_API_URL + "/timetabling/update", { method: "PUT", headers: { "Content-Type": "application/json", + "Authorization": authHeader, }, body: JSON.stringify(moddedUnits), }); @@ -225,6 +235,21 @@ export default memo(function GanttChart() { if (!response.ok) { throw new Error("Failed to save data, error in GanttChart.tsx"); } + + + + fetch(REMOTE_API_URL + "/timetabling/view", { headers: { 'Authorization': authHeader } }) + .then((response) => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.json(); + }) + .then((data) => { + const timetableSolutions: TimetableSolution[] = + data as TimetableSolution[]; + sessionStorage.setItem("campusSolutions", JSON.stringify(timetableSolutions)); + }); } catch (error) { console.error("Error saving data:", error); } @@ -233,8 +258,43 @@ export default memo(function GanttChart() { return (
- - + +
); }) diff --git a/frontend/src/pages/Enrolment.tsx b/frontend/src/pages/Enrolment.tsx index 1d1cf76..fa9557d 100644 --- a/frontend/src/pages/Enrolment.tsx +++ b/frontend/src/pages/Enrolment.tsx @@ -48,17 +48,29 @@ export default function StarterPage() {
- + Time tabler - The smartest Timetabler ever -

A timetabling website for the Victorian Institute of Technology

-

-Team JetEdge

+ + The smartest Timetabler ever + +

+ A timetabling website for the Victorian Institute of Technology +

+

-Team JetEdge

- +
- logo.exe + logo.exe