Skip to content

Fix/99 admin panel production - #198

Closed
ilyas2022 wants to merge 22 commits into
ualdra:mainfrom
ilyas2022:fix/99-admin-panel-production
Closed

ilyas2022 wants to merge 22 commits into
ualdra:mainfrom
ilyas2022:fix/99-admin-panel-production

Conversation

@ilyas2022

Copy link
Copy Markdown
Collaborator

panel de control barra lateral arreglada y usuarios

ilyas2022 and others added 22 commits May 7, 2026 16:18
- Implemented AdminController with endpoints for user management, role updates, status changes, KPI stats, and activity logs.
- Created AdminService to handle business logic for user management and stats retrieval.
- Added DTOs for user responses, stats, logs, and role/status update requests.
- Enhanced UserRepository with search and filtering capabilities.
- Updated frontend to integrate with new admin features, including user listing, role management, and status toggling.
- Improved admin dashboard with real-time stats and logs display.
- Added pagination and filtering options in the user management interface.
Add 16 unit tests (Mockito) covering all AdminService public methods:
- getUsers: blank-search normalization, pagination mapping, filter passthrough
- updateRole/updateStatus: self-operation guard (VALIDATION_ERROR), NOT_FOUND,
  successful save with ArgumentCaptor verification
- getStats: all 6 repo counts, start-of-UTC-day Instant for matchesToday
- getLogs: multi-source aggregation sorted by ts desc, INFO/ERR level logic

Also add full request/response contracts to docs/guia-de-coordinación-técnica.md
Módulo 8 for GET /api/admin/users, PUT role, PUT status, GET stats, GET logs —
including error cases and business-rule notes that were missing from the PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merged upstream/main into branch 99 preserving all admin panel
functionality: combined repo methods (MatchRepository, QuestionReportRepository,
SpiderRepository, UserRepository), removed duplicate @EnableMethodSecurity,
and added admin module row to docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReportReason is an enum, not String — use .name() in AdminService and
ReportReason.OTHER in the test builder to fix both compile errors that
were blocking CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ration, backend user management

- Fix sidebar: nav items now use [routerLink]/routerLinkActive, show real admin username,
  disabled items (Preguntas/Rankings/etc.) are dimmed and non-clickable
- Backend: add AdminController (/api/admin/users, /api/admin/stats) + AdminService
  with paginated user list, role update, status toggle (suspend/unsuspend)
- Backend: add AdminStatsResponse, AdminUserResponse, UpdateRoleRequest, UpdateStatusRequest DTOs
- Backend: extend UserRepository with findAdminUsers JPQL query (search + role filter)
  and countByIsActiveTrue; add countByCreatedAtGreaterThanEqual to MatchRepository;
  add countByStatus to QuestionReportRepository
- Frontend: add AdminService (HTTP) and admin.models.ts (typed interfaces)
- Dashboard: loads real stats + spiders from backend instead of mock data
- Spiders: loads real spider list, filter works, run button calls POST /api/admin/spiders/{name}/run
- Reports: loads real reports from /api/moderation/reports, status filter tabs reload,
  DESCARTAR/ELIMINAR buttons call resolve endpoint
- Users: loads real users with live search + role filter, role dropdown and
  SUSPENDER/ACTIVAR buttons call backend

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All 14 conflicted files resolved:
- Backend: AdminController/Service use upstream (self-protection, @AuthenticationPrincipal, getLogs, AdminUserPageResponse)
- Backend: MatchRepository + UserRepository merged (searchUsers JPQL + verification token methods)
- Frontend: admin.models.ts + admin.service.ts merged (all methods from both sides)
- Frontend: dashboard uses real spiders + logs signals; users page uses upstream's click-to-edit UX
- Frontend: spiders + reports pages keep real data integration (upstream had TODO stubs)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…x null fallback, responsive layout

- Backend: add ReportOptionItem DTO and include answer options in ReportResponse
- Backend: ModerationService.toResponse() maps question options (lazy-loaded, transactional)
- Frontend: add ReportOption interface and options[] field to AdminReport model
- Frontend: replace UUID hash fallback with "Pregunta eliminada" label
- Frontend: render answer options in report cards using existing vs-report-card__opts CSS
- Frontend: replace hardcoded 1fr 1fr grid with responsive auto-fill minmax(360px) grid
- Frontend: add mobile breakpoint (768px) collapsing admin layout to single column

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…provements

