-
Notifications
You must be signed in to change notification settings - Fork 113
feat: add user's activeness to admin dashboard #3625
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a user activity tracking feature to the admin dashboard that allows administrators to visually distinguish between active and inactive users. Active users (those who made HTTP requests within the last 15 minutes) are displayed with a green ring around their avatar, while inactive users have a gray ring.
- Implements user activity tracking by recording last login timestamps in a new
time_logdatabase table - Updates JWT token expiration to 15 minutes with 16-minute refresh interval to align with activity window
- Modifies admin user interface to display visual activity indicators around user avatars
Reviewed Changes
Copilot reviewed 10 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| core/scripts/sql/updates/10.sql | Creates new time_log table to store user activity timestamps |
| core/auth/src/main/scala/edu/uci/ics/texera/auth/JwtAuth.scala | Updates JWT token expiration to 15 minutes |
| core/auth/src/main/scala/edu/uci/ics/texera/auth/JwtAuthFilter.scala | Adds logic to upsert user activity on each authenticated request |
| core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/admin/user/AdminUserResource.scala | Implements new endpoint returning users with last activity data |
| core/gui/src/app/common/type/user.ts | Adds lastActive field to User interface |
| core/gui/src/app/dashboard/component/admin/user/admin-user.component.* | Implements frontend logic and styling for activity indicators |
| core/gui/src/app/dashboard/service/admin/user/admin-user.service.ts | Updates service to use new activity-enabled endpoint |
| core/gui/src/app/common/service/user/auth.service.ts | Adjusts token refresh interval to 16 minutes |
|
@aicam Please help me assign labels, assignee and reviewers. Thank you so much! |
core/auth/src/main/scala/edu/uci/ics/texera/auth/JwtAuthFilter.scala
Outdated
Show resolved
Hide resolved
.../src/main/scala/edu/uci/ics/texera/web/resource/dashboard/admin/user/AdminUserResource.scala
Outdated
Show resolved
Hide resolved
|
@aicam @aglinxinyuan Made changes to the code. Re-requesting review. |
aicam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
aglinxinyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. You don't need to list the files changed.
…xera into jaeyun-active-user
Head branch was pushed to by a user without write access
|
@aicam I think an approval is needed from the maintainer's side |
|
@aicam Final approval needed |
…thLastLogin (#3682) ## Summary In effort to improve the naming convention of variables and api endpoints of previous PR #3625, this PR is raised to change `UserWithLastLogin` to `UserInfo` and `/listWIthActivity` to `/list`. ## Changes 1. The code inside the api endpoint `/listWithActivity` has been moved to `/list`. `/listWithActivity` has been removed. 2. The class name `UserWithLastLogin` is changed to `UserInfo`. ## Notes Fixes Issue #3624. After discussion, we decided to change the api endpoint as the code in `/list` was no longer used and `/listWithActivity` has a too specific name. To make the name more intuitive and generalized, we decided to move the code into `/list` to make it more clear. Same thing happens to `UserWithLastLogin`. It has a specific name and we decided it to change it into `UserInfo` so it can be generally used and be added with more attributes. --------- Co-authored-by: ali risheh <ali.risheh876@gmail.com>
### What changes were proposed in this PR? This PR fixes the active ring size around user's avatar in the admin dashboard tab to enhance visibility. ### Current Implementation <img width="132" height="106" alt="image" src="https://github.com/user-attachments/assets/8b30aff4-87a7-4d34-8bcb-39f8c24430c9" /> ### Proposed Implementation <img width="102" height="122" alt="image" src="https://github.com/user-attachments/assets/d7c9816f-6221-41f2-8a13-30319bd5b1f6" /> ### Any related issues, documentation, discussions? Fixes #3625 ### How was this PR tested? Test was not added to this part as this is a styling-related issue. ### Was this PR authored or co-authored using generative AI tooling? No.
Summary
This pr adds a new feature where the admin can keep track of the active/inactive users on the Admin Dashboard. The feature is added in order to give admin users a better use experience and straightforward overview of users' activeness. A ring is added around the avatars and it will turn green whenever a user is active and gray if a user is inactive.
Closes #3624.
For Developers
Please do the following steps to incorporate with new changes:
Change made to Database
A new table
time_logis introduced to the db with primary key beinguidthat references theuidfromusertable andlast_activeas an column to store the last active time of the user. Thelast_activecolumn can be null and when a user is active, one of the following will happen:uidexists in thetime_logtable, thelast_activewill simply be updated.uiddoes NOT exist in thetime_logtable, (uid, last_active) will be added to the table.Context of the Design
The reasons why we chose to create a separate table
time_loginstead of adding the information to theusertable are as follows:usertable frequently: When a user becomes "active",last_activewill be updated. And how we defined a user to be active is that when a user makes a http request and they hold a valid jwt token that has a lifespan of 15 minutes, the user is active. Whenever the user makes a http request thelast_activecolumn will have to be updated. And with a scalable system like Texera, it will become more and more costly to update the information when a large number of users are "active" on the system if thelast_activeis in theusertable.Based on the internal discussions on the design of the tables, we decided to create a
time_logtable.Image of Database Diagram
Functionality & Explanation of the Feature
When a user makes a http request, the attribute will be updated in the db. Future changes might be made to this table since we are planning to introduce more attributes like account creation time.
Since every http request triggers the jwtFilter, our design is to upsert the user's last login time record whenever the request triggers the jwtFilter. The upsert function will add a new record if the user never logged in before, and will update the last_login attribute. When the admin visits the admin dashboard, the call to the getUserList will now contain a list of users with a new attribute named lastActive, which is a Unix epoch timestamp in seconds. If a user's lastActive attribute is null or the difference between the current timestamp and its lastActive timestamp is larger than the set threshold (a.k.a active window), the user will be inactive, otherwise active. Here we define the active window as 15 minutes. With this threshold, admin users will be able to know which users were active within the last 15 minutes.
The token's expiration time is set to 15 minutes, and refresh time is set to 16 minutes in order to make sure a user is "logged out" when they don't make anymore http requests. As soon as the system detects that the last active time has a 15 minutes difference with the current time, it will mark the user as inactive.
Screenshot of Feature