WIP: Create settings tab
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
public class UserController {
|
||||
public class AuthController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@@ -31,30 +31,24 @@ public class UserService {
|
||||
throw ApiError.USERNAME_ALREADY_TAKEN.createException(request.getUsername());
|
||||
}
|
||||
|
||||
// Create new user entity
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setUsername(request.getUsername());
|
||||
userEntity.setPasswordHash(passwordEncoder.encode(request.getPassword()));
|
||||
userEntity.setName(request.getName());
|
||||
userEntity.setEmail(request.getEmail());
|
||||
|
||||
// Create permissions entity with values from the user request
|
||||
UserPermissionsEntity permissions = new UserPermissionsEntity();
|
||||
permissions.setUser(userEntity);
|
||||
permissions.setPermissionUpload(request.isPermissionUpload());
|
||||
permissions.setPermissionDownload(request.isPermissionDownload());
|
||||
permissions.setPermissionEditMetadata(request.isPermissionEditMetadata());
|
||||
|
||||
// Associate permissions with user
|
||||
userEntity.setPermissions(permissions);
|
||||
|
||||
// Save user (CascadeType.ALL ensures permissions are also saved)
|
||||
userRepository.save(userEntity);
|
||||
|
||||
// Generate JWT token
|
||||
String token = jwtUtils.generateToken(userEntity);
|
||||
|
||||
// Prepare response
|
||||
Map<String, String> response = new HashMap<>();
|
||||
response.put("token", token);
|
||||
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { PdfViewerComponent } from './book/components/pdf-viewer/pdf-viewer.component';
|
||||
import { BookBrowserComponent } from './book/components/book-browser/book-browser.component';
|
||||
import { MainDashboardComponent } from './dashboard/components/main-dashboard/main-dashboard.component';
|
||||
import { AppLayoutComponent } from './layout/component/layout-main/app.layout.component';
|
||||
import { EpubViewerComponent } from './epub-viewer/component/epub-viewer.component';
|
||||
import { SettingsComponent } from './core/component/settings/settings.component';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
import { AuthGuard } from './auth.guard';
|
||||
import {Routes} from '@angular/router';
|
||||
import {BookBrowserComponent} from './book/components/book-browser/book-browser.component';
|
||||
import {MainDashboardComponent} from './dashboard/components/main-dashboard/main-dashboard.component';
|
||||
import {AppLayoutComponent} from './layout/component/layout-main/app.layout.component';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {AuthGuard} from './auth.guard';
|
||||
import {SettingsComponent} from './core/component/settings/settings.component';
|
||||
import {PdfViewerComponent} from './book/components/pdf-viewer/pdf-viewer.component';
|
||||
import {EpubViewerComponent} from './epub-viewer/component/epub-viewer.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'dashboard',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: AppLayoutComponent,
|
||||
children: [
|
||||
{ path: '', component: MainDashboardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'all-books', component: BookBrowserComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'settings', component: SettingsComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'library/:libraryId/books', component: BookBrowserComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'shelf/:shelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard] },
|
||||
{path: 'dashboard', component: MainDashboardComponent, canActivate: [AuthGuard]},
|
||||
{path: 'all-books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'settings', component: SettingsComponent, canActivate: [AuthGuard]},
|
||||
{path: 'library/:libraryId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
{path: 'shelf/:shelfId/books', component: BookBrowserComponent, canActivate: [AuthGuard]},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -30,6 +35,6 @@ export const routes: Routes = [
|
||||
component: EpubViewerComponent,
|
||||
canActivate: [AuthGuard]
|
||||
},
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: '**', redirectTo: 'login', pathMatch: 'full' }
|
||||
{path: 'login', component: LoginComponent},
|
||||
{path: '**', redirectTo: 'login', pathMatch: 'full'}
|
||||
];
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<p>admin works!</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
imports: [],
|
||||
templateUrl: './admin.component.html',
|
||||
styleUrl: './admin.component.scss'
|
||||
})
|
||||
export class AdminComponent {
|
||||
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
<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>
|
||||
|
||||
<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-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>
|
||||
</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>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {AppSettingsService} from '../../../service/app-settings.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AppSettings} from '../../../model/app-settings.model';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgForOf} from '@angular/common';
|
||||
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';
|
||||
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-book-preferences',
|
||||
templateUrl: './book-preferences.component.html',
|
||||
imports: [Select, FormsModule, NgForOf, ToggleSwitch, RadioButton, Divider, Button, Tooltip, MetadataAdvancedFetchOptionsComponent],
|
||||
standalone: true,
|
||||
styleUrls: ['./book-preferences.component.scss']
|
||||
})
|
||||
export class BookPreferences implements OnInit {
|
||||
spreads = [
|
||||
{name: 'Even Spread', key: 'even'},
|
||||
{name: 'Odd Spread', key: 'odd'},
|
||||
{name: 'No Spread', key: 'off'}
|
||||
];
|
||||
zooms = [
|
||||
{name: 'Auto Zoom', key: 'auto'},
|
||||
{name: 'Page Fit', key: 'page-fit'},
|
||||
{name: 'Page Width', key: 'page-width'},
|
||||
{name: 'Actual Size', key: 'page-actual'}
|
||||
];
|
||||
themes = [
|
||||
{name: 'White', key: 'white'},
|
||||
{name: 'Black', key: 'black'},
|
||||
{name: 'Grey', key: 'grey'},
|
||||
{name: 'Sepia', key: 'sepia'}
|
||||
];
|
||||
fonts = [
|
||||
{name: 'Serif', key: 'serif'},
|
||||
{name: 'Sans Serif', key: 'sans-serif'},
|
||||
{name: 'Roboto', key: 'roboto'},
|
||||
{name: 'Cursive', key: 'cursive'},
|
||||
{name: 'Monospace', key: 'monospace'}
|
||||
];
|
||||
|
||||
selectedSpread: any;
|
||||
selectedZoom: any;
|
||||
showSidebar = false;
|
||||
selectedTheme!: any;
|
||||
fontSize: number = 100;
|
||||
selectedFont: any;
|
||||
selectedPdfScope!: string;
|
||||
selectedEpubScope!: string;
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
individualOrGlobal = ['global', 'individual'];
|
||||
currentMetadataOptions!: MetadataRefreshOptions;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$.subscribe(settings => {
|
||||
if (settings) {
|
||||
this.populateSettings(settings);
|
||||
this.currentMetadataOptions = settings.metadataRefreshOptions;
|
||||
console.log(this.currentMetadataOptions)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
populateSettings(settings: AppSettings): void {
|
||||
if (settings.pdf) {
|
||||
const pdfSettings = settings.pdf;
|
||||
this.selectedSpread = this.spreads.find(s => s.key === pdfSettings.spread)?.key;
|
||||
this.selectedZoom = this.zooms.find(z => z.key === pdfSettings.zoom)?.key;
|
||||
this.showSidebar = pdfSettings.sidebar;
|
||||
}
|
||||
|
||||
if (settings.epub) {
|
||||
const epubSettings = settings.epub;
|
||||
this.selectedTheme = this.themes.find(t => t.key === epubSettings.theme)?.key;
|
||||
this.fontSize = Number(epubSettings.fontSize);
|
||||
this.selectedFont = this.fonts.find(f => f.key === epubSettings.font)?.key;
|
||||
}
|
||||
|
||||
if (settings.readerSettings) {
|
||||
this.selectedPdfScope = settings.readerSettings.pdfScope;
|
||||
this.selectedEpubScope = settings.readerSettings.epubScope;
|
||||
}
|
||||
}
|
||||
|
||||
onThemeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'theme', this.selectedTheme);
|
||||
}
|
||||
|
||||
onFontChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'font', this.selectedFont);
|
||||
}
|
||||
|
||||
onSpreadChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'spread', this.selectedSpread);
|
||||
}
|
||||
|
||||
onZoomChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'zoom', this.selectedZoom);
|
||||
}
|
||||
|
||||
onSidebarChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'sidebar', this.showSidebar.toString());
|
||||
}
|
||||
|
||||
onFontSizeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'fontSize', this.fontSize);
|
||||
}
|
||||
|
||||
onPdfScopeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('reader_setting', 'pdf', this.selectedPdfScope);
|
||||
}
|
||||
|
||||
onEpubScopeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('reader_setting', '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();
|
||||
}
|
||||
}
|
||||
|
||||
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
||||
this.appSettingsService.saveAppSetting('quick_book_match', 'all_books', metadataRefreshOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,149 +1,17 @@
|
||||
<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>
|
||||
<div class="card">
|
||||
<p-tabs value="0">
|
||||
<p-tablist>
|
||||
<p-tab value="0">Book Preferences</p-tab>
|
||||
<p-tab value="1">Admin</p-tab>
|
||||
</p-tablist>
|
||||
|
||||
<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 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-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>
|
||||
|
||||
<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>
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="0">
|
||||
<app-book-preferences></app-book-preferences>
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="1">
|
||||
<app-admin></app-admin>
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.enclosing-container {
|
||||
border-color: var(--p-content-border-color);
|
||||
}
|
||||
|
||||
@@ -1,143 +1,22 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {AppSettingsService} from '../../service/app-settings.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AppSettings} from '../../model/app-settings.model';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgForOf} from '@angular/common';
|
||||
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';
|
||||
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';
|
||||
import { Component } from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {BookPreferences} from './book-preferences/book-preferences.component';
|
||||
import {AdminComponent} from './admin/admin.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
imports: [
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabPanels,
|
||||
TabPanel,
|
||||
BookPreferences,
|
||||
AdminComponent
|
||||
],
|
||||
templateUrl: './settings.component.html',
|
||||
imports: [Select, FormsModule, NgForOf, ToggleSwitch, RadioButton, Divider, Button, Tooltip, MetadataAdvancedFetchOptionsComponent],
|
||||
standalone: true,
|
||||
styleUrls: ['./settings.component.scss']
|
||||
styleUrl: './settings.component.scss'
|
||||
})
|
||||
export class SettingsComponent implements OnInit {
|
||||
spreads = [
|
||||
{name: 'Even Spread', key: 'even'},
|
||||
{name: 'Odd Spread', key: 'odd'},
|
||||
{name: 'No Spread', key: 'off'}
|
||||
];
|
||||
zooms = [
|
||||
{name: 'Auto Zoom', key: 'auto'},
|
||||
{name: 'Page Fit', key: 'page-fit'},
|
||||
{name: 'Page Width', key: 'page-width'},
|
||||
{name: 'Actual Size', key: 'page-actual'}
|
||||
];
|
||||
themes = [
|
||||
{name: 'White', key: 'white'},
|
||||
{name: 'Black', key: 'black'},
|
||||
{name: 'Grey', key: 'grey'},
|
||||
{name: 'Sepia', key: 'sepia'}
|
||||
];
|
||||
fonts = [
|
||||
{name: 'Serif', key: 'serif'},
|
||||
{name: 'Sans Serif', key: 'sans-serif'},
|
||||
{name: 'Roboto', key: 'roboto'},
|
||||
{name: 'Cursive', key: 'cursive'},
|
||||
{name: 'Monospace', key: 'monospace'}
|
||||
];
|
||||
export class SettingsComponent {
|
||||
|
||||
selectedSpread: any;
|
||||
selectedZoom: any;
|
||||
showSidebar = false;
|
||||
selectedTheme!: any;
|
||||
fontSize: number = 100;
|
||||
selectedFont: any;
|
||||
selectedPdfScope!: string;
|
||||
selectedEpubScope!: string;
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
individualOrGlobal = ['global', 'individual'];
|
||||
currentMetadataOptions!: MetadataRefreshOptions;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.appSettings$.subscribe(settings => {
|
||||
if (settings) {
|
||||
this.populateSettings(settings);
|
||||
this.currentMetadataOptions = settings.metadataRefreshOptions;
|
||||
console.log(this.currentMetadataOptions)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
populateSettings(settings: AppSettings): void {
|
||||
if (settings.pdf) {
|
||||
const pdfSettings = settings.pdf;
|
||||
this.selectedSpread = this.spreads.find(s => s.key === pdfSettings.spread)?.key;
|
||||
this.selectedZoom = this.zooms.find(z => z.key === pdfSettings.zoom)?.key;
|
||||
this.showSidebar = pdfSettings.sidebar;
|
||||
}
|
||||
|
||||
if (settings.epub) {
|
||||
const epubSettings = settings.epub;
|
||||
this.selectedTheme = this.themes.find(t => t.key === epubSettings.theme)?.key;
|
||||
this.fontSize = Number(epubSettings.fontSize);
|
||||
this.selectedFont = this.fonts.find(f => f.key === epubSettings.font)?.key;
|
||||
}
|
||||
|
||||
if (settings.readerSettings) {
|
||||
this.selectedPdfScope = settings.readerSettings.pdfScope;
|
||||
this.selectedEpubScope = settings.readerSettings.epubScope;
|
||||
}
|
||||
}
|
||||
|
||||
onThemeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'theme', this.selectedTheme);
|
||||
}
|
||||
|
||||
onFontChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'font', this.selectedFont);
|
||||
}
|
||||
|
||||
onSpreadChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'spread', this.selectedSpread);
|
||||
}
|
||||
|
||||
onZoomChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'zoom', this.selectedZoom);
|
||||
}
|
||||
|
||||
onSidebarChange(): void {
|
||||
this.appSettingsService.saveAppSetting('pdf', 'sidebar', this.showSidebar.toString());
|
||||
}
|
||||
|
||||
onFontSizeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('epub', 'fontSize', this.fontSize);
|
||||
}
|
||||
|
||||
onPdfScopeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('reader_setting', 'pdf', this.selectedPdfScope);
|
||||
}
|
||||
|
||||
onEpubScopeChange(): void {
|
||||
this.appSettingsService.saveAppSetting('reader_setting', '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();
|
||||
}
|
||||
}
|
||||
|
||||
onMetadataSubmit(metadataRefreshOptions: MetadataRefreshOptions) {
|
||||
this.appSettingsService.saveAppSetting('quick_book_match', 'all_books', metadataRefreshOptions)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export class AppMenuComponent implements OnInit {
|
||||
{
|
||||
label: 'Dashboard',
|
||||
icon: 'pi pi-fw pi-home',
|
||||
routerLink: ['/'],
|
||||
routerLink: ['/dashboard'],
|
||||
},
|
||||
{
|
||||
label: 'All Books',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.login-container {
|
||||
@apply flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-orange-200 to-gray-700;
|
||||
@apply flex flex-col items-center justify-center min-h-screen bg-gradient-to-br from-blue-700 to-gray-700;
|
||||
|
||||
.login-card {
|
||||
@apply w-96 shadow-lg rounded-xl;
|
||||
|
||||
Reference in New Issue
Block a user