added loading function

This commit is contained in:
2025-12-04 17:45:20 +01:00
parent 41bfc9b8ae
commit f812ce856c
3 changed files with 14 additions and 4 deletions

View File

@@ -10,7 +10,6 @@ import {DeliverynotesService, GetDeliveryNoteDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification"; import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs"; import {firstValueFrom} from "rxjs";
import {format} from "date-fns"; import {format} from "date-fns";
import {HttpResponse} from "@angular/common/http";
import {FileService} from "../../services/file.service"; import {FileService} from "../../services/file.service";
@Component({ @Component({
@@ -40,7 +39,6 @@ export class DelivereryNoteTable implements OnInit {
async fetchDeliveryNotes() { async fetchDeliveryNotes() {
this.deliveryNotesLoading.set(true) this.deliveryNotesLoading.set(true)
try { try {
const deliveryNotes = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNoteEndpoint()) const deliveryNotes = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNoteEndpoint())
this.deliveryNotes.set(deliveryNotes); this.deliveryNotes.set(deliveryNotes);
@@ -54,6 +52,7 @@ export class DelivereryNoteTable implements OnInit {
} }
async delete(deliveryNote:number) { async delete(deliveryNote:number) {
this.deliveryNotesLoading.set(true)
try { try {
await firstValueFrom(this.deliveryNotesService.deleteDeliveryNoteEndpoint(deliveryNote)); await firstValueFrom(this.deliveryNotesService.deleteDeliveryNoteEndpoint(deliveryNote));
this.notificationService.success( this.notificationService.success(
@@ -66,10 +65,12 @@ export class DelivereryNoteTable implements OnInit {
'Impossible de supprimer la ligne' 'Impossible de supprimer la ligne'
) )
} }
this.deliveryNotesLoading.set(false)
await this.fetchDeliveryNotes(); await this.fetchDeliveryNotes();
} }
async validate(deliveryNote:number) { async validate(deliveryNote:number) {
this.deliveryNotesLoading.set(true)
try { try {
const PatchRealDate = { const PatchRealDate = {
realDeliveryDate: format(new Date(), 'yyyy-MM-dd') realDeliveryDate: format(new Date(), 'yyyy-MM-dd')
@@ -94,11 +95,12 @@ export class DelivereryNoteTable implements OnInit {
'Erreur d\'actualisation de la date' 'Erreur d\'actualisation de la date'
) )
} }
this.deliveryNotesLoading.set(false)
await this.fetchDeliveryNotes() await this.fetchDeliveryNotes()
} }
async export(deliveryNoteId: number) { async export(deliveryNoteId: number) {
this.deliveryNotesLoading.set(true)
try { try {
const pdf = await firstValueFrom( const pdf = await firstValueFrom(
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response") this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response")
@@ -111,6 +113,6 @@ export class DelivereryNoteTable implements OnInit {
'Impossible de générer un PDF' 'Impossible de générer un PDF'
); );
} }
this.deliveryNotesLoading.set(false)
} }
} }

View File

@@ -50,6 +50,7 @@ export class PurchaseOrderTable implements OnInit {
} }
async delete(purchaseOrderId:number) { async delete(purchaseOrderId:number) {
this.purchaseOrdersLoading.set(true)
try { try {
await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId)) await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
this.notificationService.success( this.notificationService.success(
@@ -62,10 +63,12 @@ export class PurchaseOrderTable implements OnInit {
'Impossible de supprimer la ligne' 'Impossible de supprimer la ligne'
) )
} }
this.purchaseOrdersLoading.set(false)
await this.fetchPurchaseOrder(); await this.fetchPurchaseOrder();
} }
async export(purchaseOrderId: number){ async export(purchaseOrderId: number){
this.purchaseOrdersLoading.set(true)
try { try {
const pdf = await firstValueFrom( const pdf = await firstValueFrom(
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response") this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
@@ -78,6 +81,7 @@ export class PurchaseOrderTable implements OnInit {
'Impossible de générer un PDF' 'Impossible de générer un PDF'
); );
} }
this.purchaseOrdersLoading.set(false)
} }
transfer() { transfer() {

View File

@@ -51,6 +51,7 @@ export class QuotationTable implements OnInit {
} }
async delete(quotation:number) { async delete(quotation:number) {
this.quotationsLoading.set(true)
try { try {
await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation)) await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation))
this.notificationService.success( this.notificationService.success(
@@ -63,10 +64,12 @@ export class QuotationTable implements OnInit {
'Impossible de supprimer la ligne' 'Impossible de supprimer la ligne'
) )
} }
this.quotationsLoading.set(false)
await this.fetchQuotations(); await this.fetchQuotations();
} }
async export(quotationId: number){ async export(quotationId: number){
this.quotationsLoading.set(true)
try { try {
const pdf = await firstValueFrom( const pdf = await firstValueFrom(
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response") this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
@@ -79,6 +82,7 @@ export class QuotationTable implements OnInit {
'Impossible de générer un PDF' 'Impossible de générer un PDF'
); );
} }
this.quotationsLoading.set(false)
} }
} }