finish all getall into table
This commit is contained in:
55
src/app/components/author-table/author-table.ts
Normal file
55
src/app/components/author-table/author-table.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {Modal} from "../modal/modal";
|
||||
import {NzButtonComponent} from "ng-zorro-antd/button";
|
||||
import {AuthorsService, GetAuthorDto} 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 {UpdateAuthor} from "../update-author/update-author";
|
||||
|
||||
@Component({
|
||||
selector: 'app-author-table',
|
||||
imports: [
|
||||
Modal,
|
||||
NzButtonComponent,
|
||||
NzTableComponent,
|
||||
NzDividerComponent,
|
||||
UpdateAuthor
|
||||
],
|
||||
templateUrl: './author-table.html',
|
||||
styleUrl: './author-table.css',
|
||||
})
|
||||
export class AuthorTable implements OnInit {
|
||||
private authorsService = inject(AuthorsService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
|
||||
authors = signal<GetAuthorDto[]>([]);
|
||||
|
||||
authorsLoading = signal<boolean>(false);
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchauthors();
|
||||
}
|
||||
|
||||
async fetchauthors() {
|
||||
this.authorsLoading.set(true)
|
||||
|
||||
try {
|
||||
const authors = await firstValueFrom(this.authorsService.getAllAuthorsEndpoint());
|
||||
|
||||
this.authors.set(authors);
|
||||
|
||||
} catch (e) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur de communication avec l\'API'
|
||||
)
|
||||
}
|
||||
this.authorsLoading.set(false)
|
||||
}
|
||||
|
||||
delete() {
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user