Add checkbox to enable or disable automatic book match search on opening book details
This commit is contained in:
committed by
Aditya Chandel
parent
bb5c0d473c
commit
2ef67f450a
@@ -0,0 +1,128 @@
|
||||
<div class="w-full h-[calc(100vh-12.1rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
|
||||
<p class="text-xl pb-4 pt-6">
|
||||
Book Reader Settings: Global or Per-Book
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Choose whether you want to apply the same settings (like font, theme, spread, zoom, etc.) to all your books by default, or have individual setting for each book."
|
||||
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="text-lg py-1">PDF:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let item of individualOrGlobal" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="item"
|
||||
name="spread"
|
||||
[value]="item"
|
||||
[(ngModel)]="selectedPdfScope"
|
||||
(ngModelChange)="onPdfScopeChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="item">{{ item }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-lg py-1">Epub:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let item of individualOrGlobal" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="item"
|
||||
name="spread"
|
||||
[value]="item"
|
||||
[(ngModel)]="selectedEpubScope"
|
||||
(ngModelChange)="onEpubScopeChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="item">{{ item }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl pb-6 pt-6">
|
||||
PDF Reader: Global Preferences
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="These settings apply globally to all PDFs. You can customize how PDFs are displayed, including page spread type, zoom level, and sidebar visibility."
|
||||
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="text-lg py-1">Page Spread:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let spread of spreads" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="spread.key"
|
||||
name="spread"
|
||||
[value]="spread.key"
|
||||
[(ngModel)]="selectedSpread"
|
||||
(ngModelChange)="onSpreadChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="spread.key">{{ spread.name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-lg py-1">Page Zoom:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<div *ngFor="let zoom of zooms" class="flex items-center gap-2">
|
||||
<p-radiobutton
|
||||
[inputId]="zoom.key"
|
||||
name="zoom"
|
||||
[value]="zoom.key"
|
||||
[(ngModel)]="selectedZoom"
|
||||
(ngModelChange)="onZoomChange()">
|
||||
</p-radiobutton>
|
||||
<label [for]="zoom.key">{{ zoom.name }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl pb-6 pt-6">
|
||||
Epub Reader: Global Preferences
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="These settings apply globally to all EPUBs. Customize how EPUBs are displayed, including themes, font types, and font sizes." 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="text-lg">Theme:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="themes"
|
||||
[(ngModel)]="selectedTheme"
|
||||
optionLabel="name"
|
||||
optionValue="key"
|
||||
placeholder="Select a Theme"
|
||||
class="w-full md:w-56"
|
||||
(ngModelChange)="onThemeChange()">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg">Font:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="fonts"
|
||||
[(ngModel)]="selectedFont"
|
||||
optionLabel="name"
|
||||
optionValue="key"
|
||||
placeholder="Select a Font"
|
||||
class="w-full md:w-56"
|
||||
(ngModelChange)="onFontChange()">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg py-1">Font Size:</p>
|
||||
<div class="flex gap-4 justify-start items-center">
|
||||
<p-button icon="pi pi-minus" rounded="true" (click)="decreaseFontSize()"></p-button>
|
||||
<p>{{ fontSize }}%</p>
|
||||
<p-button icon="pi pi-plus" rounded="true" (click)="increaseFontSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {Select} from 'primeng/select';
|
||||
import {RadioButton} from 'primeng/radiobutton';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {User, UserBookPreferences, UserService} from '../../user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-preferences',
|
||||
templateUrl: './book-preferences.component.html',
|
||||
standalone: true,
|
||||
styleUrls: ['./book-preferences.component.scss'],
|
||||
imports: [Select, FormsModule, NgForOf, RadioButton, Divider, Button, Tooltip]
|
||||
})
|
||||
export class BookPreferences implements OnInit {
|
||||
readonly spreads = [
|
||||
{ name: 'Even Spread', key: 'even' },
|
||||
{ name: 'Odd Spread', key: 'odd' },
|
||||
{ name: 'No Spread', key: 'off' }
|
||||
];
|
||||
|
||||
readonly zooms = [
|
||||
{ name: 'Auto Zoom', key: 'auto' },
|
||||
{ name: 'Page Fit', key: 'page-fit' },
|
||||
{ name: 'Page Width', key: 'page-width' },
|
||||
{ name: 'Actual Size', key: 'page-actual' }
|
||||
];
|
||||
|
||||
readonly themes = [
|
||||
{ name: 'White', key: 'white' },
|
||||
{ name: 'Black', key: 'black' },
|
||||
{ name: 'Grey', key: 'grey' },
|
||||
{ name: 'Sepia', key: 'sepia' }
|
||||
];
|
||||
|
||||
readonly fonts = [
|
||||
{ name: 'Serif', key: 'serif' },
|
||||
{ name: 'Sans Serif', key: 'sans-serif' },
|
||||
{ name: 'Roboto', key: 'roboto' },
|
||||
{ name: 'Cursive', key: 'cursive' },
|
||||
{ name: 'Monospace', key: 'monospace' }
|
||||
];
|
||||
|
||||
readonly individualOrGlobal = ['Global', 'Individual'];
|
||||
|
||||
selectedSpread!: 'off' | 'even' | 'odd';
|
||||
selectedZoom!: string;
|
||||
showSidebar = false;
|
||||
selectedTheme!: string;
|
||||
fontSize = 100;
|
||||
selectedFont!: string;
|
||||
selectedPdfScope!: string;
|
||||
selectedEpubScope!: string;
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
userData$: Observable<User | null> = this.userService.userData$;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userData$.subscribe(userData => {
|
||||
if (userData) this.populateSettings(userData.bookPreferences);
|
||||
});
|
||||
}
|
||||
|
||||
private populateSettings(prefs: UserBookPreferences): void {
|
||||
this.selectedPdfScope = prefs.perBookSetting.pdf;
|
||||
this.selectedEpubScope = prefs.perBookSetting.epub;
|
||||
this.selectedSpread = prefs.pdfReaderSetting.pageSpread;
|
||||
this.selectedZoom = prefs.pdfReaderSetting.pageZoom;
|
||||
this.showSidebar = prefs.pdfReaderSetting.showSidebar;
|
||||
this.selectedTheme = prefs.epubReaderSetting.theme;
|
||||
this.fontSize = prefs.epubReaderSetting.fontSize;
|
||||
this.selectedFont = prefs.epubReaderSetting.font;
|
||||
}
|
||||
|
||||
private updatePreference<T>(updateFn: (prefs: UserBookPreferences) => void): void {
|
||||
const user = this.userService.getLocalUser();
|
||||
if (user) {
|
||||
updateFn(user.bookPreferences);
|
||||
this.userService.updateBookPreferences(user.id, user.bookPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
onThemeChange(): void {
|
||||
this.updatePreference(prefs => prefs.epubReaderSetting.theme = this.selectedTheme);
|
||||
}
|
||||
|
||||
onFontChange(): void {
|
||||
this.updatePreference(prefs => prefs.epubReaderSetting.font = this.selectedFont);
|
||||
}
|
||||
|
||||
onSpreadChange(): void {
|
||||
this.updatePreference(prefs => prefs.pdfReaderSetting.pageSpread = this.selectedSpread);
|
||||
}
|
||||
|
||||
onZoomChange(): void {
|
||||
this.updatePreference(prefs => prefs.pdfReaderSetting.pageZoom = this.selectedZoom);
|
||||
}
|
||||
|
||||
onFontSizeChange(): void {
|
||||
this.updatePreference(prefs => prefs.epubReaderSetting.fontSize = this.fontSize);
|
||||
}
|
||||
|
||||
onPdfScopeChange(): void {
|
||||
this.updatePreference(prefs => prefs.perBookSetting.pdf = this.selectedPdfScope);
|
||||
}
|
||||
|
||||
onEpubScopeChange(): void {
|
||||
this.updatePreference(prefs => prefs.perBookSetting.epub = this.selectedEpubScope);
|
||||
}
|
||||
|
||||
increaseFontSize(): void {
|
||||
if (this.fontSize < 250) {
|
||||
this.fontSize += 10;
|
||||
this.onFontSizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
decreaseFontSize(): void {
|
||||
if (this.fontSize > 50) {
|
||||
this.fontSize -= 10;
|
||||
this.onFontSizeChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user