feat: add admin dashboard, audit logs, token expiry check and test suite
Frontend Features: - Add ProtectedRoute component with token expiry validation - Create AdminDashboardPage with system statistics and user management - Create AuditLogsPage with filtering and pagination - Add admin-only navigation (Shield icon) for ymirliu@panjit.com.tw - Add admin API methods to apiV2 service - Add admin type definitions (SystemStats, AuditLog, etc.) Token Management: - Auto-redirect to login on token expiry - Check authentication on route change - Show loading state during auth check - Admin privilege verification Backend Testing: - Add pytest configuration (pytest.ini) - Create test fixtures (conftest.py) - Add unit tests for auth, tasks, and admin endpoints - Add integration tests for complete workflows - Test user isolation and admin access control Documentation: - Add TESTING.md with comprehensive testing guide - Include test running instructions - Document fixtures and best practices Routes: - /admin - Admin dashboard (admin only) - /admin/audit-logs - Audit logs viewer (admin only) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -115,3 +115,72 @@ export interface TaskFilters {
|
||||
order_by: string
|
||||
order_desc: boolean
|
||||
}
|
||||
|
||||
// ==================== Admin Types ====================
|
||||
|
||||
export interface SystemStats {
|
||||
total_users: number
|
||||
active_users: number
|
||||
total_tasks: number
|
||||
total_sessions: number
|
||||
recent_activity_count: number
|
||||
task_stats: {
|
||||
pending: number
|
||||
processing: number
|
||||
completed: number
|
||||
failed: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserWithStats {
|
||||
id: number
|
||||
email: string
|
||||
display_name: string | null
|
||||
created_at: string
|
||||
last_login: string | null
|
||||
is_active: boolean
|
||||
task_count: number
|
||||
completed_tasks: number
|
||||
failed_tasks: number
|
||||
}
|
||||
|
||||
export interface TopUser {
|
||||
user_id: number
|
||||
email: string
|
||||
display_name: string | null
|
||||
task_count: number
|
||||
completed_tasks: number
|
||||
}
|
||||
|
||||
export interface AuditLog {
|
||||
id: number
|
||||
user_id: number
|
||||
user_email: string
|
||||
category: 'auth' | 'task' | 'file' | 'admin' | 'system'
|
||||
action: string
|
||||
resource_type: string | null
|
||||
resource_id: string | null
|
||||
success: boolean
|
||||
error_message: string | null
|
||||
extra_data: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface AuditLogListResponse {
|
||||
logs: AuditLog[]
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
has_more: boolean
|
||||
}
|
||||
|
||||
export interface UserActivitySummary {
|
||||
user_id: number
|
||||
email: string
|
||||
display_name: string | null
|
||||
total_actions: number
|
||||
successful_actions: number
|
||||
failed_actions: number
|
||||
categories: Record<string, number>
|
||||
recent_actions: AuditLog[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user