Compare commits

...

10 Commits

Author SHA1 Message Date
Cristiano
4b3faa236d .... 2025-12-02 08:34:58 +01:00
5b1030570f Changed color of check zone 2025-11-24 11:14:07 +01:00
c7e962038b fixed errors 2025-11-24 10:32:11 +01:00
aa96fa25ca added search into all selects on all forms 2025-11-23 14:38:25 +01:00
af1dec318f updated create-form of loan and book 2025-11-23 13:41:55 +01:00
6b1f3ece94 updated create-form of loan and book 2025-11-23 12:14:45 +01:00
0f75d1768b added all edit function 2025-11-23 12:03:14 +01:00
448f43e3eb added edit function for author and book pages 2025-11-22 12:21:24 +01:00
ebea9f1a6b created all delete functions 2025-11-21 18:51:35 +01:00
230560dbbc updated form for edited all user 2025-11-21 18:40:44 +01:00
58 changed files with 943 additions and 683 deletions

82
package-lock.json generated
View File

@@ -28,6 +28,7 @@
"@angular/cli": "^20.3.9",
"@angular/compiler-cli": "^20.3.0",
"less": "^4.2.0",
"rimraf": "^6.1.2",
"typescript": "~5.9.2"
}
},
@@ -8988,6 +8989,87 @@
"dev": true,
"license": "MIT"
},
"node_modules/rimraf": {
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.2.tgz",
"integrity": "sha512-cFCkPslJv7BAXJsYlK1dZsbP8/ZNLkCAQ0bi1hf5EKX2QHegmDFEFA6QhuYJlk7UDdc+02JjO80YSOrWPpw06g==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"glob": "^13.0.0",
"package-json-from-dist": "^1.0.1"
},
"bin": {
"rimraf": "dist/esm/bin.mjs"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rimraf/node_modules/glob": {
"version": "13.0.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.0.tgz",
"integrity": "sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"minimatch": "^10.1.1",
"minipass": "^7.1.2",
"path-scurry": "^2.0.0"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rimraf/node_modules/lru-cache": {
"version": "11.2.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz",
"integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/rimraf/node_modules/minimatch": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz",
"integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/brace-expansion": "^5.0.0"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rimraf/node_modules/path-scurry": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz",
"integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^11.0.0",
"minipass": "^7.1.2"
},
"engines": {
"node": "20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rollup": {
"version": "4.52.3",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.3.tgz",

View File

@@ -6,7 +6,8 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"openapi": "rm -rf src/app/services/api && openapi-generator-cli generate -i http://localhost:5228/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml"
"openapi": "rm -rf src/app/services/api && openapi-generator-cli generate -i http://localhost:5156/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml",
"openapiWin": "set JAVA_TOOL_OPTIONS=-Dcom.sun.net.ssl.checkRevocation=false -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT && openapi-generator-cli generate -i https://localhost:44390/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml\n"
},
"prettier": {
"printWidth": 100,
@@ -42,6 +43,7 @@
"@angular/cli": "^20.3.9",
"@angular/compiler-cli": "^20.3.0",
"less": "^4.2.0",
"rimraf": "^6.1.2",
"typescript": "~5.9.2"
}
}

View File

@@ -12,9 +12,9 @@
<tbody style="text-align: center">
@for (author of authors(); track author.id) {
<tr>
<td>{{ author.name}}</td>
<td>{{ author.firstName }}</td>
<td>
<td>{{ author.firstName}}</td>
<td>{{ author.name }}</td>
<td style="text-align: center;">
<app-modal type="link" [name]="'Voir les livres'">
<nz-table [nzData]="authors()"
[nzFrontPagination]="false">
@@ -40,16 +40,10 @@
<td>
<div style="justify-content: center; display: flex">
<td>
<app-modal-icon nameIcon="edit" [name]="'Modifier'">
<app-update-author></app-update-author>
</app-modal-icon>
<nz-divider nzType="vertical"></nz-divider>
<div>
<div>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete()" class="text-red-600"></nz-icon>
</div>
<div style="display: flex; align-items: center;">
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(author)"></nz-icon>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(author.id)" class="text-red-600 cursor-pointer"></nz-icon>
</div>
</td>
</div>
@@ -58,3 +52,9 @@
}
</tbody>
</nz-table>
<div class="hidden">
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedAuthor.id, updateAuthor, modalIcon)" (cancel)="onModalCancel(modalIcon)">
<app-update-author #updateAuthor [author]="selectedAuthor"></app-update-author>
</app-modal-icon>
</div>

View File

