Add global vs individual in settings page.
This commit is contained in:
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -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);
|
||||
|
||||
@@ -1,11 +1,59 @@
|
||||
<p class="text-3xl font-semibold">Preferences</p>
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl font-medium pb-4 pt-6">PDF Reader Settings</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">
|
||||
|
||||
<p class="text-lg font-medium py-1">Page Spread:</p>
|
||||
<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)]="selectedPdf"
|
||||
(ngModelChange)="onPdfIndividualOrGlobalChange()">
|
||||
</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)]="selectedEpub"
|
||||
(ngModelChange)="onEpubIndividualOrGlobalChange()">
|
||||
</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
|
||||
@@ -19,7 +67,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-lg font-medium py-1">Page Zoom:</p>
|
||||
<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
|
||||
@@ -33,7 +81,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-lg font-medium py-1">Show Sidebar:</p>
|
||||
<p class="text-lg py-1">Show Sidebar:</p>
|
||||
<div class="flex justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="showSidebar"
|
||||
@@ -44,11 +92,14 @@
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<p class="text-xl font-medium pb-4 pt-4">ePUB Reader Settings</p>
|
||||
<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 font-medium">Theme:</p>
|
||||
<p class="text-lg">Theme:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="themes"
|
||||
@@ -61,7 +112,7 @@
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg font-medium">Font:</p>
|
||||
<p class="text-lg">Font:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
[options]="fonts"
|
||||
@@ -74,7 +125,7 @@
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<p class="text-lg font-medium py-1">Font Size:</p>
|
||||
<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>
|
||||
|
||||
@@ -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<AppSettings | null> = 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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: () => {
|
||||
|
||||
Reference in New Issue
Block a user