Skip to content

Commit

Permalink
Merge branch 'master' into uitestbranch
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrytapia committed Jul 1, 2022
2 parents 3a75970 + 747cd35 commit 82190fa
Show file tree
Hide file tree
Showing 13 changed files with 383 additions and 109 deletions.
6 changes: 3 additions & 3 deletions src/components/HomePage/DashBoard/Graph1.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default function Area() {
const [legend, setLegend]=React.useState([]);
const [settingsView, setSettingsView]=React.useState(false);
const [settingsVisible, setSettingsVisible]=React.useState(false);





const handleTime = (event: SelectChangeEvent) => {
setTime(event.target.value);
};
Expand Down Expand Up @@ -332,7 +332,7 @@ if ( graph==='totalTime'&&selection==='difficulty') {
setInput(finalResultC);
}

}, [graph, selection, subject, time, language, range])
}, [graph, selection, subject, time, language, range, userProblemArray])


const option = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/HomePage/DashBoard/Graph2.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ if ( graph==='totalTime'&&selection==='difficulty') {
setInput(finalResult);
}

}, [graph,selection, subject,time, language,range])
}, [graph, selection, subject,time, language, range, userProblemArray ])


const option = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/HomePage/HomeGraphs/AreaGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ if ( graph==='totalTime'&&selection==='difficulty') {
setInput(finalResultC);
}

}, [graph, selection, subject, time, language,range])
}, [graph, selection, subject, time, language,range, userProblemArray])


