Skip to content

Commit

Permalink
Merge branch 'master' into fixSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
zebibg committed Jul 1, 2022
2 parents ee22eda + 5fe2682 commit 045d4ee
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 100 deletions.
43 changes: 16 additions & 27 deletions src/components/HomePage/HomeGraphs/LineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default function Line() {


if (graph === 'totalTime' && selection === 'subject') {
setInput([]);
const subjectTeam = {};
timeAndLangFiltered.forEach(problem => {
const sub = problem.topics;
Expand Down Expand Up @@ -163,7 +164,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 @@ -198,24 +202,28 @@ 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, userProblemArray])
Expand Down Expand Up @@ -267,26 +275,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>
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
2 changes: 1 addition & 1 deletion src/components/RecordLibraryPage/InputFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default function InputFields({ search, setSearch, filters, setFilters })
>
<MenuItem value="all">All Time</MenuItem>
<MenuItem value="daily">Past Day</MenuItem>
<MenuItem value="weekly">Past Week</MenuItem>
<MenuItem value="monthly">Past Month</MenuItem>
<MenuItem value="yearly">Past Year</MenuItem>
</Select>
</FormControl>
</Paper>
Expand Down
6 changes: 4 additions & 2 deletions src/components/RecordLibraryPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function RecordLibrary() {
difficulty: 'all',
timeFrame: 'all',
});

useEffect(() => {
let newData = userProblemArray.filter((prompt) => (
(prompt.promptName.includes(search) ||
Expand All @@ -25,7 +24,10 @@ export default function RecordLibrary() {
filters.difficulty === prompt.difficulty
) &&
(
filters.timeFrame === 'all'
filters.timeFrame === 'all' ||
(filters.timeFrame === 'daily' && new Date(prompt.timeStamp).getFullYear() === new Date().getFullYear() && new Date(prompt.timeStamp).getMonth() === new Date().getMonth() && new Date(prompt.timeStamp).getDate() === new Date().getDate()) ||
(filters.timeFrame === 'monthly' && new Date(prompt.timeStamp).getFullYear() === new Date().getFullYear() && new Date(prompt.timeStamp).getMonth() === new Date().getMonth()) ||
(filters.timeFrame === 'yearly' && new Date(prompt.timeStamp).getFullYear() === new Date().getFullYear())
)
));
setShownData(newData);
Expand Down
Loading

0 comments on commit 045d4ee

Please sign in to comment.