Book additional files support library (3/3) (#872)
* feat(api/model): add new entity BookAdditionalFileEntity * feat(api/db): add book additional file repository * feat(api/db): add migration * test(api/db): add book additional file repository test * test(api/db): add book additional file repository tests for hash uniqueness * feat(api/domain): add support to additional file model * feat(api): add additional files controller * refactor(api): move addAdditionalFile to FileUploadService as uploadAdditionalFile method * feat(service): search book by additional file * feat(services): process deleted additional files with ability to promote alternative formats to book instead of deleting them * refactor(util): use common code to resolve patter for entity and domain object * feat(service): move additional files * test(service): test move additional files along with book itself * feat(ui/domain): add alternativeFormats and supplementaryFiles to book model * feat(ui/domain): add download additional file method to book service * refactor(api/domain): extract FileInfo interface with common fields Allow to share the same interface thet is implemented by AdditionFile and Book * feat(ui): show multiple download options * feat(ui/domain): add delete additional file method to book service * feat(ui): add delete additional file ui * feat(ui): add additional-file-uploader.component * feat(ui/domain): add uploadAdditionalFile to the service * feat(ui): add Upload File menu item * feat(ui): show supplementary files in download menu item * feat(ui): show supplementary files in delete file menu item * feat(ui): book card allow to select single file to download or delete * feat(api/domain): add scan mode and default book format to the library * feat(ui): select scan mode and default book format * feat(api): create/update library settings * refactor(services): get processor based on scan mode * feat(services): read all files if processor supports supplimentary files * fix(services): detectNewBookPaths should check additional files as well * feat(services): implement folder as book file processor * test(service): add tests for FolderAsBookFileProcessor * feat(services): allow follow links for search library files * test(library): add tests for folder as book file processor * refactor(library): use Path instead of String for directory path * feat(library): sort directories before processing * feat(library): reuse library file book type * fix(library): do not add additional format if it is used in another book * test(library): test same hashes files * refactor(library): simplify FolderAsBookFileProcessor * test(library): add test with deep folder structure * test(library): add additional files to existing book --------- Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
co-authored by
Aditya Chandel
parent
f725ececf5
commit
694ee11540
@@ -37,6 +37,37 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<label class="self-center">Scan Mode</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<p-select
|
||||
[(ngModel)]="scanMode"
|
||||
[options]="scanModeOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select scan mode"
|
||||
class="w-full" />
|
||||
<i
|
||||
class="pi pi-info-circle text-sky-600 cursor-pointer"
|
||||
pTooltip="File as Book: Each file is a separate book. Folder as Book: Each folder contains one book in multiple formats."
|
||||
tooltipPosition="right"></i>
|
||||
</div>
|
||||
|
||||
<label class="self-center">Default Format</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<p-select
|
||||
[(ngModel)]="defaultBookFormat"
|
||||
[options]="bookFormatOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select default format"
|
||||
class="w-full"
|
||||
[disabled]="scanMode !== 'FOLDER_AS_BOOK'" />
|
||||
<i
|
||||
class="pi pi-info-circle text-sky-600 cursor-pointer"
|
||||
pTooltip="When a folder contains multiple book formats, this format will be used as the primary book file. Only applicable in 'Folder as Book' mode."
|
||||
tooltipPosition="right"></i>
|
||||
</div>
|
||||
|
||||
<label class="self-center">Monitor Folders</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<p-toggleswitch [(ngModel)]="watch" />
|
||||
|
||||
@@ -9,16 +9,17 @@ import {TableModule} from 'primeng/table';
|
||||
import {Step, StepList, StepPanel, StepPanels, Stepper} from 'primeng/stepper';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Library} from '../../model/library.model';
|
||||
import {Library, LibraryScanMode, BookFileType} from '../../model/library.model';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import { IconPickerService } from '../../../utilities/services/icon-picker.service';
|
||||
import {Select} from 'primeng/select';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
standalone: true,
|
||||
templateUrl: './library-creator.component.html',
|
||||
imports: [Button, TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip],
|
||||
imports: [Button, TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip, Select],
|
||||
styleUrl: './library-creator.component.scss'
|
||||
})
|
||||
export class LibraryCreatorComponent implements OnInit {
|
||||
@@ -31,6 +32,20 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
editModeLibraryName: string = '';
|
||||
directoryPickerDialogRef!: DynamicDialogRef<DirectoryPickerComponent>;
|
||||
watch: boolean = false;
|
||||
scanMode: LibraryScanMode = 'FILE_AS_BOOK';
|
||||
defaultBookFormat: BookFileType | undefined = undefined;
|
||||
|
||||
readonly scanModeOptions = [
|
||||
{label: 'Each file is a separate book', value: 'FILE_AS_BOOK'},
|
||||
{label: 'Each folder is a book', value: 'FOLDER_AS_BOOK'}
|
||||
];
|
||||
|
||||
readonly bookFormatOptions = [
|
||||
{label: 'None', value: undefined},
|
||||
{label: 'EPUB', value: 'EPUB'},
|
||||
{label: 'PDF', value: 'PDF'},
|
||||
{label: 'CBX/CBZ/CBR', value: 'CBX'}
|
||||
];
|
||||
|
||||
private dialogService = inject(DialogService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
@@ -46,11 +61,13 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
this.mode = data.mode;
|
||||
this.library = this.libraryService.findLibraryById(data.libraryId);
|
||||
if (this.library) {
|
||||
const {name, icon, paths, watch} = this.library;
|
||||
const {name, icon, paths, watch, scanMode, defaultBookFormat} = this.library;
|
||||
this.chosenLibraryName = name;
|
||||
this.editModeLibraryName = name;
|
||||
this.selectedIcon = `pi pi-${icon}`;
|
||||
this.watch = watch;
|
||||
this.scanMode = scanMode || 'FILE_AS_BOOK';
|
||||
this.defaultBookFormat = defaultBookFormat || undefined;
|
||||
this.folders = paths.map(path => path.path);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +140,9 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
name: this.chosenLibraryName,
|
||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||
paths: this.folders.map(folder => ({path: folder})),
|
||||
watch: this.watch
|
||||
watch: this.watch,
|
||||
scanMode: this.scanMode,
|
||||
defaultBookFormat: this.defaultBookFormat
|
||||
};
|
||||
this.libraryService.updateLibrary(library, this.library?.id).subscribe({
|
||||
next: () => {
|
||||
@@ -140,7 +159,9 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
name: this.chosenLibraryName,
|
||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||
paths: this.folders.map(folder => ({path: folder})),
|
||||
watch: this.watch
|
||||
watch: this.watch,
|
||||
scanMode: this.scanMode,
|
||||
defaultBookFormat: this.defaultBookFormat
|
||||
};
|
||||
this.libraryService.createLibrary(library).subscribe({
|
||||
next: (createdLibrary) => {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {SortOption} from './sort.model';
|
||||
|
||||
export type LibraryScanMode = 'FILE_AS_BOOK' | 'FOLDER_AS_BOOK';
|
||||
export type BookFileType = 'PDF' | 'EPUB' | 'CBX';
|
||||
|
||||
export interface Library {
|
||||
id?: number;
|
||||
name: string;
|
||||
@@ -8,6 +11,8 @@ export interface Library {
|
||||
fileNamingPattern?: string;
|
||||
sort?: SortOption;
|
||||
paths: LibraryPath[];
|
||||
scanMode?: LibraryScanMode;
|
||||
defaultBookFormat?: BookFileType;
|
||||
}
|
||||
|
||||
export interface LibraryPath {
|
||||
|
||||
Reference in New Issue
Block a user