Skip to content
Open
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: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# VITE_API_URL=https://360Api.gordon.edu/

# @TRAIN
VITE_API_URL=https://360ApiTrain.gordon.edu/
# VITE_API_URL=https://360ApiTrain.gordon.edu/

# @LOCALHOST
# VITE_API_URL=http://localhost:51660/
VITE_API_URL=http://localhost:51634/

13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lodash": "^4.17.21",
"prop-types": ">=15.7.2",
"react": "^18.3.1",
"react-big-calendar": "^1.10.3",
"react-big-calendar": "^1.19.2",
"react-chartjs-2": "^5.2.0",
"react-cropper": "^2.3.3",
"react-csv": "^2.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
border-top-right-radius: 4px;
}
}

.quad-course {
max-width: 50%;
background-color: red;
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,18 @@ button.rbc-input::-moz-focus-inner {
border-bottom: 1px solid var(--mui-palette-neutral-dark);
flex-shrink: 0;
}

.subterm {
max-width: 55% !important;
padding-left: 2px;
filter: brightness(145%);
left: auto !important;
}

.subterm1 {
left: 0%;
}

.subterm2 {
right: 0%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import './ScheduleCalendar.css';
import { format, getDay, startOfWeek } from 'date-fns';
import { enUS } from 'date-fns/locale';
import EventWrapper from 'react-big-calendar/lib/addons/dragAndDrop';

Check warning on line 6 in src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx

View workflow job for this annotation

GitHub Actions / build

'EventWrapper' is defined but never used

const locales = {
'en-US': enUS,
Expand All @@ -20,6 +21,10 @@
onSelectEvent: (event: CourseEvent) => void;
};

const EventWrapperCustom = ({ label }: { label: CourseEvent }) => {

Check warning on line 24 in src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx

View workflow job for this annotation

GitHub Actions / build

'EventWrapperCustom' is assigned a value but never used
return <strong>test {label.title}</strong>;
};

const GordonScheduleCalendar = ({ schedule, onSelectEvent }: Props) => {
const dayStart = new Date();
dayStart.setHours(8, 0, 0, 0);
Expand All @@ -35,12 +40,31 @@
: course.location.includes('null')
? (title = tempTitle)
: (title = tempTitle + `\n${course.location}`);

return { ...course, title };
});

console.log(courseFormat);

return (
<Calendar
//components={{event: EventWrapperCustom}}
style={{ whiteSpace: 'pre-wrap' }}
eventPropGetter={(event: CourseEvent) => {
const firstQuadOfSemester = ['Fall 1', 'Spring 1', 'Summer 1'];
const secondQuadOfSemester = ['Fall 2', 'Spring 2', 'Summer 2'];
let subtermClassNames = ['subterm'];
console.log(event.subtermCode);
console.log(secondQuadOfSemester.includes(event.subtermCode));
if (firstQuadOfSemester.includes(event.subtermCode)) {
subtermClassNames.push('subterm1');
} else if (secondQuadOfSemester.includes(event.subtermCode)) {
subtermClassNames.push('subterm2');
} else {
return {};
}
return { className: subtermClassNames.join(' ') };
}}
events={courseFormat}
localizer={localizer}
min={dayStart}
Expand Down
26 changes: 16 additions & 10 deletions src/components/Profile/components/SchedulePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import styles from './ScheduleHeader.module.css';
import scheduleService, { CourseEvent, Schedule } from 'services/schedule';
import sessionService from 'services/session';
import { Profile } from 'services/user';
import { AuthError } from 'services/error';

type Props = {
profile: Profile;
Expand All @@ -38,17 +39,22 @@ const GordonSchedulePanel = ({ profile, myProf }: Props) => {
Promise.all([
scheduleService.getAllSessionSchedules(profile.AD_Username),
sessionService.getCurrent(),
]).then(([allSessionSchedules, currentSession]) => {
setAllSchedules(allSessionSchedules);
const defaultSchedule =
// If there is a schedule for the current session, make it d4fault
allSessionSchedules.find((s) => s.session.SessionCode === currentSession.SessionCode) ??
// Otherwise, use the most recent session
allSessionSchedules[0];
setSelectedSchedule(defaultSchedule);
setLoading(false);
});
])
.then(([allSessionSchedules, currentSession]) => {
setAllSchedules(allSessionSchedules);
const defaultSchedule =
// If there is a schedule for the current session, make it d4fault
allSessionSchedules.find((s) => s.session.SessionCode === currentSession.SessionCode) ??
// Otherwise, use the most recent session
allSessionSchedules[0];
setSelectedSchedule(defaultSchedule);
setLoading(false);
})
.catch((reason: AuthError) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This AuthError comes from Microsoft's Authentication library, and is unrelated to authorization errors thrown by the backend.

setLoading(false);
});
}, [profile.AD_Username]);

