Created a dashboard on the admin side to see contents of each course. - #175
Created a dashboard on the admin side to see contents of each course.#175Deadman1225 wants to merge 8 commits into
Conversation
RsbhThakur
left a comment
There was a problem hiding this comment.
Note on Client Cache Desync:
Currently, when an admin deletes a file or folder using this new dashboard, it correctly deletes it from MongoDB, but the student client still shows the stale deleted file. This is because the student portal aggressively caches the course tree in sessionStorage (under the AllCourses key).
Since we want admin updates to reflect in the client, we need to invalidate this cache. As a simple fix, when navigating a folder on the client (handleFolderClick in BrowseFolder), we should fire an asynchronous background refresh API request to the backend and dispatch the fresh data to Redux. That way, any deleted items disappear dynamically for the student!
There was a problem hiding this comment.
Note on Client Cache Desync:
Currently, when an admin deletes a file or folder using this new dashboard, it correctly deletes it from MongoDB, but the student client still shows the stale deleted file. This is because the student portal aggressively caches the course tree in sessionStorage (under the AllCourses key).
Since we want admin updates to reflect in the client, we need to invalidate this cache. As a simple fix, when navigating a folder on the client (handleFolderClick in BrowseFolder), we should fire an asynchronous background refresh API request to the backend and dispatch the fresh data to Redux. That way, any deleted items disappear dynamically for the student!
Almost all issues are fixed! But this issue is still unresolved, @Deadman1225 think something for this.
DreamBot706
left a comment
There was a problem hiding this comment.
Review Summary:
The file tree and pending contributions UI are functioning, but there are critical backend bugs and security oversights in this implementation that need to be resolved. Review the client cache invalidation issue raised by @RsbhThakur, the previous feedback on using react-toastify, and fix the routing and validation issues listed below.
File Comments:
-
File:
admin/src/App.jsx- Comment: Security: The new
<Route path="/admin/courses/:code" ... />route is missing the<PrivateRoute>wrapper. This leaves the admin course dashboard accessible without authentication. Wrap it properly.
- Comment: Security: The new
-
File:
server/modules/admin/adminDashboard.controller.js(Function:handleContribution)- Comment: Bug: If the
actionparameter is neither"approve"nor"reject", the function reaches the end and returnsundefinedwithout sending any HTTP response. This hangs the client's request. Add a fallback to return a400 Bad Requestresponse for invalid actions. - Comment: Convention: Use strict equality (
===) instead of loose equality (==) when checking theactionparameter.
- Comment: Bug: If the
-
File:
server/modules/admin/adminDashboard.controller.js(Function:deleteNode)- Comment: Security/Validation: The
typeparameter fromreq.paramsis used directly in the deletion logic, but there is no validation to ensure it is exactly"file"or"folder". Validate thetypeto prevent malformed requests from silently skipping the deletion logic and returning success.
- Comment: Security/Validation: The
-
File:
server/modules/admin/adminDashboard.controller.js(Function:deleteFolderTree)- Comment: Performance: The recursive deletion logic triggers individual database calls in a loop. For deep folder structures, this will bottleneck the server. Batch the deletions or use a single bulk write operation.
-
File:
admin/src/apis/courses.js- Comment: Cleanup: You imported
Deletefromlucide-reactat the top of the file but never used it. Remove unused imports.
- Comment: Cleanup: You imported
The admin can see each folders and file for specific course number of students registered and contributions.
The admin can approve each contributions or reject it.
The admin can also delete any folder or file as well.