Added download option to cards
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fd8b7e56da
commit
1ca5d3ea07
@ -37,7 +37,7 @@ export class PdfController {
|
|||||||
|
|
||||||
@Post('/cards')
|
@Post('/cards')
|
||||||
@OpenAPI({ description: "Generate runner card pdfs from runner card objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
|
@OpenAPI({ description: "Generate runner card pdfs from runner card objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
|
||||||
async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string) {
|
async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("download") download: boolean) {
|
||||||
if (!this.initialized) {
|
if (!this.initialized) {
|
||||||
await this.pdf.init();
|
await this.pdf.init();
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
@ -48,6 +48,9 @@ export class PdfController {
|
|||||||
cards = this.mapCardGroupNames(cards);
|
cards = this.mapCardGroupNames(cards);
|
||||||
const contracts = await this.pdf.generateRunnerCards(cards, locale);
|
const contracts = await this.pdf.generateRunnerCards(cards, locale);
|
||||||
res.setHeader('content-type', 'application/pdf');
|
res.setHeader('content-type', 'application/pdf');
|
||||||
|
if (download) {
|
||||||
|
res.setHeader('Content-Disposition', 'attachment; filename="cards.pdf"')
|
||||||
|
}
|
||||||
return contracts;
|
return contracts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user