WIP: Arrange UI files for better structuring
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
<div class="container pt-2 flex flex-col h-full">
|
||||
<div class="book-metadata-container flex-shrink-0" *ngIf="bookMetadata$ | async as bookMetadata">
|
||||
<div class="flex flex-row w-full">
|
||||
|
||||
<img [src]="coverImageSrc(bookMetadata.bookId)" class="book-cover placeholder" alt="Cover of {{ bookMetadata.title }}" loading="lazy" width="225"/>
|
||||
|
||||
<div class="pl-6 flex flex-col w-full space-y-4">
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<p class="text-lg font-bold">{{ bookMetadata.title }}</p>
|
||||
<div class="flex items-center gap-4 pt-1">
|
||||
<p-rating [(ngModel)]="bookMetadata.rating" readonly stars="5"></p-rating>
|
||||
<p class="font-semibold">({{ bookMetadata.reviewCount || 0 }} Reviews)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-4 pr-4">
|
||||
<p-button [rounded]="true" [raised]="true" severity="info" (onClick)="readBook(bookMetadata.bookId)" icon="pi pi-eye"></p-button>
|
||||
<p-button [rounded]="true" [raised]="true" severity="info" icon="pi pi-download"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<p class="font-semibold text-lg">Authors:</p>
|
||||
<div class="flex flex-wrap gap-2 ml-2">
|
||||
<p class="text-lg" *ngFor="let author of bookMetadata.authors">
|
||||
{{ author }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<p><span class="font-bold">Publisher:</span> {{ bookMetadata.publisher || 'N/A' }}</p>
|
||||
<p><span class="font-bold">Published:</span> {{ bookMetadata.publishedDate || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">Language:</span> {{ bookMetadata.language || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">ISBN:</span> {{ bookMetadata.isbn10 || 'Unknown' }}</p>
|
||||
<p><span class="font-bold">Page Count:</span> {{ bookMetadata.pageCount || 'Unknown' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<p-tag *ngFor="let category of bookMetadata.categories" value="{{category}}"></p-tag>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<p-divider></p-divider>-->
|
||||
|
||||
<div *ngIf="bookMetadata$ | async as bookMetadata" class="book-description space-y-4 overflow-y-auto flex-1">
|
||||
<!--<p class="pt-2 px-2" [innerHTML]="bookMetadata.description || 'No description available.'"></p>-->
|
||||
<div class="pt-6">
|
||||
<p-editor [(ngModel)]="bookMetadata.description" [style]="{ height: '350px' }" [readonly]="true">
|
||||
<ng-template #header>
|
||||
</ng-template>
|
||||
</p-editor>
|
||||
</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="Close" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
::ng-deep .ql-toolbar.ql-snow {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-toolbar.ql-snow {
|
||||
border: 0.5px solid var(--p-editor-toolbar-border-color) !important;
|
||||
}
|
||||
|
||||
::ng-deep .p-editor .p-editor-content {
|
||||
border-end-end-radius: 0 !important;
|
||||
border-end-start-radius: 0 !important;
|
||||
}
|
||||
|
||||
::ng-deep .ql-container {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {BookMetadataBI} from '../../../book/model/book-metadata-for-book-info.model';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {Rating} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Editor} from 'primeng/editor';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [
|
||||
Button,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
AsyncPipe,
|
||||
Rating,
|
||||
FormsModule,
|
||||
Tag,
|
||||
Editor
|
||||
]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit {
|
||||
|
||||
bookMetadata$: Observable<BookMetadataBI | null>;
|
||||
currentBookId!: number;
|
||||
|
||||
constructor(private bookService: BookService, private router: Router, private bookInfoService: BookMetadataCenterService) {
|
||||
this.bookMetadata$ = this.bookInfoService.bookMetadata$;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookMetadata$.subscribe((bookMetadata) => {
|
||||
if(bookMetadata) {
|
||||
this.currentBookId = bookMetadata?.bookId;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
navigateToBook(bookId: number | null, libraryId: number | null): void {
|
||||
if (bookId && libraryId) {
|
||||
this.router.navigate(['/library', libraryId, 'book', bookId, 'info']);
|
||||
}
|
||||
}
|
||||
|
||||
getAuthorNames(book: Book | null): string {
|
||||
if (book && book.metadata && book.metadata.authors) {
|
||||
return book.metadata.authors.map((author) => author.name).join(', ');
|
||||
}
|
||||
return 'No authors available';
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number | undefined): string {
|
||||
if (bookId === null) {
|
||||
return 'assets/book-cover-metadata.png';
|
||||
}
|
||||
return this.bookService.getBookCoverUrl(bookId!);
|
||||
}
|
||||
|
||||
readBook(bookId: number) {
|
||||
this.bookService.readBook(bookId);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
return this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user