Conflicts resolved:
- admin.models.ts: keep ReportOption interface + options[] field (fix ualdra#172)
- admin-reports.html: keep responsive grid + options block (fix ualdra#172)

Upstream changes incorporated:
- Rankings/ELO backend + frontend (ualdra#168)
- CI improvements with coverage scripts (ualdra#169)
- Survival arena grid fix (ualdra#174)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Elimina datos inventados y UI no funcional del panel de admin.

Backend:
- AdminService.getModeDistribution() + endpoint GET /api/admin/stats/modes
  (reparto real de partidas finalizadas por modo, vía
  MatchRepository.countFinishedByMode); devuelve siempre las 5 modalidades
- SpiderController: @PreAuthorize("hasRole('ADMIN')") (defensa en profundidad)
- elimina DTOs duplicados sin uso (UpdateRoleRequest, UpdateStatusRequest)
- test de getModeDistribution en AdminServiceTest

Frontend:
- Dashboard: reparto por modo con datos reales del backend con estado vacío;
  quita sparklines falsas y botón EXPORTAR sin función; arregla el enlace
  "VER TODOS" que no navegaba (faltaba RouterLink)
- Spiders: elimina el gráfico "actividad últimas 24h" (datos inventados)
- Sidebar: deja solo items funcionales (quita Preguntas/Rankings/Configuración/
  Logs); muestra el rol real del usuario en vez del literal "Administrador"
- Reports: paginación real (antes solo se veía la primera página)

Docs: contrato técnico actualizado con /api/admin/stats/modes

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tend — keep production-ready admin panel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ePipe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tail

Backend:
- Add `answerText` field to PlayerRoundOutcome so engines can pass human-readable option text
- BinaryDuelEngine and SabotageEngine now resolve option text from question.getOptions() at round-resolution time
- PrecisionDuelEngine passes null (already stores numeric value via valueGiven)
- DuelPersistenceService.answerGivenOf() now prefers answerText over raw UUID
- GameService.answerSurvival() stores selectedCard.getNombre() instead of card UUID
- MatchService.getDetail() injects CardRepository to build question text for card-based rounds (Survival/Precision)

Frontend:
- match-detail-modal: add overflow-x:auto on table wrapper, flex-wrap on player chips, mobile bottom-sheet breakpoint at 600px, hide deviation column on small screens
- profile: wrap singleplayer/multiplayer/history tables in .vs-table-wrap (overflow-x:auto) so columns don't get clipped on narrow viewports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Incorpora: panel admin completo (ualdra#185), propuestas de preguntas, rework
de historial/perfil (ualdra#193), motores de duelo y migraciones backend.

Conflictos resueltos a favor de upstream en sidebar (.html/.ts) y profile
(.html/.scss); se acepta el borrado del match-detail-modal (vista rehecha
inline por el equipo). El fix ualdra#96 permanece en el historial de la rama.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
El merge con upstream combinó la firma nueva (CardRoundContext) con el
fix ualdra#96 (answerText desde question.getOptions), que ya no existe → no
compilaba. Se añade CardRoundContext.optionText(UUID) y los textos de las
cards (con constructor de 6 args de conveniencia para los tests), y los
engines Binary/Sabotage resuelven el texto desde el context. Conserva el
ualdra#96 (historial muestra el nombre de la card, no el UUID).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ponente

Los selectores .vs-admin__side/.vs-admin__nav-item/.vs-admin__nav-section
vivían en admin-dashboard.scss (scoped con la encapsulación del dashboard),
por lo que nunca se aplicaban al <aside> que el AdminSidebarComponent renderiza
desde su propio scope. Resultado: sidebar sin estilos en todas las páginas admin.

- Crear sidebar.scss y mover allí todos los selectores del sidebar +
  bloque de perfil (antes con inline-styles)
- Añadir styleUrl en sidebar.ts; sustituir inline-styles del HTML por clases
- Ocultar items del sidebar que no tienen ruta implementada (Preguntas,
  Rankings, Configuración, Logs) en vez de mostrarlos disabled
- Limpiar admin-dashboard.scss de los selectores movidos
…visible

El listado /admin/usuarios devolvía 0 resultados pese a haber usuarios
en BD (el dashboard mostraba 4 activos). Causa: la @query JPQL con
patrón "(:role IS NULL OR …)" sobre tres parámetros nullables
(String/Enum/Boolean) fallaba bajo Hibernate 6 + PostgreSQL por
inferencia de tipos. El frontend no tenía error handler, así que
la respuesta caída se renderizaba como tabla vacía silenciosa.

Backend:
- AdminService.getUsers: construir Specification dinámicamente,
  añadiendo cada predicado SOLO si el filtro no es null
- Eliminar UserRepository.searchUsers @query (la interfaz ya extiende
  JpaSpecificationExecutor)
- Actualizar AdminServiceTest para mockear findAll(Specification, Pageable)

Frontend:
- admin-users.ts: signals loading + errorMsg; .subscribe({next, error})
  con mensajes según status (401/403/0/genérico)
- admin-users.html: banner .vs-admin-error antes de la tabla;
  distinguir "Cargando…" de "Sin resultados" cuando users().length===0
@github-actions

Copy link
Copy Markdown

🧪 Resultados de CI

Suite Total ✅ Passed ❌ Failed ⚠️ Errors ⏭️ Skipped 📊 Coverage
✅ Backend · Unit 34 34 0 0 0 60.5%
✅ Backend · Integration 93 93 0 0 0 70.3%
✅ Frontend · Unit 78 78 0 0 0 59.5%

Total de pruebas ejecutadas: 205 · Build de imágenes: ✅

commit fdec04f41d0acd4b8b99a684e043a4b1833a7269 · ver run

@ualbrl973 ualbrl973 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deshacer cambios que afectan a los modos de juego

@ualbrl973 ualbrl973 closed this May 28, 2026
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.

3 participants