feat(admin): add user management, quotas, and stats dashboard to admin panel
- Dashboard tab: total users, active users, admins, storage usage, quota warnings - User management tab: list, edit role, activate/deactivate, update quota, delete - Self-protection: cannot delete/deactivate/demote yourself - Paginated user listing (default 50 per page) - Efficient single-query dashboard stats with direct SQL aggregation - Quota modal with GB/MB/TB unit selector - Backend: added methods to UserStoragePort, UserRepository, PgRepository - Backend: added 7 admin methods to AuthApplicationService - Backend: added 5 new DTOs for admin operations - Backend: 7 new endpoints under /api/admin/ Files modified: - src/application/ports/auth_ports.rs (4 new UserStoragePort methods) - src/domain/repositories/user_repository.rs (StorageStats + 3 methods) - src/infrastructure/repositories/pg/user_pg_repository.rs (implementations) - src/application/services/auth_application_service.rs (admin methods) - src/application/dtos/settings_dto.rs (5 new DTOs) - src/interfaces/api/handlers/admin_handler.rs (7 new endpoints) - static/admin.html (complete UI with 3 tabs: Dashboard, Users, OIDC)
This commit is contained in:
@@ -94,4 +94,24 @@ pub trait UserRepository: Send + Sync + 'static {
|
||||
|
||||
/// Finds a user by OIDC provider + subject pair
|
||||
async fn get_user_by_oidc_subject(&self, provider: &str, subject: &str) -> UserRepositoryResult<User>;
|
||||
|
||||
/// Actualiza la cuota de almacenamiento de un usuario
|
||||
async fn update_storage_quota(&self, user_id: &str, quota_bytes: i64) -> UserRepositoryResult<()>;
|
||||
|
||||
/// Cuenta el número total de usuarios
|
||||
async fn count_users(&self) -> UserRepositoryResult<i64>;
|
||||
|
||||
/// Obtiene estadísticas de almacenamiento agregadas
|
||||
async fn get_storage_stats(&self) -> UserRepositoryResult<StorageStats>;
|
||||
}
|
||||
|
||||
/// Estadísticas de almacenamiento agregadas
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StorageStats {
|
||||
pub total_users: i64,
|
||||
pub active_users: i64,
|
||||
pub total_quota_bytes: i64,
|
||||
pub total_used_bytes: i64,
|
||||
pub users_over_80_percent: i64,
|
||||
pub users_over_quota: i64,
|
||||
}
|
||||
Reference in New Issue
Block a user