The Species page, accessible atDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/HectorDNC/galactic-tournament-front/llms.txt
Use this file to discover all available pages before exploring further.
/species, is the primary catalogue management screen in the Galactic Tournament application. It combines a server-paginated Angular Material table with a modal form that handles both creation and editing workflows. All mutations go through SpeciesService, which wraps the /api/species REST resource, and results are communicated back to the user through AlertService toast notifications.
API Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/species?page=0&size=10 | Fetch a paginated page of species. Optionally filter by name. |
GET | /api/species/{id} | Fetch a single species by ID (used to pre-populate the edit form). |
POST | /api/species | Create a new species. |
PUT | /api/species/{id} | Update an existing species. |
https://galactic-tournament-app-production.up.railway.app
Data Models
SpecieRequest Fields
The display name of the species. Must be non-empty and no longer than 100 characters.
A positive integer representing the species’ combat power. Must be at least 1 and must be a whole number (no decimals). Used by the battle engine to determine fight outcomes.
A short description of the species’ unique combat ability. Must be non-empty and no longer than 200 characters.
Paginated Table
The table is rendered withMatTable and MatSort from Angular Material. The component declares the following column set:
| Column | Description |
|---|---|
| name | Species name; sortable via mat-sort-header. |
| powerLevel | Numeric power level; sortable. |
| specialAbility | Free-text ability description; sortable. |
| createdAt | Creation date, formatted dd/MM/yyyy; sortable. |
| actions | Edit icon button that opens the pre-populated form modal. |
MatTableDataSource<Specie> bound to @ViewChild('tbSort') tbSort, which enables client-side sorting on top of server-side pagination.
Filtering by Name
TheSpeciesService.findAll method accepts an optional name query parameter:
Name-based filtering is used by the battle page fighter search, but the species listing page does not expose a search input of its own — it loads all species for the current page without a name filter.
Pagination
Pagination is controlled server-side using Spring Data’sPage envelope:
currentPage (1-based) and totalPages and calls goToPage(page) when the user clicks a page button or the Previous / Next controls:
this.speciesService.findAll(this.currentPage - 1, this.pageSize).
After a successful create or update operation the component resets to page 1 (
currentPage = 1) before reloading the list so the newly saved record is immediately visible.Species Form Modal
Clicking Nueva Especie opens theSpeciesFormComponent modal in create mode. Clicking the edit icon on any row opens it in edit mode with the selected species’ ID passed via @Input() speciesId.
Create Mode
The form initialises with empty fields. On submit, the payload is sent toPOST /api/species. A success toast (“Especie creada exitosamente”) is shown and the modal closes; on error, an error toast is displayed.
Edit Mode
WhenspeciesId is set, the form calls GET /api/species/{id} via SpeciesService.findById to populate the fields. A spinner is shown during this fetch. Submitting in edit mode does not immediately call the API — instead it opens a confirmation dialog.
Confirmation Dialog
The<app-confirm> dialog asks the user to confirm before saving changes. Only after clicking Guardar in that dialog does the component call PUT /api/species/{id}. Cancelling the dialog returns the user to the open form without discarding their edits.
Validation Rules
| Field | Rules |
|---|---|
name | Required · Max 100 characters |
powerLevel | Required · Minimum value 1 · Must match /^\d+$/ (positive integer) |
specialAbility | Required · Max 200 characters |
Toast Notifications
All form outcomes are surfaced throughAlertService:
| Event | Message |
|---|---|
| Create success | "Especie creada exitosamente" |
| Update success | "Especie actualizada exitosamente" |
| Create error | "Error al crear especie" |
| Update error | "Error al actualizar especie" |
| Load (edit) error | "Error al cargar especie" |
Loading & Error States
| State | Behaviour |
|---|---|
loading = true | A “Cargando especies…” placeholder row spans the full table width. |
error is set | A red error row appears spanning the full table width. |
| Empty data | A “No hay especies registradas.” message is rendered below the table. |