finish all getall into table

This commit is contained in:
2025-11-18 12:04:51 +01:00
parent 73ce63d7d0
commit 4b5fd254a1
57 changed files with 3048 additions and 82 deletions

View File

@@ -0,0 +1,85 @@
/* Table globale */
nz-table {
width: 100%;
border-collapse: separate;
border-spacing: 0 8px; /* espace entre les lignes */
background: #fff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* En-tête */
nz-table thead tr {
background-color: #f5f5f5;
text-align: left;
font-weight: 600;
color: #333;
border-bottom: 2px solid #e0e0e0;
}
nz-table thead th {
padding: 12px 16px;
}
/* Lignes du tableau */
nz-table tbody tr {
background-color: #fff;
transition: background 0.2s ease;
}
nz-table tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
nz-table tbody tr:hover {
background-color: #e6f7ff; /* survol */
}
/* Cellules */
nz-table tbody td {
padding: 12px 16px;
vertical-align: middle;
color: #444;
}
/* Boutons */
nz-table button[nz-button] {
margin-right: 8px;
}
/* Modals dans le tableau */
nz-table app-modal {
margin-right: 8px;
}
/* Dates (pour alignement et style) */
nz-table tbody td p {
margin: 0;
font-size: 14px;
color: #555;
}
/* Responsive */
@media (max-width: 768px) {
nz-table thead {
display: none;
}
nz-table tbody tr {
display: block;
margin-bottom: 16px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
border-radius: 8px;
padding: 12px;
}
nz-table tbody td {
display: flex;
justify-content: space-between;
padding: 6px 12px;
}
nz-table tbody td::before {
content: attr(data-label);
font-weight: 600;
}
}

View File

@@ -0,0 +1,36 @@
<nz-table [nzData]="books()"
[nzLoading]="booksLoading()"
[nzFrontPagination]="false">
<thead>
<tr style="text-align: center">
<th>Titre</th>
<th>ISBN</th>
<th>Auteur</th>
<th>Date de publication</th>
<th>Action</th>
</tr>
</thead>
<tbody style="text-align: center">
@for (book of books(); track book.id) {
<tr>
<td>{{ book.title}}</td>
<td>{{ book.isbn }}</td>
<td>{{ book.bookAuthorName }} {{ book.bookAuthorFirstName }}</td>
<td>{{ book.releaseYear}}</td>
<div style="justify-content: center; display: flex">
<td>
<app-modal [name]="'Modifier'">
<app-update-book></app-update-book>
</app-modal>
<nz-divider nzType="vertical"></nz-divider>
<div>
<button nz-button nzType="primary" (click)="delete()" class="bg-red-600 border-red-600">Supprimer</button>
</div>
</td>
</div>
</tr>
}
</tbody>
</nz-table>

View File

@@ -0,0 +1,56 @@
import {Component, inject, OnInit, signal} from '@angular/core'; // Importation de la fonction input() et des components
import {Modal} from "../modal/modal";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {BooksService, GetBookDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
import {NzTableComponent} from "ng-zorro-antd/table";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {UpdateBook} from "../update-book/update-book";
@Component({
selector: 'app-book-table',
imports: [
Modal,
NzButtonComponent,
NzTableComponent,
NzDividerComponent,
UpdateBook,
],
templateUrl: './book-table.html',
styleUrl: './book-table.css',
})
export class BookTable implements OnInit {
private booksService = inject(BooksService);
private notificationService = inject(NzNotificationService)
books = signal<GetBookDto[]>([]);
booksLoading = signal<boolean>(false);
async ngOnInit() {
await this.fetchbooks();
}
async fetchbooks() {
this.booksLoading.set(true)
try {
const books = await firstValueFrom(this.booksService.getAllBooksEndpoint());
this.books.set(books);
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur de communication avec l\'API'
)
}
this.booksLoading.set(false)
}
delete() {
return
}
}