diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/controller/AppSettingController.java b/booklore-api/src/main/java/com/adityachandel/booklore/controller/AppSettingController.java index 04aaa17c9..403992e47 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/controller/AppSettingController.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/controller/AppSettingController.java @@ -17,8 +17,8 @@ public class AppSettingController { } @PutMapping("/api/settings") - public void updateSetting(@RequestParam String category, @RequestParam String name, @RequestParam String newValue) { - appSettingService.updateSetting(category, name, newValue); + public void updateSetting(@RequestParam String category, @RequestParam String name, @RequestParam String val) { + appSettingService.updateSetting(category, name, val); } } \ No newline at end of file diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/AppSettingService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/AppSettingService.java index de94cfe64..5ffac11a0 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/AppSettingService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/AppSettingService.java @@ -33,10 +33,10 @@ public class AppSettingService { } @Transactional - public void updateSetting(String category, String name, String newValue) { + public void updateSetting(String category, String name, String val) { AppSettingEntity setting = appSettingsRepository.findByCategoryAndName(category, name); if (setting != null) { - setting.setVal(newValue); + setting.setVal(val); appSettingsRepository.save(setting); } else { throw new IllegalArgumentException("Setting not found for category: " + category + " and key: " + name); diff --git a/booklore-ui/src/app/core/component/settings/settings.component.html b/booklore-ui/src/app/core/component/settings/settings.component.html index 22f39e383..6c767e08d 100644 --- a/booklore-ui/src/app/core/component/settings/settings.component.html +++ b/booklore-ui/src/app/core/component/settings/settings.component.html @@ -1,11 +1,59 @@

Preferences

-

PDF Reader Settings

+

+ Book Reader Settings: Global or Per-Book + + +

-

Page Spread:

+

PDF:

+
+
+ + + +
+
+ +

Epub:

+
+
+ + + +
+
+ +
+ + +

+ PDF Reader: Global Preferences + +

+ +
+ +

Page Spread:

-

Page Zoom:

+

Page Zoom:

-

Show Sidebar:

+

Show Sidebar:

-

ePUB Reader Settings

+

+ Epub Reader: Global Preferences + +

-

Theme:

+

Theme:

-

Font:

+

Font:

-

Font Size:

+

Font Size:

{{ fontSize }}%

diff --git a/booklore-ui/src/app/core/component/settings/settings.component.ts b/booklore-ui/src/app/core/component/settings/settings.component.ts index 2f6baa458..e027919d3 100644 --- a/booklore-ui/src/app/core/component/settings/settings.component.ts +++ b/booklore-ui/src/app/core/component/settings/settings.component.ts @@ -9,6 +9,7 @@ import {ToggleSwitch} from 'primeng/toggleswitch'; import {RadioButton} from 'primeng/radiobutton'; import {Divider} from 'primeng/divider'; import {Button} from 'primeng/button'; +import {Tooltip} from 'primeng/tooltip'; @Component({ selector: 'app-settings', @@ -20,7 +21,8 @@ import {Button} from 'primeng/button'; ToggleSwitch, RadioButton, Divider, - Button + Button, + Tooltip ], styleUrls: ['./settings.component.scss'] }) @@ -56,10 +58,12 @@ export class SettingsComponent implements OnInit { selectedTheme!: any; fontSize: number = 100; selectedFont: any; + selectedPdf!: string; + selectedEpub!: string; private appSettingsService = inject(AppSettingsService); appSettings$: Observable = this.appSettingsService.appSettings$; - + individualOrGlobal = ['Global', 'Individual']; ngOnInit(): void { this.appSettings$.subscribe(settings => { @@ -80,7 +84,7 @@ export class SettingsComponent implements OnInit { if (settings.epub) { const epubSettings = settings.epub; this.selectedTheme = this.themes.find(t => t.key === epubSettings.theme)?.key; - this.fontSize = epubSettings.fontSize; + this.fontSize = Number(epubSettings.fontSize); this.selectedFont = this.fonts.find(f => f.key === epubSettings.font)?.key; } } @@ -106,7 +110,7 @@ export class SettingsComponent implements OnInit { } onFontSizeChange(): void { - this.appSettingsService.saveAppSetting('epub', 'fontSize', this.fontSize.toString()); + this.appSettingsService.saveAppSetting('epub', 'fontSize', this.fontSize); } increaseFontSize(): void { @@ -122,4 +126,12 @@ export class SettingsComponent implements OnInit { this.onFontSizeChange(); } } + + onPdfIndividualOrGlobalChange() { + + } + + onEpubIndividualOrGlobalChange() { + + } } diff --git a/booklore-ui/src/app/core/service/app-settings.service.ts b/booklore-ui/src/app/core/service/app-settings.service.ts index aefda159b..9f0f652fc 100644 --- a/booklore-ui/src/app/core/service/app-settings.service.ts +++ b/booklore-ui/src/app/core/service/app-settings.service.ts @@ -28,11 +28,11 @@ export class AppSettingsService { }); } - saveAppSetting(category: string, key: string, newValue: string): void { + saveAppSetting(category: string, key: string, newValue: string | number): void { const params = new HttpParams() .set('category', category) - .set('key', key) - .set('newValue', newValue); + .set('name', key) + .set('val', newValue); this.http.put(this.apiUrl, null, { params }).subscribe({ next: () => {