WPI: Add table for display books
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<div *ngIf="!(bookState$ | async)?.loaded && !(bookState$ | async)?.error">
|
||||
<p-progressSpinner></p-progressSpinner>
|
||||
</div>
|
||||
|
||||
<div *ngIf="(bookState$ | async)?.books as book">
|
||||
<p-table [value]="book" [resizableColumns]="true" showGridlines stripedRows [scrollable]="true"
|
||||
scrollHeight="900px" [virtualScroll]="true" [virtualScrollItemSize]="46">
|
||||
<ng-template #header>
|
||||
<tr>
|
||||
<th class="max-w-16">Cover</th>
|
||||
<th class="w-1/2 max-w-52 overflow-hidden truncate" pResizableColumn>Title</th>
|
||||
<th class="w-1/6 max-w-48 overflow-hidden truncate">Publisher</th>
|
||||
<th class="w-1/12 max-w-40 overflow-hidden truncate" pResizableColumn>Subtitle</th>
|
||||
<th class="w-1/8 max-w-36 overflow-hidden truncate">ISBN</th>
|
||||
<th class="w-1/8 max-w-32 overflow-hidden truncate">Language</th>
|
||||
<th class="w-1/8 max-w-36 overflow-hidden truncate">Rating</th>
|
||||
<th class="max-w-16">
|
||||
<p-tableHeaderCheckbox/>
|
||||
</th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
<ng-template #body let-book>
|
||||
<tr style="height:46px">
|
||||
<td class="w-6 h-6">
|
||||
<img [src]="getBookCoverUrl(book.id)" alt="Book Cover" class="size-7"/>
|
||||
</td>
|
||||
<td class="w-1/2 max-w-52 overflow-hidden truncate" [title]="book.metadata?.title">{{ book.metadata?.title }}</td>
|
||||
<td class="w-1/6 max-w-48 overflow-hidden truncate">{{ book.metadata?.publisher }}</td>
|
||||
<td class="w-1/12 max-w-40 overflow-hidden truncate">{{ book.metadata?.subtitle }}</td>
|
||||
<td class="w-1/8 max-w-36 overflow-hidden truncate">{{ book.metadata?.isbn10 }}</td>
|
||||
<td class="w-1/8 max-w-32 overflow-hidden truncate">{{ book.metadata?.language }}</td>
|
||||
<td class="w-1/8 max-w-36 overflow-hidden truncate">
|
||||
<ng-container *ngIf="book.metadata">
|
||||
<p-rating [(ngModel)]="book.metadata.rating" readonly stars="5"></p-rating>
|
||||
</ng-container>
|
||||
</td>
|
||||
<td class="max-w-16">
|
||||
<p-tableCheckbox [value]="book"/>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
@@ -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<BookState>;
|
||||
|
||||
constructor(private bookService: BookService) {
|
||||
this.bookState$ = this.bookService.bookState$;
|
||||
}
|
||||
|
||||
getBookCoverUrl(bookId: number): string {
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user