Skip to content

Conversation

@mcclown
Copy link

@mcclown mcclown commented Dec 6, 2025

So this was something I wanted and it may actually close out issue #110 as well. This change was a bit more involved, so here are the details of what I changed.

Backend Changes:

  1. New Admin Endpoint (routes/admin.go): Added ApiGetUserStatistics that allows admins to retrieve wrapped statistics for a specific user by user ID.
  2. Route Registration (main.go): Registered the new endpoint at /api/get/users/:userId/statistics.

Frontend Changes:

  1. Users List UI (web/js/users.js):
    • Added a "View As User" column header to the users table
    • Added a "View Wrapped As User" button (gift icon) for each active user
    • Created viewUserWrapped() function that fetches the wrapped data and opens it in a new window
  2. Frontpage Support (web/html/frontpage.html & web/js/index.js):
    • Modified the frontpage to detect the viewWrappedAsUser query parameter
    • Added get_wrapper_version_for_admin() and get_functions_for_admin() functions to load wrapped data from sessionStorage and display it. Also refactored this file, to allow for better code reuse in these functions.

How It Works:

  1. When an admin clicks the "View Wrapped As User" button next to a user, it fetches that user's wrapped statistics via the admin API
  2. The data is stored in sessionStorage with a unique key
  3. A new window opens to the frontpage with the data key as a query parameter
  4. The frontpage detects the parameter, loads the data from sessionStorage, and displays the wrapped page
  5. The implementation reuses the existing wrapped display logic, so the wrapped page looks and functions the same as when users view their own wrapped.

@aunefyren
Copy link
Owner

Very cool feature! I'll look through the commits soon

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.

2 participants