Add buttons to the book description page
This commit is contained in:
committed by
Aditya Chandel
parent
6004c2cbaa
commit
3630b27e37
+32
-28
@@ -8,40 +8,44 @@
|
||||
loading="lazy"
|
||||
width="250"/>
|
||||
|
||||
<div class="pl-6 flex flex-col w-full space-y-4">
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<p *ngIf="metadata.seriesName" class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }} </p>
|
||||
<p class="text-2xl font-bold">{{ metadata.title }}</p>
|
||||
<p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p>
|
||||
</div>
|
||||
<div class="flex gap-4 pr-4">
|
||||
<p-button [rounded]="true" [raised]="true" severity="info" (onClick)="readBook(metadata.bookId)" icon="pi pi-eye"></p-button>
|
||||
<div *ngIf="userService.userData$ | async as userData">
|
||||
<p-button *ngIf="userData.permissions.canDownload" [rounded]="true" [raised]="true" severity="info" icon="pi pi-download" (onClick)="download(metadata.bookId)"></p-button>
|
||||
<div class="flex flex-col justify-between">
|
||||
<div class="pl-6 flex flex-col w-full space-y-4">
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
<p *ngIf="metadata.seriesName" class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }} </p>
|
||||
<p class="text-2xl font-bold">{{ metadata.title }}</p>
|
||||
<p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4 pb-4">
|
||||
<p-rating [(ngModel)]="metadata.rating" readonly stars="5"></p-rating>
|
||||
<p class="font-semibold">({{ metadata.reviewCount || 0 }} Reviews)</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<p><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
|
||||
<p><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>
|
||||
<p><span class="font-bold">Language:</span> {{ metadata.language || '-' }}</p>
|
||||
<p><span class="font-bold">ISBN 10:</span> {{ metadata.isbn10 || '-' }}</p>
|
||||
<p><span class="font-bold">ISBN 13:</span> {{ metadata.isbn13 || '-' }}</p>
|
||||
<p><span class="font-bold">Page Count:</span> {{ metadata.pageCount || '-' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2 pt-2">
|
||||
<p-tag *ngFor="let category of metadata.categories" [value]="category"></p-tag>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4 pb-4">
|
||||
<p-rating [(ngModel)]="metadata.rating" readonly stars="5"></p-rating>
|
||||
<p class="font-semibold">({{ metadata.reviewCount || 0 }} Reviews)</p>
|
||||
<div *ngIf="userService.userData$ | async as userData" class="pl-6 flex flex-row w-full gap-4">
|
||||
<p-button label="Read" icon="pi pi-book" severity="info" (onClick)="read(metadata.bookId)"></p-button>
|
||||
<p-button label="Assign Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(metadata.bookId)"></p-button>
|
||||
<p-button *ngIf="userData.permissions.canDownload" label="Download" icon="pi pi-download" severity="info" outlined (onClick)="download(metadata.bookId)"></p-button>
|
||||
<p-splitbutton *ngIf="userData.permissions.canEmailBook" label="Quick Send" icon="pi pi-send" [model]="items" (onClick)="quickSend(metadata.bookId)" outlined severity="info"/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<p><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
|
||||
<p><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>
|
||||
<p><span class="font-bold">Language:</span> {{ metadata.language || '-' }}</p>
|
||||
<p><span class="font-bold">ISBN 10:</span> {{ metadata.isbn10 || '-' }}</p>
|
||||
<p><span class="font-bold">ISBN 13:</span> {{ metadata.isbn13 || '-' }}</p>
|
||||
<p><span class="font-bold">Page Count:</span> {{ metadata.pageCount || '-' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2 pt-2">
|
||||
<p-tag *ngFor="let category of metadata.categories" [value]="category"></p-tag>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+79
-4
@@ -1,4 +1,4 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
@@ -11,24 +11,62 @@ import {BookMetadata} from '../../../book/model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../user.service';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {BookSenderComponent} from '../../../book/components/book-sender/book-sender.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {EmailService} from '../../../settings/email/email.service';
|
||||
import {ShelfAssignerComponent} from '../../../book/components/shelf-assigner/shelf-assigner.component';
|
||||
|
||||
@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, Divider]
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton]
|
||||
})
|
||||
export class MetadataViewerComponent {
|
||||
export class MetadataViewerComponent implements OnInit {
|
||||
|
||||
private dialogService = inject(DialogService);
|
||||
private emailService = inject(EmailService);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
private metadataCenterService = inject(BookMetadataCenterService);
|
||||
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
protected userService = inject(UserService);
|
||||
|
||||
metadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||
items: MenuItem[] | undefined;
|
||||
|
||||
readBook(bookId: number): void {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.items = [
|
||||
{
|
||||
label: 'Custom Send',
|
||||
command: () => {
|
||||
this.metadata$.subscribe((metadata) => {
|
||||
if (metadata) {
|
||||
this.dialogService.open(BookSenderComponent, {
|
||||
header: 'Send Book to Email',
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
},
|
||||
data: {
|
||||
book: metadata.bookId,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
read(bookId: number): void {
|
||||
this.bookService.readBook(bookId);
|
||||
}
|
||||
|
||||
@@ -43,4 +81,41 @@ export class MetadataViewerComponent {
|
||||
download(bookId: number) {
|
||||
this.bookService.downloadFile(bookId);
|
||||
}
|
||||
|
||||
quickSend(bookId: number) {
|
||||
this.emailService.emailBookQuick(bookId).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'info',
|
||||
summary: 'Success',
|
||||
detail: 'The book sending has been scheduled.',
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
const errorMessage = err?.error?.message || 'An error occurred while sending the book.';
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: errorMessage,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
assignShelf(bookId: number) {
|
||||
this.dialogService.open(ShelfAssignerComponent, {
|
||||
header: `Update Book's Shelves`,
|
||||
modal: true,
|
||||
closable: true,
|
||||
contentStyle: {overflow: 'auto'},
|
||||
baseZIndex: 10,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
},
|
||||
data: {
|
||||
book: this.bookService.getBookByIdFromState(bookId),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user