From ca8ace3759dd94415fd76109d9e9d22afad7a730 Mon Sep 17 00:00:00 2001 From: acx10 Date: Sun, 18 Jan 2026 23:30:40 -0700 Subject: [PATCH] Add global and per-book settings for the streaming PDF reader --- .../booklore/model/dto/BookLoreUser.java | 1 + .../user/DefaultUserSettingsProvider.java | 1 + .../reader-preferences.component.html | 83 +--------- .../reader-preferences.component.scss | 51 ------ .../reader-preferences.component.ts | 32 +--- .../settings-application-mode.component.html | 105 ++++++++++++ .../settings-application-mode.component.scss | 151 ++++++++++++++++++ .../settings-application-mode.component.ts | 52 ++++++ .../settings/user-management/user.service.ts | 1 + 9 files changed, 314 insertions(+), 163 deletions(-) create mode 100644 booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.html create mode 100644 booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.scss create mode 100644 booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.ts diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java index 773a9cb7b..1dc8e0717 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java @@ -208,6 +208,7 @@ public class BookLoreUser { private GlobalOrIndividual pdf; private GlobalOrIndividual epub; private GlobalOrIndividual cbx; + private GlobalOrIndividual newPdf; public enum GlobalOrIndividual { Global, Individual diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/user/DefaultUserSettingsProvider.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/user/DefaultUserSettingsProvider.java index 9e414f8e3..79e837b23 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/user/DefaultUserSettingsProvider.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/user/DefaultUserSettingsProvider.java @@ -54,6 +54,7 @@ public class DefaultUserSettingsProvider { .epub(BookLoreUser.UserSettings.PerBookSetting.GlobalOrIndividual.Individual) .pdf(BookLoreUser.UserSettings.PerBookSetting.GlobalOrIndividual.Individual) .cbx(BookLoreUser.UserSettings.PerBookSetting.GlobalOrIndividual.Individual) + .newPdf(BookLoreUser.UserSettings.PerBookSetting.GlobalOrIndividual.Individual) .build(); } diff --git a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.html b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.html index 8acfc51b5..fa1e14582 100644 --- a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.html +++ b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.html @@ -10,88 +10,7 @@
-
-
-

- - Settings Application Mode -

-

- Control how default settings are applied. Select "Default Override" to apply your configured defaults to all books of the same format, overriding individual book preferences. Choose "Book-Specific" to let each book retain its own custom reading settings. -

-
- -
-
-
-
- -
- @for (item of scopeOptions; track item) { - - } -
-
-

- Choose whether default zoom, layout, and navigation settings override individual PDF preferences or if each document maintains its own settings. -

-
-
- -
-
-
- -
- @for (item of scopeOptions; track item) { - - } -
-
-

- Choose whether default font, theme, and layout settings override individual eBook preferences (EPUB, FB2, MOBI, AZW3) or if each book maintains its own settings. -

-
-
- -
-
-
- -
- @for (item of scopeOptions; track item) { - - } -
-
-

- Choose whether default layout, direction, and scaling settings override individual comic book preferences (CBZ, CBR, CB7) or if each file maintains its own settings. -

-
-
-
-
+
diff --git a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.scss b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.scss index 882c3f04d..24166cd74 100644 --- a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.scss +++ b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.scss @@ -106,57 +106,6 @@ } } -.setting-item { - display: flex; - align-items: flex-start; - gap: 2rem; - padding: 0.25rem 0; - - &:last-child { - border-bottom: none; - padding-bottom: 0; - } - - @media (max-width: 768px) { - flex-direction: column; - gap: 1rem; - } -} - -.setting-info { - flex: 1; - min-width: 0; - - .setting-label { - display: block; - font-weight: 600; - color: var(--p-text-color); - font-size: 1rem; - margin-bottom: 0.5rem; - } - - .setting-label-row { - display: flex; - align-items: center; - gap: 1rem; - margin-bottom: 0.5rem; - flex-wrap: wrap; - - .setting-label { - margin-bottom: 0; - flex-shrink: 0; - min-width: 150px; - } - } - - .setting-description { - color: var(--p-text-muted-color); - font-size: 0.875rem; - line-height: 1.5; - margin: 0; - } -} - .setting-control { flex-shrink: 0; display: flex; diff --git a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.ts b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.ts index 8b3346508..31695143c 100644 --- a/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.ts +++ b/booklore-ui/src/app/features/settings/reader-preferences/reader-preferences.component.ts @@ -11,26 +11,17 @@ import {PdfReaderPreferencesComponent} from './pdf-reader-preferences/pdf-reader import {CbxReaderPreferencesComponent} from './cbx-reader-preferences/cbx-reader-preferences-component'; import {CustomFontsComponent} from '../custom-fonts/custom-fonts.component'; import {NewPdfReaderPreferencesComponent} from './new-pdf-reader-preferences/new-pdf-reader-preferences-component'; +import {SettingsApplicationModeComponent} from './settings-application-mode/settings-application-mode.component'; @Component({ selector: 'app-reader-preferences', templateUrl: './reader-preferences.component.html', standalone: true, styleUrls: ['./reader-preferences.component.scss'], - imports: [FormsModule, TooltipModule, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, NewPdfReaderPreferencesComponent] + imports: [FormsModule, TooltipModule, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, NewPdfReaderPreferencesComponent, SettingsApplicationModeComponent] }) export class ReaderPreferences implements OnInit, OnDestroy { - readonly scopeOptions = [ - {name: 'Global', key: 'Global', icon: 'pi pi-globe'}, - {name: 'Individual', key: 'Individual', icon: 'pi pi-user'} - ]; - - selectedPdfScope!: string; - selectedEpubScope!: string; - selectedCbxScope!: string; - private readonly userService = inject(UserService); - private readonly readerPreferencesService = inject(ReaderPreferencesService); private readonly destroy$ = new Subject(); userData$: Observable = this.userService.userState$; @@ -46,7 +37,6 @@ export class ReaderPreferences implements OnInit, OnDestroy { this.userSettings = userState.user!.userSettings; const perms = userState.user!.permissions; this.hasFontManagementPermission = (perms.admin || perms.canManageFonts); - this.loadPreferences(userState.user!.userSettings); }); } @@ -54,22 +44,4 @@ export class ReaderPreferences implements OnInit, OnDestroy { this.destroy$.next(); this.destroy$.complete(); } - - private loadPreferences(settings: UserSettings): void { - this.selectedPdfScope = settings.perBookSetting.pdf; - this.selectedEpubScope = settings.perBookSetting.epub; - this.selectedCbxScope = settings.perBookSetting.cbx; - } - - onPdfScopeChange() { - this.readerPreferencesService.updatePreference(['perBookSetting', 'pdf'], this.selectedPdfScope); - } - - onEpubScopeChange() { - this.readerPreferencesService.updatePreference(['perBookSetting', 'epub'], this.selectedEpubScope); - } - - onCbxScopeChange() { - this.readerPreferencesService.updatePreference(['perBookSetting', 'cbx'], this.selectedCbxScope); - } } diff --git a/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.html b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.html new file mode 100644 index 000000000..b1f8202e2 --- /dev/null +++ b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.html @@ -0,0 +1,105 @@ +
+
+

+ + Settings Application Mode +

+

+ Configure how default reader settings are applied across your library. Choose "Default Override" to enforce your preferred defaults across all books of the same format, or select "Book-Specific" to preserve individual reading preferences for each book. +

+
+ +
+
+
+
+ +
+ @for (item of scopeOptions; track item) { + + } +
+
+

+ Control whether your default zoom level, page layout, and navigation preferences apply to all PDFs or if each document retains its own settings. +

+
+
+ +
+
+
+ +
+ @for (item of scopeOptions; track item) { + + } +
+
+

+ Determine whether your default font, theme, and layout preferences apply to all eBooks (EPUB, FB2, MOBI, AZW3) or if each book maintains its own settings. +

+
+
+ +
+
+
+ +
+ @for (item of scopeOptions; track item) { + + } +
+
+

+ Set whether your default page layout, reading direction, and scaling preferences apply to all comics (CBZ, CBR, CB7) or if each file keeps its own settings. +

+
+
+ +
+
+
+ +
+ @for (item of scopeOptions; track item) { + + } +
+
+

+ Choose whether your default view mode, fit mode, and scroll direction apply to all streaming PDFs or if each document maintains its own configuration. +

+
+
+
+
diff --git a/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.scss b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.scss new file mode 100644 index 000000000..1b67d3d3f --- /dev/null +++ b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.scss @@ -0,0 +1,151 @@ +.preferences-section { + @media (min-width: 768px) { + padding: 0 1rem; + } +} + +.section-header { + margin-bottom: 1rem; +} + +.section-title { + display: flex; + align-items: center; + gap: 0.5rem; + font-size: 1.125rem; + font-weight: 600; + color: var(--p-text-color); + margin: 0 0 0.5rem 0; + + .pi { + color: var(--p-primary-color); + } +} + +.section-description { + display: flex; + align-items: flex-start; + gap: 0.5rem; + color: var(--p-text-muted-color); + font-size: 0.875rem; + line-height: 1.5; + margin: 0; + + .pi { + color: var(--p-primary-color); + margin-top: 0.125rem; + flex-shrink: 0; + } +} + +.settings-card { + border: 1px solid var(--p-content-border-color); + border-radius: 8px; + background: var(--p-content-background); + padding: 1.5rem; + display: flex; + flex-direction: column; + gap: 1rem; +} + +.setting-item { + display: flex; + align-items: flex-start; + gap: 2rem; + padding: 0.25rem 0; + + &:last-child { + border-bottom: none; + padding-bottom: 0; + } + + @media (max-width: 768px) { + flex-direction: column; + gap: 1rem; + } +} + +.setting-info { + flex: 1; + min-width: 0; + + .setting-label { + display: block; + font-weight: 600; + color: var(--p-text-color); + font-size: 1rem; + margin-bottom: 0.5rem; + min-width: 220px; + flex-shrink: 0; + } + + .setting-label-row { + display: flex; + align-items: flex-start; + gap: 1rem; + margin-bottom: 0.5rem; + flex-wrap: wrap; + + .setting-label { + margin-bottom: 0; + min-width: 220px; + flex-shrink: 0; + } + } + + .setting-description { + color: var(--p-text-muted-color); + font-size: 0.875rem; + line-height: 1.5; + margin: 0; + } +} + +.button-group { + display: flex; + flex-direction: row; + gap: 0.5rem; + flex-wrap: wrap; + + .option-button { + display: flex; + align-items: center; + justify-content: center; + gap: 0.375rem; + padding: 0.5rem 0.75rem; + border-radius: 0.375rem; + border: 1.5px solid color-mix(in srgb, var(--text-color) 20%, transparent); + background: color-mix(in srgb, var(--text-color) 5%, transparent); + color: var(--text-color); + cursor: pointer; + transition: all 0.2s ease; + font-size: 0.8125rem; + font-weight: 500; + min-width: 4.5rem; + + i { + font-size: 0.875rem; + } + + .option-text { + white-space: nowrap; + } + + &:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + border-color: color-mix(in srgb, var(--primary-color) 40%, transparent); + } + + &.selected { + border-color: var(--primary-color); + background: color-mix(in srgb, var(--primary-color) 10%, transparent); + color: var(--primary-color); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent); + + &:hover { + transform: translateY(-2px); + } + } + } +} diff --git a/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.ts b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.ts new file mode 100644 index 000000000..011479bcc --- /dev/null +++ b/booklore-ui/src/app/features/settings/reader-preferences/settings-application-mode/settings-application-mode.component.ts @@ -0,0 +1,52 @@ +import {Component, inject, Input, OnInit} from '@angular/core'; +import {ReaderPreferencesService} from '../reader-preferences.service'; +import {UserSettings} from '../../user-management/user.service'; + +@Component({ + selector: 'app-settings-application-mode', + templateUrl: './settings-application-mode.component.html', + standalone: true, + styleUrls: ['./settings-application-mode.component.scss'] +}) +export class SettingsApplicationModeComponent implements OnInit { + @Input() userSettings!: UserSettings; + + readonly scopeOptions = [ + {name: 'Global', key: 'Global', icon: 'pi pi-globe'}, + {name: 'Individual', key: 'Individual', icon: 'pi pi-user'} + ]; + + selectedPdfScope!: string; + selectedNewPdfScope!: string; + selectedEpubScope!: string; + selectedCbxScope!: string; + + private readonly readerPreferencesService = inject(ReaderPreferencesService); + + ngOnInit(): void { + this.loadPreferences(); + } + + private loadPreferences(): void { + this.selectedPdfScope = this.userSettings.perBookSetting.pdf; + this.selectedNewPdfScope = this.userSettings.perBookSetting.newPdf || 'Global'; + this.selectedEpubScope = this.userSettings.perBookSetting.epub; + this.selectedCbxScope = this.userSettings.perBookSetting.cbx; + } + + onPdfScopeChange() { + this.readerPreferencesService.updatePreference(['perBookSetting', 'pdf'], this.selectedPdfScope); + } + + onNewPdfScopeChange() { + this.readerPreferencesService.updatePreference(['perBookSetting', 'newPdf'], this.selectedNewPdfScope); + } + + onEpubScopeChange() { + this.readerPreferencesService.updatePreference(['perBookSetting', 'epub'], this.selectedEpubScope); + } + + onCbxScopeChange() { + this.readerPreferencesService.updatePreference(['perBookSetting', 'cbx'], this.selectedCbxScope); + } +} diff --git a/booklore-ui/src/app/features/settings/user-management/user.service.ts b/booklore-ui/src/app/features/settings/user-management/user.service.ts index 1d881da7c..b5239de3e 100644 --- a/booklore-ui/src/app/features/settings/user-management/user.service.ts +++ b/booklore-ui/src/app/features/settings/user-management/user.service.ts @@ -46,6 +46,7 @@ export interface PerBookSetting { pdf: string; epub: string; cbx: string; + newPdf?: string; } export type PageSpread = 'off' | 'even' | 'odd';