@@ -1,4 +1,4 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {Modal} from "../modal/modal";
import {AuthorsService, GetAuthorDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
@@ -25,16 +25,16 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
export class AuthorTable implements OnInit {
private authorsService = inject(AuthorsService);
private notificationService = inject(NzNotificationService)
authors = signal<GetAuthorDto[]>([]);
authorsLoading = signal<boolean>(false);
updateAuthor = viewChild.required<UpdateAuthor>('updateAuthor');
modal = viewChild.required<ModalIcon>('modalIcon');
async ngOnInit() {
await this.fetchauthors();
await this.fetchAuthors();
}
async fetchauthors() {
async fetchAuthors() {
this.authorsLoading.set(true)
try {
@@ -51,7 +51,62 @@ export class AuthorTable implements OnInit {
this.authorsLoading.set(false)
}
delete() {
return
async delete(author:number) {
try {
await firstValueFrom(this.authorsService.deleteAuthorEndpoint(author))
this.notificationService.success(
'Success',
'Suppression effectuée'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Impossible de supprimer la ligne'
)
}
await this.fetchAuthors();
}
async edit(id: number, updateAuthorComponent: UpdateAuthor) {
if (updateAuthorComponent.updateAuthorForm.invalid) {
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
return;
}
try {
const authors = updateAuthorComponent.updateAuthorForm.getRawValue();
await firstValueFrom(this.authorsService.updateAuthorEndpoint(id, authors))
this.notificationService.success(
'Success',
'Auteur modifié'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur lors de la modification'
)
}
}
selectedAuthor: GetAuthorDto | null = null;
openEditModal(author: GetAuthorDto) {
this.selectedAuthor = { ...author };
this.modal().showModal();
}
async onModalOk(authorId: number, updateAuthorComponent: UpdateAuthor, modal: ModalIcon) {
await this.edit(authorId, updateAuthorComponent);
updateAuthorComponent.updateAuthorForm.reset();
modal.isVisible = false;
await this.fetchAuthors();
}
onModalCancel(modal: ModalIcon) {
modal.isVisible = false;
}
}

View File

@@ -15,20 +15,14 @@
<tr>
<td>{{ book.title}}</td>
<td>{{ book.isbn }}</td>
<td>{{ book.bookAuthorName }} {{ book.bookAuthorFirstName }}</td>
<td>{{ book.authorFirstName }} {{ book.authorName }}</td>
<td>{{ book.releaseYear}}</td>
<div style="justify-content: center; display: flex">
<td>
<app-modal-icon nameIcon="edit" [name]="'Modifier'">
<app-update-book></app-update-book>
</app-modal-icon>
<nz-divider nzType="vertical"></nz-divider>
<div>
<div>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete()" class="text-red-600"></nz-icon>
</div>
<div style="display: flex; align-items: center;">
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(book)"></nz-icon>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(book.id)" class="text-red-600 cursor-pointer"></nz-icon>
</div>
</td>
</div>
@@ -36,3 +30,9 @@
}
</tbody>
</nz-table>
<div class="hidden">
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedBook.id, updateBook, modalIcon)" (cancel)="onModalCancel(modalIcon)">
<app-update-book #updateBook [book]="selectedBook"></app-update-book>
</app-modal-icon>
</div>

View File

@@ -1,4 +1,4 @@
import {Component, inject, OnInit, signal} from '@angular/core'; // Importation de la fonction input() et des components
import {Component, inject, OnInit, signal, viewChild} from '@angular/core'; // Importation de la fonction input() et des components
import {BooksService, GetBookDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@@ -20,23 +20,24 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
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);
updateBook = viewChild.required<UpdateBook>('updateBook');
modal = viewChild.required<ModalIcon>('modalIcon');
async ngOnInit() {
await this.fetchbooks();
await this.fetchBooks();
}
async fetchbooks() {
async fetchBooks() {
this.booksLoading.set(true)
try {
const books = await firstValueFrom(this.booksService.getAllBooksEndpoint());
const books = await firstValueFrom(this.booksService.getAllBookEndpoint());
this.books.set(books);
@@ -50,7 +51,64 @@ export class BookTable implements OnInit {
this.booksLoading.set(false)
}
delete() {
return
async delete(book:number) {
try {
await firstValueFrom(this.booksService.deleteBookEndpoint(book))
this.notificationService.success(
'Success',
'Suppression effectuée'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Impossible de supprimer la ligne'
)
}
await this.fetchBooks();
}
async edit(id: number, updateBookComponent: UpdateBook) {
if (updateBookComponent.updateBookForm.invalid) {
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
return;
}
try {
const books = updateBookComponent.updateBookForm.getRawValue();
await firstValueFrom(this.booksService.updateBookEndpoint(id, books))
console.log("Payload envoyé :", books);
this.notificationService.success(
'Success',
'Livre modifié'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur lors de la modification'
)
}
}
selectedBook: GetBookDto | null = null;
openEditModal(book: GetBookDto) {
this.selectedBook = { ...book };
this.modal().showModal();
}
async onModalOk(bookId: number, updateBookComponent: UpdateBook, modal: ModalIcon) {
await this.edit(bookId, updateBookComponent);
updateBookComponent.updateBookForm.reset();
modal.isVisible = false;
await this.fetchBooks();
}
onModalCancel(modal: ModalIcon) {
modal.isVisible = false;
}
}

View File

@@ -1,4 +1,4 @@
<form nz-form nzLayout="horizontal" [formGroup]="createAuthorForm" (ngSubmit)="submitForm()">
<form nz-form nzLayout="horizontal" [formGroup]="createAuthorForm">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Nom

View File

@@ -2,6 +2,7 @@ import {Component, input} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
@Component({
selector: 'app-create-author',
@@ -13,7 +14,8 @@ import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabe
NzFormItemComponent,
NzFormLabelComponent,
NzRowDirective,
ReactiveFormsModule
ReactiveFormsModule,
NzInputDirective
],
templateUrl: './create-author.html',
styleUrl: './create-author.css',
@@ -23,15 +25,4 @@ export class CreateAuthor {
name: new FormControl<string>(null, [Validators.required]),
firstName: new FormControl<string>(null, [Validators.required])
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.createAuthorForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.createAuthorForm.getRawValue())
// Pour vider le formulaire
this.createAuthorForm.reset()
}
}

View File

@@ -1,4 +1,4 @@
<form nz-form nzLayout="horizontal" [formGroup]="createBookForm" (ngSubmit)="submitForm()">
<form nz-form nzLayout="horizontal" [formGroup]="createBookForm">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Titre
@@ -25,7 +25,11 @@
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Auteur" formControlName="author">
<nz-select formControlName="authorId" [nzPlaceHolder]="'Choisir un auteur'" nzShowSearch [nzFilterOption]="filterAuthor">
@for (author of authors(); track author.id) {
<nz-option [nzValue]="author.id" [nzLabel]="author.firstName + ' ' + author.name"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>

View File

@@ -1,30 +1,44 @@
import { Component } from '@angular/core';
import {Component, inject, input, OnInit, signal} from '@angular/core';
import {NzFormModule} from "ng-zorro-antd/form";
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {AuthorsService, GetAuthorDto, GetBookDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-create-book',
imports: [NzFormModule, ReactiveFormsModule, NzInputDirective],
imports: [NzFormModule, ReactiveFormsModule, NzInputDirective, NzOptionComponent, NzSelectComponent],
templateUrl: './create-book.html',
styleUrls: ['./create-book.css'],
})
export class CreateBook {
export class CreateBook implements OnInit {
createBookForm = new FormGroup({
title: new FormControl<string>(null, [Validators.required]),
isbn: new FormControl<string>(null, [Validators.required]),
releaseYear: new FormControl<string>(null, [Validators.required]),
author: new FormControl<string>(null, [Validators.required])
releaseYear: new FormControl<number>(null, [Validators.required]),
authorId: new FormControl<number>(null, Validators.required)
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.createBookForm.invalid) return;
private authorsService = inject(AuthorsService);
private notificationService = inject(NzNotificationService);
authors = signal<GetAuthorDto[]>([]);
// Pour obtenir la valeur du formulaire
console.log(this.createBookForm.getRawValue())
async fetchAuthors() {
try {
const authors = await firstValueFrom(this.authorsService.getAllAuthorsEndpoint());
this.authors.set(authors);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les auteurs');
}
}
// Pour vider le formulaire
this.createBookForm.reset()
async ngOnInit() {
await this.fetchAuthors();
}
filterAuthor(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
}

View File

@@ -1,21 +1,29 @@
<form nz-form nzLayout="horizontal" [formGroup]="createLoanForm" (ngSubmit)="submitForm()">
<form nz-form nzLayout="horizontal" [formGroup]="createLoanForm">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Nom / Prénom
<nz-form-label nzSpan="10" nzRequired>
Utilisateur
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Non défini" formControlName="name">
<nz-select formControlName="userId" [nzPlaceHolder]="'Choisir un utilisateur'" nzShowSearch [nzFilterOption]="filter">
@for (user of users(); track user.id) {
<nz-option [nzValue]="user.id" [nzLabel]="user.firstName + ' ' + user.name"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
<nz-form-label nzSpan="10" nzRequired>
Livre
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Prénom de l'auteur" formControlName="book">
<nz-select formControlName="bookId" [nzPlaceHolder]="'Choisir un livre'" nzShowSearch [nzFilterOption]="filter">
@for (book of books(); track book.id) {
<nz-option [nzValue]="book.id" [nzLabel]="book.title"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>
</form>

View File

@@ -1,8 +1,12 @@
import { Component } from '@angular/core';
import {Component, inject, OnInit, signal} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {BooksService, GetBookDto, GetUserDto, UsersService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
import {format} from "date-fns";
@Component({
selector: 'app-create-loan',
@@ -15,25 +19,49 @@ import {NzInputDirective} from "ng-zorro-antd/input";
NzFormLabelComponent,
NzRowDirective,
ReactiveFormsModule,
NzInputDirective
NzOptionComponent,
NzSelectComponent
],
templateUrl: './create-loan.html',
styleUrl: './create-loan.css',
})
export class CreateLoan {
export class CreateLoan implements OnInit {
createLoanForm = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
book: new FormControl<string>(null, [Validators.required])
userId: new FormControl<number>(null, Validators.required),
bookId: new FormControl<number>(null, Validators.required),
date: new FormControl<string>(format(new Date(), 'yyyy-MM-dd'))
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.createLoanForm.invalid) return;
private userService = inject(UsersService);
private bookService = inject(BooksService);
private notificationService = inject(NzNotificationService);
users = signal<GetUserDto[]>([]);
books = signal<GetBookDto[]>([]);
// Pour obtenir la valeur du formulaire
console.log(this.createLoanForm.getRawValue())
async fetchUsers() {
try {
const users = await firstValueFrom(this.userService.getAllUserEndpoint());
this.users.set(users);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les utilisateurs');
}
}
// Pour vider le formulaire
this.createLoanForm.reset()
async fetchBooks() {
try {
const books = await firstValueFrom(this.bookService.getAllBookEndpoint());
this.books.set(books);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les livres');
}
}
async ngOnInit() {
await this.fetchUsers();
await this.fetchBooks();
}
filter(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
}

View File

@@ -1,5 +1,6 @@
<nz-table [nzData]="loans()"
[nzLoading]="loansLoading()">
[nzLoading]="loansLoading()"
[nzFrontPagination]="false">
<thead>
<tr style="text-align: center">
<th>Utilisateur</th>
@@ -20,20 +21,22 @@
<td>{{ loan.effectiveReturningDate | date: 'dd/MM/yyyy'}}</td>
<div style="justify-content: center; display: flex">
<td>
<app-modal-icon nameIcon="edit" [name]="'Modifier'">
<app-update-loan></app-update-loan>
</app-modal-icon>
<nz-divider nzType="vertical"></nz-divider>
<div>
<div>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete()" class="text-red-600"></nz-icon>
</div>
<div style="display: flex; align-items: center;">
<nz-icon nzType="check" nzTheme="outline" class="cursor-pointer text-green-600" (click)="validationDate(loan.id)"></nz-icon>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(loan)"></nz-icon>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(loan.id)" class="text-red-600 cursor-pointer"></nz-icon>
</div>
</td>
</div>
</tr>
}
</tbody>
</nz-table>
</nz-table>
<div class="hidden">
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedLoan.id, updateLoan, modalIcon)" (cancel)="onModalCancel(modalIcon)">
<app-update-loan #updateLoan [loan]="selectedLoan"></app-update-loan>
</app-modal-icon>
</div>

View File

@@ -1,4 +1,4 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {DatePipe} from "@angular/common";
import {NzTableComponent} from "ng-zorro-antd/table";
import {UpdateLoan} from "../update-loan/update-loan";
@@ -8,6 +8,7 @@ import {firstValueFrom} from "rxjs";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {ModalIcon} from "../modal-icon/modal-icon";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {format} from "date-fns";
@Component({
selector: 'app-loan-table',
@@ -25,16 +26,16 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
export class LoanTable implements OnInit {
private loansService = inject(LoansService);
private notificationService = inject(NzNotificationService)
loans = signal<GetLoanDto[]>([]);
loansLoading = signal<boolean>(false);
updateLoan = viewChild.required<UpdateLoan>('updateLoan');
modal = viewChild.required<ModalIcon>('modalIcon');
async ngOnInit() {
await this.fetchloans();
await this.fetchLoans();
}
async fetchloans() {
async fetchLoans() {
this.loansLoading.set(true)
try {
@@ -51,7 +52,109 @@ export class LoanTable implements OnInit {
this.loansLoading.set(false)
}
delete() {
return
async delete(loan: number) {
try {
await firstValueFrom(this.loansService.deleteLoanEndpoint(loan))
this.notificationService.success(
'Success',
'Suppression effectuée'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Impossible de supprimer la ligne'
)
}
await this.fetchLoans();
}
async edit(id: number, updateLoanComponent: UpdateLoan) {
if (updateLoanComponent.updateLoanForm.invalid) {
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
return;
}
try {
const plannedDate = updateLoanComponent.updateLoanForm.get('plannedReturningDate').value;
const plannedDateResult = format(plannedDate, 'yyyy-MM-dd');
const effectiveDate = updateLoanComponent.updateLoanForm.get('effectiveReturningDate').value;
const effectiveDateResult = format(effectiveDate, 'yyyy-MM-dd');
const loans = updateLoanComponent.updateLoanForm.getRawValue();
loans.plannedReturningDate = plannedDateResult;
loans.effectiveReturningDate = effectiveDateResult;
const updatedLoanDto = {
id: this.selectedLoan.id,
bookId: updateLoanComponent.updateLoanForm.get('bookId').value,
userId: updateLoanComponent.updateLoanForm.get('userId').value,
date: this.selectedLoan.date,
plannedReturningDate: loans.plannedReturningDate,
effectiveReturningDate: loans.effectiveReturningDate
};
await firstValueFrom(this.loansService.updateLoanEndpoint(id, updatedLoanDto))
this.notificationService.success(
'Success',
'Emprunt modifié'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur lors de la modification'
)
}
}
async validationDate(loanId: number) {
try {
const PatchLoanValue = {
effectiveReturningDate: format(new Date(), 'yyyy-MM-dd')
};
try {
await firstValueFrom(this.loansService.updateLoanEffectiveReturnDateEndpoint(loanId, PatchLoanValue))
this.notificationService.success(
'Success',
'Date de retour actualisée'
)
} catch (e) {
this.notificationService.error(
'Error',
'Can\'t set returning date'
)
}
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur d\'actualisation de la date de retour'
)
}
await this.fetchLoans()
}
selectedLoan: GetLoanDto | null = null;
openEditModal(loan: GetLoanDto) {
this.selectedLoan = { ...loan };
this.modal().showModal();
}
async onModalOk(loanId: number, updateLoanComponent: UpdateLoan, modal: ModalIcon) {
await this.edit(loanId, updateLoanComponent);
updateLoanComponent.updateLoanForm.reset();
modal.isVisible = false;
await this.fetchLoans();
}
onModalCancel(modal: ModalIcon) {
modal.isVisible = false;
}
}

View File

@@ -1,14 +1,4 @@
<form nz-form nzLayout="horizontal" [formGroup]="updateAuthorForm" (ngSubmit)="submitForm()">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Nom
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Nom de l'auteur" formControlName="name">
</nz-form-control>
</nz-form-item>
<form nz-form nzLayout="horizontal" [formGroup]="updateAuthorForm">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Prénom
@@ -18,4 +8,14 @@
<input nz-input placeholder="Prénom de l'auteur" formControlName="firstName">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Nom
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Nom de l'auteur" formControlName="name">
</nz-form-control>
</nz-form-item>
</form>

View File

@@ -1,7 +1,9 @@
import { Component } from '@angular/core';
import {Component, input} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {GetAuthorDto, GetLoanDto} from "../../services/api";
import {NzInputDirective} from "ng-zorro-antd/input";
@Component({
selector: 'app-update-author',
@@ -13,7 +15,8 @@ import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabe
NzFormItemComponent,
NzFormLabelComponent,
NzRowDirective,
ReactiveFormsModule
ReactiveFormsModule,
NzInputDirective
],
templateUrl: './update-author.html',
styleUrl: './update-author.css',
@@ -24,14 +27,13 @@ export class UpdateAuthor {
firstName: new FormControl<string>(null, [Validators.required])
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.updateAuthorForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.updateAuthorForm.getRawValue())
// Pour vider le formulaire
this.updateAuthorForm.reset()
author = input.required<GetAuthorDto>()
ngOnChanges() {
if (this.author) {
this.updateAuthorForm.patchValue({
name: this.author().name,
firstName: this.author().firstName,
});
}
}
}

View File

@@ -1,4 +1,4 @@
<form nz-form nzLayout="horizontal" [formGroup]="updateBookForm" (ngSubmit)="submitForm()">
<form nz-form nzLayout="horizontal" [formGroup]="updateBookForm">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Titre
@@ -25,7 +25,11 @@
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Auteur" formControlName="author">
<nz-select formControlName="authorId" [nzPlaceHolder]="'Choisir un auteur'" nzShowSearch [nzFilterOption]="filterAuthor">
@for (author of authors(); track author.id) {
<nz-option [nzValue]="author.id" [nzLabel]="author.firstName + ' ' + author.name"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>
@@ -35,7 +39,7 @@
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<nz-date-picker nzPlaceHolder="2025-11-14" formControlName="releaseYear"></nz-date-picker>
<input nz-input type="number" placeholder="YYYY" formControlName="releaseYear">
</nz-form-control>
</nz-form-item>
</form>

View File

@@ -1,31 +1,56 @@
import { Component } from '@angular/core';
import {Component, inject, input, OnInit, signal} from '@angular/core';
import {NzFormModule} from "ng-zorro-antd/form";
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {GetBookDto, GetAuthorDto, AuthorsService} from "../../services/api";
import {firstValueFrom} from "rxjs";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
@Component({
selector: 'app-update-book',
imports: [NzFormModule, ReactiveFormsModule, NzInputDirective, NzDatePickerComponent],
imports: [NzFormModule, ReactiveFormsModule, NzInputDirective, NzSelectComponent, NzOptionComponent],
templateUrl: './update-book.html',
styleUrl: './update-book.css',
})
export class UpdateBook {
export class UpdateBook implements OnInit {
updateBookForm = new FormGroup({
title: new FormControl<string>(null, [Validators.required]),
isbn: new FormControl<string>(null, [Validators.required]),
releaseYear: new FormControl<string>(null, [Validators.required]),
author: new FormControl<string>(null, [Validators.required])
releaseYear: new FormControl<number>(null, [Validators.required]),
authorId: new FormControl<number>(null, Validators.required)
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.updateBookForm.invalid) return;
private authorsService = inject(AuthorsService);
private notificationService = inject(NzNotificationService);
authors = signal<GetAuthorDto[]>([]);
book = input.required<GetBookDto>()
// Pour obtenir la valeur du formulaire
console.log(this.updateBookForm.getRawValue())
ngOnChanges() {
if (this.book) {
this.updateBookForm.patchValue({
title: this.book().title,
isbn: this.book().isbn,
releaseYear: this.book().releaseYear,
authorId: this.book().authorId
});
}
}
// Pour vider le formulaire
this.updateBookForm.reset()
async fetchAuthors() {
try {
const authors = await firstValueFrom(this.authorsService.getAllAuthorsEndpoint());
this.authors.set(authors);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les auteurs');
}
}
async ngOnInit() {
await this.fetchAuthors();
}
filterAuthor(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
}

View File

@@ -1,11 +1,15 @@
<form nz-form nzLayout="horizontal" [formGroup]="updateLoanForm" (ngSubmit)="submitForm()">
<form nz-form nzLayout="horizontal" [formGroup]="updateLoanForm">
<nz-form-item>
<nz-form-label nzSpan="10" nzRequired>
Nom / Prénom
Utilisateur
</nz-form-label>
<nz-form-control nzSpan="30" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Non défini" formControlName="name">
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<nz-select formControlName="userId" [nzPlaceHolder]="'Choisir un utilisateur'" nzShowSearch [nzFilterOption]="filter">
@for (user of users(); track user.id) {
<nz-option [nzValue]="user.id" [nzLabel]="user.firstName + ' ' + user.name"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>
@@ -14,8 +18,12 @@
Livre
</nz-form-label>
<nz-form-control nzSpan="30" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Prénom de l'auteur" formControlName="book">
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<nz-select formControlName="bookId" [nzPlaceHolder]="'Choisir un livre'" nzShowSearch [nzFilterOption]="filter">
@for (book of books(); track book.id) {
<nz-option [nzValue]="book.id" [nzLabel]="book.title"></nz-option>
}
</nz-select>
</nz-form-control>
</nz-form-item>
@@ -25,7 +33,7 @@
</nz-form-label>
<nz-form-control nzSpan="30" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="JJ/MM/AAAA" formControlName="plannedDate">
<nz-date-picker formControlName="plannedReturningDate"></nz-date-picker>
</nz-form-control>
</nz-form-item>
@@ -35,7 +43,7 @@
</nz-form-label>
<nz-form-control nzSpan="30" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="JJ/MM/AAAA" formControlName="effectiveDate">
<nz-date-picker formControlName="effectiveReturningDate"></nz-date-picker>
</nz-form-control>
</nz-form-item>
</form>

View File

@@ -1,11 +1,15 @@
import { Component } from '@angular/core';
import {Component, inject, input, OnChanges, OnInit, signal} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {BooksService, GetBookDto, GetLoanDto, GetUserDto, UsersService} from "../../services/api";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-update-loan',
selector: 'app-update-loan',
imports: [
FormsModule,
NzColDirective,
@@ -13,29 +17,75 @@ import {NzInputDirective} from "ng-zorro-antd/input";
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
NzRowDirective,
ReactiveFormsModule
ReactiveFormsModule,
NzDatePickerComponent,
NzOptionComponent,
NzSelectComponent
],
templateUrl: './update-loan.html',
styleUrl: './update-loan.css',
templateUrl: './update-loan.html',
styleUrl: './update-loan.css',
})
export class UpdateLoan {
export class UpdateLoan implements OnInit, OnChanges {
updateLoanForm = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
book: new FormControl<string>(null, [Validators.required]),
plannedDate: new FormControl(null, [Validators.required]),
effectiveDate: new FormControl(null, [Validators.required]),
})
userId: new FormControl<number>(null, Validators.required),
bookId: new FormControl<number>(null, Validators.required),
plannedReturningDate: new FormControl(null, Validators.required),
effectiveReturningDate: new FormControl(null),
});
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.updateLoanForm.invalid) return;
private userService = inject(UsersService);
private bookService = inject(BooksService);
private notificationService = inject(NzNotificationService);
users = signal<GetUserDto[]>([]);
books = signal<GetBookDto[]>([]);
loan = input.required<GetLoanDto>()
// Pour obtenir la valeur du formulaire
console.log(this.updateLoanForm.getRawValue())
ngOnChanges() {
if (this.loan) {
if (this.loan().effectiveReturningDate != null) {
this.updateLoanForm.patchValue({
userId: this.loan().userId,
bookId: this.loan().bookId,
plannedReturningDate: new Date(this.loan().plannedReturningDate),
effectiveReturningDate: new Date(this.loan().effectiveReturningDate)
});
// Pour vider le formulaire
this.updateLoanForm.reset()
} else {
this.updateLoanForm.patchValue({
userId: this.loan().userId,
bookId: this.loan().bookId,
plannedReturningDate: new Date(this.loan().plannedReturningDate),
effectiveReturningDate: null
});
}
}
}
async fetchUsers() {
try {
const users = await firstValueFrom(this.userService.getAllUserEndpoint());
this.users.set(users);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les utilisateurs');
}
}
async fetchBooks() {
try {
const books = await firstValueFrom(this.bookService.getAllBookEndpoint());
this.books.set(books);
} catch (e) {
this.notificationService.error('Erreur', 'Impossible de récupérer les livres');
}
}
async ngOnInit() {
await this.fetchUsers();
await this.fetchBooks();
}
filter(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
}

View File

@@ -4,8 +4,6 @@ import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {format} from "date-fns";
import {firstValueFrom} from "rxjs";
import {GetUserDto} from "../../services/api";
@Component({

View File

@@ -1,7 +1,6 @@
<nz-table [nzData]="users()"
[nzLoading]="usersLoading()"
[nzFrontPagination]="false"
>
[nzFrontPagination]="false">
<thead>
<tr style="text-align: center">
<th>Nom</th>
@@ -9,20 +8,19 @@
<th>Email</th>
<th>Anniversaire</th>
<th>Emprunt</th>
<th style="display: flex; align-items: center;">Action</th>
<th style="display: flex; align-items: center;">Action</th>
</tr>
</thead>
<tbody style="text-align: center">
@for (user of users(); track user.id) {
<tr>
<td>{{ user.name}}</td>
<td>{{ user.name }}</td>
<td>{{ user.firstName }}</td>
<td>{{ user.email }}</td>
<td>{{ user.birthDate | date: 'dd/MM/yyyy'}}</td>
<td>
<app-modal type="link" [name]="'Voir les emprunts'">
<nz-table [nzData]="users()"
[nzFrontPagination]="false">
<nz-table [nzData]="user.loans" [nzFrontPagination]="false">
<thead>
<tr style="text-align: center">
<th>Livre</th>
@@ -44,24 +42,18 @@
</td>
<td>
<div style="display: flex; align-items: center;">
<div class="cursor-pointer">
<app-modal-icon #modalIcon
nameIcon="edit"
[name]="'Modifier'"
(ok)="onModalOk(selectedUser?.id, updateUser, modalIcon)"
(cancel)="onModalCancel(modalIcon)"
(click)="openEditModal(user)">
<app-update-user #updateUser [user]="selectedUser"></app-update-user>
</app-modal-icon>
</div>
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(user)"></nz-icon>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(user.id)" class="text-red-600 cursor-pointer">
</nz-icon>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(user.id)" class="text-red-600 cursor-pointer"></nz-icon>
</div>
</td>
</tr>
}
</tbody>
</nz-table>
</nz-table>
<div class="hidden">
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedUser.id, updateUser, modalIcon)" (cancel)="onModalCancel(modalIcon)">
<app-update-user #updateUser [user]="selectedUser"></app-update-user>
</app-modal-icon>
</div>

View File

@@ -10,7 +10,6 @@ import {NzDividerComponent} from "ng-zorro-antd/divider";
import {ModalIcon} from "../modal-icon/modal-icon";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {format} from "date-fns";
import {CreateUser} from "../create-user/create-user";
@Component({
selector: 'app-user-table',
@@ -42,7 +41,7 @@ export class UserTable implements OnInit {
this.usersLoading.set(true)
try {
const users = await firstValueFrom(this.usersService.getAllUsersEndpoint())
const users = await firstValueFrom(this.usersService.getAllUserEndpoint())
this.users.set(users);
} catch (e) {
this.notificationService.error(
@@ -69,23 +68,6 @@ export class UserTable implements OnInit {
await this.fetchUsers();
}
selectedUser: GetUserDto;
openEditModal(user: GetUserDto) {
this.selectedUser = user;
this.modal().showModal();
}
async onModalOk(userId: number, updateUserComponent: UpdateUser, modal: ModalIcon) {
await this.edit(userId, updateUserComponent);
updateUserComponent.updateUserForm.reset();
modal.isVisible = false;
await this.fetchUsers();
}
onModalCancel(modal: ModalIcon) {
modal.isVisible = false;
}
async edit(id: number, updateUserComponent: UpdateUser) {
if (updateUserComponent.updateUserForm.invalid) {
this.notificationService.error(
@@ -96,7 +78,7 @@ export class UserTable implements OnInit {
}
try {
const rawDate = updateUserComponent.updateUserForm.get('birthDate')?.value;
const rawDate = updateUserComponent.updateUserForm.get('birthDate').value;
const birthDate = format(rawDate, 'yyyy-MM-dd');
const users = updateUserComponent.updateUserForm.getRawValue();
@@ -115,4 +97,21 @@ export class UserTable implements OnInit {
)
}
}
selectedUser: GetUserDto | null = null;
openEditModal(user: GetUserDto) {
this.selectedUser = { ...user };
this.modal().showModal();
}
async onModalOk(userId: number, updateUserComponent: UpdateUser, modal: ModalIcon) {
await this.edit(userId, updateUserComponent);
updateUserComponent.updateUserForm.reset();
modal.isVisible = false;
await this.fetchUsers();
}
onModalCancel(modal: ModalIcon) {
modal.isVisible = false;
}
}

View File

@@ -1,8 +1,8 @@
<app-modal type="primary" [name]="'Ajouter un auteur'">
<app-create-author></app-create-author>
<app-modal #modal type="primary" [name]="'Ajouter un auteur'" (ok)="onModalOk()" (cancel)="onModalCancel()">>
<app-create-author #createAuthor></app-create-author>
</app-modal>
<section class="mt-5">
<app-author-table></app-author-table>
<app-author-table #authorTable></app-author-table>
</section>

View File

@@ -1,7 +1,10 @@
import {Component} from '@angular/core';
import {Component, inject, viewChild} from '@angular/core';
import {CreateAuthor} from "../../components/create-author/create-author";
import {Modal} from "../../components/modal/modal";
import {AuthorTable} from "../../components/author-table/author-table";
import {AuthorsService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-author',
@@ -14,5 +17,45 @@ import {AuthorTable} from "../../components/author-table/author-table";
styleUrl: './author.css',
})
export class Author{
modal = viewChild.required<Modal>('modal');
createAuthor = viewChild.required<CreateAuthor>('createAuthor');
authorTable = viewChild.required<AuthorTable>('authorTable');
private authorsService = inject(AuthorsService);
private notificationService = inject(NzNotificationService)
async onModalOk() {
await this.addAuthor()
this.createAuthor().createAuthorForm.reset();
this.modal().isVisible = false;
await this.authorTable().fetchAuthors()
}
onModalCancel() {
this.modal().isVisible = false;
}
async addAuthor() {
if (this.createAuthor().createAuthorForm.invalid)
{
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
}
try {
const authors = this.createAuthor().createAuthorForm.getRawValue();
await firstValueFrom(this.authorsService.createAuthorEndpoint(authors))
this.notificationService.success(
'Success',
'Auteur enregistré'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur d\'enregistrement'
)
}
}
}

View File

@@ -1,8 +1,8 @@
<app-modal type="primary" [name]="'Ajouter un livre'">
<app-create-book></app-create-book>
<app-modal #modal type="primary" [name]="'Ajouter un livre'" (ok)="onModalOk()" (cancel)="onModalCancel()">
<app-create-book #createBook></app-create-book>
</app-modal>
<section class="mt-5">
<app-book-table></app-book-table>
<app-book-table #bookTable></app-book-table>
</section>

View File

@@ -1,7 +1,10 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {Component, inject, viewChild} from '@angular/core';
import {BookTable} from "../../components/book-table/book-table";
import {Modal} from "../../components/modal/modal";
import {CreateBook} from "../../components/create-book/create-book";
import {BooksService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-book',
@@ -14,4 +17,45 @@ import {CreateBook} from "../../components/create-book/create-book";
styleUrls: ['./book.css'],
})
export class Book{
modal = viewChild.required<Modal>('modal');
createBook = viewChild.required<CreateBook>('createBook');
booksTable = viewChild.required<BookTable>('bookTable');
private booksService = inject(BooksService);
private notificationService = inject(NzNotificationService)
async onModalOk() {
await this.addBook()
this.createBook().createBookForm.reset();
this.modal().isVisible = false;
await this.booksTable().fetchBooks()
}
onModalCancel() {
this.modal().isVisible = false;
}
async addBook() {
if (this.createBook().createBookForm.invalid)
{
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
}
try {
const books = this.createBook().createBookForm.getRawValue();
await firstValueFrom(this.booksService.createBookEndpoint(books))
this.notificationService.success(
'Success',
'Enregistrement réussi'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur d\'enregistrement'
)
}
}
}

View File

@@ -1,7 +1,7 @@
<app-modal type="primary" [name]="'Ajouter un emprunt'">
<app-create-loan></app-create-loan>
<app-modal #modal type="primary" [name]="'Ajouter un emprunt'" (ok)="onModalOk()" (cancel)="onModalCancel()">
<app-create-loan #createLoan></app-create-loan>
</app-modal>
<div class="mt-5">
<app-loan-table></app-loan-table>
<app-loan-table #loanTable></app-loan-table>
</div>

View File

@@ -1,7 +1,11 @@
import { Component } from '@angular/core';
import {Component, inject, viewChild} from '@angular/core';
import {Modal} from "../../components/modal/modal";
import {CreateLoan} from "../../components/create-loan/create-loan";
import {LoanTable} from "../../components/loan-table/loan-table";
import {LoansService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {format} from "date-fns";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-loan',
@@ -14,5 +18,44 @@ import {LoanTable} from "../../components/loan-table/loan-table";
styleUrl: './loan.css',
})
export class Loan {
modal = viewChild.required<Modal>('modal');
createLoan = viewChild.required<CreateLoan>('createLoan');
loansTable = viewChild.required<LoanTable>('loanTable');
private loansService = inject(LoansService);
private notificationService = inject(NzNotificationService)
async onModalOk() {
await this.addLoan()
this.createLoan().createLoanForm.reset();
this.modal().isVisible = false;
await this.loansTable().fetchLoans()
}
onModalCancel() {
this.modal().isVisible = false;
}
async addLoan() {
if (this.createLoan().createLoanForm.invalid)
{
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
}
try {
const loans = this.createLoan().createLoanForm.getRawValue();
await firstValueFrom(this.loansService.createLoanEndpoint(loans))
this.notificationService.success(
'Success',
'Enregistrement réussi'
)
} catch (e) {
this.notificationService.error(
'Erreur',
'Erreur d\'enregistrement'
)
}
}
}

View File

@@ -1,8 +1,8 @@
import {Component, inject, OnInit, viewChild} from '@angular/core';
import {Component, inject, viewChild} from '@angular/core';
import {Modal} from "../../components/modal/modal";
import {CreateUser} from "../../components/create-user/create-user";
import {UserTable} from "../../components/user-table/user-table";
import {CreateUserDto, UsersService} from "../../services/api";
import {UsersService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
import { format } from 'date-fns';

View File

@@ -8,7 +8,6 @@ api/authors.service.ts
api/books.service.ts
api/loans.service.ts
api/login.service.ts
api/logins.service.ts
api/users.service.ts
configuration.ts
encoder.ts
@@ -23,15 +22,13 @@ model/create-user-dto.ts
model/get-author-dto.ts
model/get-book-dto.ts
model/get-loan-dto.ts
model/get-login-connect-dto.ts
model/get-login-dto.ts
model/get-user-dto.ts
model/models.ts
model/patch-loan-dto.ts
model/update-author-dto.ts
model/update-book-dto.ts
model/update-loan-dto.ts
model/update-login-dto.ts
model/update-loan-effective-return-date-dto.ts
model/update-user-dto.ts
param.ts
provide-api.ts

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -12,7 +12,7 @@ import { CustomHttpParameterCodec } from './encoder';
import { Configuration } from './configuration';
export class BaseService {
protected basePath = 'http://localhost:5228';
protected basePath = 'http://localhost:5156';
public defaultHeaders = new HttpHeaders();
public configuration: Configuration;
public encoder: HttpParameterCodec;

View File

@@ -6,8 +6,6 @@ export * from './loans.service';
import { LoansService } from './loans.service';
export * from './login.service';
import { LoginService } from './login.service';
export * from './logins.service';
import { LoginsService } from './logins.service';
export * from './users.service';
import { UsersService } from './users.service';
export const APIS = [AuthorsService, BooksService, LoansService, LoginService, LoginsService, UsersService];
export const APIS = [AuthorsService, BooksService, LoansService, LoginService, UsersService];

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -222,6 +222,9 @@ export class AuthorsService extends BaseService {
let localVarHeaders = this.defaultHeaders;
// authentication (JWTBearerAuth) required
localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer ');
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -161,10 +161,10 @@ export class BooksService extends BaseService {
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAllBooksEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetBookDto>>;
public getAllBooksEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetBookDto>>>;
public getAllBooksEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetBookDto>>>;
public getAllBooksEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public getAllBookEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetBookDto>>;
public getAllBookEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetBookDto>>>;
public getAllBookEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetBookDto>>>;
public getAllBookEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarHeaders = this.defaultHeaders;

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -21,9 +21,9 @@ import { CreateLoanDto } from '../model/create-loan-dto';
// @ts-ignore
import { GetLoanDto } from '../model/get-loan-dto';
// @ts-ignore
import { PatchLoanDto } from '../model/patch-loan-dto';
// @ts-ignore
import { UpdateLoanDto } from '../model/update-loan-dto';
// @ts-ignore
import { UpdateLoanEffectiveReturnDateDto } from '../model/update-loan-effective-return-date-dto';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -224,6 +224,9 @@ export class LoansService extends BaseService {
let localVarHeaders = this.defaultHeaders;
// authentication (JWTBearerAuth) required
localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer ');
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
@@ -263,21 +266,21 @@ export class LoansService extends BaseService {
}
/**
* @endpoint patch /API/loans/{id}/EffectiveReturningDate
* @endpoint patch /API/loans/{id}/EffectiveReturnDate
* @param id
* @param patchLoanDto
* @param updateLoanEffectiveReturnDateDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public patchLoanEndpoint(id: number, patchLoanDto: PatchLoanDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoanDto>;
public patchLoanEndpoint(id: number, patchLoanDto: PatchLoanDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoanDto>>;
public patchLoanEndpoint(id: number, patchLoanDto: PatchLoanDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoanDto>>;
public patchLoanEndpoint(id: number, patchLoanDto: PatchLoanDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public updateLoanEffectiveReturnDateEndpoint(id: number, updateLoanEffectiveReturnDateDto: UpdateLoanEffectiveReturnDateDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoanDto>;
public updateLoanEffectiveReturnDateEndpoint(id: number, updateLoanEffectiveReturnDateDto: UpdateLoanEffectiveReturnDateDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoanDto>>;
public updateLoanEffectiveReturnDateEndpoint(id: number, updateLoanEffectiveReturnDateDto: UpdateLoanEffectiveReturnDateDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoanDto>>;
public updateLoanEffectiveReturnDateEndpoint(id: number, updateLoanEffectiveReturnDateDto: UpdateLoanEffectiveReturnDateDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling patchLoanEndpoint.');
throw new Error('Required parameter id was null or undefined when calling updateLoanEffectiveReturnDateEndpoint.');
}
if (patchLoanDto === null || patchLoanDto === undefined) {
throw new Error('Required parameter patchLoanDto was null or undefined when calling patchLoanEndpoint.');
if (updateLoanEffectiveReturnDateDto === null || updateLoanEffectiveReturnDateDto === undefined) {
throw new Error('Required parameter updateLoanEffectiveReturnDateDto was null or undefined when calling updateLoanEffectiveReturnDateEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
@@ -314,12 +317,12 @@ export class LoansService extends BaseService {
}
}
let localVarPath = `/API/loans/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/EffectiveReturningDate`;
let localVarPath = `/API/loans/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/EffectiveReturnDate`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoanDto>('patch', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: patchLoanDto,
body: updateLoanEffectiveReturnDateDto,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -19,7 +19,9 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { ConnectLoginDto } from '../model/connect-login-dto';
// @ts-ignore
import { GetLoginConnectDto } from '../model/get-login-connect-dto';
import { CreateLoginDto } from '../model/create-login-dto';
// @ts-ignore
import { GetLoginDto } from '../model/get-login-dto';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -38,21 +40,24 @@ export class LoginService extends BaseService {
}
/**
* @endpoint post /API/login
* @param connectLoginDto
* @endpoint post /API/login/create
* @param createLoginDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoginConnectDto>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoginConnectDto>>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoginConnectDto>>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (connectLoginDto === null || connectLoginDto === undefined) {
throw new Error('Required parameter connectLoginDto was null or undefined when calling userLoginEndpoint.');
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoginDto>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoginDto>>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoginDto>>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (createLoginDto === null || createLoginDto === undefined) {
throw new Error('Required parameter createLoginDto was null or undefined when calling createLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
// authentication (JWTBearerAuth) required
localVarHeaders = this.configuration.addCredentialToHeaders('JWTBearerAuth', 'Authorization', localVarHeaders, 'Bearer ');
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
@@ -65,6 +70,69 @@ export class LoginService extends BaseService {
const localVarTransferCache: boolean = options?.transferCache ?? true;
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/login/create`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoginDto>('post', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: createLoginDto,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* @endpoint post /API/login
* @param connectLoginDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
public userLoginEndpoint(connectLoginDto: ConnectLoginDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (connectLoginDto === null || connectLoginDto === undefined) {
throw new Error('Required parameter connectLoginDto was null or undefined when calling userLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
@@ -87,7 +155,7 @@ export class LoginService extends BaseService {
let localVarPath = `/API/login`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoginConnectDto>('post', `${basePath}${localVarPath}`,
return this.httpClient.request<any>('post', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: connectLoginDto,

View File

@@ -1,331 +0,0 @@
/**
* ApiEfCoreLibrary
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { CreateLoginDto } from '../model/create-login-dto';
// @ts-ignore
import { GetLoginDto } from '../model/get-login-dto';
// @ts-ignore
import { UpdateLoginDto } from '../model/update-login-dto';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root'
})
export class LoginsService extends BaseService {
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
super(basePath, configuration);
}
/**
* @endpoint post /API/logins
* @param createLoginDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoginDto>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoginDto>>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoginDto>>;
public createLoginEndpoint(createLoginDto: CreateLoginDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (createLoginDto === null || createLoginDto === undefined) {
throw new Error('Required parameter createLoginDto was null or undefined when calling createLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/logins`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoginDto>('post', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: createLoginDto,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* @endpoint delete /API/logins/{id}
* @param id
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deleteLoginEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>;
public deleteLoginEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>;
public deleteLoginEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>;
public deleteLoginEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling deleteLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/logins/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('delete', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* @endpoint get /API/logins
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAllLoginEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetLoginDto>>;
public getAllLoginEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetLoginDto>>>;
public getAllLoginEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetLoginDto>>>;
public getAllLoginEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/logins`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<GetLoginDto>>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* @endpoint get /API/logins/{id}
* @param id
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getLoginEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoginDto>;
public getLoginEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoginDto>>;
public getLoginEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoginDto>>;
public getLoginEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/logins/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoginDto>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
/**
* @endpoint put /API/logins/{id}
* @param id
* @param updateLoginDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public updateLoginEndpoint(id: number, updateLoginDto: UpdateLoginDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetLoginDto>;
public updateLoginEndpoint(id: number, updateLoginDto: UpdateLoginDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetLoginDto>>;
public updateLoginEndpoint(id: number, updateLoginDto: UpdateLoginDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetLoginDto>>;
public updateLoginEndpoint(id: number, updateLoginDto: UpdateLoginDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling updateLoginEndpoint.');
}
if (updateLoginDto === null || updateLoginDto === undefined) {
throw new Error('Required parameter updateLoginDto was null or undefined when calling updateLoginEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/logins/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetLoginDto>('put', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: updateLoginDto,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -161,10 +161,10 @@ export class UsersService extends BaseService {
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getAllUsersEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetUserDto>>;
public getAllUsersEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetUserDto>>>;
public getAllUsersEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetUserDto>>>;
public getAllUsersEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public getAllUserEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetUserDto>>;
public getAllUserEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetUserDto>>>;
public getAllUserEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetUserDto>>>;
public getAllUserEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
let localVarHeaders = this.defaultHeaders;

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -10,7 +10,7 @@
export interface CreateAuthorDto {
name?: string | null;
firstName?: string | null;
name?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -11,8 +11,8 @@
export interface CreateBookDto {
title?: string | null;
authorId?: number;
releaseYear?: number | null;
isbn?: string | null;
authorId?: number;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -10,8 +10,8 @@
export interface CreateLoanDto {
bookId?: number;
userId?: number;
bookId?: number;
date?: string;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -10,8 +10,9 @@
export interface CreateLoginDto {
username?: string | null;
fullName?: string | null;
password?: string | null;
username?: string;
password?: string;
fullName?: string;
role?: string;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -12,8 +12,8 @@ import { GetBookDto } from './get-book-dto';
export interface GetAuthorDto {
id?: number;
name?: string | null;
firstName?: string | null;
name?: string | null;
books?: Array<GetBookDto> | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -12,11 +12,10 @@
export interface GetBookDto {
id?: number;
title?: string | null;
authorId?: number;
bookAuthorId?: number;
bookAuthorName?: string | null;
bookAuthorFirstName?: string | null;
releaseYear?: number | null;
isbn?: string | null;
authorId?: number;
authorFirstName?: string | null;
authorName?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -11,20 +11,19 @@
export interface GetLoanDto {
id?: number;
bookId?: number;
bookTitle?: string | null;
bookAuthorId?: number;
bookAuthorName?: string | null;
bookAuthorFirstName?: string | null;
bookReleaseYear?: number | null;
bookIsbn?: string | null;
date?: string;
plannedReturningDate?: string;
effectiveReturningDate?: string | null;
userId?: number;
userName?: string | null;
userFirstName?: string | null;
userEmail?: string | null;
userBirthDate?: string | null;
date?: string;
plannedReturningDate?: string;
effectiveReturningDate?: string | null;
bookId?: number;
bookTitle?: string | null;
bookReleaseYear?: number | null;
bookISBN?: string | null;
bookAuthorName?: string | null;
bookAuthorFirstName?: string | null;
}

View File

@@ -1,15 +0,0 @@
/**
* ApiEfCoreLibrary
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface GetLoginConnectDto {
token?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -12,8 +12,9 @@
export interface GetLoginDto {
id?: number;
username?: string | null;
fullName?: string | null;
password?: string | null;
fullName?: string | null;
salt?: string | null;
role?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -16,6 +16,6 @@ export interface GetUserDto {
firstName?: string | null;
email?: string | null;
birthDate?: string | null;
loans?: Array<GetLoanDto> | null;
loans?: Array<GetLoanDto>;
}

View File

@@ -7,12 +7,10 @@ export * from './create-user-dto';
export * from './get-author-dto';
export * from './get-book-dto';
export * from './get-loan-dto';
export * from './get-login-connect-dto';
export * from './get-login-dto';
export * from './get-user-dto';
export * from './patch-loan-dto';
export * from './update-author-dto';
export * from './update-book-dto';
export * from './update-loan-dto';
export * from './update-login-dto';
export * from './update-loan-effective-return-date-dto';
export * from './update-user-dto';

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -10,7 +10,7 @@
export interface UpdateAuthorDto {
name?: string | null;
firstName?: string | null;
name?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -11,8 +11,8 @@
export interface UpdateBookDto {
title?: string | null;
releaseYear?: number | null;
isbn?: string | null;
authorId?: number;
releaseYear?: number;
isbn?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -10,8 +10,8 @@
export interface UpdateLoanDto {
bookId?: number;
userId?: number;
bookId?: number;
date?: string;
plannedReturningDate?: string;
effectiveReturningDate?: string | null;

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*
@@ -9,7 +9,7 @@
*/
export interface PatchLoanDto {
export interface UpdateLoanEffectiveReturnDateDto {
effectiveReturningDate?: string;
}

View File

@@ -1,17 +0,0 @@
/**
* ApiEfCoreLibrary
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface UpdateLoginDto {
username?: string | null;
fullName?: string | null;
password?: string | null;
}

View File

@@ -1,5 +1,5 @@
/**
* ApiEfCoreLibrary
* ApiLibrary
*
*
*