Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin page refresh, admin manager modal #443

Closed
wants to merge 28 commits into from
Closed

Conversation

qiandrewj
Copy link
Contributor

@qiandrewj qiandrewj commented Apr 14, 2024

Summary

This PR works on the Admin page feature, fixing old bugs and adding the ability to manage admin users by net-id.

PR Type

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Mobile + Desktop Screenshots & Recordings

Screenshot 2024-05-05 195112
Screenshot 2024-05-05 195151

QA - Test Plan

  • Tested all endpoints through rendering on front-end.
  • Tested admin management modal by removing Jacqueline's admin privilege. She was then unable to access admin features. After re-adding her as an admin user, she then had access to the admin site.

Breaking Changes & Notes

  • Moved stats rendering (counting reviews, writing to CSV file) to backend. Split up endpoints in order to improve performance.
  • Minor styling changes to whole Admin page.
  • Updated old class components to functional components.
  • Developed admin privilege interface.

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ notion
  • πŸ“• Method specifications
  • πŸ™… no documentation needed

@qiandrewj qiandrewj requested a review from a team as a code owner April 14, 2024 20:26
@dti-github-bot
Copy link
Member

dti-github-bot commented Apr 14, 2024

[diff-counting] Significant lines: 455.

leihelen

This comment was marked as outdated.

.catch((err) => {
console.log('error retrieving totalReviews ', err)
})
getReviewsPerClassCSV() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also I think for the CSV, since className shows the database id of the class, maybe you can make another endpoint after calling /fetchAllReviews that will get the class name from the classes database using the class id stored in each review and then map that to the review count instead.

@leihelen leihelen dismissed their stale review April 14, 2024 22:53

accidentally approved

Copy link
Contributor

@leihelen leihelen left a comment

Choose a reason for hiding this comment

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

The admin page looks a lot better now and the changes you made definitely make everything easier to read and use. I think everything looks really good, however maybe a small visual change you could make would be to wrap the "admin interface", "pending reviews", and "reported reviews" labels in a css class as well and add some more margins or padding to align it with everything else.

Copy link
Collaborator

@wizhaaa wizhaaa left a comment

Choose a reason for hiding this comment

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

Great work Andrew! This is a very heavy task - a lot of sifting through old code and trying to figure how it all works. I also don't think I was super helpful either giving you pretty ambiguous directions and goals. After looking through your code and the admin page a bit more, I'll try to consolidate what I would like to seen accomplished (hopefully by the end of the semester). Do as much as you can for now - and don't worry too much if you can't get it all done.

  • Fix the loading time by separating endpoints (discussed)
  • Update old class components to functional components
  • Remove any outdated and unused code (unused states, functions, endpoints) such as raffle winner and stat charts (let me know if there is anything else you are considering)
  • CSV generation done in back end
  • Admin & user privilege management tool/interface (will try to sketch this one out) - feel free to make a sketch of your initial idea and design too! and we'll give feedback or iterate upon it
  • actual updating roster buttons & functionality - [ a hard one, first, if you can summarize and breakdown how they work, that would be a helpful first step ( because this is kind of the back bone of our database and app functionality :o ) ]

image

  • should add a wrapper for the admin page to set a max-wdith (ie. 1440px is standard)
  • add some left-right and top-bottom padding too (ie padding: 64px 32px), we can play around with this too and see what looks best.

I left some other comments, a lot of which we already discussed but I wanted to put it in the PR. You probably updated a lot since then but haven't pushed yet - so some comments might already be addressed. Keep up the great work! This tasks is definitely very complex, requires quite a bit of thought, lots of moving pieces, and low-key pretty impactful.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should keep an endpoint for getting pending reviews and reported reviews instead of one endpoint to request a large number of review items (causing a heavy initial load time).

IE. endpoints

  • /api/admin/get/reviews/pending
  • /api/admin/get/reviews/reported

Now, we do want "all" reviews to "count" how many each class has for our CSV.
This should be handled in the backend and our frontend shouldn't handle any of this or need to load the review objects themselves to massage/do calculations with.

For example, we can instead have an endpoint like:
/api/admin/get/reviewcountbycourse or /api/admin/get/csv/reviewcount

  • this endpoint can either return a JSON of courseID/courseName (key) -> count (value) dictionary or just a csv string
  • it should NOT return all review objects to our frontend => our frontend SHOULD NOT loop through all review objects and then generate on the frontend.

server/src/admin/admin.data-access.ts Show resolved Hide resolved
server/src/admin/admin.controller.ts Outdated Show resolved Hide resolved
client/src/modules/Admin/Styles/RaffleWinner.module.css Outdated Show resolved Hide resolved
client/src/modules/Admin/Components/Stats.tsx Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also change this to functional component (not class)

)
} else {
console.log('Error at fetchPendingReviews')
console.log('Error at fetchAllReviews')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like there are console logs initially - (from before you worked on it) - fine for testing right now but should delete all console logs when you are done

Copy link
Collaborator

Choose a reason for hiding this comment

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

We discussed a lot of this already - but yep - separate the reviews endpoint into reported & pending and do not return all reviews to the frontend!

A quick solution I can think of right now is:

useEffect( 

axios.hit('api/admin/get/reviews/pending' and '.../reported`) 
=> setLoading(false) => setPendingReviews( res.data.pending ... ) , setReported( res.data.reported ... ) 

)
return <div> ... 
<PendingReviews props = { ... } /> 
<ReportedReviews />  // might want to create a new component to make the Admin page less messy and chaotic 
</div>

@qiandrewj qiandrewj changed the title Admin page refresh and feature fixes Admin page refresh, admin manager modal May 6, 2024
@qiandrewj qiandrewj closed this May 6, 2024
@jacquelinecai jacquelinecai self-requested a review May 10, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants