Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/app/services/api/api/deliverynotes.service.ts
#	src/app/services/api/api/purchaseorders.service.ts
#	src/app/services/api/api/quotations.service.ts
This commit is contained in:
Enzo
2025-12-11 17:17:27 +01:00
11 changed files with 129 additions and 80 deletions

View File

@@ -1,11 +1,11 @@
import {Component, inject, signal} from '@angular/core'; import {Component, effect, inject, input, OnInit, signal} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzColDirective} from "ng-zorro-antd/grid"; import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {DeliverersService, GetDelivererDto} from "../../services/api"; import {DeliverersService, GetDelivererDto, 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";
@@ -21,13 +21,14 @@ import {firstValueFrom} from "rxjs";
ReactiveFormsModule, ReactiveFormsModule,
NzDatePickerComponent, NzDatePickerComponent,
NzSelectComponent, NzSelectComponent,
NzOptionComponent NzOptionComponent,
], ],
templateUrl: './deliverery-note-form.html', templateUrl: './deliverery-note-form.html',
styleUrl: './deliverery-note-form.css', styleUrl: './deliverery-note-form.css',
}) })
export class DelivereryNoteForm { export class DelivereryNoteForm implements OnInit {
deliveryNoteForm: FormGroup = new FormGroup({ deliveryNoteForm: FormGroup = new FormGroup({
trackingNumber: new FormControl<string>("TRK-" + Date.now),
deliverer: new FormControl<string>(null,[Validators.required]), deliverer: new FormControl<string>(null,[Validators.required]),
expeditionDate: new FormControl(null,[Validators.required]), expeditionDate: new FormControl(null,[Validators.required]),
estimatedDate: new FormControl(null), estimatedDate: new FormControl(null),

View File

@@ -48,24 +48,15 @@
</td> </td>
<td> <td>
<div style="justify-content: center; display: flex"> <div style="justify-content: center; display: flex">
<div>
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/> <nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
</div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<app-modal-nav nameIcon="edit" name="Modification du bon de livraison" class="cursor-pointer">
<app-deliverery-note-form></app-deliverery-note-form>
</app-modal-nav>
<nz-divider nzType="vertical"></nz-divider>
<div>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/> <nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
</div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div>
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/> <nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
</div> </div>
</div>
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</nz-table> </nz-table>

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 {DatePipe} from "@angular/common";
import {ModalButton} from "../modal-button/modal-button"; import {ModalButton} from "../modal-button/modal-button";
import {ModalNav} from "../modal-nav/modal-nav"; import {ModalNav} from "../modal-nav/modal-nav";
@@ -10,6 +10,7 @@ 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 {FileService} from "../../services/file.service";
@Component({ @Component({
selector: 'app-deliverery-note-table', selector: 'app-deliverery-note-table',
@@ -27,9 +28,11 @@ import {format} from "date-fns";
}) })
export class DelivereryNoteTable implements OnInit { export class DelivereryNoteTable implements OnInit {
private deliveryNotesService = inject(DeliverynotesService); private deliveryNotesService = inject(DeliverynotesService);
private notificationService = inject(NzNotificationService) private notificationService = inject(NzNotificationService);
private fileService = inject(FileService);
deliveryNotes = signal<GetDeliveryNoteDto[]>([]); deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
deliveryNotesLoading = signal<boolean>(false); deliveryNotesLoading = signal<boolean>(false);
modal = viewChild.required<ModalNav>('modalNav');
async ngOnInit() { async ngOnInit() {
await this.fetchDeliveryNotes(); await this.fetchDeliveryNotes();
@@ -37,7 +40,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);
@@ -51,6 +53,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(
@@ -63,10 +66,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')
@@ -91,11 +96,24 @@ 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()
} }
export(deliveryNote: number) { async export(deliveryNoteId: number) {
return this.deliveryNotesLoading.set(true)
try {
const pdf = await firstValueFrom(
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response")
);
this.fileService.downloadBlob(pdf)
} catch (e) {
console.error(e);
this.notificationService.error(
'Erreur',
'Impossible de générer un PDF'
);
}
this.deliveryNotesLoading.set(false)
} }
} }

View File

@@ -67,7 +67,7 @@
</div> </div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div> <div>
<nz-icon nzType="export" nzTheme="outline" (click)="export()" class="cursor-pointer text-green-700"/> <nz-icon nzType="export" nzTheme="outline" (click)="export(purchaseOrder.id)" class="cursor-pointer text-green-700"/>
</div> </div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div> <div>

View File

@@ -8,6 +8,7 @@ import {ModalButton} from "../modal-button/modal-button";
import {GetPurchaseOrderDto, PurchaseordersService} from "../../services/api"; import {GetPurchaseOrderDto, PurchaseordersService} 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 {FileService} from "../../services/file.service";
@Component({ @Component({
selector: 'app-purchase-order-table', selector: 'app-purchase-order-table',
@@ -24,7 +25,8 @@ import {firstValueFrom} from "rxjs";
}) })
export class PurchaseOrderTable implements OnInit { export class PurchaseOrderTable implements OnInit {
private purchaseOrdersService = inject(PurchaseordersService); private purchaseOrdersService = inject(PurchaseordersService);
private notificationService = inject(NzNotificationService) private notificationService = inject(NzNotificationService);
private fileService = inject(FileService);
purchaseOrders = signal<GetPurchaseOrderDto[]>([]); purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
purchaseOrdersLoading = signal<boolean>(false); purchaseOrdersLoading = signal<boolean>(false);
@@ -48,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(
@@ -60,11 +63,25 @@ 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();
} }
export(){ async export(purchaseOrderId: number){
return this.purchaseOrdersLoading.set(true)
try {
const pdf = await firstValueFrom(
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
);
this.fileService.downloadBlob(pdf)
} catch (e) {
console.error(e);
this.notificationService.error(
'Erreur',
'Impossible de générer un PDF'
);
}
this.purchaseOrdersLoading.set(false)
} }
transfer() { transfer() {

View File

@@ -65,7 +65,7 @@
</div> </div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div> <div>
<nz-icon nzType="export" nzTheme="outline" class="cursor-pointer text-green-700"/> <nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
</div> </div>
</div> </div>
</td> </td>

View File

@@ -8,6 +8,7 @@ import {QuotationForm} from "../quotation-form/quotation-form";
import {GetQuotationDto, QuotationsService} from "../../services/api"; import {GetQuotationDto, QuotationsService} 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 {FileService} from "../../services/file.service";
@Component({ @Component({
selector: 'app-quotation-table', selector: 'app-quotation-table',
@@ -25,7 +26,8 @@ import {firstValueFrom} from "rxjs";
export class QuotationTable implements OnInit { export class QuotationTable implements OnInit {
private quotationsService = inject(QuotationsService); private quotationsService = inject(QuotationsService);
private notificationService = inject(NzNotificationService) private notificationService = inject(NzNotificationService);
private fileService = inject(FileService);
quotations = signal<GetQuotationDto[]>([]); quotations = signal<GetQuotationDto[]>([]);
quotationsLoading = signal<boolean>(false); quotationsLoading = signal<boolean>(false);
@@ -49,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(
@@ -61,7 +64,25 @@ 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){
this.quotationsLoading.set(true)
try {
const pdf = await firstValueFrom(
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
);
this.fileService.downloadBlob(pdf)
} catch (e) {
console.error(e);
this.notificationService.error(
'Erreur',
'Impossible de générer un PDF'
);
}
this.quotationsLoading.set(false)
}
} }

View File

@@ -266,10 +266,10 @@ export class DeliverynotesService 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 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. * @param reportProgress flag to report request and response progress.
*/ */
public getDeliveryNotePdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>; public getDeliveryNotePdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<Blob>;
public getDeliveryNotePdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>; public getDeliveryNotePdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Blob>>;
public getDeliveryNotePdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>; public getDeliveryNotePdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Blob>>;
public getDeliveryNotePdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> { public getDeliveryNotePdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) { if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getDeliveryNotePdfEndpoint.'); throw new Error('Required parameter id was null or undefined when calling getDeliveryNotePdfEndpoint.');
} }
@@ -277,6 +277,7 @@ export class DeliverynotesService extends BaseService {
let localVarHeaders = this.defaultHeaders; let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/pdf'
]); ]);
if (localVarHttpHeaderAcceptSelected !== undefined) { if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
@@ -287,23 +288,12 @@ export class DeliverynotesService extends BaseService {
const localVarTransferCache: boolean = options?.transferCache ?? true; 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/deliveryNotes/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`; let localVarPath = `/API/deliveryNotes/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`;
const { basePath, withCredentials } = this.configuration; const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('get', `${basePath}${localVarPath}`, return this.httpClient.request('get', `${basePath}${localVarPath}`,
{ {
context: localVarHttpContext, context: localVarHttpContext,
responseType: <any>responseType_, responseType: "blob",
...(withCredentials ? { withCredentials } : {}), ...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders, headers: localVarHeaders,
observe: observe, observe: observe,

View File

@@ -200,10 +200,10 @@ export class PurchaseordersService 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 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. * @param reportProgress flag to report request and response progress.
*/ */
public getPurchaseOrderPdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>; public getPurchaseOrderPdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<Blob>;
public getPurchaseOrderPdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>; public getPurchaseOrderPdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Blob>>;
public getPurchaseOrderPdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>; public getPurchaseOrderPdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Blob>>;
public getPurchaseOrderPdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> { public getPurchaseOrderPdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) { if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getPurchaseOrderPdfEndpoint.'); throw new Error('Required parameter id was null or undefined when calling getPurchaseOrderPdfEndpoint.');
} }
@@ -211,6 +211,7 @@ export class PurchaseordersService extends BaseService {
let localVarHeaders = this.defaultHeaders; let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/pdf'
]); ]);
if (localVarHttpHeaderAcceptSelected !== undefined) { if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
@@ -221,23 +222,12 @@ export class PurchaseordersService extends BaseService {
const localVarTransferCache: boolean = options?.transferCache ?? true; 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/purchaseOrders/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`; let localVarPath = `/API/purchaseOrders/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`;
const { basePath, withCredentials } = this.configuration; const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('get', `${basePath}${localVarPath}`, return this.httpClient.request('get', `${basePath}${localVarPath}`,
{ {
context: localVarHttpContext, context: localVarHttpContext,
responseType: <any>responseType_, responseType: "blob",
...(withCredentials ? { withCredentials } : {}), ...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders, headers: localVarHeaders,
observe: observe, observe: observe,

View File

@@ -200,10 +200,10 @@ export class QuotationsService 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 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. * @param reportProgress flag to report request and response progress.
*/ */
public getQuotationPdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>; public getQuotationPdfEndpoint(id: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<Blob>;
public getQuotationPdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>; public getQuotationPdfEndpoint(id: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Blob>>;
public getQuotationPdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>; public getQuotationPdfEndpoint(id: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Blob>>;
public getQuotationPdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> { public getQuotationPdfEndpoint(id: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/pdf', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) { if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getQuotationPdfEndpoint.'); throw new Error('Required parameter id was null or undefined when calling getQuotationPdfEndpoint.');
} }
@@ -211,6 +211,7 @@ export class QuotationsService extends BaseService {
let localVarHeaders = this.defaultHeaders; let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/pdf'
]); ]);
if (localVarHttpHeaderAcceptSelected !== undefined) { if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
@@ -221,23 +222,12 @@ export class QuotationsService extends BaseService {
const localVarTransferCache: boolean = options?.transferCache ?? true; 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/quotations/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`; let localVarPath = `/API/quotations/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}/pdf`;
const { basePath, withCredentials } = this.configuration; const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('get', `${basePath}${localVarPath}`, return this.httpClient.request('get', `${basePath}${localVarPath}`,
{ {
context: localVarHttpContext, context: localVarHttpContext,
responseType: <any>responseType_, responseType: "blob",
...(withCredentials ? { withCredentials } : {}), ...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders, headers: localVarHeaders,
observe: observe, observe: observe,

View File

@@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import {HttpResponse} from "@angular/common/http";
@Injectable({
providedIn: 'root',
})
export class FileService {
getFilenameFromHttpResponse(httpResponse: HttpResponse<Blob>) {
const contentDispositionHeader = httpResponse.headers.get('Content-Disposition');
// console.log(contentDispositionHeader);
let result = contentDispositionHeader.split(';')[1].trim().split('=')[1];
// Removing the " from the after trim operation
result = result.replace(/"/g, '');
// Removing . from filename
// return result.replace(/./g, '_');
return result;
}
downloadBlob(data: HttpResponse<Blob>) {
const url = window.URL.createObjectURL(data.body);
const anchor = document.createElement('a');
anchor.download = this.getFilenameFromHttpResponse(data);
anchor.href = url;
anchor.click();
anchor.remove();
window.URL.revokeObjectURL(url);
}
}