Skip to content

Commit

Permalink
Merge pull request #274 from cmu15122/preview
Browse files Browse the repository at this point in the history
Merge centralized course name setting into prod
  • Loading branch information
jacksontromero authored Oct 8, 2024
2 parents 4d43436 + 73afdc8 commit 39484a9
Show file tree
Hide file tree
Showing 12 changed files with 1,986 additions and 1,552 deletions.
7 changes: 2 additions & 5 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<base href="%PUBLIC_URL%/">
<base href="%PUBLIC_URL%/" />
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Online queue for 15-122 Office Hours"
/>
<meta name="description" content="Online queue for 15-122 Office Hours" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand Down
2 changes: 1 addition & 1 deletion client/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"short_name": "15122 OHQ",
"short_name": "15-122 OHQ",
"name": "15-122 Office Hours Queue",
"icons": [
{
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/navbar/OHQueueHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import React from 'react';
import {
Link,
} from '@mui/material';
import {useContext} from 'react';
import {AdminSettingsContext} from '../../contexts/AdminSettingsContext';

export default function OHQueueHeader() {
const {adminSettings} = useContext(AdminSettingsContext);
const courseName = adminSettings.courseName;
return (
<Link variant="h6" color="#FFFFFF" fontWeight='bold' href="" underline="none" sx={{pt: 0.3}}>
15-122 Office Hours Queue
{courseName} Office Hours Queue
</Link>
);
}
36 changes: 36 additions & 0 deletions client/src/components/settings/admin/ConfigSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@ export default function ConfigSettings(props) {
const [questionsURL, setQuestionsURL] = useState('');
const [enforceCMUEmail, setEnforceCMUEmail] = useState(true);
const [allowCDOverride, setAllowCDOverride] = useState(true);
const [courseName, setCourseName] = useState('');

useEffect(() => {
setCurrSem(adminSettings.currSem);
setSlackURL(adminSettings.slackURL);
setEnforceCMUEmail(adminSettings.enforceCMUEmail);
setCourseName(adminSettings.courseName);
}, [adminSettings]);
useEffect(() => {
setAllowCDOverride(queueData.allowCDOverride);
setQuestionsURL(queueData.questionsURL);
}, [queueData]);


const handleUpdateCourseName = (event) => {
event.preventDefault();
if (courseName === adminSettings.courseName) return;

SettingsService.updateCourseName(
JSON.stringify({
courseName: courseName,
}),
);
};

const handleUpdateSemester = (event) => {
event.preventDefault();
if (currSem === adminSettings.currSem) return;
Expand Down Expand Up @@ -86,12 +100,34 @@ export default function ConfigSettings(props) {
);
};


return (
<BaseCard>
<CardContent>
<Typography sx={{fontWeight: 'bold', ml: 1, mt: 1}} variant="body1" gutterBottom>
Config Settings
</Typography>
<form onSubmit={handleUpdateCourseName}>
<Grid container spacing={2} sx={{mb: 2}}>
<Grid className="d-flex" item sx={{mx: 1, ml: 1}}>
Course Name:
<TextField
id="course-name"
placeholder="Course Name"
variant="standard"
sx={{ml: 1, mt: -1}}
style={{width: '160px'}}
value={courseName ?? ''}
onChange={(e) => {
setCourseName(e.target.value);
}}
/>
</Grid>
<Grid className="d-flex" item sx={{mr: 2}} xs={1.5}>
<Button type="submit" variant="contained">Save</Button>
</Grid>
</Grid>
</form>
<form onSubmit={handleUpdateSemester}>
<Grid container spacing={2} sx={{mb: 2}}>
<Grid className="d-flex" item sx={{mt: 1, ml: 1}}>
Expand Down
2 changes: 2 additions & 0 deletions client/src/contexts/AdminSettingsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const AdminSettingsContext = createContext({
currSem: '',
slackURL: undefined,
enforceCMUEmail: true,
courseName: '',
},
setAdminSettings: ((adminSettings: AdminSettings) => {}) as React.Dispatch<React.SetStateAction<AdminSettings>>,
});
Expand All @@ -29,6 +30,7 @@ const AdminSettingsContextProvider = ({children}: {children: React.ReactNode}) =
currSem: '',
slackURL: undefined,
enforceCMUEmail: true,
courseName: '',
});

// Load admin settings if user is an admin
Expand Down
2 changes: 1 addition & 1 deletion client/src/contexts/QueueDataContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const QueueDataContext = createContext({
*/
const QueueDataContextProvider = ({children}: {children: React.ReactNode}) => {
const [queueData, setQueueData] = useState<QueueData>({
title: '15-122 Office Hours Queue',
title: 'Office Hours Queue',
uninitializedSem: false,
queueFrozen: true,
allowCDOverride: true,
Expand Down
3 changes: 3 additions & 0 deletions client/src/services/SettingsService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class SettingsDataService {
},
});
}
updateCourseName(data) {
return http.post('/settings/config/coursename/update', data);
}
updateSemester(data) {
return http.post('/settings/config/sem/update', data);
}
Expand Down
Loading

0 comments on commit 39484a9

Please sign in to comment.