const toggleIsScheduleOpen = () => {
setIsScheduleOpen((wasOpen) => {
localStorage.setItem(scheduleOpenKey, String(!wasOpen));
Expand Down
6 changes: 4 additions & 2 deletions src/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

const isOnline = useNetworkStatus();
const viewerIsPolice = useAuthGroups(AuthGroup.Police);
const [canReadStudentSchedules, setCanReadStudentSchedules] = useState<boolean>();

Check warning on line 41 in src/components/Profile/index.tsx

View workflow job for this annotation

GitHub Actions / build

'canReadStudentSchedules' is assigned a value but never used
const profileIsStudent = profile.PersonType?.includes('stu');
const profileIsStaff = profile.Type == 'Staff'; // should we create an dict enum of the possible values?

Check failure on line 43 in src/components/Profile/index.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'Type' does not exist on type 'Profile'.

Check warning on line 43 in src/components/Profile/index.tsx

View workflow job for this annotation

GitHub Actions / build

Expected '===' and instead saw '=='

Check warning on line 43 in src/components/Profile/index.tsx

View workflow job for this annotation

GitHub Actions / build

'profileIsStaff' is assigned a value but never used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The profile.Type field is not a reliable indicator of a person's status at Gordon, sadly. For one thing, the same person can at the same time be both staff and student (or equally faculty and student). Also, people who are officially staff can teach courses, in which case their course schedule should be visible to students.

I think, rather than trying to work around this complexity in the frontend, we should clean up the logic in the backend. I think the ideal logic would be something like:

  1. Anyone can view their own course schedule without limitations
  2. Faculty (and potentially a couple special categories of staff such as Staff Advisors) can view students' course schedules
  3. Any (authenticated) user can view a person's instructor schedule - i.e. a schedule that only shows the courses where a person is an instructor, and not a student. This handles the case where a person is both a student and an instructor, since their student course schedule shouldn't be visible to other students, but their instructor schedule should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you suggest working on the authentication issue in its own branch or continuing the work you had in the schedule-quad branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. I think if you want to implement the third point in my original comment, you should probably continue work in my schedule-quad branch (and the corresponding schedule-quad-fixes branch for the UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into the branch, it is 513 commits behind develop, which would make it challenging to perform a clean merge (will definitely be easier later with more familiarity with the code). Maybe a rework of the solution from develop could be easier?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it will probably be easier to start fresh on the latest develop. Normally, that wouldn't be such an issue since you can simply rebase the commits, but there have been some really big formatting and whitespace changes in the interim, which git struggles with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For option 3 in the authorization logic, the way the process is currently set up--checking for authorization for the getAllCourses action-- makes it a little complicated to only give access to Instructor courses.
I wonder if it would be a good solution to handle this in the controller--to check who is requesting all the courses and if it is a student to only return instructor courses for that profile. otherwise return all of them.
maybe a getAllInstructorCourses could be added in the service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would work. Except I would say, if the requestor is a faculty/staff member, return all courses, otherwise return only instructor courses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. sounds good! Is it an issue if all faculty can see classes that a faculty or staff is taking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so. It's part of faculty's job to see student's course schedules, and just because someone is a faculty or staff member doesn't mean they're not also a student.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
We are trying to recover the updates we made in Terms last week from the VM. Could we merge this current solution to the permisions and quad issues? I can work on the Terms vs sessions in a different pull Request.


const createSnackbar = useCallback(
(message: string, severity: AlertColor, link?: string, linkText?: string) => {
Expand Down Expand Up @@ -84,11 +85,12 @@
</Grid>
)}

{(myProf || !profileIsStudent || canReadStudentSchedules) && (
{
// is it only faculty that have schedule? could we say if faculty instead here?
<Grid item xs={12} lg={10}>
<SchedulePanel profile={profile} myProf={myProf} />
</Grid>
)}
}

<Grid item xs={12} lg={5}>
<Grid container spacing={2}>
Expand Down
3 changes: 3 additions & 0 deletions src/services/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
BEGIN_TIME?: string;
/** A timespan of the format HH:mm:ss, stringified */
END_TIME?: string;
SUB_TERM_CDE?: string;
Role: string;
};

Expand Down Expand Up @@ -62,6 +63,7 @@
name: string;
title: string;
location: string;
subtermCode: string;
start: Date;
end: Date;
allDay?: boolean;
Expand All @@ -84,11 +86,12 @@
// Because saturday is only included in the schedule if a non-async course meetst that day
const asyncMeetingDays = courseDayIds.slice(0, -1);

return courses.map((course) => {

Check failure on line 89 in src/services/schedule.ts

View workflow job for this annotation

GitHub Actions / build

Type '({ resourceId: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA")[]; start: Date; end: Date; allDay: true; name: string; title: string; location: string; subtermCode: string | undefined; } | { ...; })[]' is not assignable to type 'CourseEvent[]'.
const sharedDetails = {
name: course.CRS_TITLE.trim(),
title: course.CRS_CDE.trim(),
location: course.BLDG_CDE + '\u00A0' + course.ROOM_CDE,
subtermCode: course.SUB_TERM_CDE,
};

if (course.ROOM_CDE === 'ASY') {
Expand Down
Loading