set the correct file name when triggering a download (#1513)
This commit is contained in:
+6
-6
@@ -213,7 +213,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: 'Download',
|
label: 'Download',
|
||||||
icon: 'pi pi-download',
|
icon: 'pi pi-download',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.downloadFile(this.book.id);
|
this.bookService.downloadFile(this.book);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -512,7 +512,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: `${this.book.fileName || 'Book File'}`,
|
label: `${this.book.fileName || 'Book File'}`,
|
||||||
icon: 'pi pi-file',
|
icon: 'pi pi-file',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.bookService.downloadFile(this.book.id);
|
this.bookService.downloadFile(this.book);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -528,7 +528,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
items.push({
|
items.push({
|
||||||
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(this.book.id, format.id)
|
command: () => this.downloadAdditionalFile(this.book, format.id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -546,7 +546,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
items.push({
|
items.push({
|
||||||
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(this.book.id, file.id)
|
command: () => this.downloadAdditionalFile(this.book, file.id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -619,8 +619,8 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
!!(this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0);
|
!!(this.book.supplementaryFiles && this.book.supplementaryFiles.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private downloadAdditionalFile(bookId: number, fileId: number): void {
|
private downloadAdditionalFile(book: Book, fileId: number): void {
|
||||||
this.bookService.downloadAdditionalFile(bookId, fileId);
|
this.bookService.downloadAdditionalFile(book, fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private deleteAdditionalFile(bookId: number, fileId: number, fileName: string): void {
|
private deleteAdditionalFile(bookId: number, fileId: number, fileName: string): void {
|
||||||
|
|||||||
@@ -355,14 +355,15 @@ export class BookService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadFile(bookId: number): void {
|
downloadFile(book: Book): void {
|
||||||
const downloadUrl = `${this.url}/${bookId}/download`;
|
const downloadUrl = `${this.url}/${book.id}/download`;
|
||||||
this.fileDownloadService.downloadFile(downloadUrl, `book_${bookId}`);
|
this.fileDownloadService.downloadFile(downloadUrl, book.fileName!);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadAdditionalFile(bookId: number, fileId: number): void {
|
downloadAdditionalFile(book: Book, fileId: number): void {
|
||||||
const downloadUrl = `${this.url}/${bookId}/files/${fileId}/download`;
|
const additionalFile = book.alternativeFormats!.find((f: AdditionalFile) => f.id === fileId);
|
||||||
this.fileDownloadService.downloadFile(downloadUrl, `additional_file_${fileId}`);
|
const downloadUrl = `${this.url}/${additionalFile!.id}/files/${fileId}/download`;
|
||||||
|
this.fileDownloadService.downloadFile(downloadUrl, additionalFile!.fileName!);
|
||||||
}
|
}
|
||||||
|
|
||||||
savePdfProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
savePdfProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||||
|
|||||||
+2
-2
@@ -462,7 +462,7 @@
|
|||||||
label="Download"
|
label="Download"
|
||||||
icon="pi pi-download"
|
icon="pi pi-download"
|
||||||
[model]="downloadItems"
|
[model]="downloadItems"
|
||||||
(onClick)="download(book!.id)"
|
(onClick)="download(book)"
|
||||||
severity="success"
|
severity="success"
|
||||||
outlined/>
|
outlined/>
|
||||||
}
|
}
|
||||||
@@ -472,7 +472,7 @@
|
|||||||
icon="pi pi-download"
|
icon="pi pi-download"
|
||||||
severity="success"
|
severity="success"
|
||||||
outlined
|
outlined
|
||||||
(onClick)="download(book!.id)">
|
(onClick)="download(book)">
|
||||||
</p-button>
|
</p-button>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -157,7 +157,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
items.push({
|
items.push({
|
||||||
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
label: `${format.fileName} (${this.getFileSizeInMB(format)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(book.id, format.id)
|
command: () => this.downloadAdditionalFile(book, format.id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
items.push({
|
items.push({
|
||||||
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
label: `${file.fileName} (${this.getFileSizeInMB(file)})`,
|
||||||
icon: this.getFileIcon(extension),
|
icon: this.getFileIcon(extension),
|
||||||
command: () => this.downloadAdditionalFile(book.id, file.id)
|
command: () => this.downloadAdditionalFile(book, file.id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -354,12 +354,12 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
|||||||
if (bookId) this.bookService.readBook(bookId, reader);
|
if (bookId) this.bookService.readBook(bookId, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
download(bookId: number) {
|
download(book: Book) {
|
||||||
this.bookService.downloadFile(bookId);
|
this.bookService.downloadFile(book);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadAdditionalFile(bookId: number, fileId: number) {
|
downloadAdditionalFile(book: Book, fileId: number) {
|
||||||
this.bookService.downloadAdditionalFile(bookId, fileId);
|
this.bookService.downloadAdditionalFile(book, fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAdditionalFile(bookId: number, fileId: number, fileName: string) {
|
deleteAdditionalFile(bookId: number, fileId: number, fileName: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user