Implement support for comic book files (CBZ, CBR and CB7)
This commit is contained in:
committed by
Aditya Chandel
parent
25ee510379
commit
ff64362edb
@@ -15,6 +15,7 @@ import {SetupRedirectGuard} from './core/setup/setup-redirect.guard';
|
||||
import {EmptyComponent} from './core/empty/empty.component';
|
||||
import {LoginGuard} from './core/setup/ login.guard';
|
||||
import {OidcCallbackComponent} from './core/security/oidc-callback/oidc-callback.component';
|
||||
import {CbxReaderComponent} from './book/components/cbx-reader/cbx-reader.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
@@ -52,6 +53,11 @@ export const routes: Routes = [
|
||||
component: EpubViewerComponent,
|
||||
canActivate: [AuthGuard]
|
||||
},
|
||||
{
|
||||
path: 'cbx-viewer/book/:bookId',
|
||||
component: CbxReaderComponent,
|
||||
canActivate: [AuthGuard]
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
component: LoginComponent,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<div class="comic-reader-container">
|
||||
<div class="navigation">
|
||||
<div class="page-controls">
|
||||
<button (click)="previousPage()" [disabled]="currentPage === 0">←</button>
|
||||
<span>
|
||||
Page {{ currentPage + 1 }}{{ isTwoPageView && imageUrls.length > 1 ? '-' + (currentPage + 2) : '' }} of {{ pages.length }}
|
||||
</span>
|
||||
<button (click)="nextPage()" [disabled]="currentPage >= pages.length - 1">→</button>
|
||||
</div>
|
||||
<div class="spread-controls">
|
||||
<button *ngIf="isTwoPageView" (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
|
||||
{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}
|
||||
</button>
|
||||
<button (click)="toggleView()" title="Toggle View">
|
||||
{{ isTwoPageView ? '1️⃣' : '2️⃣' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="image-container" [class.two-page-view]="isTwoPageView">
|
||||
<ng-container *ngIf="!isLoading; else loading">
|
||||
<ng-container *ngIf="pages.length > 0; else noPages">
|
||||
<img *ngFor="let url of imageUrls" [src]="url" alt="Comic Page"/>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
<ng-template #noPages>
|
||||
<p>No pages available.</p>
|
||||
</ng-template>
|
||||
<ng-template #loading>
|
||||
<div style="display: flex; justify-content: center; align-items: center; height: 100%;">
|
||||
<p-progressSpinner></p-progressSpinner>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,96 @@
|
||||
.comic-reader-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
|
||||
.navigation {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin: 1rem;
|
||||
|
||||
.page-controls {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
|
||||
span {
|
||||
min-width: 8rem;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
button {
|
||||
min-width: 3rem;
|
||||
padding: 0 0.5rem;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.spread-controls {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
|
||||
button {
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.image-container {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
overflow: hidden;
|
||||
padding: 0 1rem;
|
||||
box-sizing: border-box;
|
||||
|
||||
&.two-page-view {
|
||||
img {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.two-page-view) {
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
max-height: 100%;
|
||||
height: auto;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
||||
flex-shrink: 1;
|
||||
margin: 0;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import {Component, HostListener, inject, OnInit} from '@angular/core';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {CbxReaderService} from '../../service/cbx-reader.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {forkJoin} from 'rxjs';
|
||||
import {BookSetting, CbxPageSpread, CbxPageViewMode} from '../../model/book.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-reader',
|
||||
standalone: true,
|
||||
imports: [NgIf, NgFor, ProgressSpinner],
|
||||
templateUrl: './cbx-reader.component.html',
|
||||
styleUrl: './cbx-reader.component.scss'
|
||||
})
|
||||
export class CbxReaderComponent implements OnInit {
|
||||
bookId!: number;
|
||||
pages: number[] = [];
|
||||
currentPage = 0;
|
||||
isLoading = true;
|
||||
|
||||
pageSpread: CbxPageSpread = CbxPageSpread.ODD;
|
||||
pageViewMode: CbxPageViewMode = CbxPageViewMode.SINGLE_PAGE;
|
||||
|
||||
private touchStartX = 0;
|
||||
private touchEndX = 0;
|
||||
|
||||
private route = inject(ActivatedRoute);
|
||||
private cbxReaderService = inject(CbxReaderService);
|
||||
private bookService = inject(BookService);
|
||||
private userService = inject(UserService);
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
ngOnInit() {
|
||||
this.route.paramMap.subscribe((params) => {
|
||||
this.isLoading = true;
|
||||
this.bookId = +params.get('bookId')!;
|
||||
|
||||
forkJoin([
|
||||
this.bookService.getBookByIdFromAPI(this.bookId, false),
|
||||
this.bookService.getBookSetting(this.bookId),
|
||||
this.userService.getMyself(),
|
||||
this.cbxReaderService.getAvailablePages(this.bookId)
|
||||
]).subscribe({
|
||||
next: ([cbxMeta, bookSettings, myself, pages]) => {
|
||||
const userSettings = myself.userSettings;
|
||||
const global = userSettings.perBookSetting.cbx === 'Global';
|
||||
|
||||
this.pageViewMode = global
|
||||
? userSettings.cbxReaderSetting.pageViewMode || CbxPageViewMode.SINGLE_PAGE
|
||||
: bookSettings.cbxSettings?.pageViewMode || userSettings.cbxReaderSetting.pageViewMode || CbxPageViewMode.SINGLE_PAGE;
|
||||
|
||||
this.pageSpread = global
|
||||
? userSettings.cbxReaderSetting.pageSpread || CbxPageSpread.ODD
|
||||
: bookSettings.cbxSettings?.pageSpread || userSettings.cbxReaderSetting.pageSpread || CbxPageSpread.ODD;
|
||||
|
||||
this.pages = pages;
|
||||
this.currentPage = (cbxMeta.cbxProgress?.page || 1) - 1;
|
||||
this.alignCurrentPageToParity();
|
||||
this.isLoading = false;
|
||||
},
|
||||
error: (err) => {
|
||||
const errorMessage = err?.error?.message || 'Failed to load the book';
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: errorMessage});
|
||||
this.isLoading = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
get isTwoPageView(): boolean {
|
||||
return this.pageViewMode === CbxPageViewMode.TWO_PAGE;
|
||||
}
|
||||
|
||||
toggleView() {
|
||||
if (!this.isTwoPageView && this.isPhonePortrait()) return;
|
||||
this.pageViewMode = this.isTwoPageView ? CbxPageViewMode.SINGLE_PAGE : CbxPageViewMode.TWO_PAGE;
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleSpreadDirection() {
|
||||
this.pageSpread = this.pageSpread === CbxPageSpread.ODD ? CbxPageSpread.EVEN : CbxPageSpread.ODD;
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
nextPage() {
|
||||
if (this.isTwoPageView) {
|
||||
this.currentPage += (this.currentPage < this.pages.length - 2) ? 2 : 1;
|
||||
} else if (this.currentPage < this.pages.length - 1) {
|
||||
this.currentPage++;
|
||||
}
|
||||
this.updateProgress();
|
||||
}
|
||||
|
||||
previousPage() {
|
||||
if (this.isTwoPageView) {
|
||||
this.currentPage = Math.max(0, this.currentPage - 2);
|
||||
} else {
|
||||
this.currentPage = Math.max(0, this.currentPage - 1);
|
||||
}
|
||||
this.updateProgress();
|
||||
}
|
||||
|
||||
private alignCurrentPageToParity() {
|
||||
if (!this.pages.length || !this.isTwoPageView) return;
|
||||
|
||||
const desiredOdd = this.pageSpread === CbxPageSpread.ODD;
|
||||
for (let i = this.currentPage; i >= 0; i--) {
|
||||
if ((this.pages[i] % 2 === 1) === desiredOdd) {
|
||||
this.currentPage = i;
|
||||
this.updateProgress();
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < this.pages.length; i++) {
|
||||
if ((this.pages[i] % 2 === 1) === desiredOdd) {
|
||||
this.currentPage = i;
|
||||
this.updateProgress();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('window:keydown', ['$event'])
|
||||
handleKeyDown(event: KeyboardEvent) {
|
||||
if (event.key === 'ArrowRight') this.nextPage();
|
||||
else if (event.key === 'ArrowLeft') this.previousPage();
|
||||
}
|
||||
|
||||
@HostListener('touchstart', ['$event'])
|
||||
onTouchStart(event: TouchEvent) {
|
||||
this.touchStartX = event.changedTouches[0].screenX;
|
||||
}
|
||||
|
||||
@HostListener('touchend', ['$event'])
|
||||
onTouchEnd(event: TouchEvent) {
|
||||
this.touchEndX = event.changedTouches[0].screenX;
|
||||
this.handleSwipeGesture();
|
||||
}
|
||||
|
||||
@HostListener('window:resize')
|
||||
onResize() {
|
||||
this.enforcePortraitSinglePageView();
|
||||
}
|
||||
|
||||
private handleSwipeGesture() {
|
||||
const delta = this.touchEndX - this.touchStartX;
|
||||
if (Math.abs(delta) >= 50) delta < 0 ? this.nextPage() : this.previousPage();
|
||||
}
|
||||
|
||||
private enforcePortraitSinglePageView() {
|
||||
if (this.isPhonePortrait() && this.isTwoPageView) {
|
||||
this.pageViewMode = CbxPageViewMode.SINGLE_PAGE;
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
}
|
||||
|
||||
private isPhonePortrait(): boolean {
|
||||
return window.innerWidth < 768 && window.innerHeight > window.innerWidth;
|
||||
}
|
||||
|
||||
get imageUrls(): string[] {
|
||||
if (!this.pages.length) return [];
|
||||
|
||||
const urls = [this.cbxReaderService.getPageImageUrl(this.bookId, this.pages[this.currentPage])];
|
||||
if (this.isTwoPageView && this.currentPage + 1 < this.pages.length) {
|
||||
urls.push(this.cbxReaderService.getPageImageUrl(this.bookId, this.pages[this.currentPage + 1]));
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
private updateViewerSetting(): void {
|
||||
const bookSetting: BookSetting = {
|
||||
cbxSettings: {
|
||||
pageSpread: this.pageSpread,
|
||||
pageViewMode: this.pageViewMode,
|
||||
}
|
||||
}
|
||||
this.bookService.updateViewerSetting(bookSetting, this.bookId).subscribe();
|
||||
}
|
||||
|
||||
updateProgress(): void {
|
||||
const percentage = this.pages.length > 0
|
||||
? Math.round(((this.currentPage + 1) / this.pages.length) * 1000) / 10
|
||||
: 0;
|
||||
|
||||
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -129,28 +129,7 @@
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<ng-container *ngIf="recommendedBooks.length > 0">
|
||||
<div>
|
||||
<h3 class="text-xl font-semibold">Similar Books</h3>
|
||||
<div class="dashboard-scroller-infinite"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
[horizontal]="true">
|
||||
<div class="dashboard-scroller-card" *ngFor="let book of recommendedBooks">
|
||||
<app-book-card
|
||||
[book]="book.book"
|
||||
[isCheckboxEnabled]="false"
|
||||
[readButtonHidden]="true"
|
||||
[bottomBarHidden]="true">
|
||||
</app-book-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="bookInSeries.length > 0">
|
||||
<p-divider></p-divider>
|
||||
<div>
|
||||
<h3 class="text-xl font-semibold pt-2">More in the Series</h3>
|
||||
<div class="dashboard-scroller-infinite"
|
||||
@@ -171,5 +150,26 @@
|
||||
<p-divider></p-divider>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="recommendedBooks.length > 0">
|
||||
<div>
|
||||
<h3 class="text-xl font-semibold">Similar Books</h3>
|
||||
<div class="dashboard-scroller-infinite"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
[horizontal]="true">
|
||||
<div class="dashboard-scroller-card" *ngFor="let book of recommendedBooks">
|
||||
<app-book-card
|
||||
[book]="book.book"
|
||||
[isCheckboxEnabled]="false"
|
||||
[readButtonHidden]="true"
|
||||
[bottomBarHidden]="true">
|
||||
</app-book-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p-divider></p-divider>
|
||||
</ng-container>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+32
-9
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, Input, OnInit, OnChanges, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {Button, ButtonDirective} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
||||
import {first, Observable} from 'rxjs';
|
||||
@@ -31,10 +31,11 @@ import {ProgressBar} from 'primeng/progressbar';
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit {
|
||||
export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
@Input() book: Book | undefined;
|
||||
@Input() recommendedBooks: BookRecommendation[] = [];
|
||||
private originalRecommendedBooks: BookRecommendation[] = [];
|
||||
|
||||
@ViewChild(Editor) quillEditor!: Editor;
|
||||
|
||||
@@ -81,7 +82,7 @@ export class MetadataViewerComponent implements OnInit {
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((metadata) => {
|
||||
if (metadata) {
|
||||
this.getBooksInSeries(metadata.bookId);
|
||||
this.loadBooksInSeriesAndFilterRecommended(metadata.bookId);
|
||||
if (this.quillEditor && this.quillEditor.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
}
|
||||
@@ -89,14 +90,34 @@ export class MetadataViewerComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
toggleExpand(): void {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
private loadBooksInSeriesAndFilterRecommended(bookId: number): void {
|
||||
this.bookService.getBooksInSeries(bookId).subscribe((bookInSeries) => {
|
||||
bookInSeries.sort((a, b) => (a.metadata?.seriesNumber ?? 0) - (b.metadata?.seriesNumber ?? 0));
|
||||
this.bookInSeries = bookInSeries;
|
||||
this.originalRecommendedBooks = [...this.recommendedBooks];
|
||||
this.filterRecommendations();
|
||||
});
|
||||
}
|
||||
|
||||
getBooksInSeries(bookId: number): void {
|
||||
this.bookService.getBooksInSeries(bookId).subscribe((bookInSeries) => {
|
||||
this.bookInSeries = bookInSeries;
|
||||
});
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['recommendedBooks']) {
|
||||
this.originalRecommendedBooks = [...this.recommendedBooks];
|
||||
this.filterRecommendations();
|
||||
}
|
||||
}
|
||||
|
||||
private filterRecommendations(): void {
|
||||
if (!this.originalRecommendedBooks) {
|
||||
return;
|
||||
}
|
||||
const bookInSeriesIds = new Set(this.bookInSeries.map(book => book.id));
|
||||
this.recommendedBooks = this.originalRecommendedBooks.filter(
|
||||
rec => !bookInSeriesIds.has(rec.book.id)
|
||||
);
|
||||
}
|
||||
|
||||
toggleExpand(): void {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
|
||||
read(bookId: number): void {
|
||||
@@ -168,6 +189,8 @@ export class MetadataViewerComponent implements OnInit {
|
||||
getProgressPercent(): number | undefined {
|
||||
if (this.book?.bookType === 'PDF') {
|
||||
return this.book.pdfProgress?.percentage;
|
||||
} else if(this.book?.bookType === 'CBX') {
|
||||
return this.book?.cbxProgress?.percentage;
|
||||
} else {
|
||||
return this.book?.epubProgress?.percentage;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Shelf} from './shelf.model';
|
||||
|
||||
export type BookType = "PDF" | "EPUB";
|
||||
export type BookType = "PDF" | "EPUB" | "CBX";
|
||||
|
||||
export interface Book {
|
||||
id: number;
|
||||
@@ -12,6 +12,7 @@ export interface Book {
|
||||
addedOn?: string;
|
||||
epubProgress?: EpubProgress;
|
||||
pdfProgress?: PdfProgress;
|
||||
cbxProgress?: CbxProgress;
|
||||
filePath?: string;
|
||||
fileSizeKb?: number;
|
||||
}
|
||||
@@ -26,6 +27,11 @@ export interface PdfProgress {
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface CbxProgress {
|
||||
page: number;
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface BookMetadata {
|
||||
bookId: number;
|
||||
title: string;
|
||||
@@ -102,9 +108,15 @@ export interface EpubViewerSetting {
|
||||
flow: string;
|
||||
}
|
||||
|
||||
export interface CbxViewerSetting {
|
||||
pageSpread: CbxPageSpread;
|
||||
pageViewMode: CbxPageViewMode;
|
||||
}
|
||||
|
||||
export interface BookSetting {
|
||||
pdfSettings?: PdfViewerSetting;
|
||||
epubSettings?: EpubViewerSetting;
|
||||
cbxSettings?: CbxViewerSetting;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
@@ -113,3 +125,13 @@ export interface BookRecommendation {
|
||||
book: Book;
|
||||
similarityScore: number;
|
||||
}
|
||||
|
||||
export const enum CbxPageViewMode {
|
||||
SINGLE_PAGE = 'SINGLE_PAGE',
|
||||
TWO_PAGE = 'TWO_PAGE',
|
||||
}
|
||||
|
||||
export const enum CbxPageSpread {
|
||||
EVEN = 'EVEN',
|
||||
ODD = 'ODD',
|
||||
}
|
||||
|
||||
@@ -128,6 +128,10 @@ export class BookService {
|
||||
const url = `/epub-viewer/book/${book.id}`;
|
||||
window.open(url, '_blank');
|
||||
this.updateLastReadTime(book.id);
|
||||
} else if (book.bookType === "CBX") {
|
||||
const url = `/cbx-viewer/book/${book.id}`;
|
||||
window.open(url, '_blank');
|
||||
this.updateLastReadTime(book.id);
|
||||
} else {
|
||||
console.error('Unsupported book type:', book.bookType);
|
||||
}
|
||||
@@ -207,6 +211,17 @@ export class BookService {
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
saveCbxProgress(bookId: number, page: number, percentage: number): Observable<void> {
|
||||
const body = {
|
||||
bookId: bookId,
|
||||
cbxProgress: {
|
||||
page: page,
|
||||
percentage: percentage
|
||||
}
|
||||
};
|
||||
return this.http.post<void>(`${this.url}/progress`, body);
|
||||
}
|
||||
|
||||
regenerateCovers(): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/regenerate-covers`, {});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CbxReaderService {
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/cbx`;
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getAvailablePages(bookId: number) {
|
||||
return this.http.get<number[]>(`${this.url}/${bookId}/pages`);
|
||||
}
|
||||
|
||||
getPageImageUrl(bookId: number, page: number): string {
|
||||
return `${this.url}/${bookId}/pages/${page}`;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ export interface AppSettings {
|
||||
oidcEnabled: boolean;
|
||||
oidcProviderDetails: OidcProviderDetails;
|
||||
oidcAutoProvisionDetails: OidcAutoProvisionDetails;
|
||||
cbxCacheSizeInMb: number;
|
||||
maxFileUploadSizeInMb: number;
|
||||
}
|
||||
|
||||
export enum AppSettingKey {
|
||||
@@ -40,5 +42,7 @@ export enum AppSettingKey {
|
||||
OPDS_SERVER_ENABLED = 'OPDS_SERVER_ENABLED',
|
||||
OIDC_ENABLED = 'OIDC_ENABLED',
|
||||
OIDC_PROVIDER_DETAILS = 'OIDC_PROVIDER_DETAILS',
|
||||
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS'
|
||||
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS',
|
||||
CBX_CACHE_SIZE_IN_MB = 'CBX_CACHE_SIZE_IN_MB',
|
||||
MAX_FILE_UPLOAD_SIZE_IN_MB = 'MAX_FILE_UPLOAD_SIZE_IN_MB'
|
||||
}
|
||||
|
||||
@@ -13,14 +13,13 @@
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class=" py-1">Resolution:
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Specifies the resolution of the generated cover image. Higher resolutions result in sharper images but may increase file size. This setting will apply to future books, or else use 'Regenerate' button."
|
||||
pTooltip="Sets the resolution for generated cover images. Higher resolutions produce sharper covers but increase file size. Applies only to future books unless covers are regenerated."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="resolutionOptions"
|
||||
[(ngModel)]="selectedResolution"
|
||||
(ngModelChange)="onResolutionChange()"
|
||||
@@ -30,7 +29,7 @@
|
||||
|
||||
<p class=" py-1">Regenerate Covers?
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="This option will regenerate the covers for all EPUB and PDF books (except locked ones) using the selected resolution."
|
||||
pTooltip="Regenerates cover images for all EPUB and PDF books (excluding locked ones) using the selected resolution."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
@@ -50,7 +49,7 @@
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">Auto Book Search
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="If enabled, Booklore will automatically perform a metadata match/search when the book information tab is opened."
|
||||
pTooltip="Automatically attempts metadata matching when the book information panel is opened."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
@@ -68,7 +67,7 @@
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">Similar Book Recommendation
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enable or disable similar book recommendations entirely."
|
||||
pTooltip="Enables or disables similar book recommendations based on your library."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
@@ -89,6 +88,55 @@
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-11 p-4">
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">Max File Upload Size:
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Defines the maximum allowed size (in MB) for each uploaded file. Applies to EPUB, PDF, CBZ, CBR, and CB7 formats."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 items-center">
|
||||
<div class="relative w-28">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="maxFileUploadSizeInMb"
|
||||
class="pr-10 w-full"
|
||||
placeholder="Max size"/>
|
||||
<span class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 text-sm pointer-events-none">MB</span>
|
||||
</div>
|
||||
<p-button label="Save" outlined (onClick)="saveFileSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">CBX Cache Size:
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Limits the total size (in MB) of the CBX image cache. If exceeded, older cache entries are removed automatically."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 items-center">
|
||||
<div class="relative w-28">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="cbxCacheValue"
|
||||
class="pr-10 w-full"
|
||||
placeholder="Cache size"/>
|
||||
<span class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 text-sm pointer-events-none">MB</span>
|
||||
</div>
|
||||
<p-button label="Save" outlined (onClick)="saveCacheSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-2 pb-4">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<app-opds-settings></app-opds-settings>
|
||||
</div>
|
||||
@@ -114,7 +162,8 @@
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)"
|
||||
[currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ import {MetadataAdvancedFetchOptionsComponent} from '../../book/metadata/metadat
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {FileUploadPatternComponent} from './file-upload-pattern/file-upload-pattern.component';
|
||||
import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-preferences',
|
||||
@@ -32,7 +33,8 @@ import {OpdsSettingsComponent} from './opds-settings/opds-settings.component';
|
||||
FormsModule,
|
||||
MetadataAdvancedFetchOptionsComponent,
|
||||
FileUploadPatternComponent,
|
||||
OpdsSettingsComponent
|
||||
OpdsSettingsComponent,
|
||||
InputText
|
||||
],
|
||||
templateUrl: './global-preferences.component.html',
|
||||
styleUrl: './global-preferences.component.scss'
|
||||
@@ -59,6 +61,8 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
cbxCacheValue?: number;
|
||||
maxFileUploadSizeInMb?: number;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$.pipe(
|
||||
@@ -68,9 +72,15 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
if (settings?.coverResolution) {
|
||||
this.selectedResolution = settings.coverResolution;
|
||||
}
|
||||
if (settings.metadataRefreshOptions) {
|
||||
if (settings?.metadataRefreshOptions) {
|
||||
this.currentMetadataOptions = settings.metadataRefreshOptions;
|
||||
}
|
||||
if (settings?.cbxCacheSizeInMb) {
|
||||
this.cbxCacheValue = settings.cbxCacheSizeInMb;
|
||||
}
|
||||
if (settings?.maxFileUploadSizeInMb) {
|
||||
this.maxFileUploadSizeInMb = settings.maxFileUploadSizeInMb;
|
||||
}
|
||||
this.toggles.autoBookSearch = settings.autoBookSearch ?? false;
|
||||
this.toggles.similarBookRecommendation = settings.similarBookRecommendation ?? false;
|
||||
});
|
||||
@@ -98,6 +108,23 @@ export class GlobalPreferencesComponent implements OnInit {
|
||||
this.saveSetting(AppSettingKey.QUICK_BOOK_MATCH, metadataRefreshOptions);
|
||||
}
|
||||
|
||||
saveCacheSize(): void {
|
||||
if (!this.cbxCacheValue || this.cbxCacheValue <= 0) {
|
||||
this.showMessage('error', 'Invalid Input', 'Please enter a valid cache size in MB.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saveSetting(AppSettingKey.CBX_CACHE_SIZE_IN_MB, this.cbxCacheValue);
|
||||
}
|
||||
|
||||
saveFileSize() {
|
||||
if (!this.maxFileUploadSizeInMb || this.maxFileUploadSizeInMb <= 0) {
|
||||
this.showMessage('error', 'Invalid Input', 'Please enter a valid max file upload size in MB.');
|
||||
return;
|
||||
}
|
||||
this.saveSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, this.maxFileUploadSizeInMb);
|
||||
}
|
||||
|
||||
regenerateCovers(): void {
|
||||
this.bookService.regenerateCovers().subscribe({
|
||||
next: () =>
|
||||
|
||||
@@ -5,6 +5,7 @@ import {API_CONFIG} from '../../config/api-config';
|
||||
import {RxStompService} from '../../shared/websocket/rx-stomp.service';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {CbxPageSpread, CbxPageViewMode} from '../../book/model/book.model';
|
||||
|
||||
export interface SidebarLibrarySorting {
|
||||
field: string;
|
||||
@@ -19,6 +20,7 @@ export interface SidebarShelfSorting {
|
||||
export interface PerBookSetting {
|
||||
pdf: string;
|
||||
epub: string;
|
||||
cbx: string;
|
||||
}
|
||||
|
||||
export type PageSpread = 'off' | 'even' | 'odd';
|
||||
@@ -36,10 +38,16 @@ export interface EpubReaderSetting {
|
||||
flow: string;
|
||||
}
|
||||
|
||||
export interface CbxReaderSetting {
|
||||
pageSpread: CbxPageSpread;
|
||||
pageViewMode: CbxPageViewMode;
|
||||
}
|
||||
|
||||
export interface UserSettings {
|
||||
perBookSetting: PerBookSetting;
|
||||
pdfReaderSetting: PdfReaderSetting;
|
||||
epubReaderSetting: EpubReaderSetting;
|
||||
cbxReaderSetting: CbxReaderSetting;
|
||||
sidebarLibrarySorting: SidebarLibrarySorting;
|
||||
sidebarShelfSorting: SidebarShelfSorting
|
||||
}
|
||||
|
||||
@@ -38,6 +38,20 @@
|
||||
<label [for]="item">{{ item }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="py-1">CBX:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let item of scopeOptions" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="item"
|
||||
name="spread"
|
||||
[value]="item"
|
||||
[(ngModel)]="selectedCbxScope"
|
||||
(ngModelChange)="onCbxScopeChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="item">{{ item }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,12 +111,13 @@
|
||||
<p>Theme:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="themes"
|
||||
[(ngModel)]="selectedTheme"
|
||||
optionLabel="name"
|
||||
optionValue="key"
|
||||
placeholder="Select a Theme"
|
||||
class="w-full md:w-56"
|
||||
class="w-full md:w-32"
|
||||
(ngModelChange)="onThemeChange()">
|
||||
</p-select>
|
||||
</div>
|
||||
@@ -110,12 +125,13 @@
|
||||
<p>Font:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="fonts"
|
||||
[(ngModel)]="selectedFont"
|
||||
optionLabel="name"
|
||||
optionValue="key"
|
||||
placeholder="Select a Font"
|
||||
class="w-full md:w-56"
|
||||
class="w-full md:w-32"
|
||||
(ngModelChange)="onFontChange()">
|
||||
</p-select>
|
||||
</div>
|
||||
@@ -123,21 +139,64 @@
|
||||
<p>Flow:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="flowOptions"
|
||||
[(ngModel)]="selectedFlow"
|
||||
optionLabel="name"
|
||||
optionValue="key"
|
||||
placeholder="Select a Flow"
|
||||
class="w-full md:w-56"
|
||||
class="w-full md:w-32"
|
||||
(ngModelChange)="onFlowChange()">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="py-1">Font Size:</p>
|
||||
<div class="flex gap-4 justify-start items-center">
|
||||
<p-button icon="pi pi-minus" rounded="true" size="small" (click)="decreaseFontSize()"></p-button>
|
||||
<p-button icon="pi pi-minus" size="small" (click)="decreaseFontSize()"></p-button>
|
||||
<p>{{ fontSize }}%</p>
|
||||
<p-button icon="pi pi-plus" rounded="true" size="small" (click)="increaseFontSize()"></p-button>
|
||||
<p-button icon="pi pi-plus" size="small" (click)="increaseFontSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<div class="p-4">
|
||||
<p class="text-lg pb-6 pt-4 ">
|
||||
CBX Reader: Global Preferences
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Configure global PDF reading options such as page spread, zoom level, and sidebar visibility that apply to all PDFs."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;"></i>
|
||||
</p>
|
||||
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class="py-1">Page Spread:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let spread of cbxSpreads" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="spread.key"
|
||||
name="spread"
|
||||
[value]="spread.key"
|
||||
[(ngModel)]="selectedCbxSpread"
|
||||
(ngModelChange)="onCbxSpreadChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="spread.key">{{ spread.name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="py-1">Page Zoom:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let mode of cbxViewModes" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="mode.key"
|
||||
name="zoom"
|
||||
[value]="mode.key"
|
||||
[(ngModel)]="selectedCbxViewMode"
|
||||
(ngModelChange)="onCbxViewModeChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="mode.key">{{ mode.name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,6 +223,7 @@
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="sortingOptions"
|
||||
[(ngModel)]="selectedLibrarySorting"
|
||||
(ngModelChange)="onLibrarySortingChange()"
|
||||
@@ -180,6 +240,7 @@
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="sortingOptions"
|
||||
[(ngModel)]="selectedShelfSorting"
|
||||
(ngModelChange)="onShelfSortingChange()"
|
||||
|
||||
@@ -9,6 +9,7 @@ import {Button} from 'primeng/button';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {SidebarLibrarySorting, SidebarShelfSorting, User, UserService, UserSettings} from '../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {CbxPageSpread, CbxPageViewMode} from '../../book/model/book.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-preferences',
|
||||
@@ -19,10 +20,22 @@ import {MessageService} from 'primeng/api';
|
||||
})
|
||||
export class UserPreferences implements OnInit, OnDestroy {
|
||||
|
||||
|
||||
readonly cbxSpreads = [
|
||||
{name: 'Even', key: 'EVEN'},
|
||||
{name: 'Odd', key: 'ODD'}
|
||||
];
|
||||
|
||||
readonly cbxViewModes = [
|
||||
{name: 'Single Page', key: 'SINGLE_PAGE'},
|
||||
{name: 'Two Page', key: 'TWO_PAGE'},
|
||||
];
|
||||
|
||||
|
||||
readonly spreads = [
|
||||
{name: 'Even Spread', key: 'even'},
|
||||
{name: 'Odd Spread', key: 'odd'},
|
||||
{name: 'No Spread', key: 'off'}
|
||||
{name: 'Even', key: 'even'},
|
||||
{name: 'Odd', key: 'odd'},
|
||||
{name: 'None', key: 'off'}
|
||||
];
|
||||
|
||||
readonly zooms = [
|
||||
@@ -47,7 +60,7 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
{name: 'Monospace', key: 'monospace'}
|
||||
];
|
||||
|
||||
flowOptions = [
|
||||
readonly flowOptions = [
|
||||
{name: 'Paginated', key: 'paginated'},
|
||||
{name: 'Scrolled', key: 'scrolled'}
|
||||
];
|
||||
@@ -60,6 +73,11 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
];
|
||||
|
||||
readonly scopeOptions = ['Global', 'Individual'];
|
||||
|
||||
|
||||
selectedCbxSpread!: CbxPageSpread;
|
||||
selectedCbxViewMode!: CbxPageViewMode;
|
||||
|
||||
selectedSpread!: 'even' | 'odd' | 'off';
|
||||
selectedZoom!: string;
|
||||
selectedTheme!: string;
|
||||
@@ -67,8 +85,11 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
selectedFlow!: string;
|
||||
fontSize = 100;
|
||||
showSidebar = false;
|
||||
|
||||
selectedPdfScope!: string;
|
||||
selectedEpubScope!: string;
|
||||
selectedCbxScope!: string;
|
||||
|
||||
selectedLibrarySorting: SidebarLibrarySorting = {field: 'id', order: 'asc'};
|
||||
selectedShelfSorting: SidebarShelfSorting = {field: 'id', order: 'asc'};
|
||||
|
||||
@@ -95,13 +116,20 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
private loadPreferences(settings: UserSettings): void {
|
||||
this.selectedPdfScope = settings.perBookSetting.pdf;
|
||||
this.selectedEpubScope = settings.perBookSetting.epub;
|
||||
this.selectedCbxScope = settings.perBookSetting.cbx;
|
||||
|
||||
this.selectedSpread = settings.pdfReaderSetting.pageSpread;
|
||||
this.selectedZoom = settings.pdfReaderSetting.pageZoom;
|
||||
this.showSidebar = settings.pdfReaderSetting.showSidebar;
|
||||
|
||||
this.selectedTheme = settings.epubReaderSetting.theme;
|
||||
this.selectedFlow = settings.epubReaderSetting.flow;
|
||||
this.fontSize = settings.epubReaderSetting.fontSize;
|
||||
this.selectedFont = settings.epubReaderSetting.font;
|
||||
|
||||
this.selectedCbxSpread = settings.cbxReaderSetting.pageSpread;
|
||||
this.selectedCbxViewMode = settings.cbxReaderSetting.pageViewMode;
|
||||
|
||||
this.selectedLibrarySorting = settings.sidebarLibrarySorting;
|
||||
this.selectedShelfSorting = settings.sidebarShelfSorting;
|
||||
}
|
||||
@@ -145,6 +173,14 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
this.updatePreference(['pdfReaderSetting', 'pageSpread'], this.selectedSpread);
|
||||
}
|
||||
|
||||
onCbxSpreadChange() {
|
||||
this.updatePreference(['cbxReaderSetting', 'pageSpread'], this.selectedCbxSpread);
|
||||
}
|
||||
|
||||
onCbxViewModeChange() {
|
||||
this.updatePreference(['cbxReaderSetting', 'pageViewMode'], this.selectedCbxViewMode);
|
||||
}
|
||||
|
||||
onZoomChange() {
|
||||
this.updatePreference(['pdfReaderSetting', 'pageZoom'], this.selectedZoom);
|
||||
}
|
||||
@@ -157,6 +193,10 @@ export class UserPreferences implements OnInit, OnDestroy {
|
||||
this.updatePreference(['perBookSetting', 'epub'], this.selectedEpubScope);
|
||||
}
|
||||
|
||||
onCbxScopeChange() {
|
||||
this.updatePreference(['perBookSetting', 'cbx'], this.selectedCbxScope);
|
||||
}
|
||||
|
||||
onLibrarySortingChange() {
|
||||
this.updatePreference(['sidebarLibrarySorting'], this.selectedLibrarySorting);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
class="w-full"></p-select>
|
||||
|
||||
<p-fileupload class="w-full" name="file"
|
||||
maxFileSize="104857600"
|
||||
[maxFileSize]="maxFileSizeBytes"
|
||||
[customUpload]="true"
|
||||
[multiple]="true" accept=".pdf,.epub"
|
||||
[multiple]="true" accept=".pdf,.epub,.cbz,.cbr,.cb7"
|
||||
(onSelect)="onFilesSelect($event)"
|
||||
(uploadHandler)="uploadFiles($event)"
|
||||
[disabled]="!selectedLibrary || !selectedPath">
|
||||
@@ -101,7 +101,9 @@
|
||||
<div class="flex items-center justify-center flex-col text-center">
|
||||
<i class="pi pi-cloud-upload !border-2 !rounded-full !p-8 !text-4xl !text-muted-color"></i>
|
||||
<p class="mt-6 mb-2">Drag and drop files here to upload.</p>
|
||||
<p class="mt-2 mb-2">Only <strong>.epub</strong> and <strong>.pdf</strong> files are supported (max size: 100 MB per file).</p>
|
||||
<p class="mt-2 mb-2">
|
||||
Only <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, and <strong>.cb7</strong> files are supported (max size: 100 MB per file).
|
||||
</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-fileupload>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FileSelectEvent, FileUpload, FileUploadHandlerEvent} from 'primeng/fileupload';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgForOf, NgIf, NgSwitch, NgSwitchCase} from '@angular/common';
|
||||
@@ -14,6 +14,9 @@ import {API_CONFIG} from '../../../config/api-config';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {AppSettings} from '../../../core/model/app-settings.model';
|
||||
|
||||
interface UploadingFile {
|
||||
file: File;
|
||||
@@ -40,7 +43,7 @@ interface UploadingFile {
|
||||
templateUrl: './book-uploader.component.html',
|
||||
styleUrl: './book-uploader.component.scss'
|
||||
})
|
||||
export class BookUploaderComponent {
|
||||
export class BookUploaderComponent implements OnInit {
|
||||
files: UploadingFile[] = [];
|
||||
isUploading: boolean = false;
|
||||
selectedLibrary: Library | null = null;
|
||||
@@ -48,9 +51,23 @@ export class BookUploaderComponent {
|
||||
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
readonly libraryState$: Observable<LibraryState> = this.libraryService.libraryState$;
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
maxFileSizeBytes?: number;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$
|
||||
.pipe(
|
||||
filter(settings => settings != null),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(settings => {
|
||||
this.maxFileSizeBytes = (settings?.maxFileUploadSizeInMb ?? 100) * 1024 * 1024;
|
||||
});
|
||||
}
|
||||
|
||||
hasPendingFiles(): boolean {
|
||||
return this.files.some(f => f.status === 'Pending');
|
||||
|
||||
Reference in New Issue
Block a user