Implement new book details dialog/tab
This commit is contained in:
@@ -78,6 +78,11 @@ public class BookController {
|
||||
return ResponseEntity.ok(booksService.setBookMetadata(bookId, source, setMetadataRequest));
|
||||
}
|
||||
|
||||
@PutMapping("/{bookId}/metadata")
|
||||
public ResponseEntity<BookMetadataDTO> setBookMetadataV2(@RequestBody FetchedBookMetadata setMetadataRequest, @PathVariable long bookId) {
|
||||
return ResponseEntity.ok(booksService.setBookMetadataV2(bookId, setMetadataRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/assign-shelves")
|
||||
public ResponseEntity<List<BookDTO>> addBookToShelf(@RequestBody @Valid ShelvesAssignmentRequest request) {
|
||||
return ResponseEntity.ok(booksService.assignShelvesToBooks(request.getBookIds(), request.getShelvesToAssign(), request.getShelvesToUnassign()));
|
||||
|
||||
@@ -168,4 +168,8 @@ public class BooksService {
|
||||
public BookMetadataDTO setBookMetadata(long bookId, BookMetadataSource source, FetchedBookMetadata setMetadataRequest) {
|
||||
return bookMetadataService.setBookMetadata(bookId, setMetadataRequest, source);
|
||||
}
|
||||
|
||||
public BookMetadataDTO setBookMetadataV2(long bookId, FetchedBookMetadata setMetadataRequest) {
|
||||
return bookMetadataService.setBookMetadata(bookId, setMetadataRequest, BookMetadataSource.AMAZON);
|
||||
}
|
||||
}
|
||||
Generated
+66
@@ -25,6 +25,7 @@
|
||||
"ngx-infinite-scroll": "^19.0.0",
|
||||
"primeicons": "^7.0.0",
|
||||
"primeng": "19.0.2",
|
||||
"quill": "^2.0.3",
|
||||
"rxjs": "~7.8.0",
|
||||
"tailwindcss-primeui": "^0.3.4",
|
||||
"tslib": "^2.3.0",
|
||||
@@ -7693,6 +7694,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-diff": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
|
||||
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
|
||||
@@ -9758,6 +9765,18 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash-es": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
|
||||
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash.clonedeep": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
|
||||
"integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash.debounce": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
|
||||
@@ -9765,6 +9784,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lodash.isequal": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
|
||||
"integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/log-symbols": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||
@@ -11498,6 +11523,12 @@
|
||||
"node": "^18.17.0 || >=20.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/parchment": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0.tgz",
|
||||
"integrity": "sha512-HUrJFQ/StvgmXRcQ1ftY6VEZUq3jA2t9ncFN4F84J/vN0/FPpQF+8FKXb3l6fLces6q0uOHj6NJn+2xvZnxO6A==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/parent-module": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||
@@ -12149,6 +12180,41 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/quill": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/quill/-/quill-2.0.3.tgz",
|
||||
"integrity": "sha512-xEYQBqfYx/sfb33VJiKnSJp8ehloavImQ2A6564GAbqG55PGw1dAWUn1MUbQB62t0azawUS2CZZhWCjO8gRvTw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"eventemitter3": "^5.0.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"parchment": "^3.0.0",
|
||||
"quill-delta": "^5.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">=8.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/quill-delta": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/quill-delta/-/quill-delta-5.1.0.tgz",
|
||||
"integrity": "sha512-X74oCeRI4/p0ucjb5Ma8adTXd9Scumz367kkMK5V/IatcX6A0vlgLgKbzXWy5nZmCGeNJm2oQX0d2Eqj+ZIlCA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fast-diff": "^1.3.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lodash.isequal": "^4.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/quill/node_modules/eventemitter3": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
|
||||
"integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/randombytes": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"ngx-infinite-scroll": "^19.0.0",
|
||||
"primeicons": "^7.0.0",
|
||||
"primeng": "19.0.2",
|
||||
"quill": "^2.0.3",
|
||||
"rxjs": "~7.8.0",
|
||||
"tailwindcss-primeui": "^0.3.4",
|
||||
"tslib": "^2.3.0",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<div class="container pt-6 px-2 flex flex-col h-full">
|
||||
<div class="space-y-4 flex-grow">
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-2/3">
|
||||
<label for="title">Title</label>
|
||||
<input pInputText id="title" class="w-full" [(ngModel)]="bookForm.title"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/3">
|
||||
<label for="subtitle">Subtitle</label>
|
||||
<input pInputText id="subtitle" class="w-full" [(ngModel)]="bookForm.subtitle"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-3/4">
|
||||
<label for="authors">Authors</label>
|
||||
<input pInputText
|
||||
id="authors"
|
||||
class="w-full"
|
||||
[(ngModel)]="authorsInput"
|
||||
(ngModelChange)="onAuthorsInputChange()"
|
||||
placeholder="Enter authors separated by commas"/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/4">
|
||||
<label for="publish">Publish Date</label>
|
||||
<input pInputText id="publish" class="w-full" [(ngModel)]="bookForm.publishedDate"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label for="description">Description</label>
|
||||
<textarea id="description" rows="5" cols="30" pTextarea [(ngModel)]="bookForm.description"></textarea>
|
||||
</div>
|
||||
<div class="flex flex-grow w-full justify-between gap-4">
|
||||
<div class="w-1/3 flex justify-center items-center pt-4 pr-4 pb-4">
|
||||
<p-image src="https://m.media-amazon.com/images/I/61GzazUmKyL._SL1462_.jpg" alt="Image" width="250"/>
|
||||
</div>
|
||||
<div class="w-2/3 space-y-2">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
<label for="categories">Categories</label>
|
||||
<input
|
||||
pInputText
|
||||
id="categories"
|
||||
class="w-full"
|
||||
[(ngModel)]="categoriesInput"
|
||||
(input)="onCategoriesInputChange()"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-1/2">
|
||||
<label for="publisher">Publisher</label>
|
||||
<input pInputText id="publisher" class="w-full" [(ngModel)]="bookForm.publisher"/>
|
||||
</div>
|
||||
<div class="flex flex-col w-1/2">
|
||||
<label for="language">Language</label>
|
||||
<input pInputText id="language" class="w-full" [(ngModel)]="bookForm.language"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col gap-1 w-1/2">
|
||||
<label for="isbn10">ISBN10</label>
|
||||
<input pInputText id="isbn10" class="w-full" [(ngModel)]="bookForm.isbn10"/>
|
||||
</div>
|
||||
<div class="flex flex-col w-1/2">
|
||||
<label for="isbn13">ISBN13</label>
|
||||
<input pInputText id="isbn13" class="w-full" [(ngModel)]="bookForm.isbn13"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full gap-x-4">
|
||||
<div class="flex flex-col w-1/2">
|
||||
<label for="aisn">AISN</label>
|
||||
<input pInputText id="aisn" class="w-full" [(ngModel)]="bookForm.asin"/>
|
||||
</div>
|
||||
<div class="flex flex-col w-1/2">
|
||||
<label for="page-count">Page Count</label>
|
||||
<input pInputText id="page-count" class="w-full" [(ngModel)]="bookForm.pageCount"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" severity="secondary"/>
|
||||
<p-button label="Save" (onClick)="onSave()"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,62 @@
|
||||
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||
import { InputText } from 'primeng/inputtext';
|
||||
import { Textarea } from 'primeng/textarea';
|
||||
import { Image } from 'primeng/image';
|
||||
import { Button } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { BookMetadataForm } from '../../book/model/book-metadata-form';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-details',
|
||||
standalone: true,
|
||||
templateUrl: './book-details.component.html',
|
||||
imports: [
|
||||
InputText,
|
||||
Textarea,
|
||||
Image,
|
||||
Button,
|
||||
Divider,
|
||||
FormsModule
|
||||
],
|
||||
styleUrl: './book-details.component.scss'
|
||||
})
|
||||
export class BookDetailsComponent implements OnChanges {
|
||||
|
||||
@Input() bookForm!: BookMetadataForm;
|
||||
@Output() save = new EventEmitter<BookMetadataForm>();
|
||||
|
||||
authorsInput: string = '';
|
||||
categoriesInput: string = '';
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (this.bookForm.authors) {
|
||||
this.authorsInput = this.bookForm.authors.join(', ');
|
||||
}
|
||||
if (this.bookForm.categories) {
|
||||
this.categoriesInput = this.bookForm.categories.join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
if (this.authorsInput) {
|
||||
this.bookForm.authors = this.authorsInput.split(',').map(author => author.trim());
|
||||
}
|
||||
if (this.categoriesInput) {
|
||||
this.bookForm.categories = this.categoriesInput.split(',').map(category => category.trim());
|
||||
}
|
||||
this.save.emit(this.bookForm);
|
||||
}
|
||||
|
||||
onAuthorsInputChange(): void {
|
||||
if (this.authorsInput) {
|
||||
this.bookForm.authors = this.authorsInput.split(',').map(author => author.trim());
|
||||
}
|
||||
}
|
||||
|
||||
onCategoriesInputChange(): void {
|
||||
if (this.categoriesInput) {
|
||||
this.bookForm.categories = this.categoriesInput.split(',').map(category => category.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<p-tabs value="0">
|
||||
<p-tablist>
|
||||
<p-tab value="0">Book Details</p-tab>
|
||||
<p-tab value="1">Match Book</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="0">
|
||||
<app-book-details [bookForm]="bookForm" (save)="saveBook($event)"></app-book-details>
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {BookDetailsComponent} from './book-details/book-details.component';
|
||||
import {DynamicDialogConfig} from 'primeng/dynamicdialog';
|
||||
import {BookService} from '../book/service/book.service';
|
||||
import {Book} from '../book/model/book.model';
|
||||
import {BookMetadataForm} from '../book/model/book-metadata-form';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
@Component({
|
||||
selector: 'book-info-tabs',
|
||||
standalone: true,
|
||||
templateUrl: './book-info-tabs.component.html',
|
||||
styleUrl: './book-info-tabs.component.scss',
|
||||
imports: [
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
BookDetailsComponent,
|
||||
TabPanel
|
||||
]
|
||||
})
|
||||
export class BookInfoTabsComponent implements OnInit {
|
||||
book: Book | undefined;
|
||||
bookForm: BookMetadataForm = {} as BookMetadataForm;
|
||||
|
||||
constructor(private bookService: BookService, private dynamicDialogConfig: DynamicDialogConfig,
|
||||
private messageService: MessageService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookService.getBookByIdFromAPI(this.dynamicDialogConfig.data.bookId, true).subscribe({
|
||||
next: (book) => {
|
||||
this.book = book;
|
||||
this.initializeBookForm();
|
||||
},
|
||||
error: (error) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private initializeBookForm(): void {
|
||||
if (this.book?.metadata) {
|
||||
this.bookForm = {
|
||||
...this.book.metadata,
|
||||
authors: this.book.metadata.authors?.map(a => a.name) || [],
|
||||
categories: this.book.metadata.categories?.map(c => c.name) || []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
saveBook(bookMetadataForm: BookMetadataForm) {
|
||||
console.log(bookMetadataForm)
|
||||
this.bookService.updateMetadataV2(this.book?.id!, bookMetadataForm).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book metadata'});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,14 @@
|
||||
</div>
|
||||
</li>
|
||||
<p-divider layout="vertical" />
|
||||
|
||||
<li>
|
||||
<a class="topbar-item">
|
||||
<i class="pi pi-book text-surface-700 dark:text-surface-100" (click)="openBookDetailsDialog()"
|
||||
pTooltip="Book Details" tooltipPosition="top"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="topbar-item">
|
||||
<i class="pi pi-plus-circle text-surface-700 dark:text-surface-100" (click)="openLibraryCreatorDialog()"
|
||||
|
||||
@@ -16,6 +16,7 @@ import {Button} from 'primeng/button';
|
||||
import {AppConfiguratorComponent} from '../configurator/configurator.component';
|
||||
import {StyleClass} from 'primeng/styleclass';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookInfoTabsComponent} from '../../../book-info-tabs/book-info-tabs.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
@@ -39,7 +40,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
items!: MenuItem[];
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
latestEvent: LogNotification = { message: 'No recent notifications...' };
|
||||
latestEvent: LogNotification = {message: 'No recent notifications...'};
|
||||
eventHighlight: boolean = false;
|
||||
showEvents: boolean = false;
|
||||
eventTimeout: any;
|
||||
@@ -76,6 +77,22 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
this.showEvents = !this.showEvents;
|
||||
}
|
||||
|
||||
|
||||
openBookDetailsDialog(): void {
|
||||
this.ref = this.dialogService.open(BookInfoTabsComponent, {
|
||||
header: 'Open book details',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '1000px',
|
||||
height: '835px',
|
||||
showHeader: false,
|
||||
closeOnEscape: true,
|
||||
data: {
|
||||
bookId: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openLibraryCreatorDialog(): void {
|
||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||
header: 'Create New Library',
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface BookMetadataForm {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
authors: Array<string>;
|
||||
categories: Array<string>;
|
||||
publisher: string;
|
||||
publishedDate: string;
|
||||
isbn10: string;
|
||||
isbn13: string;
|
||||
asin: string;
|
||||
description?: string;
|
||||
pageCount: number;
|
||||
language: string;
|
||||
googleBookId: string;
|
||||
}
|
||||
@@ -17,6 +17,8 @@ export interface BookMetadata {
|
||||
publisher: string;
|
||||
publishedDate: string;
|
||||
isbn10: string;
|
||||
isbn13: string;
|
||||
asin: string;
|
||||
description?: string;
|
||||
pageCount: number;
|
||||
language: string;
|
||||
|
||||
@@ -4,6 +4,7 @@ import {HttpClient} from '@angular/common/http';
|
||||
import {catchError, map, switchMap, tap} from 'rxjs/operators';
|
||||
import {Book, BookMetadata, BookSetting, FetchedMetadata} from '../model/book.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
import {BookMetadataForm} from '../model/book-metadata-form';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -202,4 +203,9 @@ export class BookService {
|
||||
updateMetadata(bookId: number, updateMedata: FetchedMetadata): Observable<BookMetadata> {
|
||||
return this.http.put<BookMetadata>(`${this.url}/${bookId}/source/AMAZON/metadata`, updateMedata);
|
||||
}
|
||||
|
||||
updateMetadataV2(bookId: number, bookMetadataForm: BookMetadataForm): Observable<BookMetadata> {
|
||||
return this.http.put<BookMetadata>(`${this.url}/${bookId}/metadata`, bookMetadataForm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user