Add quick refresh option
This commit is contained in:
@@ -1,134 +1,149 @@
|
||||
<p class="text-3xl font-semibold">Preferences</p>
|
||||
<p-divider></p-divider>
|
||||
<div class="w-full h-[calc(100vh-6.6rem)] overflow-y-auto border rounded-lg p-4 enclosing-container">
|
||||
<p class="text-3xl font-semibold">Preferences</p>
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
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>
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
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">
|
||||
<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>
|
||||
<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-4 pt-4">
|
||||
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>
|
||||
|
||||
<p class="text-lg py-1">Show Sidebar:</p>
|
||||
<div class="flex justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="showSidebar"
|
||||
(ngModelChange)="onSidebarChange()">
|
||||
</p-toggleswitch>
|
||||
</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>
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
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>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
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>
|
||||
|
||||
<p class="text-lg py-1">Show Sidebar:</p>
|
||||
<div class="flex justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="showSidebar"
|
||||
(ngModelChange)="onSidebarChange()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
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>
|
||||
<p-divider></p-divider>
|
||||
<p class="text-xl pb-4 pt-4">
|
||||
Quick Book Match Preferences
|
||||
<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>
|
||||
<app-metadata-advanced-fetch-options (metadataOptionsSubmitted)="onMetadataSubmit($event)" [currentMetadataOptions]="currentMetadataOptions"></app-metadata-advanced-fetch-options>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
}
|
||||
|
||||
@@ -10,20 +10,13 @@ import {RadioButton} from 'primeng/radiobutton';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {MetadataAdvancedFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import {MetadataRefreshOptions} from '../../../metadata/model/request/metadata-refresh-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
templateUrl: './settings.component.html',
|
||||
imports: [
|
||||
Select,
|
||||
FormsModule,
|
||||
NgForOf,
|
||||
ToggleSwitch,
|
||||
RadioButton,
|
||||
Divider,
|
||||
Button,
|
||||
Tooltip
|
||||
],
|
||||
imports: [Select, FormsModule, NgForOf, ToggleSwitch, RadioButton, Divider, Button, Tooltip, MetadataAdvancedFetchOptionsComponent],
|
||||
styleUrls: ['./settings.component.scss']
|
||||
})
|
||||
export class SettingsComponent implements OnInit {
|
||||
@@ -63,12 +56,15 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
individualOrGlobal = ['Global', 'Individual'];
|
||||
individualOrGlobal = ['global', 'individual'];
|
||||
currentMetadataOptions!: MetadataRefreshOptions;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$.subscribe(settings => {
|
||||
if (settings) {
|
||||
this.populateSettings(settings);
|
||||
this.currentMetadataOptions = settings.metadataRefreshOptions;
|
||||
console.log(this.currentMetadataOptions)
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -139,4 +135,8 @@ export class SettingsComponent implements OnInit {
|
||||
this.onFontSizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
||||
this.appSettingsService.saveAppSetting('quick_book_match', 'all_books', metadataRefreshOptions)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {MetadataRefreshOptions} from '../../metadata/model/request/metadata-refresh-options.model';
|
||||
|
||||
export interface EpubSettings {
|
||||
theme: string;
|
||||
fontSize: number;
|
||||
@@ -13,12 +15,13 @@ export interface PdfSettings {
|
||||
}
|
||||
|
||||
export interface ReaderSettings {
|
||||
pdfScope: 'Global' | 'Individual';
|
||||
epubScope: 'Global' | 'Individual';
|
||||
pdfScope: 'global' | 'individual';
|
||||
epubScope: 'global' | 'individual';
|
||||
}
|
||||
|
||||
export interface AppSettings {
|
||||
epub?: EpubSettings;
|
||||
pdf?: PdfSettings;
|
||||
readerSettings?: ReaderSettings;
|
||||
metadataRefreshOptions: MetadataRefreshOptions;
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@ export class AppSettingsService {
|
||||
});
|
||||
}
|
||||
|
||||
saveAppSetting(category: string, key: string, newValue: string | number): void {
|
||||
const params = new HttpParams()
|
||||
.set('category', category)
|
||||
.set('name', key)
|
||||
.set('val', newValue);
|
||||
|
||||
this.http.put(this.apiUrl, null, { params }).subscribe({
|
||||
saveAppSetting(category: string, key: string, newValue: any): void {
|
||||
const payload = {
|
||||
category,
|
||||
name: key,
|
||||
value: newValue
|
||||
};
|
||||
this.http.put(this.apiUrl, payload).subscribe({
|
||||
next: () => {
|
||||
|
||||
console.log('Settings saved successfully');
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error saving setting:', error);
|
||||
|
||||
Reference in New Issue
Block a user