sharing-server: add admin overview dashboard with aggregate stats and trend chart#696
Merged
sharing-server: add admin overview dashboard with aggregate stats and trend chart#696
Conversation
- Add getAllUploads() DB function with JOIN to get github_login per row - Add day index on usage_uploads for faster admin queries - Admin dashboard (shown to is_admin users) includes: - Aggregate stats card (today/7d/30d) with Active Users count - Token usage trend chart for all users (by model/editor/by user) - Top Users by token usage table (last 30 days) - All Users list (collapsible, unchanged) - By User grouping caps at top 10 users; others shown as 'Other' - Admin today stats patched client-side using browser local timezone - Admin section appears above personal data for immediate visibility Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve conflict in sharing-server/src/routes/dashboard.ts import line. Both admin approaches coexist: inline admin section on /dashboard and separate /admin route added by main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The admin dashboard previously only showed a collapsed list of users — clicking "👑 Admin: All Users" revealed a table of usernames and join dates but no token usage data. Admins had no way to see aggregate usage across all users at a glance.
What changed
Admins now see a full overview section at the top of the dashboard (above their personal data), with the same quality of stats and charts that individual users have.
New admin section (visible only to
is_adminusers)Implementation notes
db.ts: AddedAdminUploadRow(extendsUploadRowwithgithub_login) andgetAllUploads(days)which JOINsusage_uploadswithusers. Also added aday-column index onusage_uploadsto make the cross-user date-range query efficient.dashboard.ts: Admin chart uses fully namespaced DOM IDs (admin-*) and a separate Chart.js instance to avoid any state collision with the personal chart on the same page. Admin interactive JS is emitted only for admin sessions.