Add reservation code download feature
Introduces a download button in the reservation success component to allow users to download their reservation code as a text file. Adds utility methods in PdfService for downloading text and JSON files, and integrates the new download functionality into the component.
This commit is contained in:
@@ -7,7 +7,6 @@ import { Eintrittskarte } from '@infinimotion/model-frontend';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PdfService {
|
||||
|
||||
private ticketsGreatedSignal = signal(0);
|
||||
private totalTicketsSignal = signal(0);
|
||||
|
||||
@@ -108,4 +107,35 @@ export class PdfService {
|
||||
|
||||
return `Ticket_${orderCode}_${timestamp}.pdf`;
|
||||
}
|
||||
|
||||
downloadTextFile(content: string, filename: string = 'textdatei.txt'): void {
|
||||
|
||||
const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
downloadJsonFile(data: any, filename: string = 'data.json'): void {
|
||||
const content = JSON.stringify(data, null, 2);
|
||||
const blob = new Blob([content], { type: 'application/json' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user