Checkpoint again
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<div class="book-metadata-container">
|
||||
<div class="book-metadata">
|
||||
<div class="book-header">
|
||||
<div class="cover-container">
|
||||
<img [src]="coverImageSrc(book?.id)" class="book-cover placeholder" alt="Cover of {{ book?.metadata?.title }}"
|
||||
loading="lazy"/>
|
||||
</div>
|
||||
<div class="metadata">
|
||||
<div class="title-row">
|
||||
<h2 class="book-title">{{ book?.metadata?.title || 'Untitled' }}</h2>
|
||||
<div class="button-group">
|
||||
<p-button [rounded]="true" [raised]="true" [outlined]="true" (onClick)="openEditDialog(book?.id)"
|
||||
icon="pi pi-pencil"></p-button>
|
||||
<p-button [rounded]="true" [raised]="true" [outlined]="true" (onClick)="readBook(book?.id)"
|
||||
icon="pi pi-eye"></p-button>
|
||||
<p-button [rounded]="true" [raised]="true" [outlined]="true" icon="pi pi-download"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="author">Author — {{ getAuthorNames(book) }}</p>
|
||||
<div class="categories">
|
||||
<p-button *ngFor="let category of book?.metadata?.categories" label="{{category.name}}" severity="info" [rounded]="true" [outlined]="true" size="small"></p-button>
|
||||
</div>
|
||||
<div class="details">
|
||||
<p><strong>Publisher:</strong> {{ book?.metadata?.publisher || 'N/A' }}</p>
|
||||
<p><strong>Published:</strong> {{ book?.metadata?.publishedDate || 'Unknown' }}</p>
|
||||
<p><strong>Language:</strong> {{ book?.metadata?.language || 'Unknown' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="book-description">
|
||||
<p [innerHTML]="book?.metadata?.description || 'No description available.'"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,88 @@
|
||||
.book-metadata-container {
|
||||
height: calc(100vh - 10rem); /* Full height minus header and footer */
|
||||
overflow-y: auto; /* Enable vertical scrolling */
|
||||
transition: transform 0.2s, left 0.2s; /* Smooth transition for movements */
|
||||
background-color: var(--surface-card);
|
||||
border-radius: 12px;
|
||||
padding: 1.5rem 2rem; /* Adjust padding */
|
||||
}
|
||||
|
||||
.book-metadata {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.book-header {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.cover-container {
|
||||
max-width: 200px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.book-cover {
|
||||
width: 100%;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.metadata {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.title-row {
|
||||
display: flex;
|
||||
justify-content: space-between; /* Ensures title and buttons are spaced out */
|
||||
align-items: center;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-size: 1.65rem;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 1.5rem; /* Spacing between buttons */
|
||||
}
|
||||
|
||||
.p-button-sm {
|
||||
font-size: 0.8rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.p-button-text {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.author {
|
||||
font-size: 1.1rem;
|
||||
color: var(--text-color-secondary);
|
||||
margin: 9px 0;
|
||||
}
|
||||
|
||||
.categories {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.category {
|
||||
background-color: var(--text-color);
|
||||
color: #555;
|
||||
font-size: 0.8rem;
|
||||
padding: 4px 8px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.details p {
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
.book-description {
|
||||
margin-top: 16px;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import {Component, OnInit, OnDestroy} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {BookService} from '../book/service/book.service';
|
||||
import {Book} from '../book/model/book.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {BooksMetadataDialogComponent} from '../books-metadata-dialog/books-metadata-dialog.component';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {TagModule} from 'primeng/tag';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-metadata',
|
||||
templateUrl: './book-metadata.component.html',
|
||||
styleUrls: ['./book-metadata.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
NgForOf,
|
||||
TagModule
|
||||
]
|
||||
})
|
||||
export class BookMetadataComponent implements OnInit, OnDestroy {
|
||||
book: Book | null = null;
|
||||
private routeSubscription!: Subscription;
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
constructor(
|
||||
private bookService: BookService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private dialogService: DialogService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.routeSubscription = this.activatedRoute.paramMap.subscribe((paramMap) => {
|
||||
const bookId = +paramMap.get('bookId')!;
|
||||
if (bookId) {
|
||||
this.loadBook(bookId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private loadBook(bookId: number): void {
|
||||
this.bookService.getBook(bookId).subscribe((book) => {
|
||||
this.book = book;
|
||||
});
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
openEditDialog(id: number | undefined) {
|
||||
this.ref = this.dialogService.open(BooksMetadataDialogComponent, {
|
||||
header: 'Fetch Metadata (from Google Books)',
|
||||
modal: false,
|
||||
width: '65%',
|
||||
height: '85%',
|
||||
data: {
|
||||
bookId: id,
|
||||
bookTitle: this.book?.metadata.title,
|
||||
},
|
||||
});
|
||||
|
||||
this.ref.onClose.subscribe(() => {
|
||||
// @ts-ignore
|
||||
this.loadBook(this.book?.id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
coverImageSrc(bookId: any): string {
|
||||
if (bookId === null) {
|
||||
return 'assets/placeholder.png';
|
||||
}
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.routeSubscription) {
|
||||
this.routeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
readBook(id: number | undefined) {
|
||||
const url = `/pdf-viewer/book/${id}`;
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<div *ngIf="!isLoading && bookMetadataList.length > 0" class="search-container">
|
||||
<div class="input-group">
|
||||
<input type="text" [(ngModel)]="searchText" placeholder="Enter book title" />
|
||||
<p-button severity="success" (click)="populateTitle()">Search</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="isLoading" class="loading">
|
||||
Loading metadata...
|
||||
</div>
|
||||
|
||||
<div *ngIf="errorMessage" class="error">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<div *ngIf="!isLoading && bookMetadataList.length > 0" class="metadata-list">
|
||||
<div *ngFor="let metadata of bookMetadataList" class="book-metadata">
|
||||
<div class="metadata-header">
|
||||
<div class="book-image-container">
|
||||
<img class="book-image" src="{{ metadata.thumbnail }}" alt="Book Cover" />
|
||||
<p-button class="select-button" (click)="selectMetadata(metadata)">Select</p-button>
|
||||
</div>
|
||||
<div>
|
||||
<h3>{{ metadata.title }}</h3>
|
||||
<p><strong>Authors:</strong> {{ metadata.authors?.join(', ') || 'No authors available' }}</p>
|
||||
<p><strong>Publisher:</strong> {{ metadata.publisher }}</p>
|
||||
<p><strong>Published Date:</strong> {{ metadata.publishedDate }}</p>
|
||||
<p><strong>ISBN:</strong> {{ metadata.isbn10 }}</p>
|
||||
<p><strong>Description:</strong> {{ truncateDescription(metadata.description) }}</p>
|
||||
<p><strong>Page Count:</strong> {{ metadata.pageCount }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="!isLoading && bookMetadataList.length === 0" class="no-metadata">
|
||||
No metadata found for this book.
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
.search-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px; /* Add space between the text box and button */
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
padding: 10px;
|
||||
font-size: 1rem;
|
||||
width: 90%; /* Adjust width as necessary */
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 15px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.metadata-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.metadata-header {
|
||||
display: flex;
|
||||
gap: 20px; /* Space between image and text */
|
||||
}
|
||||
|
||||
.book-image {
|
||||
width: 100px; /* Adjust the width as needed */
|
||||
height: 150px; /* Adjust the height as needed */
|
||||
object-fit: cover; /* Ensure the image covers the area without distorting */
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px; /* Add spacing between the image and the button */
|
||||
}
|
||||
|
||||
.select-button {
|
||||
width: auto; /* Button width adjusts to content */
|
||||
padding: 8px 15px; /* Adjust the button padding */
|
||||
margin-top: 10px; /* Space between the image and button */
|
||||
text-align: center; /* Ensure text is centered in the button */
|
||||
}
|
||||
|
||||
.book-metadata {
|
||||
background-color: var(--surface-50);
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.5rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 5px 0;
|
||||
color: var(--text-color-secondary);
|
||||
font-size: 1.0rem;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 15px;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
transition: background-color 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {BookMetadata} from '../book/model/book.model';
|
||||
import {BookService} from '../book/service/book.service';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {FormBuilder, FormsModule} from '@angular/forms';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Router} from '@angular/router';
|
||||
import {Button} from 'primeng/button';
|
||||
|
||||
@Component({
|
||||
selector: 'app-books-metadata-dialog',
|
||||
templateUrl: './books-metadata-dialog.component.html',
|
||||
imports: [
|
||||
NgIf,
|
||||
NgForOf,
|
||||
FormsModule,
|
||||
Button
|
||||
],
|
||||
styleUrls: ['./books-metadata-dialog.component.scss']
|
||||
})
|
||||
export class BooksMetadataDialogComponent implements OnInit {
|
||||
bookMetadataList: BookMetadata[] = [];
|
||||
isLoading = true;
|
||||
errorMessage: string | null = null;
|
||||
searchText: string = '';
|
||||
bookId: number = 0;
|
||||
|
||||
constructor(private bookService: BookService, public dynamicDialogConfig: DynamicDialogConfig,
|
||||
private dynamicDialogRef: DynamicDialogRef, private router: Router) {
|
||||
this.searchText = dynamicDialogConfig.data.bookTitle;
|
||||
this.bookId = this.dynamicDialogConfig.data.bookId;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookService.fetchBookMetadataByBookId(this.bookId).subscribe({
|
||||
next: (metadataList) => {
|
||||
this.bookMetadataList = metadataList;
|
||||
this.isLoading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
this.errorMessage = 'Failed to load metadata';
|
||||
this.isLoading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
selectMetadata(metadata: BookMetadata): void {
|
||||
this.bookService.setBookMetadata(metadata.googleBookId, this.bookId).subscribe({
|
||||
next: () => {
|
||||
this.dynamicDialogRef.close();
|
||||
this.router.navigate(['/book', this.bookId, 'info']);
|
||||
},
|
||||
error: (error) => {
|
||||
this.errorMessage = 'Failed to save book metadata';
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
truncateDescription(description: string): string {
|
||||
const maxLength = 1500;
|
||||
return description && description.length > maxLength ? description.substring(0, maxLength) + '...' : description;
|
||||
}
|
||||
|
||||
populateTitle() {
|
||||
this.bookService.fetchBookMetadataByTerm(this.searchText).subscribe({
|
||||
next: (metadataList) => {
|
||||
this.bookMetadataList = metadataList;
|
||||
this.isLoading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
this.errorMessage = 'Failed to load metadata';
|
||||
this.isLoading = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<button
|
||||
class="p-link layout-topbar-button"
|
||||
[ngClass]="{'glowing-icon': glowing}">
|
||||
<i class="pi pi-bolt"></i>
|
||||
<span>Progress</span>
|
||||
</button>
|
||||
@@ -0,0 +1,3 @@
|
||||
.glowing-icon {
|
||||
color: yellow;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import {Component, OnInit, OnDestroy} from '@angular/core';
|
||||
import {BookProgressService} from '../book/service/book-progress-service';
|
||||
import {BookUpdateEvent} from '../book/model/book-update-event.model';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {NgClass} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-notification',
|
||||
templateUrl: './notification.component.html',
|
||||
imports: [
|
||||
NgClass
|
||||
],
|
||||
styleUrls: ['./notification.component.scss']
|
||||
})
|
||||
export class NotificationComponent implements OnInit, OnDestroy {
|
||||
glowing: boolean = false;
|
||||
private eventSubscription!: Subscription;
|
||||
|
||||
constructor(private bookProgressService: BookProgressService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
/*this.eventSubscription = this.bookProgressService.connect(1).subscribe({
|
||||
next: (event: BookUpdateEvent) => {
|
||||
this.handleNewNotification(event);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error receiving progress updates:', error);
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
handleNewNotification(event: BookUpdateEvent): void {
|
||||
this.glowing = true;
|
||||
setTimeout(() => {
|
||||
this.glowing = false;
|
||||
console.log("reset")
|
||||
}, 200);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.eventSubscription) {
|
||||
this.eventSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user