+9
-3
@@ -23,6 +23,7 @@
|
||||
<p-select
|
||||
[options]="fileTypeOptions"
|
||||
[(ngModel)]="fileType"
|
||||
(ngModelChange)="onFileTypeChange()"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[placeholder]="t('selectFileType')"
|
||||
@@ -34,7 +35,7 @@
|
||||
<p-fileupload class="file-upload" name="file"
|
||||
[customUpload]="true"
|
||||
[multiple]="false"
|
||||
accept=".pdf,.epub,.cbz,.cbr,.cb7,.fb2,.mobi,.azw,.azw3,.m4b,.m4a,.mp3"
|
||||
[accept]="acceptedFormats"
|
||||
(onSelect)="onFilesSelect($event)"
|
||||
(uploadHandler)="uploadFiles($event)"
|
||||
[disabled]="isUploading">
|
||||
@@ -123,8 +124,13 @@
|
||||
<i class="pi pi-cloud-upload empty-icon"></i>
|
||||
<p class="empty-text">{{ t('dragDropText') }}</p>
|
||||
<p class="empty-subtext">
|
||||
<span [innerHTML]="t('supportedFormats')"></span>
|
||||
<br/>
|
||||
@if (fileType === AdditionalFileType.ALTERNATIVE_FORMAT) {
|
||||
<span [innerHTML]="t('supportedFormats')"></span>
|
||||
<br/>
|
||||
} @else {
|
||||
<span>{{ t('supplementaryAllFormats') }}</span>
|
||||
<br/>
|
||||
}
|
||||
{{ t('maxFileSize', { size: maxFileSizeDisplay }) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+17
-1
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectorRef, Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ChangeDetectorRef, Component, inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
@@ -48,11 +48,14 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
files: UploadingFile[] = [];
|
||||
fileType: AdditionalFileType = AdditionalFileType.ALTERNATIVE_FORMAT;
|
||||
isUploading = false;
|
||||
readonly AdditionalFileType = AdditionalFileType;
|
||||
private static readonly BOOK_FORMAT_ACCEPT = '.pdf,.epub,.cbz,.cbr,.cb7,.fb2,.mobi,.azw,.azw3,.m4b,.m4a,.mp3';
|
||||
maxFileSizeBytes?: number;
|
||||
maxFileSizeDisplay: string = '100 MB';
|
||||
|
||||
fileTypeOptions: FileTypeOption[] = [];
|
||||
|
||||
@ViewChild(FileUpload) private fileUpload!: FileUpload;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
@@ -89,6 +92,19 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
onFileTypeChange(): void {
|
||||
this.files = [];
|
||||
if (this.fileUpload) {
|
||||
this.fileUpload.clear();
|
||||
}
|
||||
}
|
||||
|
||||
get acceptedFormats(): string {
|
||||
return this.fileType === AdditionalFileType.ALTERNATIVE_FORMAT
|
||||
? AdditionalFileUploaderComponent.BOOK_FORMAT_ACCEPT
|
||||
: '';
|
||||
}
|
||||
|
||||
hasPendingFiles(): boolean {
|
||||
return this.files.some(f => f.status === 'Pending');
|
||||
}
|
||||
|
||||
@@ -445,6 +445,7 @@
|
||||
"statusFailed": "Failed",
|
||||
"dragDropText": "Drag and drop a file here to upload.",
|
||||
"supportedFormats": "Supported formats: <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, <strong>.cb7</strong>, <strong>.fb2</strong>, <strong>.mobi</strong>, <strong>.azw3</strong>, <strong>.m4b</strong>, <strong>.mp3</strong>",
|
||||
"supplementaryAllFormats": "All file formats are supported for supplementary files.",
|
||||
"maxFileSize": "Maximum file size: {{ size }} per file",
|
||||
"uploadForBook": "Upload an additional file for <strong>{{ title }}</strong>.",
|
||||
"thisBook": "this book",
|
||||
|
||||
@@ -445,6 +445,7 @@
|
||||
"statusFailed": "Fallido",
|
||||
"dragDropText": "Arrastre y suelte un archivo aquí para subir.",
|
||||
"supportedFormats": "Formatos compatibles: <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, <strong>.cb7</strong>, <strong>.fb2</strong>, <strong>.mobi</strong>, <strong>.azw3</strong>, <strong>.m4b</strong>, <strong>.mp3</strong>",
|
||||
"supplementaryAllFormats": "Todos los formatos de archivo son compatibles con archivos complementarios.",
|
||||
"maxFileSize": "Tamaño máximo de archivo: {{ size }} por archivo",
|
||||
"uploadForBook": "Subir un archivo adicional para <strong>{{ title }}</strong>.",
|
||||
"thisBook": "este libro",
|
||||
|
||||
Reference in New Issue
Block a user