From 4fbcb47479fc4ff668058bf5e8ae5541613e9141 Mon Sep 17 00:00:00 2001 From: Erica Dong Date: Sun, 14 Jan 2024 02:04:13 -0500 Subject: [PATCH] Debug roadmap --- src/components/Dashboard/Dashboard.js | 11 ++++++----- src/components/Dashboard/Flow.js | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index 8c5dba2..55fab5d 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -23,7 +23,7 @@ import { auth, logout } from "../../Firebase.js"; import RequestUtils from "../../Utils/RequestUtils.js"; import { useAuthState } from "react-firebase-hooks/auth"; -const data = require('./courses.json'); +const data = require('./Courses.json'); const { Option } = Select; const { Header, Sider, Content } = Layout; @@ -92,12 +92,13 @@ function Dashboard() { let y = 0; function setCourses() { - console.log(data); + console.log(department); tempCourses = []; tempEdges = []; + courseTracking = []; let encounteredCodes = new Set(); - for (var i = 0; i < data.Report_Entry.length; i++) { + for (let i = 0; i < data.Report_Entry.length; i++) { if ( data.Report_Entry[i]["Course_Section_Owner"] == department && !courseTracking.includes(data.Report_Entry[i]["Course_Title"]) @@ -141,7 +142,7 @@ function Dashboard() { }) // // Print the extracted course codes - for (var j = 0; j < tempCourses.length; j++) { + for (let j = 0; j < tempCourses.length; j++) { if (courseCodes.length > 0) { for (var k = 0; k < courseCodes.length; k++) { if ( @@ -177,7 +178,7 @@ function Dashboard() { tempCourses.push({ id: i - 1 + data.Report_Entry.length, data: { label: (i == 7 ? 'Grad' : i + '000') + 'Courses' }, - style: { display: "none" }, + // style: { }, type: 'group', courseType: i, courseCode: "", diff --git a/src/components/Dashboard/Flow.js b/src/components/Dashboard/Flow.js index 68b6406..a5342b5 100644 --- a/src/components/Dashboard/Flow.js +++ b/src/components/Dashboard/Flow.js @@ -13,9 +13,8 @@ import ReactFlow, { import 'reactflow/dist/style.css'; import DataParse from '../DataParse/DataParse'; -import profRatings from '../DataParse/ProfessorRating.json'; -import classRatings from '../DataParse/CourseRatings.json'; -import data from "../DataParse/prod-data.json" +import profRatingsJSON from '../DataParse/ProfessorRating.json'; +import classRatingsJSON from '../DataParse/CourseRatings.json'; const elk = new ELK(); const elkOptions = { @@ -34,7 +33,7 @@ const lerpColor = (h1, h2, progress) => { return `hsl(${h1 + Math.round((h2-h1) * progress)}, 100%, 80%)` } -const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = {}) => { +const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, profRatings, classRatings, options = {}) => { const easyColor = 125; const hardColor = -50; const codesLeft = new Set(); @@ -46,8 +45,8 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = const courseRating = classRatings[node.courseCode] ? classRatings[node.courseCode] : Math.round(Math.random() * 100); const profRating = profRatings[node.professor] ? profRatings[node.professor] : Math.round(Math.random() * 100); // shouldn't be nan so often + if(profRatings[node.professor] == NaN) console.log(node.professor); const projRating = 0.6 * profRating + 0.4 * courseRating; - // console.log(profRatings[node.professor] + " " + node.professor) let gradRe = new RegExp("[A-Z]{2,3} [5-9][0-9]*") let style = {}; @@ -71,6 +70,9 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = style.backgroundColor = "rgb(138, 138, 138)"; style.color = "rgb(225, 225, 225)"; } + if (node.type === "group") { + style.display = "none"; + } return { ...node, @@ -110,6 +112,9 @@ function FlowWithoutProvider({initialNodes, initialEdges, colorSchema, coursesTa const [edges, setEdges, onEdgesChange] = useEdgesState([]); const { fitView } = useReactFlow(); + const [profRatings, setProfRatings] = useState(profRatingsJSON); + const [classRatings, setClassRatings] = useState(classRatingsJSON); + let [courseCode, setCourseCode] = useState(""); const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), []); @@ -119,14 +124,14 @@ function FlowWithoutProvider({initialNodes, initialEdges, colorSchema, coursesTa const ns = useInitialNodes ? initialNodes : nodes; const es = useInitialNodes ? initialEdges : edges; - getLayoutedElements(ns, es, colorSchema, coursesTaken, opts).then(({ nodes: layoutedNodes, edges: layoutedEdges }) => { + getLayoutedElements(ns, es, colorSchema, coursesTaken, profRatings, classRatings, opts).then(({ nodes: layoutedNodes, edges: layoutedEdges }) => { setNodes(layoutedNodes); setEdges(layoutedEdges); window.requestAnimationFrame(() => fitView()); }); }, - [nodes, edges, initialNodes, initialEdges, colorSchema, coursesTaken] + [nodes, edges, initialNodes, initialEdges, colorSchema, coursesTaken, profRatings, classRatings] ); useLayoutEffect(() => {