From 9e1d437e74c954c184e6cef6d2670bfaf5428f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Tue, 12 Aug 2025 17:41:27 +0300 Subject: [PATCH 1/4] automatically set library/path if there is only one option available --- .../book-uploader/book-uploader.component.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts b/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts index ab9433880..39682be81 100644 --- a/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts +++ b/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts @@ -44,9 +44,21 @@ interface UploadingFile { export class BookUploaderComponent implements OnInit { files: UploadingFile[] = []; isUploading: boolean = false; - selectedLibrary: Library | null = null; + _selectedLibrary: Library | null = null; selectedPath: LibraryPath | null = null; + get selectedLibrary(): Library | null { + return this._selectedLibrary; + } + + set selectedLibrary(library: Library | null) { + this._selectedLibrary = library; + + if(library?.paths?.length === 1) { + this.selectedPath = library.paths[0]; + } + } + private readonly libraryService = inject(LibraryService); private readonly messageService = inject(MessageService); private readonly appSettingsService = inject(AppSettingsService); @@ -70,6 +82,15 @@ export class BookUploaderComponent implements OnInit { .subscribe(settings => { this.maxFileSizeBytes = (settings?.maxFileUploadSizeInMb ?? 100) * 1024 * 1024; }); + + this.libraryState$.subscribe(state => { + if (state?.libraries?.length !== 1 || this.selectedLibrary) { + return; + } + + this.selectedLibrary = state.libraries[0]; + }); + } hasPendingFiles(): boolean { From 3ebc6171966542512978911a2a6285fee4c2fa9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Tue, 12 Aug 2025 17:56:17 +0300 Subject: [PATCH 2/4] cleanup & tidy up --- .../book-uploader/book-uploader.component.ts | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts b/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts index 39682be81..ea7511ecd 100644 --- a/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts +++ b/booklore-ui/src/app/utilities/component/book-uploader/book-uploader.component.ts @@ -47,18 +47,6 @@ export class BookUploaderComponent implements OnInit { _selectedLibrary: Library | null = null; selectedPath: LibraryPath | null = null; - get selectedLibrary(): Library | null { - return this._selectedLibrary; - } - - set selectedLibrary(library: Library | null) { - this._selectedLibrary = library; - - if(library?.paths?.length === 1) { - this.selectedPath = library.paths[0]; - } - } - private readonly libraryService = inject(LibraryService); private readonly messageService = inject(MessageService); private readonly appSettingsService = inject(AppSettingsService); @@ -90,7 +78,18 @@ export class BookUploaderComponent implements OnInit { this.selectedLibrary = state.libraries[0]; }); + } + get selectedLibrary(): Library | null { + return this._selectedLibrary; + } + + set selectedLibrary(library: Library | null) { + this._selectedLibrary = library; + + if(library?.paths?.length === 1) { + this.selectedPath = library.paths[0]; + } } hasPendingFiles(): boolean { From 79ccc436d1a49a8d3c899510c0bb399a003f5cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Tue, 12 Aug 2025 18:10:45 +0300 Subject: [PATCH 3/4] book drop bulk select will auto-select if there is only one option --- .../bookdrop-file-review.component.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts index e91f8854b..34af2b821 100644 --- a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts +++ b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts @@ -75,7 +75,8 @@ export class BookdropFileReviewComponent implements OnInit { appSettings$: Observable = this.appSettingsService.appSettings$; uploadPattern = ''; - defaultLibraryId: string | null = null; + _defaultLibraryId: string | null = null; + defaultPathId: string | null = null; libraries: Library[] = []; bookdropFileUis: BookdropFileUI[] = []; @@ -108,6 +109,20 @@ export class BookdropFileReviewComponent implements OnInit { }); } + get defaultLibraryId() { + return this._defaultLibraryId; + } + + set defaultLibraryId(value: string | null) { + this._defaultLibraryId = value; + + const selected = this.libraries.find((lib) => lib?.id && String(lib.id) === value) + + if (selected && selected.paths.length ===1) { + this.defaultPathId = String(selected.paths[0].id) + } + } + get libraryOptions() { if (!this.libraries) return []; return this.libraries.map(lib => ({label: lib.name, value: String(lib.id ?? '')})); From 01d85052dfb2feeaf5ab022fe389fad79a39f7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Tue, 12 Aug 2025 18:24:33 +0300 Subject: [PATCH 4/4] book drop: single book select will also autoselect --- .../bookdrop-file-review.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts index 34af2b821..076dfbcf2 100644 --- a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts +++ b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts @@ -203,7 +203,7 @@ export class BookdropFileReviewComponent implements OnInit { onLibraryChange(file: BookdropFileUI): void { const lib = this.libraries.find(l => String(l.id) === file.selectedLibraryId); file.availablePaths = lib?.paths.map(p => ({id: String(p.id ?? ''), name: p.path})) ?? []; - file.selectedPathId = null; + file.selectedPathId = file.availablePaths.length === 1 ? file.availablePaths[0].id : null; } onMetadataCopied(fileId: number, copied: boolean): void {