From 65b7e6df8db47445a0c03991126df349cb889ba7 Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <> Date: Mon, 6 Jan 2025 15:18:14 -0700 Subject: [PATCH] WPI: Add table for display books --- .../booklore/quartz/JobSchedulerService.java | 3 ++ .../booklore/util/FileService.java | 17 ++++++-- booklore-ui/src/app/app-routing.module.ts | 3 +- booklore-ui/src/app/app.component.html | 1 - .../metadata-searcher.component.html | 2 +- .../book-browser/book-browser.component.ts | 3 +- .../book-table/book-table.component.html | 43 +++++++++++++++++++ .../book-table/book-table.component.scss | 0 .../book-table/book-table.component.ts | 35 +++++++++++++++ 9 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 booklore-ui/src/app/book/component/book-table/book-table.component.html create mode 100644 booklore-ui/src/app/book/component/book-table/book-table.component.scss create mode 100644 booklore-ui/src/app/book/component/book-table/book-table.component.ts diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/quartz/JobSchedulerService.java b/booklore-api/src/main/java/com/adityachandel/booklore/quartz/JobSchedulerService.java index a216f1f04..d7d5da217 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/quartz/JobSchedulerService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/quartz/JobSchedulerService.java @@ -30,6 +30,9 @@ public class JobSchedulerService { scheduler.scheduleJob(jobDetail, trigger); } catch (Exception e) { + if(e.getMessage().contains("already exists")) { + throw ApiError.ANOTHER_METADATA_JOB_RUNNING.createException(); + } throw ApiError.SCHEDULE_REFRESH_ERROR.createException(e.getMessage()); } } diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/util/FileService.java b/booklore-api/src/main/java/com/adityachandel/booklore/util/FileService.java index cdbc9e96e..ae3184c2a 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/util/FileService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/util/FileService.java @@ -26,16 +26,21 @@ public class FileService { private final AppProperties appProperties; public Resource getBookCover(String thumbnailPath) { - Path filePath = Paths.get(thumbnailPath); + Path thumbPath; + if (thumbnailPath == null || thumbnailPath.isEmpty()) { + thumbPath = Paths.get(getMissingThumbnailPath()); + } else { + thumbPath = Paths.get(thumbnailPath); + } try { - Resource resource = new UrlResource(filePath.toUri()); + Resource resource = new UrlResource(thumbPath.toUri()); if (resource.exists() && resource.isReadable()) { return resource; } else { - throw ApiError.IMAGE_NOT_FOUND.createException(filePath); + throw ApiError.IMAGE_NOT_FOUND.createException(thumbPath); } } catch (IOException e) { - throw ApiError.IMAGE_NOT_FOUND.createException(filePath); + throw ApiError.IMAGE_NOT_FOUND.createException(thumbPath); } } @@ -75,4 +80,8 @@ public class FileService { return appProperties.getPathConfig() + "/thumbs/" + bookId + "/"; } + public String getMissingThumbnailPath() { + return appProperties.getPathConfig() + "/thumbs/missing/m.jpg"; + } + } diff --git a/booklore-ui/src/app/app-routing.module.ts b/booklore-ui/src/app/app-routing.module.ts index e3f559859..895f6949d 100644 --- a/booklore-ui/src/app/app-routing.module.ts +++ b/booklore-ui/src/app/app-routing.module.ts @@ -4,6 +4,7 @@ import {PdfViewerComponent} from './book/component/pdf-viewer/pdf-viewer.compone import {DashboardComponent} from './book/component/dashboard/dashboard.component'; import {BookBrowserComponent} from './book/component/book-browser/book-browser.component'; import {AppLayoutComponent} from './book/component/layout/app.layout.component'; +import {BookTableComponent} from './book/component/book-table/book-table.component'; const routes: Routes = [ { @@ -13,7 +14,7 @@ const routes: Routes = [ path: '', component: DashboardComponent, }, { - path: 'all-books', component: BookBrowserComponent, + path: 'all-books', component: BookTableComponent, }, { path: 'library/:libraryId/books', component: BookBrowserComponent, diff --git a/booklore-ui/src/app/app.component.html b/booklore-ui/src/app/app.component.html index 93fea6949..b899f0920 100644 --- a/booklore-ui/src/app/app.component.html +++ b/booklore-ui/src/app/app.component.html @@ -1,4 +1,3 @@ - diff --git a/booklore-ui/src/app/book-metadata-center/metadata-searcher/metadata-searcher.component.html b/booklore-ui/src/app/book-metadata-center/metadata-searcher/metadata-searcher.component.html index a7c005340..57c53db43 100644 --- a/booklore-ui/src/app/book-metadata-center/metadata-searcher/metadata-searcher.component.html +++ b/booklore-ui/src/app/book-metadata-center/metadata-searcher/metadata-searcher.component.html @@ -37,7 +37,7 @@

{{ truncateText(book['title'], 90) }}

-

ISBN: {{ book['isbn13'] }}

+

ISBN: {{ book['isbn10'] }}

|

Published: {{ book['publishedDate'] }}

diff --git a/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts index 3fd87297a..635760ab4 100644 --- a/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/book/component/book-browser/book-browser.component.ts @@ -53,8 +53,7 @@ export class BookBrowserComponent implements OnInit { private shelfService: ShelfService, private dialogService: DialogService, private sortService: SortService, - private libraryShelfMenuService: LibraryShelfMenuService - ) { + private libraryShelfMenuService: LibraryShelfMenuService) { } ngOnInit(): void { diff --git a/booklore-ui/src/app/book/component/book-table/book-table.component.html b/booklore-ui/src/app/book/component/book-table/book-table.component.html new file mode 100644 index 000000000..494f080d4 --- /dev/null +++ b/booklore-ui/src/app/book/component/book-table/book-table.component.html @@ -0,0 +1,43 @@ +
+ +
+ +
+ + + + Cover + Title + Publisher + Subtitle + ISBN + Language + Rating + + + + + + + + + Book Cover + + {{ book.metadata?.title }} + {{ book.metadata?.publisher }} + {{ book.metadata?.subtitle }} + {{ book.metadata?.isbn10 }} + {{ book.metadata?.language }} + + + + + + + + + + + +
diff --git a/booklore-ui/src/app/book/component/book-table/book-table.component.scss b/booklore-ui/src/app/book/component/book-table/book-table.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/booklore-ui/src/app/book/component/book-table/book-table.component.ts b/booklore-ui/src/app/book/component/book-table/book-table.component.ts new file mode 100644 index 000000000..da5a46a21 --- /dev/null +++ b/booklore-ui/src/app/book/component/book-table/book-table.component.ts @@ -0,0 +1,35 @@ +import { Component } from '@angular/core'; +import {Observable} from 'rxjs'; +import {BookState} from '../../model/state/book-state.model'; +import {TableModule} from 'primeng/table'; +import {AsyncPipe, NgIf} from '@angular/common'; +import {ProgressSpinner} from 'primeng/progressspinner'; +import {BookService} from '../../service/book.service'; +import {Rating} from 'primeng/rating'; +import {FormsModule} from '@angular/forms'; + +@Component({ + selector: 'app-book-table', + standalone: true, + templateUrl: './book-table.component.html', + imports: [ + TableModule, + AsyncPipe, + NgIf, + ProgressSpinner, + Rating, + FormsModule + ], + styleUrl: './book-table.component.scss' +}) +export class BookTableComponent { + bookState$: Observable; + + constructor(private bookService: BookService) { + this.bookState$ = this.bookService.bookState$; + } + + getBookCoverUrl(bookId: number): string { + return this.bookService.getBookCoverUrl(bookId); + } +}