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