Features:
- New UserDetailsView component with expandable conversations
- Each conversation shows all messages with token usage and cost
- User information section (email, role, status, last login)
- Token usage statistics grid (8 stat cards)
- Message content truncation for long messages (500 chars)
- Role-based styling (user: blue, assistant: gold)
Backend:
- New GET /admin/users/{user_id}/details endpoint
- Complex SQL queries with joins for user stats and conversations
- Pydantic schemas: UserDetails, ConversationDetail, MessageDetail
- Per-message and per-conversation token tracking
Frontend:
- React Router integration for /admin/users/:userId route
- Navigation from Usage page "View" button to user details
- Back button to return to admin panel
- Proper error handling and loading states
- Responsive CSS styling with hover effects
Changes:
- backend/app/api/v1/endpoints/admin.py: Added getUserDetails endpoint
- frontend/src/components/UserDetailsView.tsx: New component
- frontend/src/App.tsx: Added route for user details page
- frontend/src/components/TokenUsageDashboard.tsx: Added navigation handler
- frontend/src/services/api.ts: Added adminAPI.getUserDetails method
- frontend/src/styles/admin.css: Added comprehensive styling for user details
- frontend/package.json: Added react-router-dom dependency
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
646 lines
12 KiB
CSS
646 lines
12 KiB
CSS
/**
|
|
* Admin Panel Styles
|
|
*/
|
|
|
|
.admin-panel {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--white);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.admin-header {
|
|
padding: 2rem;
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
.admin-header h2 {
|
|
margin: 0 0 0.5rem 0;
|
|
color: var(--text-primary);
|
|
font-size: 1.75rem;
|
|
}
|
|
|
|
.admin-header p {
|
|
margin: 0;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.admin-tabs {
|
|
display: flex;
|
|
gap: 0;
|
|
border-bottom: 1px solid var(--border-color);
|
|
padding: 0 2rem;
|
|
background: var(--bg-secondary);
|
|
}
|
|
|
|
.admin-tab {
|
|
padding: 1rem 1.5rem;
|
|
background: none;
|
|
border: none;
|
|
border-bottom: 3px solid transparent;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
transition: all var(--transition-normal);
|
|
}
|
|
|
|
.admin-tab:hover {
|
|
color: var(--text-primary);
|
|
background: var(--bg-hover);
|
|
}
|
|
|
|
.admin-tab.active {
|
|
color: var(--primary-gold);
|
|
border-bottom-color: var(--primary-gold);
|
|
}
|
|
|
|
.admin-content {
|
|
flex: 1;
|
|
overflow: auto;
|
|
padding: 2rem;
|
|
}
|
|
|
|
.admin-loading,
|
|
.admin-error {
|
|
text-align: center;
|
|
padding: 2rem;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.admin-error {
|
|
color: var(--error-color);
|
|
}
|
|
|
|
/* Users Table */
|
|
.admin-users-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.admin-users-header h3 {
|
|
margin: 0;
|
|
font-size: 1.5rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.admin-users-header p {
|
|
margin: 0;
|
|
color: var(--text-secondary);
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
.admin-users-table {
|
|
overflow-x: auto;
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
}
|
|
|
|
.admin-users-table table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.admin-users-table thead {
|
|
background: var(--bg-secondary);
|
|
}
|
|
|
|
.admin-users-table th {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--border-color);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.admin-users-table td {
|
|
padding: 1rem;
|
|
border-bottom: 1px solid var(--border-color);
|
|
color: var(--text-primary);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.admin-users-table tbody tr:hover {
|
|
background: var(--bg-hover);
|
|
}
|
|
|
|
.role-select {
|
|
padding: 0.4rem 0.75rem;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
background: var(--white);
|
|
color: var(--text-primary);
|
|
font-size: 0.875rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.role-select:focus {
|
|
outline: none;
|
|
border-color: var(--primary-gold);
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: var(--radius-full);
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
display: inline-block;
|
|
}
|
|
|
|
.status-badge.active {
|
|
background: var(--success-bg);
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.status-badge.inactive {
|
|
background: var(--error-bg);
|
|
color: var(--error-color);
|
|
}
|
|
|
|
.btn-toggle-status {
|
|
padding: 0.4rem 0.875rem;
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text-primary);
|
|
font-size: 0.875rem;
|
|
cursor: pointer;
|
|
transition: all var(--transition-normal);
|
|
}
|
|
|
|
.btn-toggle-status:hover {
|
|
background: var(--bg-hover);
|
|
border-color: var(--text-secondary);
|
|
}
|
|
|
|
/* Analytics */
|
|
.admin-analytics-header {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.admin-analytics-header h3 {
|
|
margin: 0;
|
|
font-size: 1.5rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.admin-stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
.admin-stat-card {
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
padding: 1.5rem;
|
|
text-align: center;
|
|
}
|
|
|
|
.admin-stat-label {
|
|
font-size: 0.875rem;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.admin-stat-value {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
color: var(--primary-gold);
|
|
}
|
|
|
|
/* Admin Usage Analytics */
|
|
.admin-stats-section {
|
|
margin-bottom: 3rem;
|
|
}
|
|
|
|
.admin-stats-section h3 {
|
|
margin: 0 0 1.5rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.admin-usage-table-section {
|
|
margin-top: 2rem;
|
|
}
|
|
|
|
.admin-usage-table-section h3 {
|
|
margin: 0 0 1.5rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.admin-usage-table-wrapper {
|
|
overflow-x: auto;
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.admin-usage-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
min-width: 800px;
|
|
}
|
|
|
|
.admin-usage-table thead {
|
|
background: var(--bg-secondary);
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 10;
|
|
}
|
|
|
|
.admin-usage-table th {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--border-color);
|
|
font-size: 0.9rem;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.admin-usage-table td {
|
|
padding: 0.875rem 1rem;
|
|
border-bottom: 1px solid var(--border-color);
|
|
color: var(--text-primary);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.admin-usage-table tbody tr:hover {
|
|
background: var(--bg-hover);
|
|
}
|
|
|
|
.admin-usage-table tbody tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.btn-details {
|
|
padding: 0.4rem 0.875rem;
|
|
background: var(--primary-gold);
|
|
border: none;
|
|
border-radius: var(--radius-sm);
|
|
color: var(--white);
|
|
font-size: 0.875rem;
|
|
cursor: pointer;
|
|
transition: all var(--transition-normal);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.btn-details:hover {
|
|
background: var(--primary-gold-dark);
|
|
transform: translateY(-1px);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
/* Empty state for admin tables */
|
|
.admin-empty-state {
|
|
text-align: center;
|
|
padding: 3rem 2rem;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.admin-empty-state h4 {
|
|
margin: 0 0 0.5rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.admin-empty-state p {
|
|
margin: 0;
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
/* User Details View */
|
|
.user-details-view {
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: auto;
|
|
padding: 2rem;
|
|
background: var(--bg-secondary);
|
|
}
|
|
|
|
.user-details-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.user-details-header h2 {
|
|
margin: 0;
|
|
font-size: 1.75rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.btn-back {
|
|
padding: 0.625rem 1.25rem;
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text-primary);
|
|
font-size: 0.95rem;
|
|
cursor: pointer;
|
|
transition: all var(--transition-normal);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.btn-back:hover {
|
|
background: var(--bg-hover);
|
|
border-color: var(--primary-gold);
|
|
color: var(--primary-gold);
|
|
}
|
|
|
|
.user-details-loading,
|
|
.user-details-error {
|
|
text-align: center;
|
|
padding: 3rem;
|
|
color: var(--text-secondary);
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.user-details-error {
|
|
color: var(--error-color);
|
|
}
|
|
|
|
/* User Information Section */
|
|
.user-info-section {
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.user-info-section h3 {
|
|
margin: 0 0 1.25rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--primary-gold);
|
|
padding-bottom: 0.5rem;
|
|
}
|
|
|
|
.user-info-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 1rem;
|
|
}
|
|
|
|
.user-info-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.25rem;
|
|
}
|
|
|
|
.user-info-label {
|
|
font-size: 0.875rem;
|
|
color: var(--text-secondary);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.user-info-value {
|
|
font-size: 1rem;
|
|
color: var(--text-primary);
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* User Stats Section */
|
|
.user-stats-section {
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.user-stats-section h3 {
|
|
margin: 0 0 1.25rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--primary-gold);
|
|
padding-bottom: 0.5rem;
|
|
}
|
|
|
|
.user-stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
.user-stat-card {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
padding: 1.25rem;
|
|
text-align: center;
|
|
transition: all var(--transition-normal);
|
|
}
|
|
|
|
.user-stat-card:hover {
|
|
border-color: var(--primary-gold);
|
|
box-shadow: var(--shadow-sm);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.user-stat-label {
|
|
font-size: 0.875rem;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 0.5rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.user-stat-value {
|
|
font-size: 1.75rem;
|
|
font-weight: 700;
|
|
color: var(--primary-gold);
|
|
}
|
|
|
|
/* Conversations Section */
|
|
.user-conversations-section {
|
|
background: var(--white);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-md);
|
|
padding: 1.5rem;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.user-conversations-section h3 {
|
|
margin: 0 0 1.25rem 0;
|
|
font-size: 1.25rem;
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--primary-gold);
|
|
padding-bottom: 0.5rem;
|
|
}
|
|
|
|
.conversations-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.conversation-card {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
overflow: hidden;
|
|
transition: all var(--transition-normal);
|
|
}
|
|
|
|
.conversation-card:hover {
|
|
border-color: var(--primary-gold);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.conversation-header {
|
|
padding: 1rem;
|
|
cursor: pointer;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
transition: background var(--transition-normal);
|
|
}
|
|
|
|
.conversation-header:hover {
|
|
background: var(--bg-hover);
|
|
}
|
|
|
|
.conversation-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.expand-icon {
|
|
color: var(--primary-gold);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.archived-badge {
|
|
padding: 0.25rem 0.5rem;
|
|
background: var(--error-bg);
|
|
color: var(--error-color);
|
|
border-radius: var(--radius-sm);
|
|
font-size: 0.75rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.conversation-stats {
|
|
display: flex;
|
|
gap: 1.5rem;
|
|
font-size: 0.875rem;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.conversation-details {
|
|
padding: 1rem;
|
|
border-top: 1px solid var(--border-color);
|
|
background: var(--white);
|
|
}
|
|
|
|
.conversation-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 0.75rem;
|
|
padding: 1rem;
|
|
background: var(--bg-secondary);
|
|
border-radius: var(--radius-sm);
|
|
margin-bottom: 1rem;
|
|
font-size: 0.875rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.conversation-meta strong {
|
|
color: var(--text-secondary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
/* Messages Section */
|
|
.messages-section h4 {
|
|
margin: 0 0 1rem 0;
|
|
font-size: 1.1rem;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.messages-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.message-item {
|
|
padding: 1rem;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-sm);
|
|
background: var(--white);
|
|
}
|
|
|
|
.message-item.user {
|
|
border-left: 3px solid var(--primary-blue);
|
|
}
|
|
|
|
.message-item.assistant {
|
|
border-left: 3px solid var(--primary-gold);
|
|
}
|
|
|
|
.message-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.message-role {
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.message-date {
|
|
font-size: 0.8rem;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.message-content {
|
|
padding: 0.75rem;
|
|
background: var(--bg-secondary);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text-primary);
|
|
font-size: 0.95rem;
|
|
line-height: 1.5;
|
|
margin-bottom: 0.75rem;
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
.message-tokens {
|
|
display: flex;
|
|
gap: 1rem;
|
|
font-size: 0.8rem;
|
|
color: var(--text-secondary);
|
|
padding-top: 0.5rem;
|
|
border-top: 1px solid var(--border-color);
|
|
}
|
|
|
|
.message-tokens span {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 3rem;
|
|
color: var(--text-secondary);
|
|
font-size: 1rem;
|
|
}
|