const option = {
Expand Down
7 changes: 4 additions & 3 deletions src/components/HomePage/HomeGraphs/BarGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import Collapse from '@mui/material/Collapse';

export default function Bar() {
const { userProblemArray } = useGlobalContext();
console.log('dataaa', userProblemArray);
const [graph, setGraph] = React.useState('totalQuantities');
const [selection, setSelection]=React.useState('difficulty');
const [subject, setSubject] = React.useState([]);
const [input, setInput]=React.useState([])
const [input, setInput]=React.useState([12,33,54])
const [time, setTime]=React.useState('whole process');
const [range, setRange]=React.useState('year');
const [language, setLanguage]=React.useState('Javascript');
Expand Down Expand Up @@ -117,8 +118,8 @@ export default function Bar() {
}
setInput([easy, medium, hard]);
}//Junsu: working now
}, [graph, selection, subject, time, language, range])

}, [graph, selection, subject, time, language, range, userProblemArray ])
console.log('inputttttt',input);
const option = {
title:{
text: graph==='totalTime'?'Speed (mins)':graph==='totalQuantities'?'Total':null,
Expand Down
2 changes: 1 addition & 1 deletion src/components/HomePage/HomeGraphs/DonutGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ setInput([{value:easy, name:'easy'},{value:medium,name:'medium'},{value:hard,nam

// console.log('state', [easy, medium, hard]);
// console.log('testtt', state.speed)
}, [graph,selection, subject, time, language,range])
}, [graph,selection, subject, time, language,range, userProblemArray])

const option = {
title:{
Expand Down
45 changes: 17 additions & 28 deletions src/components/HomePage/HomeGraphs/LineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default function Line() {


if (graph === 'totalTime' && selection === 'subject') {
setInput([]);
const subjectTeam = {};
timeAndLangFiltered.forEach(problem => {
const sub = problem.topics;
Expand Down Expand Up @@ -169,7 +170,10 @@ if (graph === 'totalTime' && selection === 'subject') {
//temp['stack']='Total';
temp['data'] = [];
for (let value in updateFormate[key]) {
temp['data'].push([value, updateFormate[key][value]]);
var data=[];
data.push(value);
data.push(updateFormate[key][value]);
temp['data'].push(data);
}
finalResult.push(temp);
}
Expand Down Expand Up @@ -204,27 +208,31 @@ if (graph === 'totalTime' && selection === 'difficulty') {
updateFormate[key]=temp;
}

const finalResult = [];
const finalResultD = [];
for (let key in updateFormate) {
const temp = {};
temp['name'] = key;
temp['type'] = 'line';
//temp['stack']='Total';
temp['data'] = [];
for (let value in updateFormate[key]) {
temp['data'].push(value, updateFormate[key][value]);
var data=[];
data.push(value);
data.push(updateFormate[key][value]);
temp['data'].push(data);
}
finalResult.push(temp);
finalResultD.push(temp);
}
const containerD = [];
for (let i=0; i<finalResult.length; i++) {
containerD.push(finalResult[i]['name']);
for (let i=0; i<finalResultD.length; i++) {
containerD.push(finalResultD[i]['name']);
}
//console.log('speed&diffculty', finalResultD);
setLegend(containerD);
setInput(finalResult);
setInput(finalResultD);
}

}, [graph,selection, subject,time, language,range])
}, [graph,selection, subject,time, language,range, userProblemArray])


const option = {
Expand Down Expand Up @@ -273,26 +281,7 @@ if (graph === 'totalTime' && selection === 'difficulty') {
type: 'value'
},
series: input
//[ //need to update according to data
// { // sample data firstly filter with range ; then filter with hardlevel;
// name: 'Hard',
// type: 'line',
// stack: 'Total',
// data: [["2022-06-27", 33], ["2022-06-27T10:35:45",132], ["2022-06-28T17:35:45",101]]
// },
// {
// name: 'Medium',
// type: 'line',
// stack: 'Total',
// data: [["2022-06-25T10:35:45", 3], ["2022-06-27T12:35:45",132], ["2022-06-28T17:35:45",101]]
// },
// {
// name: 'Easy',
// type: 'line',
// stack: 'Total',
// data: [["2022-06-25T10:35:45", 3], ["2022-06-27T19:35:45",132], ["2022-06-28T20:35:45",101]]
// }
// ]

}
return (
<Stack style={{height: '605px'}}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/HomePage/HomeGraphs/PieGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ setInput([{value:easy, name:'easy'},{value:medium,name:'medium'},{value:hard,nam

// console.log('state', [easy, medium, hard]);
// console.log('testtt', state.speed)
}, [graph,selection, subject, time, language,range])
}, [graph,selection, subject, time, language,range, userProblemArray])

const option = {
title:{
Expand Down
12 changes: 7 additions & 5 deletions src/components/HomePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export default function HomePage() {
</Collapse>
<div
className="main-layout"
style={{ display: "flex", justifyContent: "center" }}
style={{
display: "flex",
flexWrap: "wrap",
justifyContent: "center",
}}
>
{/* <div className='side-bar'> */}
<InputForm />
Expand All @@ -27,10 +31,8 @@ export default function HomePage() {
<DashBoard />
<Graphs />
</div>

</div>
{" "}
<Footer />
</div>{" "}
<Footer />
</div>
);
}
75 changes: 53 additions & 22 deletions src/components/RecordLibraryPage/EditModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export default function EditModal({ setShowEditModal, row, setRow, tableData, se

function handleFormSubmit(e) {
e.preventDefault();
// if no session storage then toastify return
if (!sessionStorage.getItem('UserID')) {
toast.error('Not Logged in', toastifyTheme);
handleExitModal();
return;
}
console.log('putting data:', row)
axios.put(
`/records/${row.id}`,
Expand Down Expand Up @@ -114,6 +120,13 @@ export default function EditModal({ setShowEditModal, row, setRow, tableData, se
});
}

function handleComplexityChange(e) {
setRow({
...row,
timeComplexity: e.target.value
});
}

return (
<div className="modal-container" onClick={handleExitModal}>
<section className="records-modal" onClick={e => e.stopPropagation()}>
Expand All @@ -125,11 +138,11 @@ export default function EditModal({ setShowEditModal, row, setRow, tableData, se
</header>
<div className="modal-content">
<FormControl autoComplete="off" sx={{ '& > :not(style)': { m: 1 } }} component="form" onChange={handleFormChange} onSubmit={handleFormSubmit}>
<TextField id="promptName" label="Name" value={row.promptName}></TextField>
<TextField id="promptLink" label="Link" value={row.promptLink}></TextField>
<TextField size="small" id="promptName" label="Name" value={row.promptName} />
<FormControl>
<InputLabel id="difficulty-select-label">Difficulty</InputLabel>
<Select
size="small"
labelId="difficulty-select-label"
id="difficulty"
value={row.difficulty}
Expand All @@ -141,18 +154,25 @@ export default function EditModal({ setShowEditModal, row, setRow, tableData, se
<MenuItem value="hard">hard</MenuItem>
</Select>
</FormControl>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker
label="Date&Time picker"
value={row.timeStamp}
onChange={handleDateChange}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
<TextField id="codeTime" type="number" label="Code Time" value={row.codeTime}></TextField>
<FormControl>
<InputLabel id="language-select-label">Language</InputLabel>
<Select
size="small"
labelId="language-select-label"
id="programmingLanguage"
value={row.programmingLanguage}
label="Language"
onChange={handleLanguageChange}
>
{languages.map((language) => (
<MenuItem key={language} value={language}>{language}</MenuItem>
))}
</Select>
</FormControl>
<FormControl>
<InputLabel id="topics-select-label">Topic</InputLabel>
<Select
size="small"
labelId="topics-select-label"
id="topics"
value={row.topics}
Expand All @@ -166,21 +186,32 @@ export default function EditModal({ setShowEditModal, row, setRow, tableData, se
))}
</Select>
</FormControl>
<FormControl>
<InputLabel id="language-select-label">Language</InputLabel>
<TextField size="small" id="codeTime" type="number" label="Code Time" value={row.codeTime} />
<TextField size="small" id="promptLink" label="Link" value={row.promptLink} />
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker
label="Date&Time picker"
value={row.timeStamp}
onChange={handleDateChange}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
<FormControl variant='outlined'>
<InputLabel id='timecomplexity-label'>Time Complexity</InputLabel>
<Select
labelId="language-select-label"
id="programmingLanguage"
value={row.programmingLanguage}
label="Language"
onChange={handleLanguageChange}
labelid='timecomplexity-label'
name="timeComplexity"
value={row.timeComplexity}
onChange={(e) => handleComplexityChange(e)}
>
{languages.map((language) => (
<MenuItem key={language} value={language}>{language}</MenuItem>
))}
<MenuItem value='O(1)'>O(1)</MenuItem>
<MenuItem value='O(log n)'>O(log n)</MenuItem>
<MenuItem value='O(n)'>O(n)</MenuItem>
<MenuItem value='O(n log n)'>O(n log n)</MenuItem>
<MenuItem value='O(n^2)'>O(n^2)</MenuItem>
</Select>
</FormControl>
<Button type="submit">Submit</Button>
<Button size="small" type="submit">Submit</Button>
</FormControl>
</div>
</section>
Expand Down
Loading

0 comments on commit 82190fa

Please sign in to comment.