Overview
The Admin Panel provides authorized administrators with complete CRUD (Create, Read, Update, Delete) functionality for managing the library’s core entities: books, authors, and genres. The panel features separate management interfaces for each entity with form-based editing and list views.Admin features are protected by role-based access control. Only users with ADMIN role can access these management interfaces.
Management Modules
The admin panel consists of three primary modules:Book Management
Create, edit, and delete books with author and genre associations
Author Management
Manage author profiles with names and photo URLs
Genre Management
Organize books by creating and managing genre categories
Book Management
Components
- List View:
src/app/features/libros/libro-list/libro-list.ts:14 - Form View:
src/app/features/libros/libro-form/libro-form.ts:23 - Service:
src/app/core/services/libro.ts:10
Book List Features
TheLibroListComponent displays all books with management actions:
libro-list.ts:14-33
Deleting Books
Admins can remove books with confirmation:libro-list.ts:35-50
Book Form
TheLibroFormComponent handles both creation and editing with complex relationships:
1
Load Dependencies
Fetch available authors and genres for dropdown selection
2
Populate Form
If editing, load existing book data including associated authors and genre
3
Validate Input
Ensure title, genre, and at least one author are selected
4
Submit
Create new book or update existing one with proper entity references
Form Initialization
libro-form.ts:23-50
Loading Dropdown Data
libro-form.ts:64-76
Form Submission with Validation
libro-form.ts:97-149
Book Service API
libro.ts:10-40
Author Management
Components
- List View:
src/app/features/autores/autor-list/autor-list.ts:14 - Form View:
src/app/features/autores/autor-form/autor-form.ts:14 - Service:
src/app/core/services/autor.ts:10
Author Form
The author form is simpler, requiring only name and optional photo URL:autor-form.ts:14-91
Deleting Authors
autor-list.ts:35-49
Deleting authors with associated books will fail due to database constraints. The system alerts users when deletion is blocked by existing relationships.
Author Service API
autor.ts:10-39
Genre Management
Components
- List View:
src/app/features/generos/genero-list/genero-list.ts:14 - Form View:
src/app/features/generos/genero-form/genero-form.ts:15 - Service:
src/app/core/services/genero.ts:10
Genre Form
The genre form is the simplest, requiring only a name:genero-form.ts:15-87
Deleting Genres
genero-list.ts:36-53
Genre Service API
genero.ts:10-38
Common Patterns
All three management modules share consistent patterns:CRUD Operations
Create
Navigate to form, fill required fields, submit to create new entity
Read
List view displays all entities with key information
Update
Edit button loads entity data into form for modification
Delete
Delete button with confirmation dialog removes entity
Form Modes
All forms support dual modes determined by route parameters:- Create Mode: No ID parameter, form displays empty
- Edit Mode: ID parameter present, form loads existing data
Navigation Structure
Common routing pattern for each module:-
/libros- Book list -
/libros/new- Create book -
/libros/edit/:id- Edit book -
/autores- Author list -
/autores/new- Create author -
/autores/edit/:id- Edit author -
/generos- Genre list -
/generos/new- Create genre -
/generos/edit/:id- Edit genre
Data Relationships
Entity Relationships
Referential Integrity
The system enforces referential integrity:- Deleting an author with associated books fails
- Deleting a genre with associated books fails
- Books can only reference existing authors and genres
API Endpoints Summary
Books
GET /libros- List all booksGET /libros/{id}- Get book by IDPOST /libros- Create bookPUT /libros/{id}- Update bookDELETE /libros/{id}- Delete book
Authors
GET /autores- List all authorsGET /autores/{id}- Get author by IDPOST /autores- Create authorPUT /autores/{id}- Update authorDELETE /autores/{id}- Delete author
Genres
GET /generos- List all genresGET /generos/{id}- Get genre by IDPOST /generos- Create genrePUT /generos/{id}- Update genreDELETE /generos/{id}- Delete genre
Features Summary
Complete CRUD
Full create, read, update, delete operations for all entities
Relationship Management
Handle complex many-to-many and one-to-many relationships
Form Validation
Client-side validation ensures data integrity before submission
Error Handling
User-friendly error messages for constraint violations
Related Features
- Book Catalog - Public-facing book browsing interface
- Loan Management - Approve and reject loan requests