feat(i18n): add Transloco translation framework with EN/ES and 7 language scaffolds (#2681)

* feat(i18n): add Transloco translation framework and translate all settings tabs (EN/ES)

* feat(i18n): translate shared, layout, dashboard, library-creator, and app-root components (EN/ES) and scaffold 7 new languages

* feat(i18n): translate bookdrop and metadata components (EN/ES), remove i18n-audit from tracking

* fix(i18n): deep-merge English as fallback base for incomplete language translations
This commit is contained in:
ACX
2026-02-10 07:49:01 -07:00
committed by GitHub
parent 45dba44833
commit 0f60faa124
376 changed files with 10487 additions and 4810 deletions
@@ -1,111 +1,113 @@
<div>
<div class="settings-content" style="position: relative;">
<div class="float-top-right">
<p-button
icon="pi pi-upload"
rounded
size="large"
(click)="openUploadDialog()"
[disabled]="customFonts.length >= maxFonts"
></p-button>
</div>
@if (customFonts.length === 0 && !isLoading) {
<div class="preferences-section">
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-palette empty-icon"></i>
</div>
<h3 class="empty-title">No Custom Fonts Yet</h3>
<p class="empty-description">
Upload your favorite fonts to personalize your reading experience.<br>
Click the "Add New Font" button above to get started.
</p>
<p class="empty-hint">
<i class="pi pi-info-circle"></i>
Supported formats: <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsReader.fonts'">
<div>
<div class="settings-content" style="position: relative;">
<div class="float-top-right">
<p-button
icon="pi pi-upload"
rounded
size="large"
(click)="openUploadDialog()"
[disabled]="customFonts.length >= maxFonts"
></p-button>
</div>
} @else {
<div class="preferences-section">
<div class="section-header">
<div>
<h3 class="section-title">
Your Font Library
<span class="font-count">({{ customFonts.length }})</span>
</h3>
</div>
</div>
<div class="fonts-grid">
@for (font of customFonts; track font.id) {
<div class="settings-card font-card">
<div class="font-card-header">
<div class="font-title-group">
<h4 class="font-name">{{ font.fontName }}</h4>
<span class="format-tag">{{ font.format }}</span>
</div>
<p-button
icon="pi pi-trash"
severity="danger"
[text]="true"
[rounded]="true"
size="small"
(click)="deleteFont(font)"
pTooltip="Delete font"
tooltipPosition="left"
></p-button>
</div>
<div class="font-preview-area">
<label class="preview-label">
<i class="pi pi-eye"></i>
Preview
</label>
@if (!fontsLoadedInBrowser) {
<div class="font-preview-skeleton">
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="95%" height="0.875rem"></p-skeleton>
</div>
} @else {
<div class="font-preview" [style.font-family]="font.fontName">
<p class="preview-paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p class="preview-paragraph-small">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<div class="preview-characters">
<span>ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789</span>
</div>
</div>
}
</div>
<div class="font-metadata">
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-file"></i>File</span>
<span class="meta-value">{{ font.originalFileName }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-database"></i>Size</span>
<span class="meta-value">{{ formatFileSize(font.fileSize) }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-calendar"></i>Uploaded</span>
<span class="meta-value">{{ font.uploadedAt | date: 'mediumDate' }}</span>
</div>
</div>
@if (customFonts.length === 0 && !isLoading) {
<div class="preferences-section">
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-palette empty-icon"></i>
</div>
}
<h3 class="empty-title">{{ t('emptyTitle') }}</h3>
<p class="empty-description">
{{ t('emptyDesc') }}<br>
{{ t('emptyHint') }}
</p>
<p class="empty-hint">
<i class="pi pi-info-circle"></i>
{{ t('supportedFormats') }} <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
</p>
</div>
</div>
</div>
}
</div>
</div>
} @else {
<div class="preferences-section">
<div class="section-header">
<div>
<h3 class="section-title">
{{ t('yourLibrary') }}
<span class="font-count">({{ customFonts.length }})</span>
</h3>
</div>
</div>
<p-confirmDialog></p-confirmDialog>
<div class="fonts-grid">
@for (font of customFonts; track font.id) {
<div class="settings-card font-card">
<div class="font-card-header">
<div class="font-title-group">
<h4 class="font-name">{{ font.fontName }}</h4>
<span class="format-tag">{{ font.format }}</span>
</div>
<p-button
icon="pi pi-trash"
severity="danger"
[text]="true"
[rounded]="true"
size="small"
(click)="deleteFont(font)"
[pTooltip]="t('deleteFont')"
tooltipPosition="left"
></p-button>
</div>
<div class="font-preview-area">
<label class="preview-label">
<i class="pi pi-eye"></i>
{{ t('preview') }}
</label>
@if (!fontsLoadedInBrowser) {
<div class="font-preview-skeleton">
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="95%" height="0.875rem"></p-skeleton>
</div>
} @else {
<div class="font-preview" [style.font-family]="font.fontName">
<p class="preview-paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p class="preview-paragraph-small">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<div class="preview-characters">
<span>ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789</span>
</div>
</div>
}
</div>
<div class="font-metadata">
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-file"></i>{{ t('file') }}</span>
<span class="meta-value">{{ font.originalFileName }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-database"></i>{{ t('size') }}</span>
<span class="meta-value">{{ formatFileSize(font.fileSize) }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-calendar"></i>{{ t('uploaded') }}</span>
<span class="meta-value">{{ font.uploadedAt | date: 'mediumDate' }}</span>
</div>
</div>
</div>
}
</div>
</div>
}
</div>
</div>
<p-confirmDialog></p-confirmDialog>
</ng-container>
@@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component, inject, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
@@ -11,11 +11,12 @@ import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {FontUploadDialogComponent} from './font-upload-dialog/font-upload-dialog.component';
import {Skeleton} from 'primeng/skeleton';
import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-custom-fonts',
standalone: true,
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton],
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton, TranslocoDirective],
templateUrl: './custom-fonts.component.html',
styleUrls: ['./custom-fonts.component.scss'],
providers: [ConfirmationService, DialogService]
@@ -28,6 +29,8 @@ export class CustomFontsComponent implements OnInit {
readonly maxFonts = 10;
private t = inject(TranslocoService);
constructor(
private customFontService: CustomFontService,
private messageService: MessageService,
@@ -60,8 +63,8 @@ export class CustomFontsComponent implements OnInit {
console.error('Failed to load fonts:', error);
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to load custom fonts'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsReader.fonts.loadError')
});
this.isLoading = false;
this.fontsLoadedInBrowser = true;
@@ -72,8 +75,8 @@ export class CustomFontsComponent implements OnInit {
if (this.customFonts.length >= this.maxFonts) {
this.messageService.add({
severity: 'error',
summary: 'Quota Exceeded',
detail: `Maximum ${this.maxFonts} fonts allowed per user`
summary: this.t.translate('settingsReader.fonts.quotaExceeded'),
detail: this.t.translate('settingsReader.fonts.quotaExceededDetail', {max: this.maxFonts})
});
return;
}
@@ -98,8 +101,8 @@ export class CustomFontsComponent implements OnInit {
deleteFont(font: CustomFont): void {
this.confirmationService.confirm({
message: `Are you sure you want to delete the font "${font.fontName}"?`,
header: 'Delete Font',
message: this.t.translate('settingsReader.fonts.deleteFontConfirm', {name: font.fontName}),
header: this.t.translate('settingsReader.fonts.deleteFontHeader'),
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.customFontService.deleteFont(font.id).subscribe({
@@ -108,15 +111,15 @@ export class CustomFontsComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Font "${font.fontName}" deleted successfully`
detail: this.t.translate('settingsReader.fonts.deleteSuccess', {name: font.fontName})
});
},
error: (error) => {
console.error('Failed to delete font:', error);
this.messageService.add({
severity: 'error',
summary: 'Delete Failed',
detail: 'Failed to delete font'
summary: this.t.translate('settingsReader.fonts.deleteFailed'),
detail: this.t.translate('settingsReader.fonts.deleteError')
});
}
});
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsReader.fonts.upload'">
<div class="font-upload-dialog">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-upload header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Add New Font</h2>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
Upload a custom font for your EPUB reader
{{ t('description') }}
</p>
</div>
<p-button
@@ -24,7 +25,7 @@
<div class="section-header">
<span class="section-title">
<i class="pi pi-file"></i>
Select Font File
{{ t('selectFile') }}
</span>
</div>
@@ -47,12 +48,9 @@
<div class="empty-icon-wrapper">
<i class="pi pi-cloud-upload empty-icon"></i>
</div>
<h3 class="empty-title">Drag and Drop Font File</h3>
<p class="empty-description">
Supported formats: <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
<br/>
Maximum file size: 5 MB
</p>
<h3 class="empty-title">{{ t('dragDrop') }}</h3>
<p class="empty-description" [innerHTML]="t('supportedFormats')"></p>
<p class="empty-description">{{ t('maxSize') }}</p>
</div>
</div>
} @else {
@@ -69,7 +67,7 @@
<div class="preview-section">
<label class="preview-label">
<i class="pi pi-eye"></i>
Font Preview
{{ t('fontPreview') }}
</label>
<div class="font-preview" [style.font-family]="previewFontFamily">
<p class="preview-paragraph">
@@ -91,9 +89,9 @@
<div class="setting-item">
<div class="setting-info">
<label for="fontName" class="setting-label">Font Display Name</label>
<label for="fontName" class="setting-label">{{ t('displayName') }}</label>
<p class="setting-description">
This name will appear in the font selector when reading EPUB books.
{{ t('displayNameDesc') }}
</p>
</div>
<div class="setting-control">
@@ -101,7 +99,7 @@
pInputText
id="fontName"
[(ngModel)]="uploadedFontName"
placeholder="e.g., Bookerly, Open Sans, Merriweather"
[placeholder]="t('displayNamePlaceholder')"
[disabled]="isUploading"
class="font-name-input"
/>
@@ -110,10 +108,11 @@
</div>
}
</div>
</div>
<div class="dialog-footer">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
[outlined]="true"
@@ -121,7 +120,7 @@
[disabled]="isUploading"
></p-button>
<p-button
label="Upload Font"
[label]="t('uploadBtn')"
icon="pi pi-upload"
(click)="uploadFont()"
[disabled]="isUploading || !selectedFile || !uploadedFontName.trim()"
@@ -129,3 +128,4 @@
></p-button>
</div>
</div>
</ng-container>
@@ -1,4 +1,4 @@
import {Component, ViewChild, ElementRef, OnDestroy} from '@angular/core';
import {Component, ViewChild, ElementRef, OnDestroy, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
@@ -7,16 +7,18 @@ import {formatFileSize} from '../../../../shared/model/custom-font.model';
import {InputText} from 'primeng/inputtext';
import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-font-upload-dialog',
standalone: true,
imports: [CommonModule, Button, InputText, FormsModule],
imports: [CommonModule, Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
templateUrl: './font-upload-dialog.component.html',
styleUrls: ['./font-upload-dialog.component.scss']
})
export class FontUploadDialogComponent implements OnDestroy {
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
private readonly t = inject(TranslocoService);
isUploading = false;
uploadedFontName = '';
@@ -96,8 +98,8 @@ export class FontUploadDialogComponent implements OnDestroy {
this.previewFontFamily = null;
this.messageService.add({
severity: 'warn',
summary: 'Preview Failed',
detail: 'Unable to preview font, but you can still upload it'
summary: this.t.translate('settingsReader.fonts.upload.previewFailed'),
detail: this.t.translate('settingsReader.fonts.upload.previewFailedDetail')
});
}
} finally {
@@ -111,8 +113,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!this.selectedFile) {
this.messageService.add({
severity: 'warn',
summary: 'No File Selected',
detail: 'Please select a font file to upload'
summary: this.t.translate('settingsReader.fonts.upload.noFileSelected'),
detail: this.t.translate('settingsReader.fonts.upload.noFileSelectedDetail')
});
return;
}
@@ -122,21 +124,20 @@ export class FontUploadDialogComponent implements OnDestroy {
next: (font) => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Font "${font.fontName}" uploaded successfully`
summary: this.t.translate('settingsReader.fonts.upload.success'),
detail: this.t.translate('settingsReader.fonts.upload.successDetail', {name: font.fontName})
});
this.isUploading = false;
this.dialogRef.close(font); // Return the uploaded font
},
error: (error) => {
console.error('Failed to upload font:', error);
let errorMessage = 'Failed to upload font';
if (error.status === 400) {
errorMessage = 'Invalid file format or quota exceeded';
}
const errorMessage = error.status === 400
? this.t.translate('settingsReader.fonts.upload.uploadFailedInvalid')
: this.t.translate('settingsReader.fonts.upload.uploadFailedDefault');
this.messageService.add({
severity: 'error',
summary: 'Upload Failed',
summary: this.t.translate('settingsReader.fonts.upload.uploadFailed'),
detail: errorMessage
});
@@ -193,8 +194,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!isValidFormat) {
this.messageService.add({
severity: 'error',
summary: 'Invalid File Type',
detail: 'Please upload a TTF, OTF, WOFF, or WOFF2 font file'
summary: this.t.translate('settingsReader.fonts.upload.invalidFileType'),
detail: this.t.translate('settingsReader.fonts.upload.invalidFileTypeDetail')
});
return false;
}
@@ -202,8 +203,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (file.size > this.maxFileSize) {
this.messageService.add({
severity: 'error',
summary: 'File Too Large',
detail: `File size must not exceed ${this.formatFileSize(this.maxFileSize)}`
summary: this.t.translate('settingsReader.fonts.upload.fileTooLarge'),
detail: this.t.translate('settingsReader.fonts.upload.fileTooLargeDetail', {size: this.formatFileSize(this.maxFileSize)})
});
return false;
}
@@ -1,14 +1,15 @@
<ng-container *transloco="let t; prefix: 'settingsDevice'">
<p-toast position="top-right"></p-toast>
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-book"></i>
Hardcover Integration
{{ t('hardcover.title') }}
<app-external-doc-link docType="hardcover"></app-external-doc-link>
</h2>
<p class="settings-description">
Sync your reading progress from Booklore to your Hardcover account.
{{ t('hardcover.description') }}
</p>
</div>
@@ -18,10 +19,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sync"></i>
Sync Configuration
{{ t('hardcover.syncConfig') }}
</h3>
<p class="section-description">
Enable and configure synchronization between Booklore and Hardcover.
{{ t('hardcover.syncConfigDesc') }}
</p>
</div>
@@ -30,7 +31,7 @@
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">
Sync KOReader Reading Progress to Hardcover</label>
{{ t('hardcover.syncLabel') }}</label>
<p-toggle-switch
id="hardcoverSyncEnabled"
name="hardcoverSyncEnabled"
@@ -39,7 +40,7 @@
</p-toggle-switch>
</div>
<p class="setting-description">
When enabled, your KOReader reading progress will be automatically synced to your Hardcover account.
{{ t('hardcover.syncDesc') }}
</p>
</div>
</div>
@@ -48,7 +49,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Hardcover API Key</label>
<label class="setting-label">{{ t('hardcover.apiKey') }}</label>
<div class="token-input-group">
<input
pInputText
@@ -57,7 +58,7 @@
[type]="showHardcoverApiKey ? 'text' : 'password'"
name="hardcoverApiKey"
class="token-input"
placeholder="Enter your Hardcover API key"
[placeholder]="t('hardcover.apiKeyPlaceholder')"
(blur)="onHardcoverApiKeyChange()"
/>
<p-button
@@ -77,10 +78,7 @@
</p-button>
</div>
</div>
<p class="setting-description">
Your personal Hardcover API key. Get it from
<a href="https://hardcover.app/account/api" target="_blank" rel="noopener">hardcover.app/account/api</a>.
This key is used only for syncing your reading progress and is not shared with other users.
<p class="setting-description" [innerHTML]="t('hardcover.apiKeyDesc')">
</p>
</div>
</div>
@@ -93,14 +91,15 @@
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>Access Restricted</h3>
<h3>{{ t('accessRestricted') }}</h3>
<p>
Access to Hardcover sync is restricted.
{{ t('hardcover.accessDenied') }}
<br>
Please contact your administrator to request permission.
{{ t('contactAdmin') }}
</p>
</div>
</div>
</div>
}
</div>
</ng-container>
@@ -10,6 +10,7 @@ import {filter, takeUntil} from 'rxjs/operators';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {UserService} from '../../../user-management/user.service';
import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
standalone: true,
@@ -20,7 +21,8 @@ import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service';
ToggleSwitch,
Button,
ToastModule,
ExternalDocLinkComponent
ExternalDocLinkComponent,
TranslocoDirective
],
providers: [MessageService],
templateUrl: './hardcover-settings-component.html',
@@ -30,6 +32,7 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
private readonly messageService = inject(MessageService);
private readonly hardcoverSyncSettingsService = inject(HardcoverSyncSettingsService);
private readonly userService = inject(UserService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
hasPermission = false;
@@ -63,8 +66,8 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Load Error',
detail: 'Unable to retrieve Hardcover sync settings. Please try again.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsDevice.hardcover.loadError')
});
}
});
@@ -76,13 +79,13 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
onHardcoverSyncToggle() {
const message = this.hardcoverSyncEnabled
? 'Hardcover sync enabled'
: 'Hardcover sync disabled';
? this.t.translate('settingsDevice.hardcover.syncEnabledMsg')
: this.t.translate('settingsDevice.hardcover.syncDisabledMsg');
this.updateHardcoverSettings(message);
}
onHardcoverApiKeyChange() {
this.updateHardcoverSettings('Hardcover API key updated');
this.updateHardcoverSettings(this.t.translate('settingsDevice.hardcover.apiKeyUpdated'));
}
private updateHardcoverSettings(successMessage: string) {
@@ -93,13 +96,13 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
next: settings => {
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
this.hardcoverApiKey = settings.hardcoverApiKey ?? '';
this.messageService.add({severity: 'success', summary: 'Settings Updated', detail: successMessage});
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.hardcover.settingsUpdated'), detail: successMessage});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Update Failed',
detail: 'Unable to update Hardcover sync settings. Please try again.'
summary: this.t.translate('settingsDevice.hardcover.updateFailed'),
detail: this.t.translate('settingsDevice.hardcover.updateError')
});
}
});
@@ -112,15 +115,15 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
navigator.clipboard.writeText(text).then(() => {
this.messageService.add({
severity: 'success',
summary: 'Copied',
detail: `${label} copied to clipboard`
summary: this.t.translate('settingsDevice.copied'),
detail: this.t.translate('settingsDevice.copiedDetail', {label})
});
}).catch(err => {
console.error('Copy failed', err);
this.messageService.add({
severity: 'error',
summary: 'Copy Failed',
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
summary: this.t.translate('settingsDevice.copyFailed'),
detail: this.t.translate('settingsDevice.copyFailedDetail', {label})
});
});
}
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'settingsDevice'">
<p-toast position="top-right"></p-toast>
<p-confirmDialog></p-confirmDialog>
@@ -5,11 +6,11 @@
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-tablet"></i>
Kobo Integration Configuration
{{ t('kobo.title') }}
<app-external-doc-link docType="kobo"></app-external-doc-link>
</h2>
<p class="settings-description">
Configure Kobo device integration to sync your library books and reading progress with your Kobo e-reader.
{{ t('kobo.description') }}
</p>
</div>
@@ -19,10 +20,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sync"></i>
Sync Configuration
{{ t('kobo.syncConfig') }}
</h3>
<p class="section-description">
Enable and configure synchronization between your Booklore library and Kobo device.
{{ t('kobo.syncConfigDesc') }}
</p>
</div>
@@ -30,7 +31,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enable Kobo Sync</label>
<label class="setting-label">{{ t('kobo.enableSync') }}</label>
<p-toggle-switch
id="syncEnabled"
name="syncEnabled"
@@ -39,7 +40,7 @@
</p-toggle-switch>
</div>
<p class="setting-description">
Turn on synchronization to automatically sync your library books to your Kobo device.
{{ t('kobo.enableSyncDesc') }}
</p>
</div>
</div>
@@ -48,7 +49,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Auto-Add New Books to Kobo Shelf</label>
<label class="setting-label">{{ t('kobo.autoAddLabel') }}</label>
<p-toggle-switch
id="autoAddToShelf"
name="autoAddToShelf"
@@ -57,8 +58,7 @@
</p-toggle-switch>
</div>
<p class="setting-description">
When enabled, newly added books will be automatically added to your Kobo shelf for syncing.
This eliminates the need to manually add each book to the shelf.
{{ t('kobo.autoAddDesc') }}
</p>
</div>
</div>
@@ -68,7 +68,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Kobo Sync Token</label>
<label class="setting-label">{{ t('kobo.token') }}</label>
<div class="token-input-group">
<input
pInputText
@@ -98,7 +98,7 @@
</div>
</div>
<p class="setting-description">
Your unique sync token for authenticating with your Kobo device. Keep this secure.
{{ t('kobo.tokenDesc') }}
</p>
</div>
</div>
@@ -106,19 +106,19 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Token Management</label>
<label class="setting-label">{{ t('kobo.tokenManagement') }}</label>
<p-button
icon="pi pi-refresh"
outlined="true"
severity="warn"
size="small"
label="Regenerate Token"
[label]="t('kobo.regenerateToken')"
(onClick)="confirmRegenerateToken()"
[disabled]="!credentialsSaved">
</p-button>
</div>
<p class="setting-description">
Regenerate your sync token if needed. This will invalidate the current token.
{{ t('kobo.tokenManagementDesc') }}
</p>
</div>
</div>
@@ -126,7 +126,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
<label class="setting-label">{{ t('kobo.markAsReading', {value: koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0)}) }}</label>
<div class="slider-container">
<p-slider
id="markAsReadingThreshold"
@@ -140,9 +140,9 @@
</div>
</div>
<p class="setting-description">
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
{{ t('kobo.markAsReadingDesc') }}
<br>
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
<strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.markAsReadingRec') }}
</p>
</div>
</div>
@@ -150,7 +150,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
<label class="setting-label">{{ t('kobo.markAsFinished', {value: koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0)}) }}</label>
<div class="slider-container">
<p-slider
id="markAsFinishedThreshold"
@@ -164,9 +164,9 @@
</div>
</div>
<p class="setting-description">
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
{{ t('kobo.markAsFinishedDesc') }}
<br>
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
<strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.markAsFinishedRec') }}
</p>
</div>
</div>
@@ -179,10 +179,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
Administrator Settings
{{ t('kobo.adminSettings') }}
</h3>
<p class="section-description">
Configure advanced Kobo sync settings that affect all users on this server.
{{ t('kobo.adminSettingsDesc') }}
</p>
</div>
@@ -190,7 +190,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Convert to KEPUB</label>
<label class="setting-label">{{ t('kobo.convertKepub') }}</label>
<p-toggle-switch
id="convertToKepub"
[(ngModel)]="koboSettings.convertToKepub"
@@ -198,10 +198,9 @@
</p-toggle-switch>
</div>
<p class="setting-description">
<strong>Pros:</strong> KEPUB format enables enhanced Kobo features like better typography, reading stats, and faster page turns.
<strong>{{ t('kobo.pros') }}</strong> {{ t('kobo.convertKepubPros') }}
<br>
<strong>Cons:</strong> Conversion takes extra processing time and may occasionally fail for complex layouts.
Books over the size limit below will skip conversion automatically.
<strong>{{ t('kobo.cons') }}</strong> {{ t('kobo.convertKepubCons') }}
</p>
</div>
</div>
@@ -209,7 +208,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Conversion Size Limit: {{ koboSettings.conversionLimitInMb }} MB</label>
<label class="setting-label">{{ t('kobo.conversionSizeLimit', {value: koboSettings.conversionLimitInMb}) }}</label>
<div class="slider-container">
<p-slider
id="conversionLimit"
@@ -222,9 +221,9 @@
</div>
</div>
<p class="setting-description">
Large files (100MB+) can cause conversion timeouts and server strain. Lower limits ensure faster syncing but may skip conversion of larger books.
{{ t('kobo.conversionSizeLimitDesc') }}
<br>
<strong>Recommended:</strong> 50-100MB for most libraries. Very large books will sync as regular EPUB regardless of this setting.
<strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.conversionSizeLimitRec') }}
</p>
</div>
</div>
@@ -232,16 +231,14 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Force Enable Hyphenation</label>
<label class="setting-label">{{ t('kobo.forceHyphenation') }}</label>
<p-toggle-switch
id="forceEnableHyphenation"
[(ngModel)]="koboSettings.forceEnableHyphenation"
(ngModelChange)="onToggleChange()">
</p-toggle-switch>
</div>
<p class="setting-description">
Force enable hyphenation. Otherwise, hyphenation is only enabled when text alignment on the Kobo
device is explicitly set to <i>justified</i>.
<p class="setting-description" [innerHTML]="t('kobo.forceHyphenationDesc')">
</p>
</div>
</div>
@@ -251,7 +248,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Convert CBX to EPUB</label>
<label class="setting-label">{{ t('kobo.convertCbx') }}</label>
<p-toggle-switch
id="convertCbxToEpub"
[(ngModel)]="koboSettings.convertCbxToEpub"
@@ -259,14 +256,14 @@
</p-toggle-switch>
</div>
<p class="setting-description">
Converts CBX files to EPUB during Kobo sync, allowing CBX files to be downloaded and read on Kobo devices.
{{ t('kobo.convertCbxDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Conversion image compression: {{ koboSettings.conversionImageCompressionPercentage }}%</label>
<label class="setting-label">{{ t('kobo.imageCompression', {value: koboSettings.conversionImageCompressionPercentage}) }}</label>
<div class="slider-container">
<p-slider
id="conversionLimit"
@@ -279,14 +276,14 @@
</div>
</div>
<p class="setting-description">
Comic book conversions can sometimes result in very large files. This setting allows you to compress the images during conversion to prevent size from shooting up.
{{ t('kobo.imageCompressionDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">CBX Conversion Size Limit: {{ koboSettings.conversionLimitInMbForCbx }} MB</label>
<label class="setting-label">{{ t('kobo.cbxSizeLimit', {value: koboSettings.conversionLimitInMbForCbx}) }}</label>
<div class="slider-container">
<p-slider
id="conversionLimitForCbx"
@@ -299,9 +296,9 @@
</div>
</div>
<p class="setting-description">
Comic book archives can be very large due to high-resolution images. Set a reasonable limit to prevent server overload during conversion.
{{ t('kobo.cbxSizeLimitDesc') }}
<br>
<strong>Recommended:</strong> 100-200MB for most comic libraries. CBX files over this limit will not be converted or synced to the device.
<strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.cbxSizeLimitRec') }}
</p>
</div>
</div>
@@ -314,14 +311,15 @@
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>Access Restricted</h3>
<h3>{{ t('accessRestricted') }}</h3>
<p>
Access to Kobo sync is restricted.
{{ t('kobo.accessDenied') }}
<br>
Please contact your administrator to request permission.
{{ t('contactAdmin') }}
</p>
</div>
</div>
</div>
}
</div>
</ng-container>
@@ -17,13 +17,14 @@ import {AppSettingKey, KoboSettings} from '../../../../../shared/model/app-setti
import {ShelfService} from '../../../../book/service/shelf.service';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {ToastModule} from 'primeng/toast';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-kobo-sync-setting-component',
standalone: true,
templateUrl: './kobo-sync-settings-component.html',
styleUrl: './kobo-sync-settings-component.scss',
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, ToastModule],
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, ToastModule, TranslocoDirective],
providers: [MessageService, ConfirmationService]
})
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
@@ -34,6 +35,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
protected appSettingsService = inject(AppSettingsService);
protected settingsHelperService = inject(SettingsHelperService);
private shelfService = inject(ShelfService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
private readonly sliderChange$ = new Subject<void>();
@@ -78,7 +80,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
debounceTime(500),
takeUntil(this.destroy$)
).subscribe(() => {
this.updateKoboSettings('Progress thresholds updated successfully');
this.updateKoboSettings(this.t.translate('settingsDevice.kobo.progressUpdated'));
});
}
@@ -122,7 +124,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
this.credentialsSaved = !!settings.token;
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to load Kobo settings'});
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('settingsDevice.kobo.loadError')});
}
});
}
@@ -150,15 +152,15 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
navigator.clipboard.writeText(text).then(() => {
this.messageService.add({
severity: 'success',
summary: 'Copied',
detail: `${label} copied to clipboard`
summary: this.t.translate('settingsDevice.copied'),
detail: this.t.translate('settingsDevice.copiedDetail', {label})
});
}).catch(err => {
console.error('Copy failed', err);
this.messageService.add({
severity: 'error',
summary: 'Copy Failed',
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
summary: this.t.translate('settingsDevice.copyFailed'),
detail: this.t.translate('settingsDevice.copyFailedDetail', {label})
});
});
}
@@ -170,8 +172,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
confirmRegenerateToken() {
this.confirmationService.confirm({
message: 'This will generate a new token and invalidate the previous one. Continue?',
header: 'Confirm Regeneration',
message: this.t.translate('settingsDevice.kobo.confirmRegenerate'),
header: this.t.translate('settingsDevice.kobo.confirmRegenerateHeader'),
icon: 'pi pi-exclamation-triangle',
accept: () => this.regenerateToken()
});
@@ -182,10 +184,10 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: (settings) => {
this.koboSyncSettings.token = settings.token;
this.credentialsSaved = true;
this.messageService.add({severity: 'success', summary: 'Token regenerated', detail: 'New token generated successfully'});
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.kobo.tokenRegenerated'), detail: this.t.translate('settingsDevice.kobo.tokenRegeneratedDetail')});
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to regenerate token'});
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('settingsDevice.kobo.tokenRegenerateError')});
}
});
}
@@ -201,16 +203,16 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
onSyncToggle() {
if (!this.koboSyncSettings.syncEnabled) {
this.confirmationService.confirm({
message: 'Disabling Kobo sync will delete your Kobo shelf. Are you sure you want to proceed?',
header: 'Confirm Disable',
message: this.t.translate('settingsDevice.kobo.confirmDisable'),
header: this.t.translate('settingsDevice.kobo.confirmDisableHeader'),
icon: 'pi pi-exclamation-triangle',
accept: () => this.updateKoboSettings('Kobo sync disabled'),
accept: () => this.updateKoboSettings(this.t.translate('settingsDevice.kobo.syncDisabled')),
reject: () => {
this.koboSyncSettings.syncEnabled = true;
}
});
} else {
this.updateKoboSettings('Kobo sync enabled');
this.updateKoboSettings(this.t.translate('settingsDevice.kobo.syncEnabled'));
}
}
@@ -220,8 +222,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
onAutoAddToggle() {
const message = this.koboSyncSettings.autoAddToShelf
? 'New books will be automatically added to Kobo shelf'
: 'Auto-add to Kobo shelf disabled';
? this.t.translate('settingsDevice.kobo.autoAddEnabled')
: this.t.translate('settingsDevice.kobo.autoAddDisabled');
this.updateKoboSettings(message);
}
@@ -230,7 +232,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Settings Updated',
summary: this.t.translate('settingsDevice.kobo.settingsUpdated'),
detail: successMessage
});
if (!this.koboSyncSettings.syncEnabled) {
@@ -240,8 +242,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update Kobo settings'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsDevice.kobo.settingsUpdateError')
});
}
});
@@ -253,15 +255,15 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Settings Saved',
detail: 'Kobo settings updated successfully'
summary: this.t.translate('settingsDevice.kobo.settingsSaved'),
detail: this.t.translate('settingsDevice.kobo.settingsSuccess')
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Save Failed',
detail: 'Failed to save Kobo settings'
summary: this.t.translate('settingsDevice.kobo.saveFailed'),
detail: this.t.translate('settingsDevice.kobo.saveError')
});
}
});
@@ -1,14 +1,15 @@
<ng-container *transloco="let t; prefix: 'settingsDevice'">
<p-toast position="top-right"></p-toast>
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-mobile"></i>
KOReader Sync Configuration
{{ t('koreader.title') }}
<app-external-doc-link docType="koReader"></app-external-doc-link>
</h2>
<p class="settings-description">
Configure KOReader integration to sync your reading progress between your device and Booklore library.
{{ t('koreader.description') }}
</p>
</div>
@@ -18,10 +19,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sync"></i>
Sync Configuration
{{ t('koreader.syncConfig') }}
</h3>
<p class="section-description">
Enable and configure synchronization between your Booklore library and KOReader device.
{{ t('koreader.syncConfigDesc') }}
</p>
</div>
@@ -30,7 +31,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enable KOReader Sync</label>
<label class="setting-label">{{ t('koreader.enableSync') }}</label>
<p-toggle-switch
name="syncEnabled"
[(ngModel)]="koReaderSyncEnabled"
@@ -40,7 +41,7 @@
</p-toggle-switch>
</div>
<p class="setting-description">
Turn on synchronization to automatically sync your reading progress.
{{ t('koreader.enableSyncDesc') }}
</p>
</div>
</div>
@@ -48,7 +49,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Sync reading progress with Booklore eBook Reader</label>
<label class="setting-label">{{ t('koreader.syncWithBooklore') }}</label>
<p-toggle-switch
name="syncWithBookloreReader"
[(ngModel)]="syncWithBookloreReader"
@@ -57,8 +58,7 @@
[disabled]="!credentialsSaved || !koReaderSyncEnabled">
</p-toggle-switch>
</div>
<p class="setting-description">
Enable bidirectional sync between Booklore's eBook reader and KOReader. <strong>Note:</strong> Progress sync is approximate and may update by chapter rather than exact page or location.
<p class="setting-description" [innerHTML]="t('koreader.syncWithBookloreDesc')">
</p>
</div>
</div>
@@ -66,7 +66,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">KOReader API Path</label>
<label class="setting-label">{{ t('koreader.apiPath') }}</label>
<div class="token-input-group">
<input
pInputText
@@ -85,7 +85,7 @@
</div>
</div>
<p class="setting-description">
The API endpoint path for your KOReader sync service.
{{ t('koreader.apiPathDesc') }}
</p>
</div>
</div>
@@ -93,7 +93,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">KOReader Username</label>
<label class="setting-label">{{ t('koreader.username') }}</label>
<div class="token-input-group">
<input
pInputText
@@ -116,11 +116,11 @@
</div>
</div>
<p class="setting-description">
Your username for authenticating with the KOReader sync service.
{{ t('koreader.usernameDesc') }}
</p>
@if (editMode && usernameModel.invalid && usernameModel.touched) {
<small class="error-message">
Username is required.
{{ t('koreader.usernameRequired') }}
</small>
}
</div>
@@ -129,7 +129,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">KOReader Password</label>
<label class="setting-label">{{ t('koreader.password') }}</label>
<div class="token-input-group">
<input
pInputText
@@ -162,11 +162,11 @@
</div>
</div>
<p class="setting-description">
Your password for authenticating with the KOReader sync service.
{{ t('koreader.passwordDesc') }}
</p>
@if (editMode && passwordModel.invalid && passwordModel.touched) {
<small class="error-message">
Password must be at least 6 characters.
{{ t('koreader.passwordMinLength') }}
</small>
}
</div>
@@ -175,19 +175,19 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Settings Management</label>
<label class="setting-label">{{ t('koreader.settingsManagement') }}</label>
<p-button
[icon]="!editMode ? 'pi pi-save' : 'pi pi-pencil'"
outlined="true"
[severity]="!editMode ? 'success' : 'warn'"
[label]="!editMode ? 'Save' : 'Edit'"
[label]="!editMode ? ('common.save' | transloco) : ('common.edit' | transloco)"
size="small"
(onClick)="onEditSave()"
[disabled]="!editMode && !canSave">
</p-button>
</div>
<p class="setting-description">
Save your credentials or edit existing settings.
{{ t('koreader.settingsManagementDesc') }}
</p>
</div>
</div>
@@ -201,14 +201,15 @@
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>Access Restricted</h3>
<h3>{{ t('accessRestricted') }}</h3>
<p>
Access to KOReader sync is restricted.
{{ t('koreader.accessDenied') }}
<br>
Please contact your administrator to request permission.
{{ t('contactAdmin') }}
</p>
</div>
</div>
</div>
}
</div>
</ng-container>
@@ -11,6 +11,7 @@ import {UserService} from '../../../user-management/user.service';
import {filter, takeUntil} from 'rxjs/operators';
import {Subject} from 'rxjs';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
standalone: true,
@@ -21,8 +22,10 @@ import {ExternalDocLinkComponent} from '../../../../../shared/components/externa
ToggleSwitch,
Button,
ToastModule,
ExternalDocLinkComponent
],
ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
],
providers: [MessageService],
templateUrl: './koreader-settings-component.html',
styleUrls: ['./koreader-settings-component.scss']
@@ -40,6 +43,7 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
private readonly messageService = inject(MessageService);
private readonly koreaderService = inject(KoreaderService);
private readonly userService = inject(UserService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
hasPermission = false;
@@ -72,8 +76,8 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
if (err.status !== 404) {
this.messageService.add({
severity: 'error',
summary: 'Load Error',
detail: 'Unable to retrieve KOReader account. Please try again.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsDevice.koreader.loadError')
});
}
}
@@ -98,10 +102,10 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
this.koreaderService.toggleSync(enabled).subscribe({
next: () => {
this.koReaderSyncEnabled = enabled;
this.messageService.add({severity: 'success', summary: 'Sync Updated', detail: `KOReader sync has been ${enabled ? 'enabled' : 'disabled'}.`});
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.koreader.syncUpdated'), detail: enabled ? this.t.translate('settingsDevice.koreader.syncEnabled') : this.t.translate('settingsDevice.koreader.syncDisabled')});
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Update Failed', detail: 'Unable to update KOReader sync setting. Please try again.'});
this.messageService.add({severity: 'error', summary: this.t.translate('settingsDevice.koreader.syncUpdateFailed'), detail: this.t.translate('settingsDevice.koreader.syncUpdateError')});
}
});
}
@@ -112,15 +116,15 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
this.syncWithBookloreReader = enabled;
this.messageService.add({
severity: 'success',
summary: 'Sync Updated',
detail: `Booklore eBook Reader sync has been ${enabled ? 'enabled' : 'disabled'}.`
summary: this.t.translate('settingsDevice.koreader.syncUpdated'),
detail: enabled ? this.t.translate('settingsDevice.koreader.bookloreReaderEnabled') : this.t.translate('settingsDevice.koreader.bookloreReaderDisabled')
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Update Failed',
detail: 'Unable to update Booklore eBook Reader sync setting. Please try again.'
summary: this.t.translate('settingsDevice.koreader.syncUpdateFailed'),
detail: this.t.translate('settingsDevice.koreader.bookloreReaderError')
});
}
});
@@ -136,10 +140,10 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
.subscribe({
next: () => {
this.credentialsSaved = true;
this.messageService.add({severity: 'success', summary: 'Saved', detail: 'KOReader account saved successfully.'});
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.koreader.saved'), detail: this.t.translate('settingsDevice.koreader.credentialsSaved')});
},
error: () =>
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to save KOReader credentials. Please try again.'})
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('settingsDevice.koreader.credentialsError')})
});
}
@@ -151,15 +155,15 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
navigator.clipboard.writeText(text).then(() => {
this.messageService.add({
severity: 'success',
summary: 'Copied',
detail: `${label} copied to clipboard`
summary: this.t.translate('settingsDevice.copied'),
detail: this.t.translate('settingsDevice.copiedDetail', {label})
});
}).catch(err => {
console.error('Copy failed', err);
this.messageService.add({
severity: 'error',
summary: 'Copy Failed',
detail: `Unable to copy ${label.toLowerCase()} to clipboard`
summary: this.t.translate('settingsDevice.copyFailed'),
detail: this.t.translate('settingsDevice.copyFailedDetail', {label})
});
});
}
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'settingsEmail.provider.create'">
<div class="email-provider-creator">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-envelope header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Create Email Provider</h2>
<p class="panel-description">Configure a new email provider for sending notifications</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -14,8 +15,7 @@
[text]="true"
[rounded]="true"
class="close-button"
pTooltip="Close"
tooltipPosition="left"/>
/>
</div>
<form [formGroup]="emailProviderForm" (ngSubmit)="createEmailProvider()">
@@ -23,7 +23,7 @@
<div class="form-group highlight-group">
<label for="providerName" class="form-label">
<i class="pi pi-tag label-icon"></i>
Provider Name
{{ t('providerName') }}
<span class="required-indicator">*</span>
</label>
<div class="input-wrapper">
@@ -33,16 +33,16 @@
pInputText
formControlName="name"
class="input-full"
placeholder="e.g., Gmail SMTP, SendGrid"
[placeholder]="t('providerNamePlaceholder')"
[class.filled]="emailProviderForm.get('name')?.value"
/>
@if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) {
<i class="pi pi-check-circle input-icon success"></i>
}
</div>
@if (emailProviderForm.get('name')?.invalid && (emailProviderForm.get('name')?.dirty || emailProviderForm.get('name')?.touched)) {
<small class="field-error">Provider name is required.</small>
<small class="field-error">{{ t('providerNameRequired') }}</small>
}
</div>
@@ -51,7 +51,7 @@
<div class="form-group highlight-group">
<label for="host" class="form-label">
<i class="pi pi-server label-icon"></i>
Host
{{ t('host') }}
<span class="required-indicator">*</span>
</label>
<div class="input-wrapper">
@@ -61,7 +61,7 @@
pInputText
formControlName="host"
class="input-full"
placeholder="e.g., smtp.gmail.com"
[placeholder]="t('hostPlaceholder')"
[class.filled]="emailProviderForm.get('host')?.value"
/>
@if (emailProviderForm.get('host')?.value && emailProviderForm.get('host')?.valid) {
@@ -69,14 +69,14 @@
}
</div>
@if (emailProviderForm.get('host')?.invalid && (emailProviderForm.get('host')?.dirty || emailProviderForm.get('host')?.touched)) {
<small class="field-error">Host is required.</small>
<small class="field-error">{{ t('hostRequired') }}</small>
}
</div>
<div class="form-group highlight-group">
<label for="port" class="form-label">
<i class="pi pi-hashtag label-icon"></i>
Port
{{ t('port') }}
<span class="required-indicator">*</span>
</label>
<div class="input-wrapper">
@@ -86,7 +86,7 @@
pInputText
formControlName="port"
class="input-full"
placeholder="e.g., 587, 465"
[placeholder]="t('portPlaceholder')"
[class.filled]="emailProviderForm.get('port')?.value"
/>
@if (emailProviderForm.get('port')?.value && emailProviderForm.get('port')?.valid) {
@@ -94,7 +94,7 @@
}
</div>
@if (emailProviderForm.get('port')?.invalid && (emailProviderForm.get('port')?.dirty || emailProviderForm.get('port')?.touched)) {
<small class="field-error">Port is required and must be a number.</small>
<small class="field-error">{{ t('portRequired') }}</small>
}
</div>
@@ -103,7 +103,7 @@
<div class="form-group highlight-group">
<label for="username" class="form-label">
<i class="pi pi-user label-icon"></i>
Username
{{ t('username') }}
</label>
<input
id="username"
@@ -111,14 +111,14 @@
pInputText
formControlName="username"
class="input-full"
placeholder="Enter username"
[placeholder]="t('usernamePlaceholder')"
/>
</div>
<div class="form-group highlight-group">
<label for="password" class="form-label">
<i class="pi pi-lock label-icon"></i>
Password
{{ t('password') }}
</label>
<input
id="password"
@@ -126,14 +126,14 @@
pInputText
formControlName="password"
class="input-full"
placeholder="Enter password"
[placeholder]="t('passwordPlaceholder')"
/>
</div>
<div class="form-group highlight-group">
<label for="fromAddress" class="form-label">
<i class="pi pi-at label-icon"></i>
From Address
{{ t('fromAddress') }}
</label>
<input
id="fromAddress"
@@ -141,7 +141,7 @@
pInputText
formControlName="fromAddress"
class="input-full"
placeholder="e.g., noreply@example.com"
[placeholder]="t('fromAddressPlaceholder')"
/>
</div>
@@ -151,8 +151,8 @@
<div class="checkbox-row">
<p-checkbox formControlName="auth" [binary]="true" inputId="auth"></p-checkbox>
<label for="auth" class="checkbox-label">
<span class="checkbox-title">Enable Authentication</span>
<span class="checkbox-description">Require username and password for SMTP</span>
<span class="checkbox-title">{{ t('enableAuth') }}</span>
<span class="checkbox-description">{{ t('enableAuthDesc') }}</span>
</label>
</div>
</div>
@@ -161,8 +161,8 @@
<div class="checkbox-row">
<p-checkbox formControlName="startTls" [binary]="true" inputId="startTls"></p-checkbox>
<label for="startTls" class="checkbox-label">
<span class="checkbox-title">Enable StartTLS</span>
<span class="checkbox-description">Use TLS encryption for secure connection</span>
<span class="checkbox-title">{{ t('enableStartTls') }}</span>
<span class="checkbox-description">{{ t('enableStartTlsDesc') }}</span>
</label>
</div>
</div>
@@ -173,25 +173,25 @@
@if (emailProviderForm.invalid) {
<div class="validation-message error">
<i class="pi pi-exclamation-circle"></i>
<span>Please fill in all required fields</span>
<span>{{ t('requiredFieldsError') }}</span>
</div>
} @else {
<div class="validation-message success">
<i class="pi pi-check-circle"></i>
<span>Ready to create provider</span>
<span>{{ t('readyToCreate') }}</span>
</div>
}
</div>
<div class="footer-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
[outlined]="true"
(onClick)="closeDialog()"
type="button"
/>
<p-button
label="Create Provider"
[label]="t('createBtn')"
icon="pi pi-plus"
severity="success"
type="submit"
@@ -201,3 +201,4 @@
</div>
</form>
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/
import {MessageService} from 'primeng/api';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-create-email-provider-dialog',
@@ -14,7 +15,9 @@ import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.ser
Button,
Checkbox,
InputText,
ReactiveFormsModule
ReactiveFormsModule,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './create-email-provider-dialog.component.html',
styleUrl: './create-email-provider-dialog.component.scss'
@@ -26,6 +29,7 @@ export class CreateEmailProviderDialogComponent implements OnInit {
private emailProviderService = inject(EmailV2ProviderService);
private messageService = inject(MessageService);
private ref = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
ngOnInit() {
this.emailProviderForm = this.fb.group({
@@ -44,8 +48,8 @@ export class CreateEmailProviderDialogComponent implements OnInit {
if (this.emailProviderForm.invalid) {
this.messageService.add({
severity: 'warn',
summary: 'Validation Error',
detail: 'Please correct errors before submitting.'
summary: this.t.translate('settingsEmail.provider.create.validationError'),
detail: this.t.translate('settingsEmail.provider.create.validationErrorDetail')
});
return;
}
@@ -56,18 +60,18 @@ export class CreateEmailProviderDialogComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Email Provider Created',
detail: 'The email provider has been successfully created.'
summary: this.t.translate('settingsEmail.provider.create.success'),
detail: this.t.translate('settingsEmail.provider.create.successDetail')
});
this.ref.close(true);
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Email Provider Creation Failed',
summary: this.t.translate('settingsEmail.provider.create.failed'),
detail: err?.error?.message
? `Unable to create email provider: ${err.error.message}`
: 'An unexpected error occurred while creating the email provider. Please try again later.'
? this.t.translate('settingsEmail.provider.create.failedDetail', {message: err.error.message})
: this.t.translate('settingsEmail.provider.create.failedDefault')
});
}
});
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'settingsEmail.recipient.create'">
<div class="email-recipient-creator">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-user header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Create Email Recipient</h2>
<p class="panel-description">Add a new recipient for email notifications</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -14,7 +15,7 @@
[text]="true"
[rounded]="true"
class="close-button"
pTooltip="Close"
[pTooltip]="'common.close' | transloco"
tooltipPosition="left"/>
</div>
@@ -23,7 +24,7 @@
<div class="form-group highlight-group">
<label for="recipientName" class="form-label">
<i class="pi pi-user label-icon"></i>
Recipient Name
{{ t('recipientName') }}
<span class="required-indicator">*</span>
</label>
<div class="input-wrapper">
@@ -33,16 +34,16 @@
pInputText
formControlName="name"
class="input-full"
placeholder="Enter recipient name..."
[placeholder]="t('recipientNamePlaceholder')"
[class.filled]="emailRecipientForm.get('name')?.value"
/>
@if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) {
<i class="pi pi-check-circle input-icon success"></i>
}
</div>
@if (emailRecipientForm.get('name')?.invalid && (emailRecipientForm.get('name')?.dirty || emailRecipientForm.get('name')?.touched)) {
<small class="field-error">Recipient name is required.</small>
<small class="field-error">{{ t('recipientNameRequired') }}</small>
}
</div>
@@ -51,7 +52,7 @@
<div class="form-group highlight-group">
<label for="email" class="form-label">
<i class="pi pi-at label-icon"></i>
Email Address
{{ t('emailAddress') }}
<span class="required-indicator">*</span>
</label>
<div class="input-wrapper">
@@ -61,7 +62,7 @@
pInputText
formControlName="email"
class="input-full"
placeholder="Enter email address..."
[placeholder]="t('emailAddressPlaceholder')"
[class.filled]="emailRecipientForm.get('email')?.value"
/>
@if (emailRecipientForm.get('email')?.value && emailRecipientForm.get('email')?.valid) {
@@ -69,7 +70,7 @@
}
</div>
@if (emailRecipientForm.get('email')?.invalid && (emailRecipientForm.get('email')?.dirty || emailRecipientForm.get('email')?.touched)) {
<small class="field-error">Valid email is required.</small>
<small class="field-error">{{ t('emailRequired') }}</small>
}
</div>
@@ -79,8 +80,8 @@
<div class="checkbox-row">
<p-checkbox formControlName="defaultRecipient" [binary]="true" inputId="defaultRecipient"></p-checkbox>
<label for="defaultRecipient" class="checkbox-label">
<span class="checkbox-title">Default Recipient</span>
<span class="checkbox-description">Set as default recipient for all notifications</span>
<span class="checkbox-title">{{ t('defaultRecipient') }}</span>
<span class="checkbox-description">{{ t('defaultRecipientDesc') }}</span>
</label>
</div>
</div>
@@ -91,25 +92,25 @@
@if (emailRecipientForm.invalid) {
<div class="validation-message error">
<i class="pi pi-exclamation-circle"></i>
<span>Please fill in all required fields</span>
<span>{{ t('requiredFieldsError') }}</span>
</div>
} @else {
<div class="validation-message success">
<i class="pi pi-check-circle"></i>
<span>Ready to add recipient</span>
<span>{{ t('readyToAdd') }}</span>
</div>
}
</div>
<div class="footer-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
[outlined]="true"
(onClick)="closeDialog()"
type="button"
/>
<p-button
label="Add Recipient"
[label]="t('addBtn')"
icon="pi pi-plus"
severity="success"
type="submit"
@@ -119,3 +120,4 @@
</div>
</form>
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {Button} from 'primeng/button';
import {InputText} from 'primeng/inputtext';
import {EmailV2RecipientService} from '../email-v2-recipient/email-v2-recipient.service';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-create-email-recipient-dialog',
@@ -15,7 +16,9 @@ import {Tooltip} from 'primeng/tooltip';
ReactiveFormsModule,
Button,
InputText,
Tooltip
Tooltip,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './create-email-recipient-dialog.component.html',
styleUrls: ['./create-email-recipient-dialog.component.scss']
@@ -26,6 +29,7 @@ export class CreateEmailRecipientDialogComponent {
private emailRecipientService = inject(EmailV2RecipientService);
private messageService = inject(MessageService);
private ref = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
constructor() {
this.emailRecipientForm = this.fb.group({
@@ -43,8 +47,8 @@ export class CreateEmailRecipientDialogComponent {
if (this.emailRecipientForm.invalid) {
this.messageService.add({
severity: 'warn',
summary: 'Validation Error',
detail: 'Please correct errors before submitting.'
summary: this.t.translate('settingsEmail.recipient.create.validationError'),
detail: this.t.translate('settingsEmail.recipient.create.validationErrorDetail')
});
return;
}
@@ -55,18 +59,18 @@ export class CreateEmailRecipientDialogComponent {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Recipient Added',
detail: `${emailRecipientData.name} has been successfully added.`
summary: this.t.translate('settingsEmail.recipient.create.success'),
detail: this.t.translate('settingsEmail.recipient.create.successDetail', {name: emailRecipientData.name})
});
this.ref.close(true);
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Recipient Creation Failed',
summary: this.t.translate('settingsEmail.recipient.create.failed'),
detail: err?.error?.message
? `Unable to create recipient: ${err.error.message}`
: 'An unexpected error occurred while adding the recipient. Please try again later.'
? this.t.translate('settingsEmail.recipient.create.failedDetail', {message: err.error.message})
: this.t.translate('settingsEmail.recipient.create.failedDefault')
});
}
});
@@ -1,209 +1,211 @@
<div class="settings-card">
<div class="section-header">
<div class="section-header-row">
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-server"></i>
Email Providers
</h3>
<p class="section-description">
Configure email-sending services like Gmail, Outlook, or custom SMTP servers. The default provider is used for 'Quick Book Send' in the Book Card menu.
</p>
<ng-container *transloco="let t; prefix: 'settingsEmail.provider'">
<div class="settings-card">
<div class="section-header">
<div class="section-header-row">
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-server"></i>
{{ t('title') }}
</h3>
<p class="section-description">
{{ t('description') }}
</p>
</div>
<p-button
icon="pi pi-plus"
[label]="t('addProvider')"
severity="success"
size="small"
[outlined]="true"
(onClick)="openCreateProviderDialog()">
</p-button>
</div>
<p-button
icon="pi pi-plus"
label="Add Provider"
severity="success"
size="small"
[outlined]="true"
(onClick)="openCreateProviderDialog()">
</p-button>
</div>
</div>
<div class="section-body">
@if (emailProviders.length === 0) {
<div class="empty-state">
<i class="pi pi-envelope"></i>
<p class="empty-title">No email providers configured</p>
<p class="empty-subtitle">Create your first email provider to start sending books</p>
</div>
} @else {
<div class="providers-list">
@for (provider of emailProviders; track provider.id) {
<div class="provider-item" [class.is-default]="provider.id === defaultProviderId">
<div class="provider-header">
<div class="provider-info">
<div class="provider-name-row">
<p-radioButton
name="defaultProvider"
[value]="provider.id"
[(ngModel)]="defaultProviderId"
(onClick)="setDefaultProvider(provider)">
</p-radioButton>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.name" placeholder="Provider name" class="name-input"/>
} @else {
<span class="provider-name">{{ provider.name }}</span>
@if (provider.shared) {
<span class="shared-badge" pTooltip="Shared with all users">
<i class="pi pi-share-alt"></i>
</span>
<div class="section-body">
@if (emailProviders.length === 0) {
<div class="empty-state">
<i class="pi pi-envelope"></i>
<p class="empty-title">{{ t('emptyTitle') }}</p>
<p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
</div>
} @else {
<div class="providers-list">
@for (provider of emailProviders; track provider.id) {
<div class="provider-item" [class.is-default]="provider.id === defaultProviderId">
<div class="provider-header">
<div class="provider-info">
<div class="provider-name-row">
<p-radioButton
name="defaultProvider"
[value]="provider.id"
[(ngModel)]="defaultProviderId"
(onClick)="setDefaultProvider(provider)">
</p-radioButton>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.name" [placeholder]="t('providerNamePlaceholder')" class="name-input"/>
} @else {
<span class="provider-name">{{ provider.name }}</span>
@if (provider.shared) {
<span class="shared-badge" [pTooltip]="t('sharedTooltip')">
<i class="pi pi-share-alt"></i>
</span>
}
@if (provider.id === defaultProviderId) {
<span class="default-badge">{{ t('default') }}</span>
}
}
@if (provider.id === defaultProviderId) {
<span class="default-badge">Default</span>
</div>
</div>
<div class="provider-actions">
@if (!provider.isEditing) {
<p-button
[icon]="canModifyProvider(provider) ? 'pi pi-pencil' : 'pi pi-lock'"
[severity]="canModifyProvider(provider) ? 'info' : 'secondary'"
size="small"
[outlined]="true"
[rounded]="true"
[disabled]="!canModifyProvider(provider)"
(onClick)="canModifyProvider(provider) && toggleEdit(provider)"
[pTooltip]="canModifyProvider(provider) ? t('editProvider') : t('cannotEditShared')"
tooltipPosition="left">
</p-button>
<p-button
[icon]="canModifyProvider(provider) ? 'pi pi-trash' : 'pi pi-lock'"
[severity]="canModifyProvider(provider) ? 'danger' : 'secondary'"
size="small"
[outlined]="true"
[rounded]="true"
[disabled]="!canModifyProvider(provider)"
(onClick)="canModifyProvider(provider) && deleteProvider(provider)"
[pTooltip]="canModifyProvider(provider) ? t('deleteProvider') : t('cannotDeleteShared')"
tooltipPosition="left">
</p-button>
} @else {
<p-button
icon="pi pi-check"
severity="success"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="saveProvider(provider)"
[pTooltip]="t('saveChanges')">
</p-button>
<p-button
icon="pi pi-times"
severity="secondary"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEdit(provider)"
[pTooltip]="'common.cancel' | transloco">
</p-button>
}
</div>
</div>
<div class="provider-details">
<div class="detail-grid">
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-server"></i>
{{ t('host') }}
</label>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.host" [placeholder]="t('hostPlaceholder')"/>
} @else {
<span class="detail-value">{{ provider.host }}</span>
}
}
</div>
</div>
<div class="provider-actions">
@if (!provider.isEditing) {
<p-button
[icon]="canModifyProvider(provider) ? 'pi pi-pencil' : 'pi pi-lock'"
[severity]="canModifyProvider(provider) ? 'info' : 'secondary'"
size="small"
[outlined]="true"
[rounded]="true"
[disabled]="!canModifyProvider(provider)"
(onClick)="canModifyProvider(provider) && toggleEdit(provider)"
[pTooltip]="canModifyProvider(provider) ? 'Edit provider' : 'Cannot edit shared provider'"
tooltipPosition="left">
</p-button>
<p-button
[icon]="canModifyProvider(provider) ? 'pi pi-trash' : 'pi pi-lock'"
[severity]="canModifyProvider(provider) ? 'danger' : 'secondary'"
size="small"
[outlined]="true"
[rounded]="true"
[disabled]="!canModifyProvider(provider)"
(onClick)="canModifyProvider(provider) && deleteProvider(provider)"
[pTooltip]="canModifyProvider(provider) ? 'Delete provider' : 'Cannot delete shared provider'"
tooltipPosition="left">
</p-button>
} @else {
<p-button
icon="pi pi-check"
severity="success"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="saveProvider(provider)"
pTooltip="Save changes">
</p-button>
<p-button
icon="pi pi-times"
severity="secondary"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEdit(provider)"
pTooltip="Cancel">
</p-button>
}
</div>
</div>
</div>
<div class="provider-details">
<div class="detail-grid">
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-server"></i>
Host
</label>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.host" placeholder="smtp.example.com"/>
} @else {
<span class="detail-value">{{ provider.host }}</span>
}
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-link"></i>
{{ t('port') }}
</label>
@if (provider.isEditing) {
<input type="number" pInputText [(ngModel)]="provider.port" [placeholder]="t('portPlaceholder')"/>
} @else {
<span class="detail-value">{{ provider.port }}</span>
}
</div>
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-user"></i>
{{ t('username') }}
</label>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.username" [placeholder]="t('usernamePlaceholder')"/>
} @else {
<span class="detail-value">{{ provider.username }}</span>
}
</div>
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-lock"></i>
{{ t('password') }}
</label>
@if (provider.isEditing) {
<input type="password" pInputText [(ngModel)]="provider.password" [placeholder]="t('passwordPlaceholder')"/>
} @else {
<span class="detail-value password-hidden">********</span>
}
</div>
<div class="detail-item detail-item-wide">
<label class="detail-label">
<i class="pi pi-envelope"></i>
{{ t('fromAddress') }}
</label>
@if (provider.isEditing) {
<input type="email" pInputText [(ngModel)]="provider.fromAddress" [placeholder]="t('fromAddressPlaceholder')"/>
} @else {
<span class="detail-value">{{ provider.fromAddress }}</span>
}
</div>
</div>
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-link"></i>
Port
</label>
@if (provider.isEditing) {
<input type="number" pInputText [(ngModel)]="provider.port" placeholder="587"/>
} @else {
<span class="detail-value">{{ provider.port }}</span>
}
</div>
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-user"></i>
Username
</label>
@if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.username" placeholder="user@example.com"/>
} @else {
<span class="detail-value">{{ provider.username }}</span>
}
</div>
<div class="detail-item">
<label class="detail-label">
<i class="pi pi-lock"></i>
Password
</label>
@if (provider.isEditing) {
<input type="password" pInputText [(ngModel)]="provider.password" placeholder="Enter password"/>
} @else {
<span class="detail-value password-hidden">********</span>
}
</div>
<div class="detail-item detail-item-wide">
<label class="detail-label">
<i class="pi pi-envelope"></i>
From Address
</label>
@if (provider.isEditing) {
<input type="email" pInputText [(ngModel)]="provider.fromAddress" placeholder="noreply@example.com"/>
} @else {
<span class="detail-value">{{ provider.fromAddress }}</span>
}
</div>
</div>
<div class="toggle-options">
<div class="toggle-item">
<p-checkbox
[(ngModel)]="provider.auth"
[binary]="true"
[disabled]="!provider.isEditing"
inputId="auth-{{provider.id}}">
</p-checkbox>
<label [for]="'auth-' + provider.id" class="toggle-label">Authentication</label>
</div>
<div class="toggle-item">
<p-checkbox
[(ngModel)]="provider.startTls"
[binary]="true"
[disabled]="!provider.isEditing"
inputId="starttls-{{provider.id}}">
</p-checkbox>
<label [for]="'starttls-' + provider.id" class="toggle-label">StartTLS</label>
</div>
@if (isAdmin) {
<div class="toggle-options">
<div class="toggle-item">
<p-checkbox
[(ngModel)]="provider.shared"
[(ngModel)]="provider.auth"
[binary]="true"
(onChange)="toggleShared(provider)"
inputId="shared-{{provider.id}}"
pTooltip="Share this provider with all users">
[disabled]="!provider.isEditing"
inputId="auth-{{provider.id}}">
</p-checkbox>
<label [for]="'shared-' + provider.id" class="toggle-label">Shared</label>
<label [for]="'auth-' + provider.id" class="toggle-label">{{ t('authentication') }}</label>
</div>
}
<div class="toggle-item">
<p-checkbox
[(ngModel)]="provider.startTls"
[binary]="true"
[disabled]="!provider.isEditing"
inputId="starttls-{{provider.id}}">
</p-checkbox>
<label [for]="'starttls-' + provider.id" class="toggle-label">{{ t('startTls') }}</label>
</div>
@if (isAdmin) {
<div class="toggle-item">
<p-checkbox
[(ngModel)]="provider.shared"
[binary]="true"
(onChange)="toggleShared(provider)"
inputId="shared-{{provider.id}}"
[pTooltip]="t('shareTooltip')">
</p-checkbox>
<label [for]="'shared-' + provider.id" class="toggle-label">{{ t('shared') }}</label>
</div>
}
</div>
</div>
</div>
</div>
}
</div>
}
}
</div>
}
</div>
</div>
</div>
</ng-container>
@@ -11,6 +11,7 @@ import {EmailV2ProviderService} from './email-v2-provider.service';
import {EmailProvider} from '../email-provider.model';
import {UserService} from '../../user-management/user.service';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-email-v2-provider',
@@ -21,7 +22,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
ReactiveFormsModule,
TableModule,
Tooltip,
FormsModule
FormsModule,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './email-v2-provider.component.html',
styleUrl: './email-v2-provider.component.scss'
@@ -34,6 +37,7 @@ export class EmailV2ProviderComponent implements OnInit {
private emailProvidersService = inject(EmailV2ProviderService);
private messageService = inject(MessageService);
private userService = inject(UserService);
private t = inject(TranslocoService);
defaultProviderId: unknown;
currentUserId: number | null = null;
isAdmin: boolean = false;
@@ -62,8 +66,8 @@ export class EmailV2ProviderComponent implements OnInit {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to load Email Providers',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.provider.loadError'),
});
},
});
@@ -84,37 +88,37 @@ export class EmailV2ProviderComponent implements OnInit {
provider.isEditing = false;
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Provider updated successfully',
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsEmail.provider.updateSuccess'),
});
this.loadEmailProviders();
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update provider',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.provider.updateError'),
});
},
});
}
deleteProvider(provider: EmailProvider): void {
if (confirm(`Are you sure you want to delete provider "${provider.name}"?`)) {
if (confirm(this.t.translate('settingsEmail.provider.deleteConfirm', {name: provider.name}))) {
this.emailProvidersService.deleteProvider(provider.id).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Provider "${provider.name}" deleted successfully`,
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsEmail.provider.deleteSuccess', {name: provider.name}),
});
this.loadEmailProviders();
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to delete provider',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.provider.deleteError'),
});
},
});
@@ -136,16 +140,16 @@ export class EmailV2ProviderComponent implements OnInit {
this.defaultProviderId = provider.id;
this.messageService.add({
severity: 'success',
summary: 'Default Provider Set',
detail: `${provider.name} is now the default email provider.`
summary: this.t.translate('settingsEmail.provider.defaultSetSummary'),
detail: this.t.translate('settingsEmail.provider.defaultSetDetail', {name: provider.name}),
});
},
error: (err) => {
console.error('Failed to set default provider', err);
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: `Failed to set ${provider.name} as the default provider. Please try again.`
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.provider.defaultSetError', {name: provider.name}),
});
}
});
@@ -158,18 +162,19 @@ export class EmailV2ProviderComponent implements OnInit {
toggleShared(provider: EmailProvider): void {
this.emailProvidersService.updateProvider(provider).subscribe({
next: () => {
const status = this.t.translate(provider.shared ? 'settingsEmail.provider.sharedStatusOn' : 'settingsEmail.provider.sharedStatusOff');
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Provider "${provider.name}" is now ${provider.shared ? 'shared' : 'not shared'}`,
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsEmail.provider.sharedSuccess', {name: provider.name, status}),
});
},
error: () => {
provider.shared = !provider.shared;
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update shared status',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.provider.sharedError'),
});
},
});
@@ -1,129 +1,131 @@
<div class="settings-card">
<div class="section-header">
<div class="section-header-row">
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-users"></i>
Recipient Emails
</h3>
<p class="section-description">
Manage recipient email addresses for sending books. The default recipient is used for 'Quick Book Send' in the Book Card menu.
</p>
<ng-container *transloco="let t; prefix: 'settingsEmail.recipient'">
<div class="settings-card">
<div class="section-header">
<div class="section-header-row">
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-users"></i>
{{ t('title') }}
</h3>
<p class="section-description">
{{ t('description') }}
</p>
</div>
<p-button
icon="pi pi-plus"
[label]="t('addRecipient')"
severity="success"
size="small"
[outlined]="true"
(onClick)="openAddRecipientDialog()">
</p-button>
</div>
<p-button
icon="pi pi-plus"
label="Add Recipient"
severity="success"
size="small"
[outlined]="true"
(onClick)="openAddRecipientDialog()">
</p-button>
</div>
</div>
<div class="section-body">
@if (recipientEmails.length === 0) {
<div class="empty-state">
<i class="pi pi-users"></i>
<p class="empty-title">No recipients configured</p>
<p class="empty-subtitle">Add your first email recipient to start sending books</p>
</div>
} @else {
<div class="recipients-list">
@for (recipient of recipientEmails; track recipient.id) {
<div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId">
<div class="recipient-content">
<div class="recipient-select">
<p-radioButton
name="defaultRecipient"
[value]="recipient.id"
[(ngModel)]="defaultRecipientId"
(onClick)="setDefaultRecipient(recipient)">
</p-radioButton>
</div>
<div class="section-body">
@if (recipientEmails.length === 0) {
<div class="empty-state">
<i class="pi pi-users"></i>
<p class="empty-title">{{ t('emptyTitle') }}</p>
<p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
</div>
} @else {
<div class="recipients-list">
@for (recipient of recipientEmails; track recipient.id) {
<div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId">
<div class="recipient-content">
<div class="recipient-select">
<p-radioButton
name="defaultRecipient"
[value]="recipient.id"
[(ngModel)]="defaultRecipientId"
(onClick)="setDefaultRecipient(recipient)">
</p-radioButton>
</div>
<div class="recipient-info">
@if (recipient.isEditing) {
<div class="edit-form">
<div class="form-field">
<label class="field-label">
<div class="recipient-info">
@if (recipient.isEditing) {
<div class="edit-form">
<div class="form-field">
<label class="field-label">
<i class="pi pi-envelope"></i>
{{ t('email') }}
</label>
<input type="email" pInputText [(ngModel)]="recipient.email" [placeholder]="t('emailPlaceholder')"/>
</div>
<div class="form-field">
<label class="field-label">
<i class="pi pi-user"></i>
{{ t('name') }}
</label>
<input type="text" pInputText [(ngModel)]="recipient.name" [placeholder]="t('namePlaceholder')"/>
</div>
</div>
} @else {
<div class="recipient-details">
<div class="recipient-email">
<i class="pi pi-envelope"></i>
Email
</label>
<input type="email" pInputText [(ngModel)]="recipient.email" placeholder="recipient@example.com"/>
</div>
<div class="form-field">
<label class="field-label">
<i class="pi pi-user"></i>
Name
</label>
<input type="text" pInputText [(ngModel)]="recipient.name" placeholder="Recipient name"/>
</div>
</div>
} @else {
<div class="recipient-details">
<div class="recipient-email">
<i class="pi pi-envelope"></i>
<span>{{ recipient.email }}</span>
@if (recipient.id === defaultRecipientId) {
<span class="default-badge">Default</span>
<span>{{ recipient.email }}</span>
@if (recipient.id === defaultRecipientId) {
<span class="default-badge">{{ t('default') }}</span>
}
</div>
@if (recipient.name) {
<div class="recipient-name">
<i class="pi pi-user"></i>
<span>{{ recipient.name }}</span>
</div>
}
</div>
@if (recipient.name) {
<div class="recipient-name">
<i class="pi pi-user"></i>
<span>{{ recipient.name }}</span>
</div>
}
</div>
}
</div>
}
</div>
<div class="recipient-actions">
@if (!recipient.isEditing) {
<p-button
icon="pi pi-pencil"
severity="info"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEditRecipient(recipient)"
pTooltip="Edit recipient">
</p-button>
<p-button
icon="pi pi-trash"
severity="danger"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="deleteRecipient(recipient)"
pTooltip="Delete recipient">
</p-button>
} @else {
<p-button
icon="pi pi-check"
severity="success"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="saveRecipient(recipient)"
pTooltip="Save changes">
</p-button>
<p-button
icon="pi pi-times"
severity="secondary"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEditRecipient(recipient)"
pTooltip="Cancel">
</p-button>
}
<div class="recipient-actions">
@if (!recipient.isEditing) {
<p-button
icon="pi pi-pencil"
severity="info"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEditRecipient(recipient)"
[pTooltip]="t('editRecipient')">
</p-button>
<p-button
icon="pi pi-trash"
severity="danger"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="deleteRecipient(recipient)"
[pTooltip]="t('deleteRecipient')">
</p-button>
} @else {
<p-button
icon="pi pi-check"
severity="success"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="saveRecipient(recipient)"
[pTooltip]="t('saveChanges')">
</p-button>
<p-button
icon="pi pi-times"
severity="secondary"
size="small"
[outlined]="true"
[rounded]="true"
(onClick)="toggleEditRecipient(recipient)"
[pTooltip]="'common.cancel' | transloco">
</p-button>
}
</div>
</div>
</div>
</div>
}
</div>
}
}
</div>
}
</div>
</div>
</div>
</ng-container>
@@ -9,6 +9,7 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {EmailV2RecipientService} from './email-v2-recipient.service';
import {EmailRecipient} from '../email-recipient.model';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-email-v2-recipient',
@@ -18,7 +19,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
ReactiveFormsModule,
TableModule,
Tooltip,
FormsModule
FormsModule,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './email-v2-recipient.component.html',
styleUrl: './email-v2-recipient.component.scss'
@@ -30,6 +33,7 @@ export class EmailV2RecipientComponent implements OnInit {
private dialogLauncherService = inject(DialogLauncherService);
private emailRecipientService = inject(EmailV2RecipientService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
defaultRecipientId: unknown;
ngOnInit(): void {
@@ -49,8 +53,8 @@ export class EmailV2RecipientComponent implements OnInit {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to load recipient emails',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.recipient.loadError'),
});
},
});
@@ -71,37 +75,37 @@ export class EmailV2RecipientComponent implements OnInit {
recipient.isEditing = false;
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Recipient updated successfully',
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsEmail.recipient.updateSuccess'),
});
this.loadRecipientEmails();
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update recipient',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.recipient.updateError'),
});
},
});
}
deleteRecipient(recipient: EmailRecipient): void {
if (confirm(`Are you sure you want to delete recipient "${recipient.email}"?`)) {
if (confirm(this.t.translate('settingsEmail.recipient.deleteConfirm', {email: recipient.email}))) {
this.emailRecipientService.deleteRecipient(recipient.id).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Recipient "${recipient.email}" deleted successfully`,
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsEmail.recipient.deleteSuccess', {email: recipient.email}),
});
this.loadRecipientEmails();
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to delete recipient',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsEmail.recipient.deleteError'),
});
},
});
@@ -122,8 +126,8 @@ export class EmailV2RecipientComponent implements OnInit {
this.defaultRecipientId = recipient.id;
this.messageService.add({
severity: 'success',
summary: 'Default Recipient Set',
detail: `${recipient.email} is now the default recipient.`
summary: this.t.translate('settingsEmail.recipient.defaultSetSummary'),
detail: this.t.translate('settingsEmail.recipient.defaultSetDetail', {email: recipient.email}),
});
});
}
@@ -1,30 +1,32 @@
<div class="email-settings-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-envelope"></i>
Email Configuration
<app-external-doc-link docType="email"></app-external-doc-link>
</h2>
<p class="settings-description">
Configure email settings to send books directly to your devices or recipients. Set up email providers (like Gmail, Outlook, or custom SMTP servers) and manage recipient email addresses.
</p>
</div>
@if (hasPermission) {
<app-email-v2-provider></app-email-v2-provider>
<div class="section-divider"><hr></div>
<app-email-v2-recipient></app-email-v2-recipient>
} @else {
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>Access Restricted</h3>
<p>
Access to Email Configuration is restricted.
<br>
Please contact your administrator to request permission.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsEmail'">
<div class="email-settings-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-envelope"></i>
{{ t('title') }}
<app-external-doc-link docType="email"></app-external-doc-link>
</h2>
<p class="settings-description">
{{ t('description') }}
</p>
</div>
}
</div>
@if (hasPermission) {
<app-email-v2-provider></app-email-v2-provider>
<div class="section-divider"><hr></div>
<app-email-v2-recipient></app-email-v2-recipient>
} @else {
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>{{ t('accessRestricted') }}</h3>
<p>
{{ t('accessDenied') }}
<br>
{{ t('contactAdmin') }}
</p>
</div>
</div>
}
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
import {UserService} from '../user-management/user.service';
import {Subject} from 'rxjs';
import {filter, takeUntil, tap} from 'rxjs/operators';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
@@ -16,7 +17,8 @@ import {filter, takeUntil, tap} from 'rxjs/operators';
TableModule,
EmailV2ProviderComponent,
EmailV2RecipientComponent,
ExternalDocLinkComponent
ExternalDocLinkComponent,
TranslocoDirective
],
templateUrl: './email-v2.component.html',
styleUrls: ['./email-v2.component.scss'],
@@ -1,20 +1,20 @@
<ng-container *transloco="let t; prefix: 'settingsNaming'">
<div class="file-naming-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-file"></i>
File Naming Patterns
{{ t('title') }}
<app-external-doc-link docType="fileNamePatterns"></app-external-doc-link>
</h2>
<p class="settings-description">
Configure automatic file organization using metadata placeholders. Patterns are applied when uploading, moving files, or after metadata updates.
{{ t('description') }}
</p>
</div>
<div class="warning-notice">
<i class="pi pi-exclamation-triangle"></i>
<div>
<strong>Metadata Quality Notice:</strong> File naming relies entirely on metadata stored in Booklore.
This feature is recommended only for high-quality, curated libraries with complete metadata.
<strong>{{ t('warning.title') }}</strong> {{ t('warning.text') }}
</div>
</div>
@@ -22,9 +22,9 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-bolt"></i>
Default Pattern
{{ t('defaultPattern.sectionTitle') }}
</h3>
<p class="section-description">Fallback pattern when no library-specific override is configured.</p>
<p class="section-description">{{ t('defaultPattern.sectionDesc') }}</p>
</div>
<div class="section-body">
@@ -35,11 +35,11 @@
pInputText
id="defaultPattern"
[(ngModel)]="defaultPattern"
placeholder="e.g., {title} - {authors}"
[placeholder]="t('defaultPattern.placeholder')"
(input)="onDefaultPatternChange(defaultPattern)"
class="pattern-input"/>
<p-button
label="Save"
[label]="'common.save' | transloco"
icon="pi pi-save"
(onClick)="savePatterns()"
severity="success"
@@ -53,7 +53,7 @@
<div class="preview-row">
<span class="preview-label">
<i class="pi pi-eye"></i>
Preview:
{{ t('defaultPattern.preview') }}
</span>
<code class="preview-value">{{ generateDefaultPreview() }}</code>
</div>
@@ -66,10 +66,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-folder"></i>
Library Overrides
{{ t('libraryOverrides.sectionTitle') }}
</h3>
<p class="section-description">
Define custom patterns for specific libraries. Leave empty to use the default pattern.
{{ t('libraryOverrides.sectionDesc') }}
</p>
</div>
@@ -77,8 +77,8 @@
@if (libraries.length === 0) {
<div class="empty-state">
<i class="pi pi-folder-open"></i>
<p class="empty-title">No libraries found</p>
<p class="empty-subtitle">Create a library to configure custom naming patterns</p>
<p class="empty-title">{{ t('libraryOverrides.emptyTitle') }}</p>
<p class="empty-subtitle">{{ t('libraryOverrides.emptySubtitle') }}</p>
</div>
} @else {
<div class="libraries-list">
@@ -91,9 +91,9 @@
</div>
<span class="library-name">{{ library.name }}</span>
@if (library.fileNamingPattern) {
<span class="custom-badge">Custom</span>
<span class="custom-badge">{{ t('libraryOverrides.custom') }}</span>
} @else {
<span class="default-badge">Using Default</span>
<span class="default-badge">{{ t('libraryOverrides.usingDefault') }}</span>
}
</div>
<p-button
@@ -104,7 +104,7 @@
[rounded]="true"
(onClick)="clearLibraryPattern(library)"
[disabled]="!library.fileNamingPattern"
pTooltip="Clear pattern">
[pTooltip]="t('libraryOverrides.clearPattern')">
</p-button>
</div>
<div class="library-body">
@@ -112,13 +112,13 @@
<input
pInputText
[(ngModel)]="library.fileNamingPattern"
placeholder="Leave empty to use default pattern"
[placeholder]="t('libraryOverrides.placeholder')"
(input)="onLibraryPatternChange(library)"
class="pattern-input"/>
<div class="preview-row">
<span class="preview-label">
<i class="pi pi-eye"></i>
Preview:
{{ t('libraryOverrides.preview') }}
</span>
<code class="preview-value">{{ generateLibraryPreview(library) }}</code>
</div>
@@ -130,7 +130,7 @@
<div class="actions-row">
<p-button
label="Save All"
[label]="t('libraryOverrides.saveAll')"
(onClick)="saveLibraryPatterns()"
severity="success"
icon="pi pi-save"
@@ -145,10 +145,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-info-circle"></i>
Placeholders Reference
{{ t('placeholders.sectionTitle') }}
</h3>
<p class="section-description">
Use placeholders to dynamically insert metadata into file names and folder paths.
{{ t('placeholders.sectionDesc') }}
</p>
</div>
@@ -157,43 +157,41 @@
<div class="placeholder-group">
<h4 class="group-title">
<i class="pi pi-hashtag"></i>
Available Placeholders
{{ t('placeholders.available') }}
</h4>
<div class="placeholder-list">
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>Book title</span></div>
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>Book subtitle</span></div>
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>Author(s)</span></div>
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>Publication year</span></div>
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>Series name</span></div>
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>Series index</span></div>
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>Language code</span></div>
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>Publisher</span></div>
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>ISBN number</span></div>
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>Original filename</span></div>
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>{{ t('placeholders.title') }}</span></div>
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>{{ t('placeholders.subtitle') }}</span></div>
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>{{ t('placeholders.authors') }}</span></div>
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>{{ t('placeholders.year') }}</span></div>
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>{{ t('placeholders.series') }}</span></div>
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>{{ t('placeholders.seriesIndex') }}</span></div>
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>{{ t('placeholders.language') }}</span></div>
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>{{ t('placeholders.publisher') }}</span></div>
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>{{ t('placeholders.isbn') }}</span></div>
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>{{ t('placeholders.currentFilename') }}</span></div>
</div>
</div>
<div class="placeholder-group">
<h4 class="group-title">
<i class="pi pi-code"></i>
Optional Blocks
{{ t('placeholders.optionalBlocks') }}
</h4>
<p class="group-description">
Wrap parts in angle brackets <code>{{ '{<...>}' }}</code> to make them conditional.
If any placeholder in the block has no value, the entire block is omitted.
<p class="group-description" [innerHTML]="t('placeholders.optionalDesc', { syntax: '{<...>}' })">
</p>
<div class="example-block">
<div class="example-pattern">
<span class="pattern-prefix">Pattern:</span>
<span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
<code>{{ '{<{seriesIndex} - >{title}' }}</code>
</div>
<div class="example-results">
<div class="result-item">
<span class="result-prefix">With index:</span>
<span class="result-prefix">{{ t('placeholders.withIndex') }}</span>
<code>01 - Dune</code>
</div>
<div class="result-item">
<span class="result-prefix">Without:</span>
<span class="result-prefix">{{ t('placeholders.without') }}</span>
<code>Dune</code>
</div>
</div>
@@ -207,10 +205,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-eye"></i>
Pattern Examples
{{ t('examples.sectionTitle') }}
</h3>
<p class="section-description">
Sample patterns with example metadata to help you understand how patterns work.
{{ t('examples.sectionDesc') }}
</p>
</div>
@@ -220,7 +218,7 @@
<div class="category-header">
<h4 class="category-title">
<i class="pi pi-check-circle"></i>
With Full Metadata
{{ t('examples.withFull') }}
</h4>
<div class="sample-metadata">
<div class="metadata-items">
@@ -236,32 +234,32 @@
<div class="example-grid">
<div class="example-row">
<span class="pattern-label">Basic pattern</span>
<span class="pattern-label">{{ t('examples.basicPattern') }}</span>
<span class="pattern-col"><code>{{ '{authors} - {title}' }}</code></span>
<span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">With punctuation</span>
<span class="pattern-label">{{ t('examples.withPunctuation') }}</span>
<span class="pattern-col"><code>{{ '{title}: {series}' }}</code></span>
<span class="result-col"><code>The Name of the Wind: The Kingkiller Chronicle.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Series in folder</span>
<span class="pattern-label">{{ t('examples.seriesInFolder') }}</span>
<span class="pattern-col"><code>{{ '{authors}/{series}/{seriesIndex} - {title}' }}</code></span>
<span class="result-col"><code>Patrick Rothfuss/The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Folder only</span>
<span class="pattern-label">{{ t('examples.folderOnly') }}</span>
<span class="pattern-col"><code>{{ '{title}/' }}</code></span>
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Absolute path</span>
<span class="pattern-label">{{ t('examples.absolutePath') }}</span>
<span class="pattern-col"><code>{{ '/{authors}/{title}' }}</code></span>
<span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Title + Subtitle</span>
<span class="pattern-label">{{ t('examples.titleSubtitle') }}</span>
<span class="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
</div>
@@ -274,48 +272,48 @@
<div class="category-header">
<h4 class="category-title">
<i class="pi pi-question-circle"></i>
With Missing Optional Fields
{{ t('examples.withMissing') }}
</h4>
<div class="sample-metadata">
<div class="metadata-items">
<span><strong>title:</strong> <code>Project Hail Mary</code></span>
<span><strong>subtitle:</strong> <em class="not-set">not set</em></span>
<span><strong>subtitle:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
<span><strong>authors:</strong> <code>Andy Weir</code></span>
<span><strong>year:</strong> <code>2021</code></span>
<span><strong>series:</strong> <em class="not-set">not set</em></span>
<span><strong>seriesIndex:</strong> <em class="not-set">not set</em></span>
<span><strong>series:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
<span><strong>seriesIndex:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
</div>
</div>
</div>
<div class="example-grid">
<div class="example-row">
<span class="pattern-label">Optional blocks</span>
<span class="pattern-label">{{ t('examples.optionalBlocks') }}</span>
<span class="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
<span class="result-col"><code>Andy Weir/Project Hail Mary (2021).epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">SeriesIndex fallback</span>
<span class="pattern-label">{{ t('examples.seriesIndexFallback') }}</span>
<span class="pattern-col"><code>{{ '<{seriesIndex}. >{title}< - {authors}>' }}</code></span>
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Brackets fallback</span>
<span class="pattern-label">{{ t('examples.bracketsFallback') }}</span>
<span class="pattern-col"><code>{{ '<[{series}] >{title} - {authors}' }}</code></span>
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Series punctuation</span>
<span class="pattern-label">{{ t('examples.seriesPunctuation') }}</span>
<span class="pattern-col"><code>{{ '<{series}: >{title} by {authors}' }}</code></span>
<span class="result-col"><code>Project Hail Mary by Andy Weir.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Year prefix</span>
<span class="pattern-label">{{ t('examples.yearPrefix') }}</span>
<span class="pattern-col"><code>{{ '{authors}/{year}__{currentFilename}' }}</code></span>
<span class="result-col"><code>Andy Weir/2021__project_hail_mary_final.epub</code></span>
</div>
<div class="example-row">
<span class="pattern-label">Subtitle fallback</span>
<span class="pattern-label">{{ t('examples.subtitleFallback') }}</span>
<span class="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
<span class="result-col"><code>Project Hail Mary.epub</code></span>
</div>
@@ -325,3 +323,4 @@
</div>
</div>
</div>
</ng-container>
@@ -9,13 +9,15 @@ import {catchError, filter, take} from 'rxjs/operators';
import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service';
import {InputText} from 'primeng/inputtext';
import {Tooltip} from 'primeng/tooltip';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-file-naming-pattern',
templateUrl: './file-naming-pattern.component.html',
standalone: true,
imports: [FormsModule, Button, InputText, ExternalDocLinkComponent],
imports: [FormsModule, Button, InputText, Tooltip, ExternalDocLinkComponent, TranslocoDirective, TranslocoPipe],
styleUrls: ['./file-naming-pattern.component.scss'],
})
export class FileNamingPatternComponent implements OnInit {
@@ -38,6 +40,7 @@ export class FileNamingPatternComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService);
private libraryService = inject(LibraryService);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -100,7 +103,7 @@ export class FileNamingPatternComponent implements OnInit {
onDefaultPatternChange(pattern: string): void {
this.defaultPattern = pattern;
this.defaultErrorMessage = this.validatePattern(pattern) ? '' : 'Pattern contains invalid characters.';
this.defaultErrorMessage = this.validatePattern(pattern) ? '' : this.t.translate('settingsNaming.defaultPattern.invalidChars');
}
onLibraryPatternChange(library: Library): void {
@@ -113,7 +116,7 @@ export class FileNamingPatternComponent implements OnInit {
savePatterns(): void {
if (this.defaultErrorMessage) {
this.showMessage('error', 'Invalid Pattern', 'Please fix errors before saving.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.invalidError'));
return;
}
this.appSettingsService
@@ -121,8 +124,8 @@ export class FileNamingPatternComponent implements OnInit {
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
])
.subscribe({
next: () => this.showMessage('success', 'Settings Saved', 'The default pattern was successfully saved!'),
error: () => this.showMessage('error', 'Error', 'There was an error saving the settings.'),
next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
error: () => this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.saveError')),
});
}
@@ -135,9 +138,9 @@ export class FileNamingPatternComponent implements OnInit {
forkJoin(patchRequests).subscribe(results => {
const failures = results.filter(result => result === null);
if (failures.length === 0) {
this.showMessage('success', 'Library Patterns Saved', 'Library-specific patterns were successfully saved!');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.libraryOverrides.saveSuccess'));
} else {
this.showMessage('error', 'Error', `Failed to save ${failures.length} library pattern(s).`);
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.libraryOverrides.saveError', {count: failures.length}));
}
});
}
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'settingsApp'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-cog"></i>
Global Preferences
{{ t('title') }}
</h2>
<p class="settings-description">
Configure global settings for your Booklore instance, including cover image handling, search preferences, and file upload limits.
{{ t('description') }}
</p>
</div>
@@ -14,7 +15,7 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-image"></i>
Book Cover Image
{{ t('covers.sectionTitle') }}
</h3>
</div>
@@ -22,9 +23,9 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Regenerate Covers</label>
<label class="setting-label">{{ t('covers.regenerate') }}</label>
<p-button
label="Regenerate"
[label]="t('covers.regenerateBtn')"
icon="pi pi-refresh"
outlined="true"
size="small"
@@ -34,7 +35,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Regenerates cover images for all books from the embedded covers in the file.
{{ t('covers.regenerateDesc') }}
</p>
</div>
</div>
@@ -42,7 +43,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Vertical Cover Cropping</label>
<label class="setting-label">{{ t('covers.verticalCropping') }}</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.verticalCroppingEnabled"
(onChange)="onCoverCroppingChange()">
@@ -50,7 +51,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically crop extremely tall images (like web comics) from the top to create usable cover thumbnails.
{{ t('covers.verticalCroppingDesc') }}
</p>
</div>
</div>
@@ -58,7 +59,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Horizontal Cover Cropping</label>
<label class="setting-label">{{ t('covers.horizontalCropping') }}</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.horizontalCroppingEnabled"
(onChange)="onCoverCroppingChange()">
@@ -66,7 +67,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically crop extremely wide images from the left to create usable cover thumbnails.
{{ t('covers.horizontalCroppingDesc') }}
</p>
</div>
</div>
@@ -74,7 +75,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Aspect Ratio Threshold: {{ coverCroppingSettings.aspectRatioThreshold }}</label>
<label class="setting-label">{{ t('covers.aspectRatio', {value: coverCroppingSettings.aspectRatioThreshold}) }}</label>
<div class="slider-container">
<p-slider
[(ngModel)]="coverCroppingSettings.aspectRatioThreshold"
@@ -87,7 +88,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Images with aspect ratios exceeding this threshold will be cropped. A value of 2.5 means images more than 2.5x taller (or wider) than normal will be cropped.
{{ t('covers.aspectRatioDesc') }}
</p>
</div>
</div>
@@ -95,7 +96,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Smart Cropping</label>
<label class="setting-label">{{ t('covers.smartCropping') }}</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.smartCroppingEnabled"
(onChange)="onCoverCroppingChange()">
@@ -103,7 +104,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Skip uniform colour regions when determining where to crop. Focuses the cover image on the most relevant content.
{{ t('covers.smartCroppingDesc') }}
</p>
</div>
</div>
@@ -114,7 +115,7 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-search"></i>
Search & Recommendations
{{ t('search.sectionTitle') }}
</h3>
</div>
@@ -122,7 +123,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Auto Book Search</label>
<label class="setting-label">{{ t('search.autoBookSearch') }}</label>
<p-toggleswitch
[(ngModel)]="toggles.autoBookSearch"
(onChange)="onToggleChange('autoBookSearch', $event.checked)">
@@ -130,7 +131,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically attempts metadata matching when the book information panel is opened.
{{ t('search.autoBookSearchDesc') }}
</p>
</div>
</div>
@@ -138,7 +139,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Similar Book Recommendation</label>
<label class="setting-label">{{ t('search.similarBook') }}</label>
<p-toggleswitch
[(ngModel)]="toggles.similarBookRecommendation"
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)">
@@ -146,7 +147,7 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Enables or disables similar book recommendations based on your library.
{{ t('search.similarBookDesc') }}
</p>
</div>
</div>
@@ -157,7 +158,7 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-upload"></i>
File Management
{{ t('fileManagement.sectionTitle') }}
</h3>
</div>
@@ -165,26 +166,26 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Max File Upload Size</label>
<label class="setting-label">{{ t('fileManagement.maxUploadSize') }}</label>
<div class="input-group">
<div class="input-with-unit">
<input
type="text"
pInputText
[(ngModel)]="maxFileUploadSizeInMb"
placeholder="Max size"/>
[placeholder]="t('fileManagement.maxUploadPlaceholder')"/>
<span class="unit">MB</span>
</div>
<p-button label="Save" outlined severity="success" (onClick)="saveFileSize()"></p-button>
<p-button [label]="'common.save' | transloco" outlined severity="success" (onClick)="saveFileSize()"></p-button>
</div>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Defines the maximum allowed size (in MB) for each uploaded file. Applies to EPUB, PDF, CBZ, CBR, and CB7 formats.
{{ t('fileManagement.maxUploadDesc') }}
</p>
<div class="warning-message">
<i class="pi pi-exclamation-triangle"></i>
<span>Changes will take effect after restarting the server</span>
<span>{{ t('fileManagement.restartWarning') }}</span>
</div>
</div>
</div>
@@ -196,7 +197,7 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-chart-bar"></i>
Telemetry
{{ t('telemetry.sectionTitle') }}
<app-external-doc-link docType="telemetry"></app-external-doc-link>
</h3>
</div>
@@ -204,7 +205,7 @@
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Enable Telemetry</label>
<label class="setting-label">{{ t('telemetry.enableTelemetry') }}</label>
<p-toggleswitch
[(ngModel)]="toggles.enableTelemetry"
(onChange)="onToggleChange('enableTelemetry', $event.checked)">
@@ -212,11 +213,12 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Help improve Booklore by sharing anonymous usage statistics. This data lets the developers see which features are most used, identify bugs, and spot performance issues so they know what to work on next. No personal information, book content, or any identifiable data is ever sent. Data
is sent to the Booklore server automatically once every 24 hours. It’s completely safe and very helpful to the developers. </p>
{{ t('telemetry.telemetryDesc') }}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -12,6 +12,7 @@ import {filter, take} from 'rxjs/operators';
import {InputText} from 'primeng/inputtext';
import {Slider} from 'primeng/slider';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-global-preferences',
@@ -22,7 +23,9 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
FormsModule,
InputText,
Slider,
ExternalDocLinkComponent
ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './global-preferences.component.html',
styleUrl: './global-preferences.component.scss'
@@ -45,6 +48,7 @@ export class GlobalPreferencesComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private bookService = inject(BookService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
maxFileUploadSizeInMb?: number;
@@ -87,7 +91,7 @@ export class GlobalPreferencesComponent implements OnInit {
saveFileSize() {
if (!this.maxFileUploadSizeInMb || this.maxFileUploadSizeInMb <= 0) {
this.showMessage('error', 'Invalid Input', 'Please enter a valid max file upload size in MB.');
this.showMessage('error', this.t.translate('settingsApp.fileManagement.invalidInput'), this.t.translate('settingsApp.fileManagement.invalidInputDetail'));
return;
}
this.saveSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, this.maxFileUploadSizeInMb);
@@ -96,18 +100,18 @@ export class GlobalPreferencesComponent implements OnInit {
regenerateCovers(): void {
this.bookService.regenerateCovers().subscribe({
next: () =>
this.showMessage('success', 'Cover Regeneration Started', 'Book covers are being regenerated.'),
this.showMessage('success', this.t.translate('settingsApp.covers.regenerateStarted'), this.t.translate('settingsApp.covers.regenerateStartedDetail')),
error: () =>
this.showMessage('error', 'Error', 'Failed to start cover regeneration.')
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsApp.covers.regenerateError'))
});
}
private saveSetting(key: string, value: unknown): void {
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () =>
this.showMessage('success', 'Settings Saved', 'The settings were successfully saved!'),
this.showMessage('success', this.t.translate('settingsApp.settingsSaved'), this.t.translate('settingsApp.settingsSavedDetail')),
error: () =>
this.showMessage('error', 'Error', 'There was an error saving the settings.')
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsApp.settingsError'))
});
}
@@ -1,65 +1,67 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sliders-h"></i>
Metadata Match Weights
</h3>
<p class="section-description">
Configure how important each metadata field is when computing match scores. Higher weights make fields more influential in determining the overall match quality.
</p>
</div>
<div class="section-body">
<div class="setting-item action-item">
<div class="action-row">
<div class="action-info">
<span class="action-label">Recalculate Metadata Scores</span>
<span class="action-description">Recomputes match scores for all books based on the latest weights.</span>
</div>
<p-button
type="button"
icon="pi pi-refresh"
label="Recalculate"
[disabled]="isRecalculating"
(click)="recalculate()"
outlined>
</p-button>
</div>
<ng-container *transloco="let t; prefix: 'settingsMeta.matchWeights'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sliders-h"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="setting-item weights-item">
<div class="weights-header">
<span class="weights-icon pi pi-sliders-v"></span>
<h4 class="weights-label">Field Weights</h4>
</div>
<form [formGroup]="form" class="weights-form">
<div class="weights-grid">
@for (key of orderedKeys; track key) {
<div class="weight-field">
<label class="field-label">{{ labelMap[key] }}</label>
<p-inputNumber
size="small"
[formControlName]="key"
[min]="0"
[max]="10"
fluid
[showButtons]="true"/>
</div>
}
</div>
<div class="form-actions">
<div class="section-body">
<div class="setting-item action-item">
<div class="action-row">
<div class="action-info">
<span class="action-label">{{ t('recalculateLabel') }}</span>
<span class="action-description">{{ t('recalculateDesc') }}</span>
</div>
<p-button
type="button"
severity="success"
label="Save Weights"
icon="pi pi-save"
outlined
[disabled]="isSaving"
(click)="save()">
icon="pi pi-refresh"
[label]="t('recalculateBtn')"
[disabled]="isRecalculating"
(click)="recalculate()"
outlined>
</p-button>
</div>
</form>
</div>
<div class="setting-item weights-item">
<div class="weights-header">
<span class="weights-icon pi pi-sliders-v"></span>
<h4 class="weights-label">{{ t('fieldWeights') }}</h4>
</div>
<form [formGroup]="form" class="weights-form">
<div class="weights-grid">
@for (key of orderedKeys; track key) {
<div class="weight-field">
<label class="field-label">{{ labelMap[key] }}</label>
<p-inputNumber
size="small"
[formControlName]="key"
[min]="0"
[max]="10"
fluid
[showButtons]="true"/>
</div>
}
</div>
<div class="form-actions">
<p-button
type="button"
severity="success"
[label]="t('saveWeights')"
icon="pi pi-save"
outlined
[disabled]="isSaving"
(click)="save()">
</p-button>
</div>
</form>
</div>
</div>
</div>
</div>
</ng-container>
@@ -8,14 +8,15 @@ import {Observable} from 'rxjs';
import {AppSettingKey, AppSettings} from '../../../../shared/model/app-settings.model';
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {InputNumber} from 'primeng/inputnumber';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-match-weights-component',
imports: [
ReactiveFormsModule,
Button,
InputNumber
InputNumber,
TranslocoDirective
],
templateUrl: './metadata-match-weights-component.html',
styleUrl: './metadata-match-weights-component.scss'
@@ -56,6 +57,7 @@ export class MetadataMatchWeightsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService);
private fb = inject(FormBuilder);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -114,16 +116,16 @@ export class MetadataMatchWeightsComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Saved',
detail: 'Weights saved successfully'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsMeta.matchWeights.saveSuccess')
});
this.isSaving = false;
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to save weights'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsMeta.matchWeights.saveError')
});
this.isSaving = false;
}
@@ -136,16 +138,16 @@ export class MetadataMatchWeightsComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Recalculated',
detail: 'All book match scores were recalculated successfully.'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsMeta.matchWeights.recalcSuccess')
});
this.isRecalculating = false;
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to recalculate match scores.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsMeta.matchWeights.recalcError')
});
this.isRecalculating = false;
}
@@ -1,189 +1,191 @@
<div class="metadata-settings">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cloud"></i>
Metadata Providers
</h3>
<p class="section-description">
Configure which online sources to use for fetching book metadata. Enable providers and set up their API tokens or cookies to access richer book information.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsMeta.providers'">
<div class="metadata-settings">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cloud"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="section-body">
<div class="configurable-providers-section">
<h4 class="provider-group-title">Providers with Configuration</h4>
<div class="section-body">
<div class="configurable-providers-section">
<h4 class="provider-group-title">{{ t('configurableTitle') }}</h4>
<div class="configurable-providers-list">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="amazonEnabled"></p-toggleswitch>
<label class="setting-label">Amazon</label>
</div>
@if (amazonEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">Region</label>
<p-select
[options]="amazonDomains"
[(ngModel)]="selectedAmazonDomain"
placeholder="Select Domain"
class="config-select">
</p-select>
<div class="configurable-providers-list">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="amazonEnabled"></p-toggleswitch>
<label class="setting-label">Amazon</label>
</div>
@if (amazonEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">{{ t('region') }}</label>
<p-select
[options]="amazonDomains"
[(ngModel)]="selectedAmazonDomain"
[placeholder]="t('selectDomain')"
class="config-select">
</p-select>
</div>
<div class="config-field">
<div class="config-label-row">
<label class="config-label">{{ t('cookieLabel') }}</label>
<app-external-doc-link docType="amazonCookie"></app-external-doc-link>
</div>
<p class="config-description">{{ t('cookieDesc') }}</p>
<input
type="text"
pInputText
[placeholder]="t('cookiePlaceholder')"
[(ngModel)]="amazonCookie"
class="config-input"/>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="googleEnabled"></p-toggleswitch>
<label class="setting-label">Google Books</label>
</div>
@if (googleEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">{{ t('languageRestriction') }}</label>
<p-select
[options]="googleLanguages"
[(ngModel)]="selectedGoogleLanguage"
[showClear]="!!selectedGoogleLanguage"
[placeholder]="t('selectLanguage')"
class="config-select">
</p-select>
</div>
<div class="config-field">
<label class="config-label">{{ t('apiKeyOptional') }}</label>
<p class="config-description">{{ t('googleApiDesc') }}</p>
<input
type="text"
pInputText
[placeholder]="t('googleApiPlaceholder')"
[(ngModel)]="googleApiKey"
class="config-input"/>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="hardcoverEnabled"
[disabled]="!hardcoverToken">
</p-toggleswitch>
<label class="setting-label">Hardcover</label>
</div>
<div class="setting-options">
<div class="config-field">
<div class="config-label-row">
<label class="config-label">Cookie (Optional, but highly recommended)</label>
<app-external-doc-link docType="amazonCookie"></app-external-doc-link>
<label class="config-label">{{ t('apiToken') }}</label>
<app-external-doc-link docType="hardcover"></app-external-doc-link>
</div>
<p class="config-description">Providing your Amazon session cookie allows the app to access richer book metadata and bypass rate limits.</p>
<input
type="text"
pInputText
placeholder="Paste your Amazon cookie"
[(ngModel)]="amazonCookie"
[placeholder]="t('hardcoverPlaceholder')"
[(ngModel)]="hardcoverToken"
(ngModelChange)="onTokenChange($event)"
class="config-input"/>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="googleEnabled"></p-toggleswitch>
<label class="setting-label">Google Books</label>
</div>
@if (googleEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">Language Restriction</label>
<p-select
[options]="googleLanguages"
[(ngModel)]="selectedGoogleLanguage"
[showClear]="!!selectedGoogleLanguage"
placeholder="Select Language"
class="config-select">
</p-select>
</div>
<div class="config-field">
<label class="config-label">API Key (Optional)</label>
<p class="config-description">Providing a Google Books API key increases rate limits and improves reliability.</p>
<input
type="text"
pInputText
placeholder="Enter Google Books API key"
[(ngModel)]="googleApiKey"
class="config-input"/>
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="comicvineEnabled"></p-toggleswitch>
<label class="setting-label">Comic Vine</label>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="hardcoverEnabled"
[disabled]="!hardcoverToken">
</p-toggleswitch>
<label class="setting-label">Hardcover</label>
</div>
<div class="setting-options">
<div class="config-field">
<div class="config-label-row">
<label class="config-label">API Token</label>
<app-external-doc-link docType="hardcover"></app-external-doc-link>
@if (comicvineEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">{{ t('apiToken') }}</label>
<input
type="text"
pInputText
[placeholder]="t('comicvinePlaceholder')"
[(ngModel)]="comicvineToken"
(ngModelChange)="onComicTokenChange($event)"
class="config-input"/>
</div>
</div>
<input
type="text"
pInputText
placeholder="Enter Hardcover API token"
[(ngModel)]="hardcoverToken"
(ngModelChange)="onTokenChange($event)"
class="config-input"/>
</div>
}
</div>
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="comicvineEnabled"></p-toggleswitch>
<label class="setting-label">Comic Vine</label>
</div>
@if (comicvineEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">API Token</label>
<input
type="text"
pInputText
placeholder="Enter Comic Vine API token"
[(ngModel)]="comicvineToken"
(ngModelChange)="onComicTokenChange($event)"
class="config-input"/>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="audibleEnabled"></p-toggleswitch>
<label class="setting-label">Audible</label>
</div>
@if (audibleEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">{{ t('region') }}</label>
<p-select
[options]="audibleDomains"
[(ngModel)]="selectedAudibleDomain"
[placeholder]="t('selectDomain')"
class="config-select">
</p-select>
</div>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="audibleEnabled"></p-toggleswitch>
<label class="setting-label">Audible</label>
</div>
@if (audibleEnabled) {
<div class="setting-options">
<div class="config-field">
<label class="config-label">Region</label>
<p-select
[options]="audibleDomains"
[(ngModel)]="selectedAudibleDomain"
placeholder="Select Domain"
class="config-select">
</p-select>
</div>
</div>
}
</div>
</div>
</div>
<div class="simple-providers-section">
<h4 class="provider-group-title">Ready-to-Use Providers</h4>
<div class="simple-providers-grid">
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="goodreadsEnabled"></p-toggleswitch>
<label class="setting-label">Goodreads</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="doubanEnabled"></p-toggleswitch>
<label class="setting-label">Douban</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="lubimyCzytacEnabled"></p-toggleswitch>
<label class="setting-label">Lubimyczytac</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="ranobedbEnabled"></p-toggleswitch>
<label class="setting-label">Ranobedb</label>
}
</div>
</div>
</div>
</div>
<div class="setting-actions">
<p-button label="Save Configurations" icon="pi pi-save" severity="success" [outlined]="true" (click)="saveSettings()"></p-button>
<div class="simple-providers-section">
<h4 class="provider-group-title">{{ t('readyToUseTitle') }}</h4>
<div class="simple-providers-grid">
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="goodreadsEnabled"></p-toggleswitch>
<label class="setting-label">Goodreads</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="doubanEnabled"></p-toggleswitch>
<label class="setting-label">Douban</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="lubimyCzytacEnabled"></p-toggleswitch>
<label class="setting-label">Lubimyczytac</label>
</div>
</div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="ranobedbEnabled"></p-toggleswitch>
<label class="setting-label">Ranobedb</label>
</div>
</div>
</div>
</div>
<div class="setting-actions">
<p-button [label]="t('saveConfigurations')" icon="pi pi-save" severity="success" [outlined]="true" (click)="saveSettings()"></p-button>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -11,6 +11,7 @@ import {AppSettingKey} from '../../../../shared/model/app-settings.model';
import {Select} from 'primeng/select';
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
import { ToggleSwitchModule } from 'primeng/toggleswitch';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-provider-settings',
@@ -22,7 +23,8 @@ import { ToggleSwitchModule } from 'primeng/toggleswitch';
FormsModule,
Select,
ExternalDocLinkComponent,
ToggleSwitchModule
ToggleSwitchModule,
TranslocoDirective
],
templateUrl: './metadata-provider-settings.component.html',
styleUrl: './metadata-provider-settings.component.scss'
@@ -100,6 +102,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService);
private destroyRef = inject(DestroyRef);
private t = inject(TranslocoService);
private appSettings$ = this.appSettingsService.appSettings$;
@@ -180,14 +183,14 @@ export class MetadataProviderSettingsComponent implements OnInit {
next: () =>
this.messageService.add({
severity: 'success',
summary: 'Saved',
detail: 'Metadata provider settings saved.'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsMeta.providers.saveSuccess')
}),
error: () =>
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to save metadata provider settings.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsMeta.providers.saveError')
})
});
}
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsLibMeta'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-database"></i>
Library Metadata Configuration
{{ t('title') }}
<app-external-doc-link docType="fetchConfig"></app-external-doc-link>
</h2>
<p class="settings-description">
Configure metadata fetch behavior for your libraries. Set global defaults and create library-specific overrides to control how book metadata is retrieved from different providers.
{{ t('description') }}
</p>
</div>
@@ -15,22 +16,17 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-globe"></i>
Default Metadata Settings
{{ t('defaultSettings.sectionTitle') }}
</h3>
<p class="section-description">
Set global default provider priorities for book metadata fields. These settings apply to all libraries unless overridden below.
BookLore tries providers from left to right (1st → 2nd → 3rd → 4th priority) for each book field until it finds data.
The system checks your 1st priority provider first - if that provider doesn't have the specific field (like description or author),
it automatically moves to your 2nd priority, then 3rd, and finally 4th. Leave a priority empty to skip it entirely.
For example, if Amazon (1st) has no description but Google Books (2nd) does, Google's description will be used.
Use the Enable checkboxes to completely disable fetching for specific fields - disabled fields will be skipped entirely regardless of provider settings.
{{ t('defaultSettings.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-metadata-advanced-fetch-options
[currentMetadataOptions]="defaultMetadataOptions"
[submitButtonLabel]="'Save Default Settings'"
[submitButtonLabel]="t('defaultSettings.saveButton')"
(metadataOptionsSubmitted)="onDefaultMetadataOptionsSubmitted($event)">
</app-metadata-advanced-fetch-options>
</div>
@@ -40,11 +36,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-book"></i>
Library-Specific Overrides
{{ t('libraryOverrides.sectionTitle') }}
</h3>
<p class="section-description">
Override the default priority settings for specific libraries. For example, you might prefer Amazon for fiction but Google Books for technical books. Each library can have its own provider priority order while falling back to defaults for unspecified fields.
You can also enable or disable specific metadata fields per library - useful if certain libraries don't need specific data types like descriptions or covers.
{{ t('libraryOverrides.sectionDesc') }}
</p>
</div>
@@ -62,36 +57,36 @@
@if (hasLibraryOverride(library.id!)) {
<span class="override-indicator custom">
<i class="pi pi-check-circle"></i>
Custom Settings
{{ t('libraryOverrides.customSettings') }}
</span>
} @else {
<span class="default-indicator default">
<i class="pi pi-globe"></i>
Default Settings
{{ t('libraryOverrides.defaultSettings') }}
</span>
}
</div>
<div class="sidecar-actions">
<p-button
icon="pi pi-upload"
label="Export Sidecar"
[label]="t('libraryOverrides.exportSidecar')"
size="small"
severity="secondary"
[outlined]="true"
[loading]="isSidecarExporting(library.id!)"
(onClick)="exportSidecarForLibrary(library.id!, $event)"
pTooltip="Generate .metadata.json files for all books in this library"
[pTooltip]="t('libraryOverrides.exportTooltip')"
tooltipPosition="top"
/>
<p-button
icon="pi pi-download"
label="Import Sidecar"
[label]="t('libraryOverrides.importSidecar')"
size="small"
severity="secondary"
[outlined]="true"
[loading]="isSidecarImporting(library.id!)"
(onClick)="importSidecarForLibrary(library.id!, $event)"
pTooltip="Import metadata from existing .metadata.json files in this library"
[pTooltip]="t('libraryOverrides.importTooltip')"
tooltipPosition="top"
/>
</div>
@@ -102,7 +97,7 @@
@if (activePanel === i) {
<app-metadata-advanced-fetch-options
[currentMetadataOptions]="getLibraryOptions(library.id!)"
[submitButtonLabel]="'Save ' + library.name + ' Settings'"
[submitButtonLabel]="t('libraryOverrides.saveLibraryButton', {name: library.name})"
(metadataOptionsSubmitted)="onLibraryMetadataOptionsSubmitted(library.id!, $event)">
</app-metadata-advanced-fetch-options>
}
@@ -116,3 +111,4 @@
</div>
</div>
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {AccordionModule} from 'primeng/accordion';
import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service';
@@ -20,7 +21,7 @@ import {SidecarService} from '../../metadata/service/sidecar.service';
@Component({
selector: 'app-library-metadata-settings-component',
standalone: true,
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, ExternalDocLinkComponent, Button, Tooltip],
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, ExternalDocLinkComponent, Button, Tooltip, TranslocoDirective],
templateUrl: './library-metadata-settings.component.html',
styleUrls: ['./library-metadata-settings.component.scss']
})
@@ -29,6 +30,7 @@ export class LibraryMetadataSettingsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService);
private sidecarService = inject(SidecarService);
private t = inject(TranslocoService);
libraries$: Observable<Library[]> = this.libraryService.libraryState$.pipe(
map(state => state.libraries || [])
@@ -105,12 +107,12 @@ export class LibraryMetadataSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(settingsToSave).subscribe({
next: () => {
this.showMessage('success', 'Settings Saved', 'Default metadata options have been saved successfully.');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.defaultSettings.saveSuccess'));
this.updateLibrariesUsingDefaults();
},
error: (error) => {
console.error('Error saving default metadata options:', error);
this.showMessage('error', 'Save Failed', 'Failed to save default metadata options. Please try again.');
this.showMessage('error', this.t.translate('settingsLibMeta.defaultSettings.saveFailed'), this.t.translate('settingsLibMeta.defaultSettings.saveError'));
}
});
}
@@ -129,11 +131,11 @@ export class LibraryMetadataSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(settingsToSave).subscribe({
next: () => {
this.showMessage('success', 'Settings Saved', 'Library metadata options have been saved successfully.');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.libraryOverrides.saveSuccess'));
},
error: (error) => {
console.error('Error saving library metadata options:', error);
this.showMessage('error', 'Save Failed', 'Failed to save library metadata options. Please try again.');
this.showMessage('error', this.t.translate('settingsLibMeta.libraryOverrides.saveFailed'), this.t.translate('settingsLibMeta.libraryOverrides.saveError'));
}
});
}
@@ -254,12 +256,12 @@ export class LibraryMetadataSettingsComponent implements OnInit {
this.sidecarService.bulkExport(libraryId).subscribe({
next: (response) => {
this.sidecarExporting[libraryId] = false;
this.showMessage('success', 'Export Complete', `Exported sidecar files for ${response.exported} books.`);
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.exportComplete'), this.t.translate('settingsLibMeta.libraryOverrides.exportSuccess', {count: response.exported}));
},
error: (error) => {
this.sidecarExporting[libraryId] = false;
console.error('Bulk sidecar export failed:', error);
this.showMessage('error', 'Export Failed', 'Failed to export sidecar files. Please try again.');
this.showMessage('error', this.t.translate('settingsLibMeta.libraryOverrides.exportFailed'), this.t.translate('settingsLibMeta.libraryOverrides.exportError'));
}
});
}
@@ -271,12 +273,12 @@ export class LibraryMetadataSettingsComponent implements OnInit {
this.sidecarService.bulkImport(libraryId).subscribe({
next: (response) => {
this.sidecarImporting[libraryId] = false;
this.showMessage('success', 'Import Complete', `Imported metadata from ${response.imported} sidecar files.`);
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.importComplete'), this.t.translate('settingsLibMeta.libraryOverrides.importSuccess', {count: response.imported}));
},
error: (error) => {
this.sidecarImporting[libraryId] = false;
console.error('Bulk sidecar import failed:', error);
this.showMessage('error', 'Import Failed', 'Failed to import from sidecar files. Please try again.');
this.showMessage('error', this.t.translate('settingsLibMeta.libraryOverrides.importFailed'), this.t.translate('settingsLibMeta.libraryOverrides.importError'));
}
});
}
@@ -1,230 +1,231 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-save"></i>
Metadata Persistence
</h3>
<p class="section-description">
Configure how metadata is written to original files and how files are moved or renamed when metadata changes.
</p>
</div>
<div class="section-notice">
<div class="warning-notice">
<i class="pi pi-exclamation-triangle"></i>
<div>
<strong>Network Storage Warning:</strong> These features directly modify and move book files on disk (including rewriting metadata and renaming files). They are designed for local file systems only. Using them on NAS or cloud-backed storage is untested and may lead to file corruption,
incomplete writes, or permanent data loss. Github issues related to network storage will not be supported.
</div>
</div>
<div class="info-notice unsupported-formats-note">
<i class="pi pi-info-circle"></i>
<div>
<strong>Note:</strong> Writing metadata is <b>not supported</b> for FB2, AZW3, and MOBI formats.
</div>
</div>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
(onChange)="onSaveToOriginalFileToggle('epub')">
</p-toggleswitch>
<label class="setting-label">Write Metadata to EPUB</label>
</div>
<p class="setting-description">Write metadata directly into EPUB files when editing book information.</p>
@if (metadataPersistence.saveToOriginalFile.epub.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>Max file size:</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.epub.maxFileSizeInMb"
(change)="onFilesizeChange('epub')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
pTooltip="Only files up to this size will be updated. Larger files are ignored."
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
(onChange)="onSaveToOriginalFileToggle('cbx')">
</p-toggleswitch>
<label class="setting-label">Write Metadata to CBX</label>
</div>
<p class="setting-description">Write metadata directly into CBX files when editing book information.</p>
@if (metadataPersistence.saveToOriginalFile.cbx.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>Max file size:</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.cbx.maxFileSizeInMb"
(change)="onFilesizeChange('cbx')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
pTooltip="Only files up to this size will be updated. Larger files are ignored."
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.pdf.enabled"
(onChange)="onSaveToOriginalFileToggle('pdf')">
</p-toggleswitch>
<label class="setting-label">Write Metadata to PDF</label>
</div>
<p class="setting-description">
Write metadata directly into PDF files when editing book information.
<span class="setting-note">PDFs do not support embedded covers. Only Title, Authors, Publisher, Categories, Description, Language, and Published Date can be updated.</span>
<ng-container *transloco="let t; prefix: 'settingsMeta.persistence'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-save"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
@if (metadataPersistence.saveToOriginalFile.pdf.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>Max file size:</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.pdf.maxFileSizeInMb"
(change)="onFilesizeChange('pdf')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
pTooltip="Only files up to this size will be updated. Larger files are ignored."
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.audiobook.enabled"
(onChange)="onSaveToOriginalFileToggle('audiobook')">
</p-toggleswitch>
<label class="setting-label">Write Metadata to Audiobooks</label>
<div class="section-notice">
<div class="warning-notice">
<i class="pi pi-exclamation-triangle"></i>
<div>
<strong>{{ t('networkWarningTitle') }}</strong> {{ t('networkWarning') }}
</div>
</div>
<p class="setting-description">
Write metadata directly into audiobook files (M4B, M4A, MP3, etc.) when editing book information.
<span class="setting-note">Supports title, authors, narrator, description, publisher, categories, series, language, and cover art. For folder-based audiobooks, cover is saved as cover.jpg in the folder.</span>
</p>
@if (metadataPersistence.saveToOriginalFile.audiobook.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>Max file size:</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.audiobook.maxFileSizeInMb"
(change)="onFilesizeChange('audiobook')"
min="1"
max="2000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
pTooltip="Only files up to this size will be updated. Larger files are ignored."
tooltipPosition="right">
</i>
</div>
<div class="info-notice unsupported-formats-note">
<i class="pi pi-info-circle"></i>
<div>
<strong>Note:</strong> <span [innerHTML]="t('unsupportedNote')"></span>
</div>
}
</div>
</div>
@if ((appSettings$ | async)?.diskType === 'LOCAL') {
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
[ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
(onChange)="onSaveToOriginalFileToggle('epub')">
</p-toggleswitch>
<label class="setting-label">Auto-Move Files on Metadata Update</label>
<label class="setting-label">{{ t('writeEpub') }}</label>
</div>
<p class="setting-description">Automatically move and rename files according to their library's naming pattern when metadata is updated.</p>
<p class="setting-description">{{ t('writeEpubDesc') }}</p>
@if (metadataPersistence.saveToOriginalFile.epub.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>{{ t('maxFileSize') }}</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.epub.maxFileSizeInMb"
(change)="onFilesizeChange('epub')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
[pTooltip]="t('maxFileSizeTooltip')"
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
}
</div>
<div class="section-header sidecar-section-header">
<h3 class="section-title">
<i class="pi pi-file"></i>
Sidecar JSON Files
</h3>
<p class="section-description">
Create external .metadata.json files alongside your books for portable metadata storage and backup.
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.enabled"
(onChange)="onSidecarToggle('enabled')">
</p-toggleswitch>
<label class="setting-label">Enable Sidecar JSON</label>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
(onChange)="onSaveToOriginalFileToggle('cbx')">
</p-toggleswitch>
<label class="setting-label">{{ t('writeCbx') }}</label>
</div>
<p class="setting-description">{{ t('writeCbxDesc') }}</p>
@if (metadataPersistence.saveToOriginalFile.cbx.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>{{ t('maxFileSize') }}</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.cbx.maxFileSizeInMb"
(change)="onFilesizeChange('cbx')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
[pTooltip]="t('maxFileSizeTooltip')"
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
<p class="setting-description">Enable sidecar JSON metadata files. When enabled, metadata can be written to <code>BookName.metadata.json</code> files alongside your books.</p>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.pdf.enabled"
(onChange)="onSaveToOriginalFileToggle('pdf')">
</p-toggleswitch>
<label class="setting-label">{{ t('writePdf') }}</label>
</div>
<p class="setting-description">
{{ t('writePdfDesc') }}
<span class="setting-note">{{ t('writePdfNote') }}</span>
</p>
@if (metadataPersistence.saveToOriginalFile.pdf.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>{{ t('maxFileSize') }}</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.pdf.maxFileSizeInMb"
(change)="onFilesizeChange('pdf')"
min="1"
max="1000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
[pTooltip]="t('maxFileSizeTooltip')"
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.saveToOriginalFile.audiobook.enabled"
(onChange)="onSaveToOriginalFileToggle('audiobook')">
</p-toggleswitch>
<label class="setting-label">{{ t('writeAudiobook') }}</label>
</div>
<p class="setting-description">
{{ t('writeAudiobookDesc') }}
<span class="setting-note">{{ t('writeAudiobookNote') }}</span>
</p>
@if (metadataPersistence.saveToOriginalFile.audiobook.enabled) {
<div class="setting-options">
<div class="filesize-input">
<label>{{ t('maxFileSize') }}</label>
<input
type="number"
[(ngModel)]="metadataPersistence.saveToOriginalFile.audiobook.maxFileSizeInMb"
(change)="onFilesizeChange('audiobook')"
min="1"
max="2000"
class="filesize-field">
<span class="filesize-unit">MB</span>
<i
class="pi pi-info-circle"
[pTooltip]="t('maxFileSizeTooltip')"
tooltipPosition="right">
</i>
</div>
</div>
}
</div>
@if ((appSettings$ | async)?.diskType === 'LOCAL') {
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.moveFilesToLibraryPattern"
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')">
</p-toggleswitch>
<label class="setting-label">{{ t('autoMove') }}</label>
</div>
<p class="setting-description">{{ t('autoMoveDesc') }}</p>
</div>
}
</div>
@if (metadataPersistence.sidecarSettings?.enabled) {
<div class="setting-item nested-setting">
<div class="section-header sidecar-section-header">
<h3 class="section-title">
<i class="pi pi-file"></i>
{{ t('sidecarTitle') }}
</h3>
<p class="section-description">
{{ t('sidecarDesc') }}
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.writeOnUpdate"
(onChange)="onSidecarToggle('writeOnUpdate')">
[ngModel]="metadataPersistence.sidecarSettings?.enabled"
(onChange)="onSidecarToggle('enabled')">
</p-toggleswitch>
<label class="setting-label">Write on Metadata Update</label>
<label class="setting-label">{{ t('enableSidecar') }}</label>
</div>
<p class="setting-description">Automatically update the sidecar JSON file whenever book metadata is edited.</p>
<p class="setting-description" [innerHTML]="t('enableSidecarDesc')"></p>
</div>
<div class="setting-item nested-setting">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.writeOnScan"
(onChange)="onSidecarToggle('writeOnScan')">
</p-toggleswitch>
<label class="setting-label">Write on Initial Scan</label>
@if (metadataPersistence.sidecarSettings?.enabled) {
<div class="setting-item nested-setting">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.writeOnUpdate"
(onChange)="onSidecarToggle('writeOnUpdate')">
</p-toggleswitch>
<label class="setting-label">{{ t('writeOnUpdate') }}</label>
</div>
<p class="setting-description">{{ t('writeOnUpdateDesc') }}</p>
</div>
<p class="setting-description">Create sidecar JSON files when books are first added to the library during scanning.</p>
</div>
<div class="setting-item nested-setting">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.includeCoverFile"
(onChange)="onSidecarToggle('includeCoverFile')">
</p-toggleswitch>
<label class="setting-label">Include Cover Image File</label>
<div class="setting-item nested-setting">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.writeOnScan"
(onChange)="onSidecarToggle('writeOnScan')">
</p-toggleswitch>
<label class="setting-label">{{ t('writeOnScan') }}</label>
</div>
<p class="setting-description">{{ t('writeOnScanDesc') }}</p>
</div>
<p class="setting-description">Also save the cover image as <code>BookName.cover.jpg</code> alongside the sidecar JSON file.</p>
</div>
}
<div class="setting-item nested-setting">
<div class="setting-header">
<p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.includeCoverFile"
(onChange)="onSidecarToggle('includeCoverFile')">
</p-toggleswitch>
<label class="setting-label">{{ t('includeCover') }}</label>
</div>
<p class="setting-description" [innerHTML]="t('includeCoverDesc')"></p>
</div>
}
</div>
</div>
</div>
</ng-container>
@@ -8,6 +8,7 @@ import {Observable} from 'rxjs';
import {filter, take} from 'rxjs/operators';
import {Tooltip} from 'primeng/tooltip';
import {AsyncPipe} from '@angular/common';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-persistence-settings-component',
@@ -15,7 +16,8 @@ import {AsyncPipe} from '@angular/common';
ToggleSwitch,
FormsModule,
Tooltip,
AsyncPipe
AsyncPipe,
TranslocoDirective
],
templateUrl: './metadata-persistence-settings-component.html',
styleUrl: './metadata-persistence-settings-component.scss'
@@ -53,6 +55,7 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -92,7 +95,7 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings),
error: (error) => {
console.error('Failed to load settings:', error);
this.settingsHelper.showMessage('error', 'Error', 'Failed to load settings.');
this.settingsHelper.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsMeta.persistence.loadError'));
}
});
}
@@ -1,47 +1,49 @@
<div class="metadata-settings-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-tags"></i>
Metadata Settings
</h2>
<p class="settings-description">
Configure how metadata is retrieved, stored, and matched for your books, including provider settings and field preferences.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsMeta'">
<div class="metadata-settings-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-tags"></i>
{{ t('title') }}
</h2>
<p class="settings-description">
{{ t('description') }}
</p>
</div>
<app-metadata-persistence-settings-component></app-metadata-persistence-settings-component>
<div class="section-divider"><hr></div>
<div class="preferences-section">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-download"></i>
Automatic Metadata Download
</h3>
<p class="section-description">
<i class="pi pi-exclamation-triangle"></i>
<span>When enabled, metadata will be automatically retrieved from your configured sources whenever new files are added to the Bookdrop folder. Please note that processing a large number of files simultaneously may increase the time required for metadata fetching.</span>
</p>
</div>
<app-metadata-persistence-settings-component></app-metadata-persistence-settings-component>
<div class="section-divider"><hr></div>
<div class="preferences-section">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-download"></i>
{{ t('autoDownload.sectionTitle') }}
</h3>
<p class="section-description">
<i class="pi pi-exclamation-triangle"></i>
<span>{{ t('autoDownload.warning') }}</span>
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="metadataDownloadOnBookdrop"
(onChange)="onMetadataDownloadOnBookdropToggle($event.checked)">
</p-toggleswitch>
<label class="setting-label">Enable automatic metadata download for Bookdrop imports</label>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="metadataDownloadOnBookdrop"
(onChange)="onMetadataDownloadOnBookdropToggle($event.checked)">
</p-toggleswitch>
<label class="setting-label">{{ t('autoDownload.enableLabel') }}</label>
</div>
</div>
</div>
</div>
</div>
<app-metadata-provider-settings></app-metadata-provider-settings>
<div class="section-divider"><hr></div>
<app-metadata-provider-field-selector></app-metadata-provider-field-selector>
<div class="section-divider"><hr></div>
<app-public-reviews-settings-component></app-public-reviews-settings-component>
<div class="section-divider"><hr></div>
<app-metadata-match-weights-component></app-metadata-match-weights-component>
</div>
<app-metadata-provider-settings></app-metadata-provider-settings>
<div class="section-divider"><hr></div>
<app-metadata-provider-field-selector></app-metadata-provider-field-selector>
<div class="section-divider"><hr></div>
<app-public-reviews-settings-component></app-public-reviews-settings-component>
<div class="section-divider"><hr></div>
<app-metadata-match-weights-component></app-metadata-match-weights-component>
</div>
</ng-container>
@@ -12,6 +12,7 @@ import {MetadataMatchWeightsComponent} from '../global-preferences/metadata-matc
import {MetadataPersistenceSettingsComponent} from './metadata-persistence-settings/metadata-persistence-settings-component';
import {PublicReviewsSettingsComponent} from './public-reviews-settings/public-reviews-settings-component';
import {MetadataProviderFieldSelectorComponent} from '../../metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-settings-component',
@@ -24,7 +25,8 @@ import {MetadataProviderFieldSelectorComponent} from '../../metadata/component/m
ToggleSwitch,
MetadataPersistenceSettingsComponent,
PublicReviewsSettingsComponent,
MetadataProviderFieldSelectorComponent
MetadataProviderFieldSelectorComponent,
TranslocoDirective
],
templateUrl: './metadata-settings-component.html',
styleUrl: './metadata-settings-component.scss'
@@ -36,6 +38,7 @@ export class MetadataSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -61,7 +64,7 @@ export class MetadataSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings),
error: (error) => {
console.error('Failed to load settings:', error);
this.settingsHelper.showMessage('error', 'Error', 'Failed to load settings.');
this.settingsHelper.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsMeta.autoDownload.loadError'));
}
});
}
@@ -1,78 +1,80 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-star"></i>
Public Reviews
</h3>
<p class="section-description">
Configure automatic downloading of user reviews from external platforms. Reviews can be fetched from Amazon, Goodreads, and Hardcover for offline access.
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="publicReviewSettings.downloadEnabled"
(onChange)="onPublicReviewsToggle($event.checked)">
</p-toggleswitch>
<label class="setting-label">Download Public Reviews</label>
</div>
<ng-container *transloco="let t; prefix: 'settingsMeta.publicReviews'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-star"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
@if (publicReviewSettings.downloadEnabled) {
<div class="section-body">
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="publicReviewSettings.autoDownloadEnabled"
(onChange)="onAutoDownloadToggle($event.checked)">
[(ngModel)]="publicReviewSettings.downloadEnabled"
(onChange)="onPublicReviewsToggle($event.checked)">
</p-toggleswitch>
<label class="setting-label">Auto Download on Book Open</label>
<label class="setting-label">{{ t('downloadLabel') }}</label>
</div>
<p class="setting-description">Automatically fetch reviews when you open a book's details page. When disabled, reviews will only be downloaded manually or during metadata refresh.</p>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Review Sources</label>
@if (publicReviewSettings.downloadEnabled) {
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch
[(ngModel)]="publicReviewSettings.autoDownloadEnabled"
(onChange)="onAutoDownloadToggle($event.checked)">
</p-toggleswitch>
<label class="setting-label">{{ t('autoDownloadLabel') }}</label>
</div>
<p class="setting-description">{{ t('autoDownloadDesc') }}</p>
</div>
<p class="setting-description">Configure which platforms to download reviews from and set limits for each source.</p>
@if (publicReviewSettings.providers.length > 0) {
<div class="setting-options">
<div class="providers-grid">
@for (provider of publicReviewSettings.providers; track provider.provider) {
<div class="provider-item">
<div class="provider-row">
<p-toggleswitch
[(ngModel)]="provider.enabled"
(onChange)="onProviderToggle(provider.provider, $event.checked)">
</p-toggleswitch>
<label class="provider-label">{{ provider.provider }}</label>
</div>
@if (provider.enabled) {
<div class="max-reviews-control">
<label class="max-reviews-label">Max:</label>
<input
type="number"
class="max-reviews-input"
min="1"
max="10"
[(ngModel)]="provider.maxReviews"
(blur)="onMaxReviewsChange(provider.provider, provider.maxReviews)"
title="Number of reviews to download (1-10)">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('reviewSources') }}</label>
</div>
<p class="setting-description">{{ t('reviewSourcesDesc') }}</p>
@if (publicReviewSettings.providers.length > 0) {
<div class="setting-options">
<div class="providers-grid">
@for (provider of publicReviewSettings.providers; track provider.provider) {
<div class="provider-item">
<div class="provider-row">
<p-toggleswitch
[(ngModel)]="provider.enabled"
(onChange)="onProviderToggle(provider.provider, $event.checked)">
</p-toggleswitch>
<label class="provider-label">{{ provider.provider }}</label>
</div>
}
</div>
}
@if (provider.enabled) {
<div class="max-reviews-control">
<label class="max-reviews-label">{{ t('maxLabel') }}</label>
<input
type="number"
class="max-reviews-input"
min="1"
max="10"
[(ngModel)]="provider.maxReviews"
(blur)="onMaxReviewsChange(provider.provider, provider.maxReviews)"
[title]="t('maxTooltip')">
</div>
}
</div>
}
</div>
</div>
</div>
} @else {
<div class="no-providers-message">
<i class="pi pi-exclamation-triangle"></i>
<span>No review sources available. Please ensure metadata providers are configured in the Provider Settings section above.</span>
</div>
}
</div>
}
} @else {
<div class="no-providers-message">
<i class="pi pi-exclamation-triangle"></i>
<span>{{ t('noProviders') }}</span>
</div>
}
</div>
}
</div>
</div>
</div>
</ng-container>
@@ -6,6 +6,7 @@ import {AppSettingsService} from '../../../../shared/service/app-settings.servic
import {SettingsHelperService} from '../../../../shared/service/settings-helper.service';
import {Observable} from 'rxjs';
import {filter, take} from 'rxjs/operators';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
const DEFAULT_PROVIDERS: readonly ReviewProviderConfig[] = [
{provider: 'Amazon', enabled: true, maxReviews: 5},
@@ -17,7 +18,7 @@ const REQUIRED_PROVIDERS = ['Amazon', 'GoodReads', 'Douban'] as const;
@Component({
selector: 'app-public-reviews-settings-component',
imports: [FormsModule, ToggleSwitch],
imports: [FormsModule, ToggleSwitch, TranslocoDirective],
templateUrl: './public-reviews-settings-component.html',
styleUrl: './public-reviews-settings-component.scss'
})
@@ -31,6 +32,7 @@ export class PublicReviewsSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -64,7 +66,7 @@ export class PublicReviewsSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings),
error: (error) => {
console.error('Failed to load settings:', error);
this.settingsHelper.showMessage('error', 'Error', 'Failed to load settings.');
this.settingsHelper.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsMeta.publicReviews.loadError'));
}
});
}
@@ -1,13 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsOpds'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-server"></i>
OPDS Configuration
{{ t('title') }}
<app-external-doc-link docType="opds"></app-external-doc-link>
</h2>
<p class="settings-description">
Manage your OPDS credentials and control how your book collection is shared with reading apps.
By default, all libraries you have access to will be included in the OPDS feed.
{{ t('description') }}
</p>
</div>
@@ -16,10 +16,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sliders-h"></i>
Server Settings
{{ t('server.sectionTitle') }}
</h3>
<p class="section-description">
Enable or disable OPDS and Komga API services to control access to your book collection.
{{ t('server.sectionDesc') }}
</p>
</div>
@@ -32,14 +32,14 @@
<i class="pi pi-globe"></i>
</div>
<div class="toggle-info">
<span class="toggle-label">OPDS Server</span>
<span class="toggle-label">{{ t('server.opdsLabel') }}</span>
<span class="toggle-status" [class.active]="opdsEnabled">
{{ opdsEnabled ? 'Enabled' : 'Disabled' }}
{{ opdsEnabled ? t('server.enabled') : t('server.disabled') }}
</span>
</div>
</div>
<p class="toggle-description">
Enable the OPDS server to access your book collection through OPDS-compatible reading apps like KOReader, Moon+ Reader, etc.
{{ t('server.opdsDesc') }}
</p>
</div>
<p-toggleswitch
@@ -55,14 +55,14 @@
<i class="pi pi-box"></i>
</div>
<div class="toggle-info">
<span class="toggle-label">Komga API</span>
<span class="toggle-label">{{ t('server.komgaLabel') }}</span>
<span class="toggle-status" [class.active]="komgaApiEnabled">
{{ komgaApiEnabled ? 'Enabled' : 'Disabled' }}
{{ komgaApiEnabled ? t('server.enabled') : t('server.disabled') }}
</span>
</div>
</div>
<p class="toggle-description">
Enable the Komga-compatible API to use Komga clients (Tachiyomi, Komelia, etc.) with Booklore. Uses the same OPDS user accounts for authentication.
{{ t('server.komgaDesc') }}
</p>
</div>
<p-toggleswitch
@@ -79,14 +79,14 @@
<i class="pi pi-folder"></i>
</div>
<div class="toggle-info">
<span class="toggle-label">Group Unknown Series</span>
<span class="toggle-label">{{ t('server.groupUnknownLabel') }}</span>
<span class="toggle-status" [class.active]="komgaGroupUnknown">
{{ komgaGroupUnknown ? 'Grouped' : 'Individual' }}
{{ komgaGroupUnknown ? t('server.grouped') : t('server.individual') }}
</span>
</div>
</div>
<p class="toggle-description">
When enabled, books without a series will be grouped under "Unknown Series". When disabled, each book will appear as its own individual series.
{{ t('server.groupUnknownDesc') }}
</p>
</div>
<p-toggleswitch
@@ -104,10 +104,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-link"></i>
API Endpoints
{{ t('endpoints.sectionTitle') }}
</h3>
<p class="section-description">
Use these URLs to connect your reading apps to Booklore.
{{ t('endpoints.sectionDesc') }}
</p>
</div>
@@ -120,8 +120,8 @@
<i class="pi pi-globe"></i>
</div>
<div class="endpoint-info">
<span class="endpoint-label">OPDS Catalog URL</span>
<span class="endpoint-hint">For OPDS-compatible apps</span>
<span class="endpoint-label">{{ t('endpoints.opdsCatalog') }}</span>
<span class="endpoint-hint">{{ t('endpoints.opdsHint') }}</span>
</div>
</div>
<div class="endpoint-url-row">
@@ -138,7 +138,7 @@
[outlined]="true"
size="small"
(onClick)="copyEndpoint()"
pTooltip="Copy URL">
[pTooltip]="t('endpoints.copyUrl')">
</p-button>
</div>
</div>
@@ -151,8 +151,8 @@
<i class="pi pi-box"></i>
</div>
<div class="endpoint-info">
<span class="endpoint-label">Komga Base URL</span>
<span class="endpoint-hint">For Tachiyomi, Komelia, etc.</span>
<span class="endpoint-label">{{ t('endpoints.komgaBase') }}</span>
<span class="endpoint-hint">{{ t('endpoints.komgaHint') }}</span>
</div>
</div>
<div class="endpoint-url-row">
@@ -169,7 +169,7 @@
[outlined]="true"
size="small"
(onClick)="copyKomgaEndpoint()"
pTooltip="Copy URL">
[pTooltip]="t('endpoints.copyUrl')">
</p-button>
</div>
</div>
@@ -186,15 +186,15 @@
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-users"></i>
OPDS Users
{{ t('users.sectionTitle') }}
</h3>
<p class="section-description">
Manage user accounts for OPDS and Komga API access. These are separate from Booklore user accounts.
{{ t('users.sectionDesc') }}
</p>
</div>
<p-button
icon="pi pi-plus"
label="Add User"
[label]="t('users.addUser')"
severity="success"
size="small"
[outlined]="true"
@@ -207,8 +207,8 @@
@if (users.length === 0) {
<div class="empty-state">
<i class="pi pi-users"></i>
<p class="empty-title">No users found</p>
<p class="empty-subtitle">Create your first OPDS user to get started</p>
<p class="empty-title">{{ t('users.emptyTitle') }}</p>
<p class="empty-subtitle">{{ t('users.emptySubtitle') }}</p>
</div>
} @else {
<div class="users-list">
@@ -231,6 +231,12 @@
[style]="{width: '160px'}"
size="small"
[appendTo]="'body'">
<ng-template pTemplate="selectedItem" let-selected>
{{ selected.translationKey | transloco }}
</ng-template>
<ng-template pTemplate="item" let-option>
{{ option.translationKey | transloco }}
</ng-template>
</p-select>
} @else {
<span class="sort-order-badge">{{ getSortOrderLabel(user.sortOrder) }}</span>
@@ -247,7 +253,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="saveSortOrder(user)"
pTooltip="Save">
[pTooltip]="'common.save' | transloco">
</p-button>
<p-button
icon="pi pi-times"
@@ -256,7 +262,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="cancelEdit()"
pTooltip="Cancel">
[pTooltip]="'common.cancel' | transloco">
</p-button>
} @else {
<p-button
@@ -266,7 +272,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="startEdit(user)"
pTooltip="Edit sort order">
[pTooltip]="t('users.editSortOrder')">
</p-button>
<p-button
icon="pi pi-trash"
@@ -275,7 +281,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="confirmDelete(user)"
pTooltip="Delete user">
[pTooltip]="t('users.deleteUser')">
</p-button>
}
</div>
@@ -288,32 +294,32 @@
}
<p-dialog
header="Create OPDS User"
[header]="t('createDialog.title')"
[(visible)]="showCreateUserDialog"
[modal]="true"
class="user-dialog"
[style]="{width: '400px'}">
<div class="dialog-form">
<div class="form-field">
<label for="username">Username</label>
<label for="username">{{ t('createDialog.username') }}</label>
<input
id="username"
type="text"
pInputText
[(ngModel)]="newUser.username"
placeholder="Enter username"/>
[placeholder]="t('createDialog.enterUsername')"/>
</div>
<div class="form-field">
<label for="password">Password</label>
<label for="password">{{ t('createDialog.password') }}</label>
<input
id="password"
type="password"
pInputText
[(ngModel)]="newUser.password"
placeholder="Enter password"/>
[placeholder]="t('createDialog.enterPassword')"/>
</div>
<div class="form-field">
<label for="sortOrder">Default Sort Order</label>
<label for="sortOrder">{{ t('createDialog.sortOrder') }}</label>
<p-select
id="sortOrder"
[options]="sortOrderOptions"
@@ -321,25 +327,31 @@
optionLabel="label"
optionValue="value"
[style]="{width: '100%'}"
placeholder="Select sort order"
[placeholder]="t('createDialog.selectSortOrder')"
[appendTo]="'body'">
<ng-template pTemplate="selectedItem" let-selected>
{{ selected.translationKey | transloco }}
</ng-template>
<ng-template pTemplate="item" let-option>
{{ option.translationKey | transloco }}
</ng-template>
</p-select>
<small class="form-hint">
<i class="pi pi-info-circle"></i>
This will determine how books appear in the OPDS feed for this user
{{ t('createDialog.sortHint') }}
</small>
</div>
</div>
<ng-template pTemplate="footer">
<div class="dialog-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
outlined="true"
(onClick)="cancelCreateUser()">
</p-button>
<p-button
label="Create"
[label]="t('createDialog.create')"
severity="success"
[disabled]="!newUser.username || !newUser.password"
(onClick)="createUser()">
@@ -353,13 +365,14 @@
<div class="access-denied-card">
<i class="pi pi-lock"></i>
<div class="access-denied-content">
<h3>Access Restricted</h3>
<h3>{{ t('accessRestricted') }}</h3>
<p>
Access to OPDS is restricted.
{{ t('accessDenied') }}
<br>
Please contact your administrator to request permission.
{{ t('contactAdmin') }}
</p>
</div>
</div>
}
</div>
</ng-container>
@@ -18,6 +18,7 @@ import {AppSettingsService} from '../../../shared/service/app-settings.service';
import {AppSettingKey} from '../../../shared/model/app-settings.model';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {Select} from 'primeng/select';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-opds-settings',
@@ -31,7 +32,9 @@ import {Select} from 'primeng/select';
TableModule,
ToggleSwitch,
ExternalDocLinkComponent,
Select
Select,
TranslocoDirective,
TranslocoPipe
],
providers: [ConfirmationService],
templateUrl: './opds-settings.html',
@@ -50,6 +53,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
private messageService = inject(MessageService);
private userService = inject(UserService);
private appSettingsService = inject(AppSettingsService);
private t = inject(TranslocoService);
users: OpdsUserV2[] = [];
loading = false;
@@ -65,15 +69,15 @@ export class OpdsSettings implements OnInit, OnDestroy {
dummyPassword: string = "***********************";
sortOrderOptions = [
{label: 'Recently Added', value: 'RECENT' as OpdsSortOrder},
{label: 'Title (A-Z)', value: 'TITLE_ASC' as OpdsSortOrder},
{label: 'Title (Z-A)', value: 'TITLE_DESC' as OpdsSortOrder},
{label: 'Author (A-Z)', value: 'AUTHOR_ASC' as OpdsSortOrder},
{label: 'Author (Z-A)', value: 'AUTHOR_DESC' as OpdsSortOrder},
{label: 'Series (A-Z)', value: 'SERIES_ASC' as OpdsSortOrder},
{label: 'Series (Z-A)', value: 'SERIES_DESC' as OpdsSortOrder},
{label: 'Rating (Low to High)', value: 'RATING_ASC' as OpdsSortOrder},
{label: 'Rating (High to Low)', value: 'RATING_DESC' as OpdsSortOrder}
{label: 'Recently Added', value: 'RECENT' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.recent'},
{label: 'Title (A-Z)', value: 'TITLE_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleAsc'},
{label: 'Title (Z-A)', value: 'TITLE_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleDesc'},
{label: 'Author (A-Z)', value: 'AUTHOR_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorAsc'},
{label: 'Author (Z-A)', value: 'AUTHOR_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorDesc'},
{label: 'Series (A-Z)', value: 'SERIES_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesAsc'},
{label: 'Series (Z-A)', value: 'SERIES_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesDesc'},
{label: 'Rating (Low to High)', value: 'RATING_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingAsc'},
{label: 'Rating (High to Low)', value: 'RATING_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingDesc'}
];
ngOnInit(): void {
@@ -118,7 +122,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$),
catchError(err => {
console.error('Error loading users:', err);
this.showMessage('error', 'Error', 'Failed to load users');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.loadError'));
return of([]);
})
).subscribe(users => {
@@ -137,20 +141,20 @@ export class OpdsSettings implements OnInit, OnDestroy {
next: user => {
this.users.push(user);
this.resetCreateUserDialog();
this.showMessage('success', 'Success', 'User created successfully');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.createSuccess'));
},
error: err => {
console.error('Error creating user:', err);
const message = err?.error?.message || 'Failed to create user';
this.showMessage('error', 'Error', message);
const message = err?.error?.message || this.t.translate('settingsOpds.createError');
this.showMessage('error', this.t.translate('common.error'), message);
}
});
}
confirmDelete(user: OpdsUserV2): void {
this.confirmationService.confirm({
message: `Are you sure you want to delete user "${user.username}"?`,
header: 'Delete Confirmation',
message: this.t.translate('settingsOpds.deleteConfirm', {username: user.username}),
header: this.t.translate('settingsOpds.deleteHeader'),
icon: 'pi pi-exclamation-triangle',
acceptButtonStyleClass: 'p-button-danger',
accept: () => this.deleteUser(user)
@@ -164,12 +168,12 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$),
catchError(err => {
console.error('Error deleting user:', err);
this.showMessage('error', 'Error', 'Failed to delete user');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.deleteError'));
return of(null);
})
).subscribe(() => {
this.users = this.users.filter(u => u.id !== user.id);
this.showMessage('success', 'Success', 'User deleted successfully');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.deleteSuccess'));
});
}
@@ -179,7 +183,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
copyEndpoint(): void {
navigator.clipboard.writeText(this.opdsEndpoint).then(() => {
this.showMessage('success', 'Copied', 'OPDS endpoint copied to clipboard');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.opdsCopied'));
});
}
@@ -203,7 +207,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
copyKomgaEndpoint(): void {
navigator.clipboard.writeText(this.komgaEndpoint).then(() => {
this.showMessage('success', 'Copied', 'Komga API endpoint copied to clipboard');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.komgaCopied'));
});
}
@@ -211,12 +215,12 @@ export class OpdsSettings implements OnInit, OnDestroy {
this.appSettingsService.saveSettings([{key: AppSettingKey.KOMGA_GROUP_UNKNOWN, newValue: this.komgaGroupUnknown}]).subscribe({
next: () => {
const successMessage = (this.komgaGroupUnknown === true)
? 'Books without series will be grouped under "Unknown Series".'
: 'Books without series will appear as individual series.';
this.showMessage('success', 'Settings Saved', successMessage);
? this.t.translate('settingsOpds.groupEnabled')
: this.t.translate('settingsOpds.groupDisabled');
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
},
error: () => {
this.showMessage('error', 'Error', 'There was an error saving the settings.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
}
});
}
@@ -225,12 +229,12 @@ export class OpdsSettings implements OnInit, OnDestroy {
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () => {
const successMessage = (value === true)
? 'OPDS Server Enabled.'
: 'OPDS Server Disabled.';
this.showMessage('success', 'Settings Saved', successMessage);
? this.t.translate('settingsOpds.opdsEnabled')
: this.t.translate('settingsOpds.opdsDisabled');
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
},
error: () => {
this.showMessage('error', 'Error', 'There was an error saving the settings.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
}
});
}
@@ -239,12 +243,12 @@ export class OpdsSettings implements OnInit, OnDestroy {
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () => {
const successMessage = (value === true)
? 'Komga API Enabled.'
: 'Komga API Disabled.';
this.showMessage('success', 'Settings Saved', successMessage);
? this.t.translate('settingsOpds.komgaEnabled')
: this.t.translate('settingsOpds.komgaDisabled');
this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
},
error: () => {
this.showMessage('error', 'Error', 'There was an error saving the settings.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.settingsError'));
}
});
}
@@ -259,9 +263,9 @@ export class OpdsSettings implements OnInit, OnDestroy {
}
getSortOrderLabel(sortOrder?: OpdsSortOrder): string {
if (!sortOrder) return 'Recently Added';
if (!sortOrder) return this.t.translate('settingsOpds.sortOrders.recent');
const option = this.sortOrderOptions.find(o => o.value === sortOrder);
return option ? option.label : 'Recently Added';
return option ? this.t.translate(option.translationKey) : this.t.translate('settingsOpds.sortOrders.recent');
}
startEdit(user: OpdsUserV2): void {
@@ -281,7 +285,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$),
catchError(err => {
console.error('Error updating sort order:', err);
this.showMessage('error', 'Error', 'Failed to update sort order');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.sortUpdateError'));
return of(null);
})
).subscribe(updatedUser => {
@@ -290,7 +294,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
if (index !== -1) {
this.users[index] = updatedUser;
}
this.showMessage('success', 'Success', 'Sort order updated successfully');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.sortUpdateSuccess'));
}
this.cancelEdit();
});
@@ -1,123 +1,125 @@
<div class="cbx-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Spread</label>
<div class="button-group">
@for (spread of cbxSpreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxSpread === spread.key"
(click)="selectedCbxSpread = spread.key">
<i [class]="spread.icon"></i>
<span class="option-text">{{ spread.name }}</span>
</button>
}
<ng-container *transloco="let t; prefix: 'settingsReader.cbx'">
<div class="cbx-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageSpread') }}</label>
<div class="button-group">
@for (spread of cbxSpreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxSpread === spread.key"
(click)="selectedCbxSpread = spread.key">
<i [class]="spread.icon"></i>
<span class="option-text">{{ t(spread.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div>
<p class="setting-description">
Configure how comic book pages are displayed - single page or double page spread.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Layout</label>
<div class="button-group">
@for (mode of cbxViewModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxViewMode === mode.key"
(click)="selectedCbxViewMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageLayout') }}</label>
<div class="button-group">
@for (mode of cbxViewModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxViewMode === mode.key"
(click)="selectedCbxViewMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageLayoutDesc') }}
</p>
</div>
<p class="setting-description">
Choose how comic pages are displayed while reading.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Fit Mode</label>
<div class="button-group">
@for (mode of cbxFitModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxFitMode === mode.key"
(click)="selectedCbxFitMode = mode.key"
[pTooltip]="mode.name"
tooltipPosition="bottom">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fitMode') }}</label>
<div class="button-group">
@for (mode of cbxFitModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxFitMode === mode.key"
(click)="selectedCbxFitMode = mode.key"
[pTooltip]="t(mode.translationKey)"
tooltipPosition="bottom">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('fitModeDesc') }}
</p>
</div>
<p class="setting-description">
Select how images should be scaled to fit the reader window.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Scroll Mode</label>
<div class="button-group">
@for (mode of cbxScrollModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScrollMode === mode.key"
(click)="selectedCbxScrollMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('scrollMode') }}</label>
<div class="button-group">
@for (mode of cbxScrollModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScrollMode === mode.key"
(click)="selectedCbxScrollMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('scrollModeDesc') }}
</p>
</div>
<p class="setting-description">
Choose between paginated or infinite scroll reading experience.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Background Color</label>
<div class="theme-selector">
@for (color of cbxBackgroundColors; track color) {
<button
type="button"
class="theme-option"
[class.selected]="selectedCbxBackgroundColor === color.key"
[style.background-color]="color.color"
(click)="selectedCbxBackgroundColor = color.key"
[attr.aria-label]="color.name"
[pTooltip]="color.name"
tooltipPosition="bottom">
@if (selectedCbxBackgroundColor === color.key) {
<i class="pi pi-check"></i>
}
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('backgroundColor') }}</label>
<div class="theme-selector">
@for (color of cbxBackgroundColors; track color) {
<button
type="button"
class="theme-option"
[class.selected]="selectedCbxBackgroundColor === color.key"
[style.background-color]="color.color"
(click)="selectedCbxBackgroundColor = color.key"
[attr.aria-label]="t(color.translationKey)"
[pTooltip]="t(color.translationKey)"
tooltipPosition="bottom">
@if (selectedCbxBackgroundColor === color.key) {
<i class="pi pi-check"></i>
}
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('backgroundColorDesc') }}
</p>
</div>
<p class="setting-description">
Set the background color for the comic reader.
</p>
</div>
</div>
</div>
</ng-container>
@@ -1,5 +1,6 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {TooltipModule} from 'primeng/tooltip';
@@ -8,6 +9,7 @@ import {TooltipModule} from 'primeng/tooltip';
selector: 'app-cbx-reader-preferences-component',
imports: [
FormsModule,
TranslocoDirective,
TooltipModule
],
templateUrl: './cbx-reader-preferences-component.html',
@@ -27,32 +29,32 @@ export class CbxReaderPreferencesComponent {
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
readonly cbxSpreads = [
{name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left'},
{name: 'Odd', key: CbxPageSpread.ODD, icon: 'pi pi-align-right'}
{name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: CbxPageSpread.ODD, icon: 'pi pi-align-right', translationKey: 'odd'}
];
readonly cbxViewModes = [
{name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE, icon: 'pi pi-book'},
{name: 'Two Page', key: CbxPageViewMode.TWO_PAGE, icon: 'pi pi-copy'},
{name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE, icon: 'pi pi-book', translationKey: 'singlePage'},
{name: 'Two Page', key: CbxPageViewMode.TWO_PAGE, icon: 'pi pi-copy', translationKey: 'twoPage'},
];
readonly cbxFitModes = [
{name: 'Fit Page', key: CbxFitMode.FIT_PAGE, icon: 'pi pi-window-maximize'},
{name: 'Fit Width', key: CbxFitMode.FIT_WIDTH, icon: 'pi pi-arrows-h'},
{name: 'Fit Height', key: CbxFitMode.FIT_HEIGHT, icon: 'pi pi-arrows-v'},
{name: 'Actual Size', key: CbxFitMode.ACTUAL_SIZE, icon: 'pi pi-expand'},
{name: 'Automatic', key: CbxFitMode.AUTO, icon: 'pi pi-sparkles'}
{name: 'Fit Page', key: CbxFitMode.FIT_PAGE, icon: 'pi pi-window-maximize', translationKey: 'fitPage'},
{name: 'Fit Width', key: CbxFitMode.FIT_WIDTH, icon: 'pi pi-arrows-h', translationKey: 'fitWidth'},
{name: 'Fit Height', key: CbxFitMode.FIT_HEIGHT, icon: 'pi pi-arrows-v', translationKey: 'fitHeight'},
{name: 'Actual Size', key: CbxFitMode.ACTUAL_SIZE, icon: 'pi pi-expand', translationKey: 'actualSize'},
{name: 'Automatic', key: CbxFitMode.AUTO, icon: 'pi pi-sparkles', translationKey: 'automatic'}
];
readonly cbxScrollModes = [
{name: 'Paginated', key: CbxScrollMode.PAGINATED, icon: 'pi pi-book'},
{name: 'Infinite', key: CbxScrollMode.INFINITE, icon: 'pi pi-sort-alt'}
{name: 'Paginated', key: CbxScrollMode.PAGINATED, icon: 'pi pi-book', translationKey: 'paginated'},
{name: 'Infinite', key: CbxScrollMode.INFINITE, icon: 'pi pi-sort-alt', translationKey: 'infinite'}
];
readonly cbxBackgroundColors = [
{name: 'Gray', key: CbxBackgroundColor.GRAY, color: '#808080'},
{name: 'Black', key: CbxBackgroundColor.BLACK, color: '#000000'},
{name: 'White', key: CbxBackgroundColor.WHITE, color: '#FFFFFF'}
{name: 'Gray', key: CbxBackgroundColor.GRAY, color: '#808080', translationKey: 'gray'},
{name: 'Black', key: CbxBackgroundColor.BLACK, color: '#000000', translationKey: 'black'},
{name: 'White', key: CbxBackgroundColor.WHITE, color: '#FFFFFF', translationKey: 'white'}
];
get selectedCbxSpread(): CbxPageSpread {
@@ -1,289 +1,291 @@
<div class="epub-preferences-container">
<ng-container *transloco="let t; prefix: 'settingsReader.ebook'">
<div class="epub-preferences-container">
<div class="settings-group">
<h3 class="group-title">Appearance</h3>
<div class="settings-group">
<h3 class="group-title">{{ t('appearance') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Theme</label>
<div class="theme-selector">
@for (theme of themes; track theme) {
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('theme') }}</label>
<div class="theme-selector">
@for (theme of themes; track theme) {
<button
type="button"
class="theme-option"
[class.selected]="selectedTheme === theme.name"
(click)="selectedTheme = theme.name"
[attr.aria-label]="theme.label"
[pTooltip]="theme.label"
tooltipPosition="bottom">
<span class="theme-colors">
<span class="theme-color" [style.background-color]="theme.light.bg"></span>
<span class="theme-color" [style.background-color]="theme.dark.bg"></span>
</span>
@if (selectedTheme === theme.name) {
<i class="pi pi-check"></i>
}
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('themeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('darkMode') }}</label>
<div class="button-group">
<button
type="button"
class="theme-option"
[class.selected]="selectedTheme === theme.name"
(click)="selectedTheme = theme.name"
[attr.aria-label]="theme.label"
[pTooltip]="theme.label"
tooltipPosition="bottom">
<span class="theme-colors">
<span class="theme-color" [style.background-color]="theme.light.bg"></span>
<span class="theme-color" [style.background-color]="theme.dark.bg"></span>
</span>
@if (selectedTheme === theme.name) {
<i class="pi pi-check"></i>
}
class="option-button"
[class.selected]="!isDark"
(click)="isDark = false">
<i class="pi pi-sun"></i>
<span class="option-text">{{ t('light') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
Select a color scheme to match your reading environment and comfort.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Dark Mode</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!isDark"
(click)="isDark = false">
<i class="pi pi-sun"></i>
<span class="option-text">Light</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="isDark"
(click)="isDark = true">
<i class="pi pi-moon"></i>
<span class="option-text">Dark</span>
</button>
</div>
</div>
<p class="setting-description">
Switch between light and dark backgrounds for day or night reading.
</p>
</div>
</div>
</div>
<div class="settings-group">
<h3 class="group-title">Typography</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Font Family</label>
<div class="button-group">
@for (font of fonts; track font) {
<button
type="button"
class="option-button font-button"
[class.selected]="selectedFont === font.key"
[class.separator]="font.key === 'separator'"
[attr.data-font]="font.key"
[disabled]="font.key === 'separator'"
(click)="selectedFont = font.key"
[pTooltip]="font.name"
tooltipPosition="bottom">
<span class="option-text" [style.font-family]="font.key && font.key.startsWith('custom:') ? getCustomFontName(font.key) : null">
{{ font.displayName }}
</span>
class="option-button"
[class.selected]="isDark"
(click)="isDark = true">
<i class="pi pi-moon"></i>
<span class="option-text">{{ t('dark') }}</span>
</button>
}
@if (!customFontsReady) {
<p-skeleton width="3.5rem" height="2.5rem" borderRadius="6px"></p-skeleton>
}
</div>
</div>
<p class="setting-description">
{{ t('darkModeDesc') }}
</p>
</div>
<p class="setting-description">
Choose a typeface that best suits your reading preference.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Font Size</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseFontSize()"></p-button>
<span class="font-size-value">{{ fontSize }}pt</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseFontSize()"></p-button>
<div class="settings-group">
<h3 class="group-title">{{ t('typography') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fontFamily') }}</label>
<div class="button-group">
@for (font of fonts; track font) {
<button
type="button"
class="option-button font-button"
[class.selected]="selectedFont === font.key"
[class.separator]="font.key === 'separator'"
[attr.data-font]="font.key"
[disabled]="font.key === 'separator'"
(click)="selectedFont = font.key"
[pTooltip]="font.name"
tooltipPosition="bottom">
<span class="option-text" [style.font-family]="font.key && font.key.startsWith('custom:') ? getCustomFontName(font.key) : null">
{{ font.displayName }}
</span>
</button>
}
@if (!customFontsReady) {
<p-skeleton width="3.5rem" height="2.5rem" borderRadius="6px"></p-skeleton>
}
</div>
</div>
<p class="setting-description">
{{ t('fontFamilyDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fontSize') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseFontSize()"></p-button>
<span class="font-size-value">{{ fontSize }}pt</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseFontSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('fontSizeDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('lineHeight') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseLineHeight()"></p-button>
<span class="font-size-value">{{ lineHeight.toFixed(1) }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseLineHeight()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('lineHeightDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('textJustification') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!justify"
(click)="justify = false">
<i class="pi pi-align-left"></i>
<span class="option-text">{{ t('left') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="justify"
(click)="justify = true">
<i class="pi pi-align-justify"></i>
<span class="option-text">{{ t('justified') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('textJustificationDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('hyphenation') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!hyphenate"
(click)="hyphenate = false">
<i class="pi pi-times"></i>
<span class="option-text">{{ t('off') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="hyphenate"
(click)="hyphenate = true">
<i class="pi pi-check"></i>
<span class="option-text">{{ t('on') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('hyphenationDesc') }}
</p>
</div>
<p class="setting-description">
Increase or decrease text size in points for optimal readability.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Line Height</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseLineHeight()"></p-button>
<span class="font-size-value">{{ lineHeight.toFixed(1) }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseLineHeight()"></p-button>
</div>
</div>
<p class="setting-description">
Adjust vertical spacing between lines for better legibility.
</p>
</div>
</div>
<div class="settings-group">
<h3 class="group-title">{{ t('layout') }}</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Text Justification</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!justify"
(click)="justify = false">
<i class="pi pi-align-left"></i>
<span class="option-text">Left</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="justify"
(click)="justify = true">
<i class="pi pi-align-justify"></i>
<span class="option-text">Justified</span>
</button>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('flow') }}</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="flow === 'paginated'"
(click)="flow = 'paginated'">
<i class="pi pi-clone"></i>
<span class="option-text">{{ t('paginated') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="flow === 'scrolled'"
(click)="flow = 'scrolled'">
<i class="pi pi-arrows-v"></i>
<span class="option-text">{{ t('scrolled') }}</span>
</button>
</div>
</div>
<p class="setting-description">
{{ t('flowDesc') }}
</p>
</div>
<p class="setting-description">
Align text to the left or justify it for a clean edge on both sides.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Hyphenation</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="!hyphenate"
(click)="hyphenate = false">
<i class="pi pi-times"></i>
<span class="option-text">Off</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="hyphenate"
(click)="hyphenate = true">
<i class="pi pi-check"></i>
<span class="option-text">On</span>
</button>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxColumns') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount > 1 ? maxColumnCount - 1 : 1"></p-button>
<span class="font-size-value">{{ maxColumnCount }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount < 4 ? maxColumnCount + 1 : 4"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxColumnsDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('columnGap') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseGap()"></p-button>
<span class="font-size-value">{{ gap }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseGap()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('columnGapDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxWidth') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxInlineSize()"></p-button>
<span class="font-size-value">{{ maxInlineSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxInlineSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxWidthDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('maxHeight') }}</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxBlockSize()"></p-button>
<span class="font-size-value">{{ maxBlockSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxBlockSize()"></p-button>
</div>
</div>
<p class="setting-description">
{{ t('maxHeightDesc') }}
</p>
</div>
<p class="setting-description">
Enable to break long words at line ends for a smoother text flow.
</p>
</div>
</div>
</div>
<div class="settings-group">
<h3 class="group-title">Layout</h3>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Flow</label>
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="flow === 'paginated'"
(click)="flow = 'paginated'">
<i class="pi pi-clone"></i>
<span class="option-text">Paginated</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="flow === 'scrolled'"
(click)="flow = 'scrolled'">
<i class="pi pi-arrows-v"></i>
<span class="option-text">Scrolled</span>
</button>
</div>
</div>
<p class="setting-description">
Choose between paginated (page-by-page) or continuous scrolling flow.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Max Columns</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount > 1 ? maxColumnCount - 1 : 1"></p-button>
<span class="font-size-value">{{ maxColumnCount }}</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount < 4 ? maxColumnCount + 1 : 4"></p-button>
</div>
</div>
<p class="setting-description">
Set how many columns the text is split into on wide screens.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Column Gap</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseGap()"></p-button>
<span class="font-size-value">{{ gap }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseGap()"></p-button>
</div>
</div>
<p class="setting-description">
Control the space between columns for a balanced layout.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Max Width</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxInlineSize()"></p-button>
<span class="font-size-value">{{ maxInlineSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxInlineSize()"></p-button>
</div>
</div>
<p class="setting-description">
Limit the maximum width of the reading area for easier line tracking.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Max Height</label>
<div class="font-size-controls">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxBlockSize()"></p-button>
<span class="font-size-value">{{ maxBlockSize }}px</span>
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxBlockSize()"></p-button>
</div>
</div>
<p class="setting-description">
Limit the maximum height of the reading area to fit your screen.
</p>
</div>
</div>
</div>
</div>
</ng-container>
@@ -1,6 +1,7 @@
import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core';
import {Button} from 'primeng/button';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {UserSettings} from '../../user-management/user.service';
import {Tooltip} from 'primeng/tooltip';
@@ -16,6 +17,7 @@ import {themes} from '../../../readers/ebook-reader/state/themes.constant';
imports: [
Button,
FormsModule,
TranslocoDirective,
Tooltip,
Skeleton
],
@@ -1,123 +1,125 @@
<div class="pdf-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Spread</label>
<div class="button-group">
@for (spread of pdfSpreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfSpread === spread.key"
(click)="selectedPdfSpread = spread.key">
<i [class]="spread.icon"></i>
<span class="option-text">{{ spread.name }}</span>
</button>
}
<ng-container *transloco="let t; prefix: 'settingsReader.streamingPdf'">
<div class="pdf-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageSpread') }}</label>
<div class="button-group">
@for (spread of pdfSpreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfSpread === spread.key"
(click)="selectedPdfSpread = spread.key">
<i [class]="spread.icon"></i>
<span class="option-text">{{ t(spread.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div>
<p class="setting-description">
Configure how PDF pages are displayed - single page or double page spread.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Layout</label>
<div class="button-group">
@for (mode of pdfViewModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfViewMode === mode.key"
(click)="selectedPdfViewMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageLayout') }}</label>
<div class="button-group">
@for (mode of pdfViewModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfViewMode === mode.key"
(click)="selectedPdfViewMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageLayoutDesc') }}
</p>
</div>
<p class="setting-description">
Choose how PDF pages are displayed while reading.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Fit Mode</label>
<div class="button-group">
@for (mode of pdfFitModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfFitMode === mode.key"
(click)="selectedPdfFitMode = mode.key"
[pTooltip]="mode.name"
tooltipPosition="bottom">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('fitMode') }}</label>
<div class="button-group">
@for (mode of pdfFitModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfFitMode === mode.key"
(click)="selectedPdfFitMode = mode.key"
[pTooltip]="t(mode.translationKey)"
tooltipPosition="bottom">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('fitModeDesc') }}
</p>
</div>
<p class="setting-description">
Select how pages should be scaled to fit the reader window.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Scroll Mode</label>
<div class="button-group">
@for (mode of pdfScrollModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfScrollMode === mode.key"
(click)="selectedPdfScrollMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('scrollMode') }}</label>
<div class="button-group">
@for (mode of pdfScrollModes; track mode) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfScrollMode === mode.key"
(click)="selectedPdfScrollMode = mode.key">
<i [class]="mode.icon"></i>
<span class="option-text">{{ t(mode.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('scrollModeDesc') }}
</p>
</div>
<p class="setting-description">
Choose between paginated or infinite scroll reading experience.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Background Color</label>
<div class="theme-selector">
@for (color of pdfBackgroundColors; track color) {
<button
type="button"
class="theme-option"
[class.selected]="selectedPdfBackgroundColor === color.key"
[style.background-color]="color.color"
(click)="selectedPdfBackgroundColor = color.key"
[attr.aria-label]="color.name"
[pTooltip]="color.name"
tooltipPosition="bottom">
@if (selectedPdfBackgroundColor === color.key) {
<i class="pi pi-check"></i>
}
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('backgroundColor') }}</label>
<div class="theme-selector">
@for (color of pdfBackgroundColors; track color) {
<button
type="button"
class="theme-option"
[class.selected]="selectedPdfBackgroundColor === color.key"
[style.background-color]="color.color"
(click)="selectedPdfBackgroundColor = color.key"
[attr.aria-label]="t(color.translationKey)"
[pTooltip]="t(color.translationKey)"
tooltipPosition="bottom">
@if (selectedPdfBackgroundColor === color.key) {
<i class="pi pi-check"></i>
}
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('backgroundColorDesc') }}
</p>
</div>
<p class="setting-description">
Set the background color for the PDF reader.
</p>
</div>
</div>
</div>
</ng-container>
@@ -1,5 +1,6 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {PdfBackgroundColor, PdfFitMode, PdfPageSpread, PdfPageViewMode, PdfScrollMode, UserSettings} from '../../user-management/user.service';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {TooltipModule} from 'primeng/tooltip';
@@ -8,6 +9,7 @@ import {TooltipModule} from 'primeng/tooltip';
selector: 'app-new-pdf-reader-preferences-component',
imports: [
FormsModule,
TranslocoDirective,
TooltipModule
],
templateUrl: './new-pdf-reader-preferences-component.html',
@@ -27,32 +29,32 @@ export class NewPdfReaderPreferencesComponent {
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
readonly pdfSpreads = [
{name: 'Even', key: PdfPageSpread.EVEN, icon: 'pi pi-align-left'},
{name: 'Odd', key: PdfPageSpread.ODD, icon: 'pi pi-align-right'}
{name: 'Even', key: PdfPageSpread.EVEN, icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: PdfPageSpread.ODD, icon: 'pi pi-align-right', translationKey: 'odd'}
];
readonly pdfViewModes = [
{name: 'Single Page', key: PdfPageViewMode.SINGLE_PAGE, icon: 'pi pi-book'},
{name: 'Two Page', key: PdfPageViewMode.TWO_PAGE, icon: 'pi pi-copy'},
{name: 'Single Page', key: PdfPageViewMode.SINGLE_PAGE, icon: 'pi pi-book', translationKey: 'singlePage'},
{name: 'Two Page', key: PdfPageViewMode.TWO_PAGE, icon: 'pi pi-copy', translationKey: 'twoPage'},
];
readonly pdfFitModes = [
{name: 'Fit Page', key: PdfFitMode.FIT_PAGE, icon: 'pi pi-window-maximize'},
{name: 'Fit Width', key: PdfFitMode.FIT_WIDTH, icon: 'pi pi-arrows-h'},
{name: 'Fit Height', key: PdfFitMode.FIT_HEIGHT, icon: 'pi pi-arrows-v'},
{name: 'Actual Size', key: PdfFitMode.ACTUAL_SIZE, icon: 'pi pi-expand'},
{name: 'Automatic', key: PdfFitMode.AUTO, icon: 'pi pi-sparkles'}
{name: 'Fit Page', key: PdfFitMode.FIT_PAGE, icon: 'pi pi-window-maximize', translationKey: 'fitPage'},
{name: 'Fit Width', key: PdfFitMode.FIT_WIDTH, icon: 'pi pi-arrows-h', translationKey: 'fitWidth'},
{name: 'Fit Height', key: PdfFitMode.FIT_HEIGHT, icon: 'pi pi-arrows-v', translationKey: 'fitHeight'},
{name: 'Actual Size', key: PdfFitMode.ACTUAL_SIZE, icon: 'pi pi-expand', translationKey: 'actualSize'},
{name: 'Automatic', key: PdfFitMode.AUTO, icon: 'pi pi-sparkles', translationKey: 'automatic'}
];
readonly pdfScrollModes = [
{name: 'Paginated', key: PdfScrollMode.PAGINATED, icon: 'pi pi-book'},
{name: 'Infinite', key: PdfScrollMode.INFINITE, icon: 'pi pi-sort-alt'}
{name: 'Paginated', key: PdfScrollMode.PAGINATED, icon: 'pi pi-book', translationKey: 'paginated'},
{name: 'Infinite', key: PdfScrollMode.INFINITE, icon: 'pi pi-sort-alt', translationKey: 'infinite'}
];
readonly pdfBackgroundColors = [
{name: 'Gray', key: PdfBackgroundColor.GRAY, color: '#808080'},
{name: 'Black', key: PdfBackgroundColor.BLACK, color: '#000000'},
{name: 'White', key: PdfBackgroundColor.WHITE, color: '#FFFFFF'}
{name: 'Gray', key: PdfBackgroundColor.GRAY, color: '#808080', translationKey: 'gray'},
{name: 'Black', key: PdfBackgroundColor.BLACK, color: '#000000', translationKey: 'black'},
{name: 'White', key: PdfBackgroundColor.WHITE, color: '#FFFFFF', translationKey: 'white'}
];
get selectedPdfSpread(): PdfPageSpread {
@@ -1,51 +1,53 @@
<div class="pdf-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Spread</label>
<div class="button-group">
@for (spread of spreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedSpread === spread.key"
(click)="selectedSpread = spread.key"
[pTooltip]="spread.name"
tooltipPosition="bottom">
<i [class]="spread.icon"></i>
<span class="option-text">{{ spread.name }}</span>
</button>
}
<ng-container *transloco="let t; prefix: 'settingsReader.pdf'">
<div class="pdf-preferences-container">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageSpread') }}</label>
<div class="button-group">
@for (spread of spreads; track spread) {
<button
type="button"
class="option-button"
[class.selected]="selectedSpread === spread.key"
(click)="selectedSpread = spread.key"
[pTooltip]="t(spread.translationKey)"
tooltipPosition="bottom">
<i [class]="spread.icon"></i>
<span class="option-text">{{ t(spread.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div>
<p class="setting-description">
Choose how PDF pages are displayed - single page or double page spread view.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Page Zoom</label>
<div class="button-group">
@for (zoom of zooms; track zoom) {
<button
type="button"
class="option-button"
[class.selected]="selectedZoom === zoom.key"
(click)="selectedZoom = zoom.key"
[pTooltip]="zoom.name"
tooltipPosition="bottom">
<i [class]="zoom.icon"></i>
<span class="option-text">{{ zoom.name }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pageZoom') }}</label>
<div class="button-group">
@for (zoom of zooms; track zoom) {
<button
type="button"
class="option-button"
[class.selected]="selectedZoom === zoom.key"
(click)="selectedZoom = zoom.key"
[pTooltip]="t(zoom.translationKey)"
tooltipPosition="bottom">
<i [class]="zoom.icon"></i>
<span class="option-text">{{ t(zoom.translationKey) }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pageZoomDesc') }}
</p>
</div>
<p class="setting-description">
Set the default zoom level for PDF documents to enhance readability.
</p>
</div>
</div>
</div>
</ng-container>
@@ -1,5 +1,6 @@
import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {PageSpread, UserSettings} from '../../user-management/user.service';
import {TooltipModule} from 'primeng/tooltip';
@@ -8,6 +9,7 @@ import {TooltipModule} from 'primeng/tooltip';
selector: 'app-pdf-reader-preferences-component',
imports: [
FormsModule,
TranslocoDirective,
TooltipModule
],
templateUrl: './pdf-reader-preferences-component.html',
@@ -18,17 +20,17 @@ export class PdfReaderPreferencesComponent {
@Input() userSettings!: UserSettings;
readonly spreads: {name: string; key: PageSpread; icon: string}[] = [
{name: 'Even', key: 'even', icon: 'pi pi-align-left'},
{name: 'Odd', key: 'odd', icon: 'pi pi-align-right'},
{name: 'None', key: 'off', icon: 'pi pi-minus'}
readonly spreads: {name: string; key: PageSpread; icon: string; translationKey: string}[] = [
{name: 'Even', key: 'even', icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: 'odd', icon: 'pi pi-align-right', translationKey: 'odd'},
{name: 'None', key: 'off', icon: 'pi pi-minus', translationKey: 'none'}
];
readonly zooms: {name: string; key: string; icon: string}[] = [
{name: 'Auto Zoom', key: 'auto', icon: 'pi pi-sparkles'},
{name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize'},
{name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h'},
{name: 'Actual Size', key: 'page-actual', icon: 'pi pi-expand'}
readonly zooms: {name: string; key: string; icon: string; translationKey: string}[] = [
{name: 'Auto Zoom', key: 'auto', icon: 'pi pi-sparkles', translationKey: 'autoZoom'},
{name: 'Page Fit', key: 'page-fit', icon: 'pi pi-window-maximize', translationKey: 'pageFit'},
{name: 'Page Width', key: 'page-width', icon: 'pi pi-arrows-h', translationKey: 'pageWidth'},
{name: 'Actual Size', key: 'page-actual', icon: 'pi pi-expand', translationKey: 'actualSize'}
];
get selectedSpread(): 'even' | 'odd' | 'off' {
@@ -1,104 +1,106 @@
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-book"></i>
Reader Preferences
</h2>
<p class="settings-description">
Configure reading experience settings for your library. Set default preferences that serve as overrides for individual books, or allow each book to maintain its own custom settings for PDF, EPUB, FB2, MOBI, AZW3, and CBX formats.
</p>
</div>
<div class="settings-content">
<app-settings-application-mode [userSettings]="userSettings"></app-settings-application-mode>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-book"></i>
eBook Reader: Default Settings
</h3>
<p class="section-description">
Set default preferences for eBook formats (EPUB, FB2, MOBI, AZW3). When "Default Override" mode is active, these settings will override individual book preferences. Configure typography, themes, text flow, and layout options.
</p>
</div>
<div class="settings-card">
<app-epub-reader-preferences-component
[userSettings]="userSettings">
</app-epub-reader-preferences-component>
</div>
<ng-container *transloco="let t; prefix: 'settingsReader'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-book"></i>
{{ t('title') }}
</h2>
<p class="settings-description">
{{ t('description') }}
</p>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-file-pdf"></i>
PDF Reader: Default Settings
</h3>
<p class="section-description">
Set default preferences for PDF documents. When "Default Override" mode is active, these settings will override individual document preferences. Configure zoom levels, display modes, scroll behavior, and navigation.
</p>
</div>
<div class="settings-content">
<app-settings-application-mode [userSettings]="userSettings"></app-settings-application-mode>
<div class="settings-card">
<app-pdf-reader-preferences-component
[userSettings]="userSettings">
</app-pdf-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-images"></i>
Comic Book Reader: Default Settings
</h3>
<p class="section-description">
Set default preferences for comic book archives (CBZ, CBR, CB7). When "Default Override" mode is active, these settings will override individual file preferences. Configure page layout, reading direction, and image rendering.
</p>
</div>
<div class="settings-card">
<app-cbx-reader-preferences-component
[userSettings]="userSettings">
</app-cbx-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-file-pdf"></i>
Streaming PDF Reader: Default Settings
</h3>
<p class="section-description">
Configure default preferences for the streaming PDF reader. When "Default Override" mode is enabled, these settings will take precedence over per-file preferences. Adjust page layout, zoom behavior, scrolling mode, and rendering options for an optimal reading experience.
</p>
</div>
<div class="settings-card">
<app-new-pdf-reader-preferences-component
[userSettings]="userSettings">
</app-new-pdf-reader-preferences-component>
</div>
</div>
@if (hasFontManagementPermission) {
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-palette"></i>
Custom Font Library
<i class="pi pi-book"></i>
{{ t('ebook.sectionTitle') }}
</h3>
<p class="section-description">
Personalize your reading experience by uploading custom fonts to use with eBook formats (EPUB, FB2, MOBI, AZW3). Upload up to 10 custom font files that will be available for selection in the eBook reader settings.
{{ t('ebook.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-custom-fonts></app-custom-fonts>
<app-epub-reader-preferences-component
[userSettings]="userSettings">
</app-epub-reader-preferences-component>
</div>
</div>
}
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-file-pdf"></i>
{{ t('pdf.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('pdf.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-pdf-reader-preferences-component
[userSettings]="userSettings">
</app-pdf-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-images"></i>
{{ t('cbx.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('cbx.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-cbx-reader-preferences-component
[userSettings]="userSettings">
</app-cbx-reader-preferences-component>
</div>
</div>
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-file-pdf"></i>
{{ t('streamingPdf.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('streamingPdf.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-new-pdf-reader-preferences-component
[userSettings]="userSettings">
</app-new-pdf-reader-preferences-component>
</div>
</div>
@if (hasFontManagementPermission) {
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-palette"></i>
{{ t('fonts.sectionTitle') }}
</h3>
<p class="section-description">
{{ t('fonts.sectionDesc') }}
</p>
</div>
<div class="settings-card">
<app-custom-fonts></app-custom-fonts>
</div>
</div>
}
</div>
</div>
</div>
</ng-container>
@@ -4,6 +4,7 @@ import {filter, takeUntil} from 'rxjs/operators';
import {Observable, Subject} from 'rxjs';
import {TooltipModule} from 'primeng/tooltip';
import {TranslocoDirective} from '@jsverse/transloco';
import {UserService, UserSettings, UserState} from '../user-management/user.service';
import {ReaderPreferencesService} from './reader-preferences.service';
import {EpubReaderPreferencesComponent} from './epub-reader-preferences/epub-reader-preferences-component';
@@ -18,7 +19,7 @@ import {SettingsApplicationModeComponent} from './settings-application-mode/sett
templateUrl: './reader-preferences.component.html',
standalone: true,
styleUrls: ['./reader-preferences.component.scss'],
imports: [FormsModule, TooltipModule, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, NewPdfReaderPreferencesComponent, SettingsApplicationModeComponent]
imports: [FormsModule, TooltipModule, TranslocoDirective, EpubReaderPreferencesComponent, PdfReaderPreferencesComponent, CbxReaderPreferencesComponent, CustomFontsComponent, NewPdfReaderPreferencesComponent, SettingsApplicationModeComponent]
})
export class ReaderPreferences implements OnInit, OnDestroy {
private readonly userService = inject(UserService);
@@ -1,105 +1,107 @@
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
Settings Application Mode
</h3>
<p class="section-description">
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.
</p>
</div>
<div class="settings-card">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">PDF Reader Settings</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfScope === item.key"
(click)="selectedPdfScope = item.key; onPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? 'Default Override' : 'Book-Specific' }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
Control whether your default zoom level, page layout, and navigation preferences apply to all PDFs or if each document retains its own settings.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsReader.appMode'">
<div class="preferences-section">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
{{ t('title') }}
</h3>
<p class="section-description">
{{ t('description') }}
</p>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">eBook Reader Settings</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedEpubScope === item.key"
(click)="selectedEpubScope = item.key; onEpubScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? 'Default Override' : 'Book-Specific' }}</span>
</button>
}
<div class="settings-card">
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('pdfLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedPdfScope === item.key"
(click)="selectedPdfScope = item.key; onPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('pdfDesc') }}
</p>
</div>
<p class="setting-description">
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.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Comic Book Reader Settings</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScope === item.key"
(click)="selectedCbxScope = item.key; onCbxScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? 'Default Override' : 'Book-Specific' }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('ebookLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedEpubScope === item.key"
(click)="selectedEpubScope = item.key; onEpubScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('ebookDesc') }}
</p>
</div>
<p class="setting-description">
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.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Streaming PDF Reader Settings</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedNewPdfScope === item.key"
(click)="selectedNewPdfScope = item.key; onNewPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? 'Default Override' : 'Book-Specific' }}</span>
</button>
}
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('comicLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedCbxScope === item.key"
(click)="selectedCbxScope = item.key; onCbxScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('comicDesc') }}
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">{{ t('streamingPdfLabel') }}</label>
<div class="button-group">
@for (item of scopeOptions; track item) {
<button
type="button"
class="option-button"
[class.selected]="selectedNewPdfScope === item.key"
(click)="selectedNewPdfScope = item.key; onNewPdfScopeChange()">
<i [class]="item.icon"></i>
<span class="option-text">{{ item.key === 'Global' ? t('defaultOverride') : t('bookSpecific') }}</span>
</button>
}
</div>
</div>
<p class="setting-description">
{{ t('streamingPdfDesc') }}
</p>
</div>
<p class="setting-description">
Choose whether your default view mode, fit mode, and scroll direction apply to all streaming PDFs or if each document maintains its own configuration.
</p>
</div>
</div>
</div>
</div>
</ng-container>
@@ -1,4 +1,5 @@
import {Component, inject, Input, OnInit} from '@angular/core';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service';
import {UserSettings} from '../../user-management/user.service';
@@ -6,7 +7,8 @@ import {UserSettings} from '../../user-management/user.service';
selector: 'app-settings-application-mode',
templateUrl: './settings-application-mode.component.html',
standalone: true,
styleUrls: ['./settings-application-mode.component.scss']
styleUrls: ['./settings-application-mode.component.scss'],
imports: [TranslocoDirective]
})
export class SettingsApplicationModeComponent implements OnInit {
@Input() userSettings!: UserSettings;
@@ -1,132 +1,134 @@
@if (userService.userState$ | async; as userState) {
@if (userState.user) {
<div class="settings-container">
<p-tabs [(value)]="activeTab" lazy scrollable>
<p-tablist>
<p-tab [value]="SettingsTab.ReaderSettings">
<i class="pi pi-book"></i> Reader
</p-tab>
<p-tab [value]="SettingsTab.ViewPreferences">
<i class="pi pi-desktop"></i> View
</p-tab>
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tab [value]="SettingsTab.MetadataSettings">
<i class="pi pi-sliders-h"></i> Metadata 1
<ng-container *transloco="let t; prefix: 'settings.tabs'">
@if (userService.userState$ | async; as userState) {
@if (userState.user) {
<div class="settings-container">
<p-tabs [(value)]="activeTab" lazy scrollable>
<p-tablist>
<p-tab [value]="SettingsTab.ReaderSettings">
<i class="pi pi-book"></i> {{ t('reader') }}
</p-tab>
<p-tab [value]="SettingsTab.LibraryMetadataSettings">
<i class="pi pi-database"></i> Metadata 2
<p-tab [value]="SettingsTab.ViewPreferences">
<i class="pi pi-desktop"></i> {{ t('view') }}
</p-tab>
}
@if (userState.user.permissions.admin || userState.user.permissions.canManageGlobalPreferences) {
<p-tab [value]="SettingsTab.ApplicationSettings">
<i class="pi pi-cog"></i> Application
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tab [value]="SettingsTab.MetadataSettings">
<i class="pi pi-sliders-h"></i> {{ t('metadata1') }}
</p-tab>
<p-tab [value]="SettingsTab.LibraryMetadataSettings">
<i class="pi pi-database"></i> {{ t('metadata2') }}
</p-tab>
}
@if (userState.user.permissions.admin || userState.user.permissions.canManageGlobalPreferences) {
<p-tab [value]="SettingsTab.ApplicationSettings">
<i class="pi pi-cog"></i> {{ t('application') }}
</p-tab>
}
@if (userState.user.permissions.admin) {
<p-tab [value]="SettingsTab.UserManagement">
<i class="pi pi-users"></i> {{ t('users') }}
</p-tab>
}
<p-tab [value]="SettingsTab.EmailSettingsV2">
<i class="pi pi-envelope"></i> {{ t('email') }}
</p-tab>
}
@if (userState.user.permissions.admin) {
<p-tab [value]="SettingsTab.UserManagement">
<i class="pi pi-users"></i> Users
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tab [value]="SettingsTab.NamingPattern">
<i class="pi pi-sitemap"></i> {{ t('patterns') }}
</p-tab>
}
@if (userState.user.permissions.admin) {
<p-tab [value]="SettingsTab.AuthenticationSettings">
<i class="pi pi-lock"></i> {{ t('authentication') }}
</p-tab>
}
@if (userState.user.permissions.admin || userState.user.permissions.canAccessTaskManager) {
<p-tab [value]="SettingsTab.Tasks">
<i class="pi pi-list-check"></i> {{ t('tasks') }}
</p-tab>
}
<p-tab [value]="SettingsTab.OpdsV2">
<i class="pi pi-globe"></i> {{ t('opds') }}
</p-tab>
}
<p-tab [value]="SettingsTab.EmailSettingsV2">
<i class="pi pi-envelope"></i> Email
</p-tab>
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tab [value]="SettingsTab.NamingPattern">
<i class="pi pi-sitemap"></i> Patterns
<p-tab [value]="SettingsTab.DeviceSettings">
<i class="pi pi-mobile"></i> {{ t('devices') }}
</p-tab>
}
@if (userState.user.permissions.admin) {
<p-tab [value]="SettingsTab.AuthenticationSettings">
<i class="pi pi-lock"></i> Authentication
</p-tab>
}
@if (userState.user.permissions.admin || userState.user.permissions.canAccessTaskManager) {
<p-tab [value]="SettingsTab.Tasks">
<i class="pi pi-list-check"></i> Tasks
</p-tab>
}
<p-tab [value]="SettingsTab.OpdsV2">
<i class="pi pi-globe"></i> OPDS
</p-tab>
<p-tab [value]="SettingsTab.DeviceSettings">
<i class="pi pi-mobile"></i> Devices
</p-tab>
</p-tablist>
<p-tabpanels>
<p-tabpanel [value]="SettingsTab.ReaderSettings">
<ng-template #content>
<app-reader-preferences></app-reader-preferences>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="SettingsTab.ViewPreferences">
<ng-template #content>
<app-view-preferences-parent></app-view-preferences-parent>
</ng-template>
</p-tabpanel>
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tabpanel [value]="SettingsTab.MetadataSettings">
</p-tablist>
<p-tabpanels>
<p-tabpanel [value]="SettingsTab.ReaderSettings">
<ng-template #content>
<app-metadata-settings-component></app-metadata-settings-component>
<app-reader-preferences></app-reader-preferences>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="SettingsTab.LibraryMetadataSettings">
<p-tabpanel [value]="SettingsTab.ViewPreferences">
<ng-template #content>
<app-library-metadata-settings-component></app-library-metadata-settings-component>
<app-view-preferences-parent></app-view-preferences-parent>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin || userState.user.permissions.canManageGlobalPreferences) {
<p-tabpanel [value]="SettingsTab.ApplicationSettings">
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tabpanel [value]="SettingsTab.MetadataSettings">
<ng-template #content>
<app-metadata-settings-component></app-metadata-settings-component>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="SettingsTab.LibraryMetadataSettings">
<ng-template #content>
<app-library-metadata-settings-component></app-library-metadata-settings-component>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin || userState.user.permissions.canManageGlobalPreferences) {
<p-tabpanel [value]="SettingsTab.ApplicationSettings">
<ng-template #content>
<app-global-preferences></app-global-preferences>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin) {
<p-tabpanel [value]="SettingsTab.UserManagement">
<ng-template #content>
<app-user-management></app-user-management>
</ng-template>
</p-tabpanel>
}
<p-tabpanel [value]="SettingsTab.EmailSettingsV2">
<ng-template #content>
<app-global-preferences></app-global-preferences>
<app-email-v2></app-email-v2>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin) {
<p-tabpanel [value]="SettingsTab.UserManagement">
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tabpanel [value]="SettingsTab.NamingPattern">
<ng-template #content>
<app-file-naming-pattern></app-file-naming-pattern>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin) {
<p-tabpanel [value]="SettingsTab.AuthenticationSettings">
<ng-template #content>
<app-authentication-settings></app-authentication-settings>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin || userState.user.permissions.canAccessTaskManager) {
<p-tabpanel [value]="SettingsTab.Tasks">
<ng-template #content>
<app-task-management></app-task-management>
</ng-template>
</p-tabpanel>
}
<p-tabpanel [value]="SettingsTab.OpdsV2">
<ng-template #content>
<app-user-management></app-user-management>
<app-opds-settings></app-opds-settings>
</ng-template>
</p-tabpanel>
}
<p-tabpanel [value]="SettingsTab.EmailSettingsV2">
<ng-template #content>
<app-email-v2></app-email-v2>
</ng-template>
</p-tabpanel>
@if (userState.user.permissions.admin || userState.user.permissions.canManageMetadataConfig) {
<p-tabpanel [value]="SettingsTab.NamingPattern">
<p-tabpanel [value]="SettingsTab.DeviceSettings">
<ng-template #content>
<app-file-naming-pattern></app-file-naming-pattern>
<app-device-settings-component></app-device-settings-component>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin) {
<p-tabpanel [value]="SettingsTab.AuthenticationSettings">
<ng-template #content>
<app-authentication-settings></app-authentication-settings>
</ng-template>
</p-tabpanel>
}
@if (userState.user.permissions.admin || userState.user.permissions.canAccessTaskManager) {
<p-tabpanel [value]="SettingsTab.Tasks">
<ng-template #content>
<app-task-management></app-task-management>
</ng-template>
</p-tabpanel>
}
<p-tabpanel [value]="SettingsTab.OpdsV2">
<ng-template #content>
<app-opds-settings></app-opds-settings>
</ng-template>
</p-tabpanel>
<p-tabpanel [value]="SettingsTab.DeviceSettings">
<ng-template #content>
<app-device-settings-component></app-device-settings-component>
</ng-template>
</p-tabpanel>
</p-tabpanels>
</p-tabs>
</div>
</p-tabpanels>
</p-tabs>
</div>
}
}
}
</ng-container>
@@ -17,6 +17,7 @@ import {DeviceSettingsComponent} from './device-settings/device-settings-compone
import {LibraryMetadataSettingsComponent} from './library-metadata-settings/library-metadata-settings.component';
import {PageTitleService} from "../../shared/service/page-title.service";
import {EmailV2Component} from './email-v2/email-v2.component';
import {TranslocoDirective} from '@jsverse/transloco';
export enum SettingsTab {
ReaderSettings = 'reader',
@@ -53,7 +54,8 @@ export enum SettingsTab {
OpdsSettings,
LibraryMetadataSettingsComponent,
TaskManagementComponent,
EmailV2Component
EmailV2Component,
TranslocoDirective
],
templateUrl: './settings.component.html',
styleUrl: './settings.component.scss'
@@ -1,25 +1,22 @@
<ng-container *transloco="let t; prefix: 'settingsTasks'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-list-check"></i>
System Task Manager
{{ t('title') }}
<app-external-doc-link docType="taskManagement"></app-external-doc-link>
</h2>
<p class="settings-description">
Manage automated system tasks for library maintenance, metadata refreshing, and cache cleanup.
Schedule recurring operations using
<a href="https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions" target="_blank" rel="noopener noreferrer" class="cron-link">Spring cron expressions</a>.
</p>
<p class="settings-description" [innerHTML]="t('description')"></p>
</div>
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
System Tasks
{{ t('systemTasks.sectionTitle') }}
</h3>
<p class="section-description">
Execute tasks manually, monitor progress in real-time, and configure scheduled automation.
{{ t('systemTasks.sectionDesc') }}
</p>
</div>
@@ -27,14 +24,14 @@
@if (loading && taskInfos.length === 0) {
<div class="loading-state">
<i class="pi pi-spin pi-spinner"></i>
<span>Loading tasks...</span>
<span>{{ t('loading') }}</span>
</div>
}
@if (!loading && taskInfos.length === 0) {
<div class="empty-state">
<i class="pi pi-check-circle"></i>
<p class="empty-title">No tasks available</p>
<p class="empty-title">{{ t('emptyTitle') }}</p>
</div>
}
@@ -52,12 +49,12 @@
@if (isTaskRunning(taskInfo.taskType)) {
<span class="status-badge running">
<i class="pi pi-spin pi-spinner"></i>
Running
{{ t('status.running') }}
</span>
} @else if (isTaskStale(getTaskHistory(taskInfo.taskType))) {
<span class="status-badge stale">
<i class="pi pi-exclamation-triangle"></i>
Stale
{{ t('status.stale') }}
</span>
} @else if (getTaskHistory(taskInfo.taskType)?.id) {
<span class="status-badge" [ngClass]="getLastRunInfoClass(taskInfo.taskType)">
@@ -79,7 +76,7 @@
@if (getCronConfig(taskInfo.taskType)?.cronExpression) {
<code class="cron-value">{{ getCronConfig(taskInfo.taskType)!.cronExpression }}</code>
} @else {
<span class="cron-empty">No schedule</span>
<span class="cron-empty">{{ t('cron.noSchedule') }}</span>
}
<p-button
icon="pi pi-pencil"
@@ -88,7 +85,7 @@
[rounded]="true"
severity="info"
[disabled]="cronUpdating"
pTooltip="Edit"
[pTooltip]="t('cron.edit')"
(onClick)="startEditingCron(taskInfo.taskType)">
</p-button>
} @else {
@@ -99,7 +96,7 @@
[class.has-error]="!!cronValidationError"
[(ngModel)]="editingCronExpression"
(ngModelChange)="onCronExpressionChange()"
placeholder="e.g., 0 2 * * *"
[placeholder]="t('cron.placeholder')"
(keyup.enter)="saveCronExpression(taskInfo.taskType)"
(keyup.escape)="cancelEditingCron()">
<p-button
@@ -147,7 +144,7 @@
}
@if (canCancelTask(getTaskHistory(taskInfo.taskType)) && !isTaskStale(getTaskHistory(taskInfo.taskType))) {
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
[icon]="getCancelButtonIcon(taskInfo.taskType)"
severity="danger"
[outlined]="true"
@@ -169,15 +166,20 @@
@if (!isTaskRunning(taskInfo.taskType) && taskInfo.taskType === TaskType.REFRESH_LIBRARY_METADATA) {
<div class="task-options">
<label class="option-label">Metadata Replace Mode:</label>
<label class="option-label">{{ t('metadataReplace.label') }}</label>
<p-select
[options]="metadataReplaceOptions"
[(ngModel)]="selectedMetadataReplaceMode"
size="small"
optionLabel="label"
optionValue="value"
placeholder="Select mode"
[placeholder]="t('metadataReplace.selectMode')"
class="mode-select">
<ng-template let-option pTemplate="item">
{{ option.translationKey | transloco }}
</ng-template>
<ng-template let-option pTemplate="selectedItem">
{{ option.translationKey | transloco }}
</ng-template>
</p-select>
<span class="option-hint">{{ getMetadataReplaceDescription(selectedMetadataReplaceMode) }}</span>
</div>
@@ -188,18 +190,18 @@
@if (isTaskStale(getTaskHistory(taskInfo.taskType))) {
<div class="stale-warning">
<i class="pi pi-exclamation-triangle"></i>
<span>This task appears stuck. No updates received for over 5 minutes.</span>
<span>{{ t('progress.staleWarning') }}</span>
</div>
}
@if (getTaskHistory(taskInfo.taskType)?.message) {
<div class="progress-row">
<span class="progress-label">Status:</span>
<span class="progress-label">{{ t('progress.statusLabel') }}</span>
<span class="progress-value">{{ getTaskStatusMessage(taskInfo.taskType) }}</span>
</div>
}
@if (getTaskProgressPercentage(taskInfo.taskType) !== null) {
<div class="progress-row">
<span class="progress-label">Progress:</span>
<span class="progress-label">{{ t('progress.progressLabel') }}</span>
<div class="progress-bar-container">
<p-progressbar [value]="getTaskProgressPercentage(taskInfo.taskType)!"></p-progressbar>
<span class="progress-percent">{{ getTaskProgressPercentage(taskInfo.taskType) }}%</span>
@@ -208,7 +210,7 @@
}
@if (getTaskUpdatedAt(taskInfo.taskType)) {
<div class="progress-row">
<span class="progress-label">Started:</span>
<span class="progress-label">{{ t('progress.startedLabel') }}</span>
<span class="progress-value">{{ formatDate(getTaskUpdatedAt(taskInfo.taskType)!) }}</span>
</div>
}
@@ -221,3 +223,4 @@
</div>
</div>
</div>
</ng-container>
@@ -23,6 +23,7 @@ import {finalize, forkJoin, Subscription} from 'rxjs';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {ToggleSwitch} from 'primeng/toggleswitch';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-task-management',
@@ -35,7 +36,9 @@ import {Tooltip} from 'primeng/tooltip';
FormsModule,
ExternalDocLinkComponent,
ToggleSwitch,
Tooltip
Tooltip,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './task-management.component.html',
styleUrl: './task-management.component.scss'
@@ -44,6 +47,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
// Services
private messageService = inject(MessageService);
private taskService = inject(TaskService);
private t = inject(TranslocoService);
// State
taskInfos: TaskInfo[] = [];
@@ -56,11 +60,15 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
metadataReplaceOptions = [
{
label: 'Update Missing Metadata Only (Recommended)',
value: MetadataReplaceMode.REPLACE_MISSING
value: MetadataReplaceMode.REPLACE_MISSING,
translationKey: 'settingsTasks.metadataReplace.replaceMissing',
descriptionKey: 'settingsTasks.metadataReplace.replaceMissingDesc'
},
{
label: 'Replace All Metadata (Overwrite Existing)',
value: MetadataReplaceMode.REPLACE_ALL
value: MetadataReplaceMode.REPLACE_ALL,
translationKey: 'settingsTasks.metadataReplace.replaceAll',
descriptionKey: 'settingsTasks.metadataReplace.replaceAllDesc'
}
];
selectedMetadataReplaceMode: MetadataReplaceMode = MetadataReplaceMode.REPLACE_MISSING;
@@ -110,7 +118,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
},
error: (error) => {
console.error('Error loading tasks:', error);
this.showMessage('error', 'Error', 'Failed to load tasks');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsTasks.toast.loadError'));
}
});
}
@@ -170,7 +178,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
runTask(type: string): void {
const history = this.taskHistories.get(type);
if (!this.canRunTask(history) && !this.isTaskStale(history)) {
this.showMessage('warn', 'Task Already Running', 'This task is already in progress or pending.');
this.showMessage('warn', this.t.translate('settingsTasks.toast.alreadyRunning'), this.t.translate('settingsTasks.toast.alreadyRunningDetail'));
return;
}
@@ -199,22 +207,23 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
.pipe(finalize(() => this.executingTasks.delete(type)))
.subscribe({
next: (response) => {
const name = this.getTaskDisplayName(type);
if (isAsync) {
this.showMessage('info', 'Task Queued', `${this.getTaskDisplayName(type)} has been queued and will run in the background.`);
this.showMessage('info', this.t.translate('settingsTasks.toast.taskQueued'), this.t.translate('settingsTasks.toast.taskQueuedDetail', {name}));
} else {
if (response.status === TaskStatus.COMPLETED) {
this.showMessage('success', 'Task Completed', `${this.getTaskDisplayName(type)} has been completed successfully.`);
this.showMessage('success', this.t.translate('settingsTasks.toast.taskCompleted'), this.t.translate('settingsTasks.toast.taskCompletedDetail', {name}));
} else if (response.status === TaskStatus.FAILED) {
this.showMessage('error', 'Task Failed', response.message || `${this.getTaskDisplayName(type)} failed to complete.`);
this.showMessage('error', this.t.translate('settingsTasks.toast.taskFailed'), response.message || this.t.translate('settingsTasks.toast.taskFailedDetail', {name}));
} else {
this.showMessage('success', 'Task Started', `${this.getTaskDisplayName(type)} has been started successfully.`);
this.showMessage('success', this.t.translate('settingsTasks.toast.taskStarted'), this.t.translate('settingsTasks.toast.taskStartedDetail', {name}));
}
}
this.loadTasks();
},
error: (error) => {
console.error('Error starting task:', error);
this.showMessage('error', 'Error', `Failed to start ${this.getTaskDisplayName(type)}.`);
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsTasks.toast.startError', {name: this.getTaskDisplayName(type)}));
}
});
}
@@ -222,7 +231,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
cancelTask(taskType: string): void {
const history = this.taskHistories.get(taskType);
if (!history?.id) {
this.showMessage('error', 'Error', 'Cannot cancel task without ID.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsTasks.toast.cancelNoId'));
return;
}
@@ -232,15 +241,15 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
.subscribe({
next: (response) => {
if (response.cancelled) {
this.showMessage('success', 'Task Cancelled', response.message || 'Task has been cancelled successfully.');
this.showMessage('success', this.t.translate('settingsTasks.toast.taskCancelled'), response.message || this.t.translate('settingsTasks.toast.cancelledDetail'));
this.loadTasks();
} else {
this.showMessage('error', 'Cancellation Failed', response.message || 'Failed to cancel the task.');
this.showMessage('error', this.t.translate('settingsTasks.toast.cancelFailed'), response.message || this.t.translate('settingsTasks.toast.cancelError'));
}
},
error: (error) => {
console.error('Error cancelling task:', error);
this.showMessage('error', 'Error', 'Failed to cancel the task. The task may already be completed or failed.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsTasks.toast.cancelError'));
this.loadTasks();
}
});
@@ -357,11 +366,11 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
if (taskInfoIndex !== -1) {
this.taskInfos[taskInfoIndex].cronConfig = updatedConfig;
}
this.showMessage('success', 'Cron Updated', 'Scheduled task configuration has been updated successfully.');
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsTasks.cron.updateSuccess'));
},
error: (error) => {
console.error('Error updating cron config:', error);
this.showMessage('error', 'Error', 'Failed to update scheduled task configuration.');
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsTasks.cron.updateError'));
}
});
}
@@ -380,7 +389,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
const parts = trimmed.split(/\s+/);
if (parts.length !== 6) {
this.cronValidationError = 'Cron expression must have exactly 6 fields (seconds, minutes, hours, day, month, weekday)';
this.cronValidationError = this.t.translate('settingsTasks.cron.validationPrefix');
return;
}
@@ -395,7 +404,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
for (const validation of validations) {
if (!this.isValidCronField(validation.field, validation.range[0], validation.range[1])) {
this.cronValidationError = `Invalid ${validation.name} field: ${validation.field}`;
this.cronValidationError = this.t.translate('settingsTasks.cron.invalidField', {name: validation.name, value: validation.field});
return;
}
}
@@ -507,19 +516,19 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
getTaskStatusMessage(taskType: string): string {
const history = this.taskHistories.get(taskType);
if (this.isTaskStale(history)) {
return 'Task appears to be stuck (no updates received)';
return this.t.translate('settingsTasks.progress.stuckMessage');
}
return history?.message || 'Processing...';
return history?.message || this.t.translate('settingsTasks.progress.processing');
}
getLastRunMessage(taskType: string): string {
const history = this.taskHistories.get(taskType);
if (!history?.completedAt && !history?.updatedAt) {
return 'Never run';
return this.t.translate('settingsTasks.status.neverRun');
}
const dateStr = history.completedAt || history.updatedAt;
if (!dateStr) return 'Never run';
if (!dateStr) return this.t.translate('settingsTasks.status.neverRun');
const date = new Date(dateStr);
const now = new Date();
@@ -528,7 +537,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
const diffHours = Math.floor(diffMs / 3600000);
const diffDays = Math.floor(diffMs / 86400000);
if (diffMins < 1) return 'Just now';
if (diffMins < 1) return this.t.translate('settingsTasks.status.justNow');
if (diffMins < 60) return `${diffMins}m ago`;
if (diffHours < 24) return `${diffHours}h ago`;
if (diffDays < 7) return `${diffDays}d ago`;
@@ -566,9 +575,9 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
getTaskButtonLabel(taskType: string): string {
const history = this.taskHistories.get(taskType);
if (this.isTaskStale(history)) {
return 'Re-run';
return this.t.translate('settingsTasks.buttons.rerun');
}
return 'Run';
return this.t.translate('settingsTasks.buttons.run');
}
getCancelButtonIcon(taskType: string): string {
@@ -585,9 +594,9 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
getMetadataReplaceDescription(mode: MetadataReplaceMode): string {
switch (mode) {
case MetadataReplaceMode.REPLACE_MISSING:
return 'Only update books that are missing metadata information. Existing metadata will be preserved.';
return this.t.translate('settingsTasks.metadataReplace.replaceMissingDesc');
case MetadataReplaceMode.REPLACE_ALL:
return 'Replace all metadata for all books, even if they already have metadata. Use with caution as this will overwrite existing data.';
return this.t.translate('settingsTasks.metadataReplace.replaceAllDesc');
default:
return '';
}
@@ -1,39 +1,50 @@
<ng-container *transloco="let t; prefix: 'settingsUsers.contentRestrictions'">
<div class="content-restrictions-editor">
@if (isEditing) {
<div class="add-restriction-form">
<div class="form-row">
<div class="form-field">
<label>Type</label>
<label>{{ t('type') }}</label>
<p-select
[options]="restrictionTypes"
[(ngModel)]="newRestriction.restrictionType"
optionLabel="label"
optionValue="value"
placeholder="Select type"
[placeholder]="t('selectType')"
appendTo="body">
<ng-template let-item pTemplate="item">
{{ item.translationKey | transloco }}
</ng-template>
<ng-template let-item pTemplate="selectedItem">
{{ item.translationKey | transloco }}
</ng-template>
</p-select>
</div>
<div class="form-field">
<label>Mode</label>
<label>{{ t('mode') }}</label>
<p-select
[options]="restrictionModes"
[(ngModel)]="newRestriction.mode"
optionLabel="label"
optionValue="value"
placeholder="Select mode"
[placeholder]="t('selectMode')"
appendTo="body">
<ng-template let-item pTemplate="item">
{{ item.translationKey | transloco }}
</ng-template>
<ng-template let-item pTemplate="selectedItem">
{{ item.translationKey | transloco }}
</ng-template>
</p-select>
</div>
<div class="form-field form-field-wide">
<label>Value</label>
<label>{{ t('value') }}</label>
<p-select
[options]="getValueOptions()"
[(ngModel)]="newRestriction.value"
optionLabel="label"
optionValue="value"
placeholder="Select value"
[placeholder]="t('selectValue')"
[filter]="true"
filterPlaceholder="Search..."
[filterPlaceholder]="t('searchFilter')"
appendTo="body">
</p-select>
</div>
@@ -43,7 +54,7 @@
severity="success"
[outlined]="true"
(onClick)="addRestriction()"
pTooltip="Add restriction">
[pTooltip]="t('addTooltip')">
</p-button>
</div>
</div>
@@ -53,8 +64,8 @@
@if (restrictions.length === 0) {
<div class="empty-state">
<i class="pi pi-check-circle"></i>
<p>No content restrictions configured</p>
<span class="empty-hint">This user can access all content in their assigned libraries</span>
<p>{{ t('emptyTitle') }}</p>
<span class="empty-hint">{{ t('emptyHint') }}</span>
</div>
} @else {
<div class="restrictions-list">
@@ -62,9 +73,9 @@
<div class="restrictions-group">
<h5 class="group-title">
<i class="pi pi-ban"></i>
Hidden Content (Exclude)
{{ t('excludeTitle') }}
</h5>
<p class="group-description">Books matching these criteria will be hidden from this user</p>
<p class="group-description">{{ t('excludeDesc') }}</p>
<div class="restrictions-chips">
@for (restriction of getExcludeRestrictions(); track restriction.id) {
<div class="restriction-chip mode-exclude">
@@ -85,9 +96,9 @@
<div class="restrictions-group">
<h5 class="group-title">
<i class="pi pi-check"></i>
Allowed Content Only
{{ t('allowOnlyTitle') }}
</h5>
<p class="group-description">Only books matching these criteria will be visible to this user</p>
<p class="group-description">{{ t('allowOnlyDesc') }}</p>
<div class="restrictions-chips">
@for (restriction of getAllowOnlyRestrictions(); track restriction.id) {
<div class="restriction-chip mode-allow">
@@ -108,6 +119,7 @@
<div class="restrictions-info">
<i class="pi pi-info-circle"></i>
<span>Exclude rules take priority over Allow Only rules for safety</span>
<span>{{ t('infoNote') }}</span>
</div>
</div>
</ng-container>
@@ -16,6 +16,7 @@ import {ContentRestrictionService} from '../content-restriction.service';
import {BookService} from '../../../book/service/book.service';
import {filter, take} from 'rxjs/operators';
import {Book} from '../../../book/model/book.model';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-content-restrictions-editor',
@@ -25,7 +26,9 @@ import {Book} from '../../../book/model/book.model';
FormsModule,
Button,
Select,
Tooltip
Tooltip,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './content-restrictions-editor.component.html',
styleUrls: ['./content-restrictions-editor.component.scss']
@@ -38,6 +41,7 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
private contentRestrictionService = inject(ContentRestrictionService);
private bookService = inject(BookService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
restrictions: ContentRestriction[] = [];
availableCategories: string[] = [];
@@ -51,16 +55,16 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
};
restrictionTypes = [
{label: 'Category/Genre', value: ContentRestrictionType.CATEGORY},
{label: 'Tag', value: ContentRestrictionType.TAG},
{label: 'Mood', value: ContentRestrictionType.MOOD},
{label: 'Age Rating', value: ContentRestrictionType.AGE_RATING},
{label: 'Content Rating', value: ContentRestrictionType.CONTENT_RATING}
{label: 'Category/Genre', value: ContentRestrictionType.CATEGORY, translationKey: 'settingsUsers.contentRestrictions.types.category'},
{label: 'Tag', value: ContentRestrictionType.TAG, translationKey: 'settingsUsers.contentRestrictions.types.tag'},
{label: 'Mood', value: ContentRestrictionType.MOOD, translationKey: 'settingsUsers.contentRestrictions.types.mood'},
{label: 'Age Rating', value: ContentRestrictionType.AGE_RATING, translationKey: 'settingsUsers.contentRestrictions.types.ageRating'},
{label: 'Content Rating', value: ContentRestrictionType.CONTENT_RATING, translationKey: 'settingsUsers.contentRestrictions.types.contentRating'}
];
restrictionModes = [
{label: 'Exclude (Hide matching)', value: ContentRestrictionMode.EXCLUDE},
{label: 'Allow Only (Show only matching)', value: ContentRestrictionMode.ALLOW_ONLY}
{label: 'Exclude (Hide matching)', value: ContentRestrictionMode.EXCLUDE, translationKey: 'settingsUsers.contentRestrictions.modes.exclude'},
{label: 'Allow Only (Show only matching)', value: ContentRestrictionMode.ALLOW_ONLY, translationKey: 'settingsUsers.contentRestrictions.modes.allowOnly'}
];
ageRatingOptions = AGE_RATING_OPTIONS;
@@ -88,8 +92,8 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to load content restrictions'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.contentRestrictions.loadError')
});
}
});
@@ -138,8 +142,8 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
if (!this.newRestriction.value || !this.newRestriction.restrictionType || !this.newRestriction.mode) {
this.messageService.add({
severity: 'warn',
summary: 'Warning',
detail: 'Please select all fields'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.contentRestrictions.selectAllFields')
});
return;
}
@@ -152,8 +156,8 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
if (exists) {
this.messageService.add({
severity: 'warn',
summary: 'Warning',
detail: 'This restriction already exists'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.contentRestrictions.alreadyExists')
});
return;
}
@@ -172,15 +176,15 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
this.newRestriction.value = '';
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Content restriction added'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.contentRestrictions.addSuccess')
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to add content restriction'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.contentRestrictions.addError')
});
}
});
@@ -195,15 +199,15 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
this.restrictionsChanged.emit(this.restrictions);
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Content restriction removed'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.contentRestrictions.removeSuccess')
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to remove content restriction'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.contentRestrictions.removeError')
});
}
});
@@ -211,11 +215,13 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
getRestrictionTypeLabel(type: ContentRestrictionType): string {
const found = this.restrictionTypes.find(t => t.value === type);
return found?.label || type;
return found ? this.t.translate(found.translationKey) : type;
}
getModeLabel(mode: ContentRestrictionMode): string {
return mode === ContentRestrictionMode.EXCLUDE ? 'Exclude' : 'Allow Only';
return mode === ContentRestrictionMode.EXCLUDE
? this.t.translate('settingsUsers.contentRestrictions.modes.exclude')
: this.t.translate('settingsUsers.contentRestrictions.modes.allowOnly');
}
getModeClass(mode: ContentRestrictionMode): string {
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsUsers'">
<div class="create-user-dialog">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-user-plus header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Create New User</h2>
<h2 class="panel-title">{{ t('createDialog.title') }}</h2>
<p class="panel-description">
Set up a new user account with permissions and library access
{{ t('createDialog.description') }}
</p>
</div>
<p-button
@@ -24,57 +25,57 @@
<div class="form-section basic-info-section">
<h3 class="section-title">
<i class="pi pi-id-card"></i>
Basic Information
{{ t('createDialog.basicInfo') }}
</h3>
<div class="form-fields-grid">
<div class="form-field">
<label class="field-label">Full Name</label>
<label class="field-label">{{ t('createDialog.fullName') }}</label>
<input
type="text"
pInputText
formControlName="name"
placeholder="Enter full name..."
[placeholder]="t('createDialog.enterFullName')"
class="field-input"
/>
@if (userForm.get('name')?.invalid && (userForm.get('name')?.dirty || userForm.get('name')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Name is required and must be at least 3 characters.
{{ t('createDialog.nameRequired') }}
</small>
}
</div>
<div class="form-field">
<label class="field-label">Username</label>
<label class="field-label">{{ t('createDialog.username') }}</label>
<input
type="text"
pInputText
formControlName="username"
placeholder="Enter username..."
[placeholder]="t('createDialog.enterUsername')"
class="field-input"
/>
@if (userForm.get('username')?.invalid && (userForm.get('username')?.dirty || userForm.get('username')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Username is required.
{{ t('createDialog.usernameRequired') }}
</small>
}
</div>
<div class="form-field field-full">
<label class="field-label">Email</label>
<label class="field-label">{{ t('createDialog.email') }}</label>
<input
type="email"
pInputText
formControlName="email"
placeholder="Enter email..."
[placeholder]="t('createDialog.enterEmail')"
class="field-input"
/>
@if (userForm.get('email')?.invalid && (userForm.get('email')?.dirty || userForm.get('email')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Enter a valid email address.
{{ t('createDialog.emailInvalid') }}
</small>
}
</div>
@@ -82,41 +83,41 @@
<div class="password-row field-full">
<div class="password-grid">
<div class="form-field">
<label class="field-label">Password</label>
<label class="field-label">{{ t('createDialog.password') }}</label>
<input
type="password"
pInputText
formControlName="password"
placeholder="Enter password..."
[placeholder]="t('createDialog.enterPassword')"
class="field-input"
/>
@if (userForm.get('password')?.invalid && (userForm.get('password')?.dirty || userForm.get('password')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Password must be at least 6 characters long.
{{ t('createDialog.passwordMinLength') }}
</small>
}
</div>
<div class="form-field">
<label class="field-label">Confirm Password</label>
<label class="field-label">{{ t('createDialog.confirmPassword') }}</label>
<input
type="password"
pInputText
formControlName="confirmPassword"
placeholder="Confirm password..."
[placeholder]="t('createDialog.confirmPasswordPlaceholder')"
class="field-input"
/>
@if (userForm.get('confirmPassword')?.invalid && (userForm.get('confirmPassword')?.dirty || userForm.get('confirmPassword')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Password confirmation is required
{{ t('createDialog.confirmRequired') }}
</small>
}
@if (userForm.errors?.['passwordMismatch'] && (userForm.get('confirmPassword')?.dirty || userForm.get('confirmPassword')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Passwords do not match.
{{ t('createDialog.passwordMismatch') }}
</small>
}
</div>
@@ -130,15 +131,15 @@
<div class="form-section">
<h3 class="section-title">
<i class="pi pi-book"></i>
Library Access
{{ t('createDialog.libraryAccess') }}
</h3>
<div class="form-field">
<label class="field-label">Accessible Libraries</label>
<label class="field-label">{{ t('createDialog.accessibleLibraries') }}</label>
<p-multiselect
[options]="libraries"
formControlName="selectedLibraries"
placeholder="Select Libraries"
[placeholder]="t('createDialog.selectLibraries')"
optionLabel="name"
display="chip"
class="field-input"
@@ -147,7 +148,7 @@
@if (userForm.get('selectedLibraries')?.invalid && (userForm.get('selectedLibraries')?.dirty || userForm.get('selectedLibraries')?.touched)) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
At least one library must be selected.
{{ t('createDialog.libraryRequired') }}
</small>
}
</div>
@@ -158,14 +159,14 @@
<div class="form-section">
<h3 class="section-title">
<i class="pi pi-shield"></i>
Permissions
{{ t('permissions') }}
</h3>
<div class="permissions-container">
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-book"></i>
Book Management
{{ t('permGroups.bookManagement') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -174,7 +175,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-upload permission-icon"></i>
</div>
<span class="permission-name">Upload Books</span>
<span class="permission-name">{{ t('perms.uploadBooks') }}</span>
</label>
</div>
@@ -184,7 +185,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-download permission-icon"></i>
</div>
<span class="permission-name">Download Books</span>
<span class="permission-name">{{ t('perms.downloadBooks') }}</span>
</label>
</div>
@@ -194,7 +195,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-trash permission-icon"></i>
</div>
<span class="permission-name">Delete Books</span>
<span class="permission-name">{{ t('perms.deleteBooks') }}</span>
</label>
</div>
@@ -204,7 +205,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-pencil permission-icon"></i>
</div>
<span class="permission-name">Edit Metadata</span>
<span class="permission-name">{{ t('createDialog.editMetadata') }}</span>
</label>
</div>
@@ -214,7 +215,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-folder permission-icon"></i>
</div>
<span class="permission-name">Manage Library</span>
<span class="permission-name">{{ t('perms.manageLibrary') }}</span>
</label>
</div>
@@ -224,7 +225,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-envelope permission-icon"></i>
</div>
<span class="permission-name">Email Books</span>
<span class="permission-name">{{ t('perms.emailBooks') }}</span>
</label>
</div>
</div>
@@ -233,7 +234,7 @@
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-mobile"></i>
Device Sync
{{ t('permGroups.deviceSync') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -242,7 +243,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-sync permission-icon"></i>
</div>
<span class="permission-name">KOReader Sync</span>
<span class="permission-name">{{ t('perms.koreaderSync') }}</span>
</label>
</div>
@@ -252,7 +253,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-tablet permission-icon"></i>
</div>
<span class="permission-name">Kobo Sync</span>
<span class="permission-name">{{ t('perms.koboSync') }}</span>
</label>
</div>
@@ -262,7 +263,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-globe permission-icon"></i>
</div>
<span class="permission-name">OPDS Feed Access</span>
<span class="permission-name">{{ t('perms.opdsFeedAccess') }}</span>
</label>
</div>
</div>
@@ -271,7 +272,7 @@
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-eye"></i>
System Access
{{ t('permGroups.systemAccess') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -280,7 +281,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-cloud-upload permission-icon"></i>
</div>
<span class="permission-name">Access Bookdrop</span>
<span class="permission-name">{{ t('perms.accessBookdrop') }}</span>
</label>
</div>
@@ -290,7 +291,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-chart-bar permission-icon"></i>
</div>
<span class="permission-name">View Library Statistics</span>
<span class="permission-name">{{ t('perms.viewLibraryStats') }}</span>
</label>
</div>
@@ -300,7 +301,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-chart-line permission-icon"></i>
</div>
<span class="permission-name">View User Reading Statistics</span>
<span class="permission-name">{{ t('perms.viewUserStats') }}</span>
</label>
</div>
</div>
@@ -309,7 +310,7 @@
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-cog"></i>
System Configuration
{{ t('permGroups.systemConfig') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -318,7 +319,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-cog permission-icon"></i>
</div>
<span class="permission-name">Manage Metadata Configuration</span>
<span class="permission-name">{{ t('perms.manageMetadataConfig') }}</span>
</label>
</div>
@@ -328,7 +329,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-sliders-h permission-icon"></i>
</div>
<span class="permission-name">Manage Application Preferences</span>
<span class="permission-name">{{ t('perms.manageAppPreferences') }}</span>
</label>
</div>
@@ -338,7 +339,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-list-check permission-icon"></i>
</div>
<span class="permission-name">Access Task Manager</span>
<span class="permission-name">{{ t('perms.accessTaskManager') }}</span>
</label>
</div>
@@ -348,7 +349,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-images permission-icon"></i>
</div>
<span class="permission-name">Manage Icons</span>
<span class="permission-name">{{ t('perms.manageIcons') }}</span>
</label>
</div>
<div class="permission-item">
@@ -357,7 +358,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-palette permission-icon"></i>
</div>
<span class="permission-name">Manage Fonts</span>
<span class="permission-name">{{ t('perms.manageFonts') }}</span>
</label>
</div>
</div>
@@ -366,7 +367,7 @@
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-pencil"></i>
Metadata Editing
{{ t('permGroups.metadataEditing') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -375,7 +376,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-sync permission-icon"></i>
</div>
<span class="permission-name">Bulk Auto Fetch Metadata</span>
<span class="permission-name">{{ t('perms.bulkAutoFetch') }}</span>
</label>
</div>
<div class="permission-item">
@@ -384,7 +385,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-cog permission-icon"></i>
</div>
<span class="permission-name">Bulk Custom Fetch Metadata</span>
<span class="permission-name">{{ t('perms.bulkCustomFetch') }}</span>
</label>
</div>
<div class="permission-item">
@@ -393,7 +394,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-pencil permission-icon"></i>
</div>
<span class="permission-name">Bulk Edit Metadata</span>
<span class="permission-name">{{ t('createDialog.bulkEditMetadata') }}</span>
</label>
</div>
<div class="permission-item">
@@ -402,7 +403,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-image permission-icon"></i>
</div>
<span class="permission-name">Bulk Regenerate Cover</span>
<span class="permission-name">{{ t('perms.bulkRegenerateCover') }}</span>
</label>
</div>
<div class="permission-item">
@@ -411,7 +412,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-folder-open permission-icon"></i>
</div>
<span class="permission-name">Move/Organize Files</span>
<span class="permission-name">{{ t('perms.moveOrganize') }}</span>
</label>
</div>
<div class="permission-item">
@@ -420,7 +421,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-lock-open permission-icon"></i>
</div>
<span class="permission-name">Bulk Lock/Unlock Metadata</span>
<span class="permission-name">{{ t('perms.bulkLockUnlock') }}</span>
</label>
</div>
</div>
@@ -429,7 +430,7 @@
<div class="permission-group">
<h4 class="permission-group-title">
<i class="pi pi-refresh"></i>
Bulk Reset
{{ t('permGroups.bulkReset') }}
</h4>
<div class="permission-group-items">
<div class="permission-item">
@@ -438,7 +439,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-history permission-icon"></i>
</div>
<span class="permission-name">Bulk Reset Booklore Read Progress</span>
<span class="permission-name">{{ t('perms.bulkResetBooklore') }}</span>
</label>
</div>
<div class="permission-item">
@@ -447,7 +448,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-tablet permission-icon"></i>
</div>
<span class="permission-name">Bulk Reset KoReader Read Progress</span>
<span class="permission-name">{{ t('perms.bulkResetKoreader') }}</span>
</label>
</div>
<div class="permission-item">
@@ -456,7 +457,7 @@
<div class="permission-icon-wrapper">
<i class="pi pi-check-square permission-icon"></i>
</div>
<span class="permission-name">Bulk Reset Book Read Status</span>
<span class="permission-name">{{ t('perms.bulkResetReadStatus') }}</span>
</label>
</div>
</div>
@@ -465,7 +466,7 @@
<div class="permission-group full-width">
<h4 class="permission-group-title">
<i class="pi pi-shield"></i>
Administration
{{ t('permGroups.administration') }}
</h4>
<div class="permission-group-items">
<div class="permission-item admin-permission">
@@ -474,7 +475,7 @@
<div class="permission-icon-wrapper admin-icon">
<i class="pi pi-shield permission-icon"></i>
</div>
<span class="permission-name admin-name">Full Administrator Access</span>
<span class="permission-name admin-name">{{ t('perms.fullAdmin') }}</span>
</label>
</div>
</div>
@@ -486,18 +487,18 @@
<div class="dialog-footer">
<div class="footer-info">
<i class="pi pi-info-circle"></i>
<span>All fields are required to create a user</span>
<span>{{ t('createDialog.footerInfo') }}</span>
</div>
<div class="footer-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
[outlined]="true"
type="button"
(click)="closeDialog()"
/>
<p-button
label="Create User"
[label]="t('createDialog.createUser')"
icon="pi pi-check"
severity="success"
[disabled]="userForm.invalid"
@@ -507,3 +508,4 @@
</div>
</form>
</div>
</ng-container>
@@ -10,6 +10,7 @@ import {UserService} from '../user.service';
import {MessageService} from 'primeng/api';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {passwordMatchValidator} from '../../../../shared/validators/password-match.validator';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
@@ -21,7 +22,9 @@ import {passwordMatchValidator} from '../../../../shared/validators/password-mat
FormsModule,
Checkbox,
MultiSelectModule,
Button
Button,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './create-user-dialog.component.html',
styleUrl: './create-user-dialog.component.scss'
@@ -35,6 +38,7 @@ export class CreateUserDialogComponent implements OnInit {
private userService = inject(UserService);
private messageService = inject(MessageService);
private ref = inject(DynamicDialogRef);
private t = inject(TranslocoService);
ngOnInit() {
this.libraries = this.libraryService.getLibrariesFromState();
@@ -90,8 +94,8 @@ export class CreateUserDialogComponent implements OnInit {
if (this.userForm.invalid) {
this.messageService.add({
severity: 'warn',
summary: 'Validation Error',
detail: 'Please correct errors before submitting.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.createDialog.validationError')
});
return;
}
@@ -108,18 +112,18 @@ export class CreateUserDialogComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'User Created',
detail: 'The user has been successfully created.'
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.createDialog.createSuccess')
});
this.ref.close(true);
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'User Creation Failed',
summary: this.t.translate('common.error'),
detail: err?.error?.message
? `Unable to create user: ${err.error.message}`
: 'An unexpected error occurred while creating the user. Please try again later.'
? this.t.translate('settingsUsers.createDialog.createFailed', {message: err.error.message})
: this.t.translate('settingsUsers.createDialog.createError')
});
}
});
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'settingsUsers'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-users"></i>
User Management
{{ t('title') }}
</h2>
<p class="settings-description">
Manage Booklore users, their permissions, and library access. Configure user roles and capabilities for your book collection.
{{ t('description') }}
</p>
</div>
@@ -15,15 +16,15 @@
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-user"></i>
Current Users
{{ t('currentUsers.sectionTitle') }}
</h3>
<p class="section-description">
View and manage all registered users, their permissions, and library access.
{{ t('currentUsers.sectionDesc') }}
</p>
</div>
<p-button
icon="pi pi-plus"
label="Add User"
[label]="t('currentUsers.addUser')"
severity="success"
size="small"
[outlined]="true"
@@ -36,8 +37,8 @@
@if (users.length === 0) {
<div class="empty-state">
<i class="pi pi-users"></i>
<p class="empty-title">No users found</p>
<p class="empty-subtitle">Create your first user to get started</p>
<p class="empty-title">{{ t('emptyState.title') }}</p>
<p class="empty-subtitle">{{ t('emptyState.subtitle') }}</p>
</div>
} @else {
<div class="users-list">
@@ -65,7 +66,7 @@
@if (user.permissions.admin) {
<span class="admin-badge">
<i class="pi pi-shield"></i>
Admin
{{ t('admin') }}
</span>
}
</div>
@@ -88,32 +89,32 @@
<div class="user-summary">
<div class="permission-badges">
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getBookManagementPermissionsCount(user), 5)"
pTooltip="Book Management: {{ getBookManagementPermissionsCount(user) }}/5">
[pTooltip]="t('permBadges.bookMgmt', { count: getBookManagementPermissionsCount(user) })">
<i class="pi pi-book"></i>
<span>{{ getBookManagementPermissionsCount(user) }}/5</span>
</div>
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getSystemAccessPermissionsCount(user), 3)"
pTooltip="System Access: {{ getSystemAccessPermissionsCount(user) }}/3">
[pTooltip]="t('permBadges.systemAccess', { count: getSystemAccessPermissionsCount(user) })">
<i class="pi pi-eye"></i>
<span>{{ getSystemAccessPermissionsCount(user) }}/3</span>
</div>
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getSystemConfigPermissionsCount(user), 5)"
pTooltip="System Configuration: {{ getSystemConfigPermissionsCount(user) }}/5">
[pTooltip]="t('permBadges.systemConfig', { count: getSystemConfigPermissionsCount(user) })">
<i class="pi pi-cog"></i>
<span>{{ getSystemConfigPermissionsCount(user) }}/5</span>
</div>
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getMetadataEditingPermissionsCount(user), 7)"
pTooltip="Metadata Editing: {{ getMetadataEditingPermissionsCount(user) }}/7">
[pTooltip]="t('permBadges.metadataEditing', { count: getMetadataEditingPermissionsCount(user) })">
<i class="pi pi-pencil"></i>
<span>{{ getMetadataEditingPermissionsCount(user) }}/7</span>
</div>
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getDeviceSyncPermissionsCount(user), 3)"
pTooltip="Device Sync: {{ getDeviceSyncPermissionsCount(user) }}/3">
[pTooltip]="t('permBadges.deviceSync', { count: getDeviceSyncPermissionsCount(user) })">
<i class="pi pi-mobile"></i>
<span>{{ getDeviceSyncPermissionsCount(user) }}/3</span>
</div>
<div class="permission-badge" [attr.data-level]="getPermissionLevel(getBulkResetPermissionsCount(user), 3)"
pTooltip="Bulk Reset: {{ getBulkResetPermissionsCount(user) }}/3">
[pTooltip]="t('permBadges.bulkReset', { count: getBulkResetPermissionsCount(user) })">
<i class="pi pi-refresh"></i>
<span>{{ getBulkResetPermissionsCount(user) }}/3</span>
</div>
@@ -131,7 +132,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="toggleEdit(user)"
pTooltip="Edit user">
[pTooltip]="t('actions.editUser')">
</p-button>
<p-button
icon="pi pi-key"
@@ -140,7 +141,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="openChangePasswordDialog(user)"
pTooltip="Change password">
[pTooltip]="t('actions.changePassword')">
</p-button>
<p-button
[disabled]="user.id === currentUser?.id"
@@ -150,7 +151,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="deleteUser(user)"
pTooltip="Delete user">
[pTooltip]="t('actions.deleteUser')">
</p-button>
} @else {
<p-button
@@ -160,7 +161,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="saveUser(user)"
pTooltip="Save changes">
[pTooltip]="t('actions.saveChanges')">
</p-button>
<p-button
icon="pi pi-times"
@@ -169,7 +170,7 @@
[outlined]="true"
[rounded]="true"
(onClick)="toggleEdit(user)"
pTooltip="Cancel">
[pTooltip]="'common.cancel' | transloco">
</p-button>
}
</div>
@@ -180,39 +181,39 @@
<div class="user-details-section">
<h4 class="details-title">
<i class="pi pi-id-card"></i>
User Information
{{ t('userInfo.title') }}
</h4>
<div class="details-grid">
<div class="detail-field">
<label>Full Name</label>
<label>{{ t('userInfo.fullName') }}</label>
@if (user.isEditing) {
<input type="text" pInputText [(ngModel)]="user.name" placeholder="Enter full name"/>
<input type="text" pInputText [(ngModel)]="user.name" [placeholder]="t('userInfo.enterFullName')"/>
} @else {
<span>{{ user.name || 'Not set' }}</span>
<span>{{ user.name || t('userInfo.notSet') }}</span>
}
</div>
<div class="detail-field">
<label>Email</label>
<label>{{ t('userInfo.email') }}</label>
@if (user.isEditing) {
<input type="email" pInputText [(ngModel)]="user.email" placeholder="Enter email"/>
<input type="email" pInputText [(ngModel)]="user.email" [placeholder]="t('userInfo.enterEmail')"/>
} @else {
<span>{{ user.email || 'Not set' }}</span>
<span>{{ user.email || t('userInfo.notSet') }}</span>
}
</div>
<div class="detail-field detail-field-wide">
<label>Libraries</label>
<label>{{ t('userInfo.libraries') }}</label>
@if (user.isEditing) {
<p-multiSelect
[options]="allLibraries"
optionLabel="name"
optionValue="id"
[(ngModel)]="editingLibraryIds"
placeholder="Select Libraries"
[placeholder]="t('userInfo.selectLibraries')"
appendTo="body"
[disabled]="user.permissions.admin">
</p-multiSelect>
} @else {
<span>{{ user.libraryNames || 'All libraries (Admin)' }}</span>
<span>{{ user.libraryNames || t('userInfo.allLibrariesAdmin') }}</span>
}
</div>
</div>
@@ -221,19 +222,19 @@
<div class="permissions-section">
<h4 class="details-title">
<i class="pi pi-lock"></i>
Permissions
{{ t('permissions') }}
</h4>
<div class="permissions-grid">
<div class="permission-group">
<h5>
<i class="pi pi-shield"></i>
Administration
{{ t('permGroups.administration') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.admin" (onChange)="onAdminCheckboxChange(user)" [disabled]="!user.isEditing" inputId="admin-{{user.id}}"></p-checkbox>
<label [for]="'admin-'+user.id">Full Administrator Access</label>
<label [for]="'admin-'+user.id">{{ t('perms.fullAdmin') }}</label>
</div>
</div>
</div>
@@ -241,28 +242,28 @@
<div class="permission-group">
<h5>
<i class="pi pi-book"></i>
Book Management
{{ t('permGroups.bookManagement') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canUpload" [disabled]="isPermissionDisabled(user)" inputId="upload-{{user.id}}"></p-checkbox>
<label [for]="'upload-'+user.id">Upload Books</label>
<label [for]="'upload-'+user.id">{{ t('perms.uploadBooks') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canDownload" [disabled]="isPermissionDisabled(user)" inputId="download-{{user.id}}"></p-checkbox>
<label [for]="'download-'+user.id">Download Books</label>
<label [for]="'download-'+user.id">{{ t('perms.downloadBooks') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canDeleteBook" [disabled]="isPermissionDisabled(user)" inputId="delete-{{user.id}}"></p-checkbox>
<label [for]="'delete-'+user.id">Delete Books</label>
<label [for]="'delete-'+user.id">{{ t('perms.deleteBooks') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canManageLibrary" [disabled]="isPermissionDisabled(user)" inputId="library-{{user.id}}"></p-checkbox>
<label [for]="'library-'+user.id">Manage Library</label>
<label [for]="'library-'+user.id">{{ t('perms.manageLibrary') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canEmailBook" [disabled]="isPermissionDisabled(user)" inputId="email-{{user.id}}"></p-checkbox>
<label [for]="'email-'+user.id">Email Books</label>
<label [for]="'email-'+user.id">{{ t('perms.emailBooks') }}</label>
</div>
</div>
</div>
@@ -270,20 +271,20 @@
<div class="permission-group">
<h5>
<i class="pi pi-eye"></i>
System Access
{{ t('permGroups.systemAccess') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canAccessBookdrop" [disabled]="isPermissionDisabled(user)" inputId="bookdrop-{{user.id}}"></p-checkbox>
<label [for]="'bookdrop-'+user.id">Access Bookdrop</label>
<label [for]="'bookdrop-'+user.id">{{ t('perms.accessBookdrop') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canAccessLibraryStats" [disabled]="isPermissionDisabled(user)" inputId="stats-{{user.id}}"></p-checkbox>
<label [for]="'stats-'+user.id">View Library Statistics</label>
<label [for]="'stats-'+user.id">{{ t('perms.viewLibraryStats') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canAccessUserStats" [disabled]="isPermissionDisabled(user)" inputId="userstats-{{user.id}}"></p-checkbox>
<label [for]="'userstats-'+user.id">View User Reading Statistics</label>
<label [for]="'userstats-'+user.id">{{ t('perms.viewUserStats') }}</label>
</div>
</div>
</div>
@@ -291,28 +292,28 @@
<div class="permission-group">
<h5>
<i class="pi pi-cog"></i>
System Configuration
{{ t('permGroups.systemConfig') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canManageMetadataConfig" [disabled]="isPermissionDisabled(user)" inputId="metadataconfig-{{user.id}}"></p-checkbox>
<label [for]="'metadataconfig-'+user.id">Manage Metadata Configuration</label>
<label [for]="'metadataconfig-'+user.id">{{ t('perms.manageMetadataConfig') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canManageGlobalPreferences" [disabled]="isPermissionDisabled(user)" inputId="preferences-{{user.id}}"></p-checkbox>
<label [for]="'preferences-'+user.id">Manage Application Preferences</label>
<label [for]="'preferences-'+user.id">{{ t('perms.manageAppPreferences') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canAccessTaskManager" [disabled]="isPermissionDisabled(user)" inputId="taskmanager-{{user.id}}"></p-checkbox>
<label [for]="'taskmanager-'+user.id">Access Task Manager</label>
<label [for]="'taskmanager-'+user.id">{{ t('perms.accessTaskManager') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canManageIcons" [disabled]="isPermissionDisabled(user)" inputId="icons-{{user.id}}"></p-checkbox>
<label [for]="'icons-'+user.id">Manage Icons</label>
<label [for]="'icons-'+user.id">{{ t('perms.manageIcons') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canManageFonts" [disabled]="isPermissionDisabled(user)" inputId="fonts-{{user.id}}"></p-checkbox>
<label [for]="'fonts-'+user.id">Manage Fonts</label>
<label [for]="'fonts-'+user.id">{{ t('perms.manageFonts') }}</label>
</div>
</div>
</div>
@@ -320,36 +321,36 @@
<div class="permission-group">
<h5>
<i class="pi pi-pencil"></i>
Metadata Editing
{{ t('permGroups.metadataEditing') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canEditMetadata" [disabled]="isPermissionDisabled(user)" inputId="metadata-{{user.id}}"></p-checkbox>
<label [for]="'metadata-'+user.id">Edit Single Metadata</label>
<label [for]="'metadata-'+user.id">{{ t('perms.editSingleMetadata') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkAutoFetchMetadata" [disabled]="isPermissionDisabled(user)" inputId="bulkautofetch-{{user.id}}"></p-checkbox>
<label [for]="'bulkautofetch-'+user.id">Bulk Auto Fetch Metadata</label>
<label [for]="'bulkautofetch-'+user.id">{{ t('perms.bulkAutoFetch') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkCustomFetchMetadata" [disabled]="isPermissionDisabled(user)" inputId="bulkcustomfetch-{{user.id}}"></p-checkbox>
<label [for]="'bulkcustomfetch-'+user.id">Bulk Custom Fetch Metadata</label>
<label [for]="'bulkcustomfetch-'+user.id">{{ t('perms.bulkCustomFetch') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkEditMetadata" [disabled]="isPermissionDisabled(user)" inputId="bulkmetadataeditor-{{user.id}}"></p-checkbox>
<label [for]="'bulkmetadataeditor-'+user.id">Access Bulk Metadata Editor</label>
<label [for]="'bulkmetadataeditor-'+user.id">{{ t('perms.accessBulkEditor') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkRegenerateCover" [disabled]="isPermissionDisabled(user)" inputId="bulkregeneratecover-{{user.id}}"></p-checkbox>
<label [for]="'bulkregeneratecover-'+user.id">Bulk Regenerate Cover</label>
<label [for]="'bulkregeneratecover-'+user.id">{{ t('perms.bulkRegenerateCover') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canMoveOrganizeFiles" [disabled]="isPermissionDisabled(user)" inputId="moveorganizefiles-{{user.id}}"></p-checkbox>
<label [for]="'moveorganizefiles-'+user.id">Move/Organize Files</label>
<label [for]="'moveorganizefiles-'+user.id">{{ t('perms.moveOrganize') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkLockUnlockMetadata" [disabled]="isPermissionDisabled(user)" inputId="bulklockunlock-{{user.id}}"></p-checkbox>
<label [for]="'bulklockunlock-'+user.id">Bulk Lock/Unlock Metadata</label>
<label [for]="'bulklockunlock-'+user.id">{{ t('perms.bulkLockUnlock') }}</label>
</div>
</div>
</div>
@@ -357,20 +358,20 @@
<div class="permission-group">
<h5>
<i class="pi pi-mobile"></i>
Device Sync
{{ t('permGroups.deviceSync') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canSyncKoReader" [disabled]="isPermissionDisabled(user)" inputId="koreader-{{user.id}}"></p-checkbox>
<label [for]="'koreader-'+user.id">KOReader Sync</label>
<label [for]="'koreader-'+user.id">{{ t('perms.koreaderSync') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canSyncKobo" [disabled]="isPermissionDisabled(user)" inputId="kobo-{{user.id}}"></p-checkbox>
<label [for]="'kobo-'+user.id">Kobo Sync</label>
<label [for]="'kobo-'+user.id">{{ t('perms.koboSync') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canAccessOpds" [disabled]="isPermissionDisabled(user)" inputId="opds-{{user.id}}"></p-checkbox>
<label [for]="'opds-'+user.id">OPDS Feed Access</label>
<label [for]="'opds-'+user.id">{{ t('perms.opdsFeedAccess') }}</label>
</div>
</div>
</div>
@@ -378,20 +379,20 @@
<div class="permission-group">
<h5>
<i class="pi pi-refresh"></i>
Bulk Reset
{{ t('permGroups.bulkReset') }}
</h5>
<div class="permission-items">
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkResetBookloreReadProgress" [disabled]="isPermissionDisabled(user)" inputId="bulkresetbooklore-{{user.id}}"></p-checkbox>
<label [for]="'bulkresetbooklore-'+user.id">Bulk Reset Booklore Read Progress</label>
<label [for]="'bulkresetbooklore-'+user.id">{{ t('perms.bulkResetBooklore') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkResetKoReaderReadProgress" [disabled]="isPermissionDisabled(user)" inputId="bulkresetkoreader-{{user.id}}"></p-checkbox>
<label [for]="'bulkresetkoreader-'+user.id">Bulk Reset KoReader Read Progress</label>
<label [for]="'bulkresetkoreader-'+user.id">{{ t('perms.bulkResetKoreader') }}</label>
</div>
<div class="permission-item">
<p-checkbox [binary]="true" [(ngModel)]="user.permissions.canBulkResetBookReadStatus" [disabled]="isPermissionDisabled(user)" inputId="bulkresetreadstatus-{{user.id}}"></p-checkbox>
<label [for]="'bulkresetreadstatus-'+user.id">Bulk Reset Book Read Status</label>
<label [for]="'bulkresetreadstatus-'+user.id">{{ t('perms.bulkResetReadStatus') }}</label>
</div>
</div>
</div>
@@ -401,10 +402,10 @@
<div class="content-restrictions-section">
<h4 class="details-title">
<i class="pi pi-eye-slash"></i>
Content Restrictions
{{ t('contentRestrictions.title') }}
</h4>
<p class="section-description">
Configure which content this user can see based on categories, tags, moods, or age ratings.
{{ t('contentRestrictions.description') }}
</p>
<app-content-restrictions-editor
[userId]="user.id"
@@ -421,28 +422,28 @@
</div>
<p-dialog
header="Change Password"
[header]="t('passwordDialog.title')"
[(visible)]="isPasswordDialogVisible"
[modal]="true"
class="user-dialog"
[style]="{width: '400px'}">
<div class="dialog-form">
<div class="form-field">
<label for="newPassword">New Password</label>
<label for="newPassword">{{ t('passwordDialog.newPassword') }}</label>
<p-password
id="newPassword"
[(ngModel)]="newPassword"
placeholder="Enter new password"
[placeholder]="t('passwordDialog.enterNew')"
[feedback]="false"
fluid>
</p-password>
</div>
<div class="form-field">
<label for="confirmPassword">Confirm Password</label>
<label for="confirmPassword">{{ t('passwordDialog.confirmPassword') }}</label>
<p-password
id="confirmPassword"
[(ngModel)]="confirmNewPassword"
placeholder="Confirm new password"
[placeholder]="t('passwordDialog.confirmNew')"
[feedback]="false"
fluid>
</p-password>
@@ -457,13 +458,13 @@
<ng-template pTemplate="footer">
<div class="dialog-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
outlined="true"
(onClick)="isPasswordDialogVisible = false">
</p-button>
<p-button
label="Change Password"
[label]="t('passwordDialog.changeBtn')"
severity="success"
(onClick)="submitPasswordChange()">
</p-button>
@@ -471,3 +472,4 @@
</ng-template>
</p-dialog>
</div>
</ng-container>
@@ -18,6 +18,7 @@ import {Subject} from 'rxjs';
import {Tooltip} from 'primeng/tooltip';
import {DialogLauncherService} from '../../../shared/services/dialog-launcher.service';
import {ContentRestrictionsEditorComponent} from './content-restrictions-editor/content-restrictions-editor.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface UserWithEditing extends User {
isEditing?: boolean;
@@ -39,7 +40,9 @@ interface UserWithEditing extends User {
LowerCasePipe,
TitleCasePipe,
Tooltip,
ContentRestrictionsEditorComponent
ContentRestrictionsEditorComponent,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './user-management.component.html',
styleUrls: ['./user-management.component.scss'],
@@ -50,6 +53,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
private userService = inject(UserService);
private libraryService = inject(LibraryService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
users: UserWithEditing[] = [];
@@ -108,8 +112,8 @@ export class UserManagementComponent implements OnInit, OnDestroy {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to fetch users',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.fetchError'),
});
},
});
@@ -152,38 +156,38 @@ export class UserManagementComponent implements OnInit, OnDestroy {
this.loadUsers();
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'User updated successfully',
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.updateSuccess'),
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update user',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsUsers.updateError'),
});
},
});
}
deleteUser(user: User) {
if (confirm(`Are you sure you want to delete ${user.username}?`)) {
if (confirm(this.t.translate('settingsUsers.deleteConfirm', {username: user.username}))) {
this.userService.deleteUser(user.id).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `User ${user.username} deleted successfully`,
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.deleteSuccess', {username: user.username}),
});
this.loadUsers();
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
summary: this.t.translate('common.error'),
detail:
err.error?.message ||
`Failed to delete user ${user.username}`,
this.t.translate('settingsUsers.deleteError', {username: user.username}),
});
},
});
@@ -200,12 +204,12 @@ export class UserManagementComponent implements OnInit, OnDestroy {
submitPasswordChange() {
if (!this.newPassword || !this.confirmNewPassword) {
this.passwordError = 'Both fields are required';
this.passwordError = this.t.translate('settingsUsers.passwordDialog.bothRequired');
return;
}
if (this.newPassword !== this.confirmNewPassword) {
this.passwordError = 'Passwords do not match';
this.passwordError = this.t.translate('settingsUsers.passwordDialog.mismatch');
return;
}
@@ -216,8 +220,8 @@ export class UserManagementComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Password changed successfully',
summary: this.t.translate('common.success'),
detail: this.t.translate('settingsUsers.passwordDialog.success'),
});
this.isPasswordDialogVisible = false;
},
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'settingsProfile'">
<div class="user-profile-dialog">
<div class="panel-header">
@@ -5,9 +6,9 @@
<i class="pi pi-user header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">User Profile</h2>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
Manage your account information and security settings
{{ t('description') }}
</p>
</div>
<p-button
@@ -24,11 +25,11 @@
<div class="form-section">
<h3 class="section-title">
<i class="pi pi-id-card"></i>
Basic Information
{{ t('basicInfo') }}
</h3>
<div class="form-field">
<label class="field-label">Username</label>
<label class="field-label">{{ t('username') }}</label>
<input
disabled
id="username"
@@ -36,11 +37,11 @@
pInputText
[(ngModel)]="editUserData.username"
class="field-input"
placeholder="Username..."/>
[placeholder]="t('usernamePlaceholder')"/>
</div>
<div class="form-field">
<label class="field-label">Full Name</label>
<label class="field-label">{{ t('fullName') }}</label>
<input
[disabled]="!isEditing"
id="fullname"
@@ -48,11 +49,11 @@
pInputText
[(ngModel)]="editUserData.name"
class="field-input"
placeholder="Enter full name..."/>
[placeholder]="t('fullNamePlaceholder')"/>
</div>
<div class="form-field">
<label class="field-label">Email</label>
<label class="field-label">{{ t('email') }}</label>
<input
[disabled]="!isEditing"
id="email"
@@ -60,17 +61,17 @@
pInputText
[(ngModel)]="editUserData.email"
class="field-input"
placeholder="Enter email..."/>
[placeholder]="t('emailPlaceholder')"/>
</div>
<div class="edit-actions">
@if (!isEditing) {
<p-button label="Edit Profile" severity="info" icon="pi pi-pencil" [outlined]="true" (onClick)="toggleEdit()"></p-button>
<p-button [label]="t('editProfile')" severity="info" icon="pi pi-pencil" [outlined]="true" (onClick)="toggleEdit()"></p-button>
}
@if (isEditing) {
<div class="edit-buttons">
<p-button label="Cancel" severity="secondary" [outlined]="true" icon="pi pi-times" (onClick)="toggleEdit()"></p-button>
<p-button label="Save Changes" severity="success" [outlined]="true" icon="pi pi-check" (onClick)="updateProfile()"></p-button>
<p-button [label]="'common.cancel' | transloco" severity="secondary" [outlined]="true" icon="pi pi-times" (onClick)="toggleEdit()"></p-button>
<p-button [label]="t('saveChanges')" severity="success" [outlined]="true" icon="pi pi-check" (onClick)="updateProfile()"></p-button>
</div>
}
</div>
@@ -81,12 +82,12 @@
<div class="form-section">
<h3 class="section-title">
<i class="pi pi-shield"></i>
Security Settings
{{ t('security') }}
</h3>
<form [formGroup]="changePasswordForm" (ngSubmit)="submitPasswordChange()">
<div class="form-field">
<label class="field-label" for="currentPassword">Current Password</label>
<label class="field-label" for="currentPassword">{{ t('currentPassword') }}</label>
<p-password
id="currentPassword"
formControlName="currentPassword"
@@ -99,14 +100,14 @@
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
@if (changePasswordForm.get('currentPassword')?.errors?.['required']) {
<span>Current password is required.</span>
<span>{{ t('validation.currentPasswordRequired') }}</span>
}
</small>
}
</div>
<div class="form-field">
<label class="field-label" for="newPassword">New Password</label>
<label class="field-label" for="newPassword">{{ t('newPassword') }}</label>
<p-password
id="newPassword"
formControlName="newPassword"
@@ -119,17 +120,17 @@
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
@if (changePasswordForm.get('newPassword')?.errors?.['required']) {
<span>New password is required.</span>
<span>{{ t('validation.newPasswordRequired') }}</span>
}
@if (changePasswordForm.get('newPassword')?.errors?.['minlength']) {
<span>Password must be at least 6 characters long.</span>
<span>{{ t('validation.passwordMinLength') }}</span>
}
</small>
}
</div>
<div class="form-field">
<label class="field-label" for="confirmNewPassword">Confirm New Password</label>
<label class="field-label" for="confirmNewPassword">{{ t('confirmNewPassword') }}</label>
<p-password
id="confirmNewPassword"
formControlName="confirmNewPassword"
@@ -142,7 +143,7 @@
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
@if (changePasswordForm.get('confirmNewPassword')?.errors?.['required']) {
<span>Please confirm your new password.</span>
<span>{{ t('validation.confirmPasswordRequired') }}</span>
}
</small>
}
@@ -150,13 +151,13 @@
changePasswordForm.get('confirmNewPassword')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
<span>Passwords do not match.</span>
<span>{{ t('validation.passwordMismatch') }}</span>
</small>
}
</div>
<div class="password-actions">
<p-button type="submit" severity="info" [outlined]="true" label="Change Password" icon="pi pi-key" [disabled]="changePasswordForm.invalid"></p-button>
<p-button type="submit" severity="info" [outlined]="true" [label]="t('changePassword')" icon="pi pi-key" [disabled]="changePasswordForm.invalid"></p-button>
</div>
</form>
</div>
@@ -167,6 +168,7 @@
@if (!currentUser) {
<div class="loading-state">
<i class="pi pi-spin pi-spinner loading-icon"></i>
<p>Loading user data...</p>
<p>{{ t('loading') }}</p>
</div>
}
</ng-container>
@@ -8,6 +8,7 @@ import {MessageService} from 'primeng/api';
import {Subject} from 'rxjs';
import {filter, takeUntil} from 'rxjs/operators';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
const newPassword = control.get('newPassword');
@@ -27,7 +28,9 @@ export const passwordMatchValidator: ValidatorFn = (control: AbstractControl): V
FormsModule,
ReactiveFormsModule,
InputText,
Password
Password,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './user-profile-dialog.component.html',
styleUrls: ['./user-profile-dialog.component.scss']
@@ -45,6 +48,7 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
private readonly messageService = inject(MessageService);
private readonly fb = inject(FormBuilder);
private readonly dialogRef = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
constructor() {
this.changePasswordForm = this.fb.group(
@@ -93,14 +97,14 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
if (!this.currentUser) {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'User data not available.',
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsProfile.toast.errorNoUser'),
});
return;
}
if (this.editUserData.name === this.currentUser.name && this.editUserData.email === this.currentUser.email) {
this.messageService.add({severity: 'info', summary: 'Info', detail: 'No changes detected.'});
this.messageService.add({severity: 'info', summary: 'Info', detail: this.t.translate('settingsProfile.toast.noChanges')});
this.isEditing = false;
return;
}
@@ -111,14 +115,14 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
};
this.userService.updateUser(this.currentUser.id, updateRequest).subscribe({
next: () => {
this.messageService.add({severity: 'success', summary: 'Success', detail: 'Profile updated successfully'});
this.messageService.add({severity: 'success', summary: this.t.translate('common.success'), detail: this.t.translate('settingsProfile.toast.profileUpdated')});
this.isEditing = false;
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: err.error?.message || 'Failed to update profile',
summary: this.t.translate('common.error'),
detail: err.error?.message || this.t.translate('settingsProfile.toast.profileUpdateFailed'),
});
},
});
@@ -134,14 +138,14 @@ export class UserProfileDialogComponent implements OnInit, OnDestroy {
this.userService.changePassword(currentPassword, newPassword).subscribe({
next: () => {
this.messageService.add({severity: 'success', summary: 'Success', detail: 'Password changed successfully'});
this.messageService.add({severity: 'success', summary: this.t.translate('common.success'), detail: this.t.translate('settingsProfile.toast.passwordChanged')});
this.resetPasswordForm();
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: err?.message || 'Failed to change password',
summary: this.t.translate('common.error'),
detail: err?.message || this.t.translate('settingsProfile.toast.passwordChangeFailed'),
});
}
});
@@ -1,90 +1,92 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-filter"></i>
Filter Preferences
</h3>
<p class="section-description">
Configure default options for filter controls shown in the sidebar.
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Filter Mode</label>
</div>
<p class="setting-description">Choose the default mode for combining filters selected from the right filter sidebar.</p>
<div class="setting-options">
<p-select
size="small"
[options]="filterModes"
[(ngModel)]="selectedFilterMode"
(ngModelChange)="onFilterModeChange()"
appendTo="body">
</p-select>
</div>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Visible Filters</label>
</div>
<p class="setting-description">
Choose which filters appear in the sidebar and drag to reorder. Between {{ minFilters }} and {{ maxFilters }} filters.
<span class="filter-count">({{ selectionCountText }})</span>
<ng-container *transloco="let t; prefix: 'settingsView.filter'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-filter"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
<div class="filter-order-editor">
<div
#filterList
class="filter-order-list"
cdkDropList
[cdkDropListData]="selectedVisibleFilters"
(cdkDropListDropped)="onDrop($event)">
@for (f of selectedVisibleFilters; track f; let i = $index) {
<div class="filter-order-row" cdkDrag>
<div class="filter-drag-handle" cdkDragHandle>
<i class="pi pi-bars"></i>
</div>
<span class="filter-rank">{{ i + 1 }}.</span>
<span class="filter-label">{{ getFilterLabel(f) }}</span>
<button
type="button"
class="remove-filter-btn"
(click)="removeFilter(i)"
[disabled]="selectedVisibleFilters.length <= minFilters"
pTooltip="Remove"
tooltipPosition="top">
<i class="pi pi-times"></i>
</button>
</div>
}
</div>
<div class="filter-actions-row">
@if (availableFilters.length > 0 && selectedVisibleFilters.length < maxFilters) {
<p-select
size="small"
[options]="availableFilters"
[(ngModel)]="selectedAddFilter"
optionLabel="label"
optionValue="value"
placeholder="Add filter..."
[style]="{ width: '200px' }"
appendTo="body"
(onChange)="addFilter()">
</p-select>
}
<button
type="button"
class="reset-btn"
(click)="resetToDefaults()"
pTooltip="Reset to defaults"
tooltipPosition="top">
<i class="pi pi-refresh"></i>
</button>
</div>
</div>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('filterMode') }}</label>
</div>
<p class="setting-description">{{ t('filterModeDesc') }}</p>
<div class="setting-options">
<p-select
size="small"
[options]="filterModes"
[(ngModel)]="selectedFilterMode"
(ngModelChange)="onFilterModeChange()"
appendTo="body">
</p-select>
</div>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('visibleFilters') }}</label>
</div>
<p class="setting-description">
{{ t('visibleFiltersDesc', {min: minFilters, max: maxFilters}) }}
<span class="filter-count">({{ selectionCountText }})</span>
</p>
<div class="filter-order-editor">
<div
#filterList
class="filter-order-list"
cdkDropList
[cdkDropListData]="selectedVisibleFilters"
(cdkDropListDropped)="onDrop($event)">
@for (f of selectedVisibleFilters; track f; let i = $index) {
<div class="filter-order-row" cdkDrag>
<div class="filter-drag-handle" cdkDragHandle>
<i class="pi pi-bars"></i>
</div>
<span class="filter-rank">{{ i + 1 }}.</span>
<span class="filter-label">{{ getFilterLabel(f) }}</span>
<button
type="button"
class="remove-filter-btn"
(click)="removeFilter(i)"
[disabled]="selectedVisibleFilters.length <= minFilters"
[pTooltip]="'common.remove' | transloco"
tooltipPosition="top">
<i class="pi pi-times"></i>
</button>
</div>
}
</div>
<div class="filter-actions-row">
@if (availableFilters.length > 0 && selectedVisibleFilters.length < maxFilters) {
<p-select
size="small"
[options]="availableFilters"
[(ngModel)]="selectedAddFilter"
optionLabel="label"
optionValue="value"
[placeholder]="t('addFilter')"
[style]="{ width: '200px' }"
appendTo="body"
(onChange)="addFilter()">
</p-select>
}
<button
type="button"
class="reset-btn"
(click)="resetToDefaults()"
[pTooltip]="t('resetToDefaults')"
tooltipPosition="top">
<i class="pi pi-refresh"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {FormsModule} from '@angular/forms';
import {filter, takeUntil} from 'rxjs/operators';
import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
const MIN_VISIBLE_FILTERS = 5;
const MAX_VISIBLE_FILTERS = 20;
@@ -19,7 +20,9 @@ const MAX_VISIBLE_FILTERS = 20;
CdkDropList,
CdkDrag,
CdkDragHandle,
Tooltip
Tooltip,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './filter-preferences.component.html',
styleUrl: './filter-preferences.component.scss'
@@ -43,6 +46,7 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
userData$: Observable<UserState> = this.userService.userState$;
@@ -82,8 +86,8 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
this.userService.updateUserSetting(this.currentUser.id, rootKey, updatedValue);
this.messageService.add({
severity: 'success',
summary: 'Preferences Updated',
detail: 'Your preferences have been saved successfully.',
summary: this.t.translate('settingsView.sidebarSort.prefsUpdated'),
detail: this.t.translate('settingsView.sidebarSort.prefsUpdatedDetail'),
life: 1500
});
}
@@ -133,6 +137,6 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
}
get selectionCountText(): string {
return `${this.selectedVisibleFilters.length} of ${this.allFilterOptions.length} selected`;
return this.t.translate('settingsView.filter.selectionCount', {count: this.selectedVisibleFilters.length, total: this.allFilterOptions.length});
}
}
@@ -1,67 +1,69 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
View Preferences
</h3>
<p class="section-description">
Customize how you view metadata and series information.
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Metadata Center Display Mode</label>
</div>
<p class="setting-description">Choose whether to open the Metadata Center in the current page or as a popup dialog window.</p>
<div class="setting-options">
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="viewMode === 'route'"
(click)="onViewModeChange('route')">
<i class="pi pi-window-maximize"></i>
<span class="option-text">Open in Page</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="viewMode === 'dialog'"
(click)="onViewModeChange('dialog')">
<i class="pi pi-external-link"></i>
<span class="option-text">Open in Dialog</span>
</button>
</div>
</div>
<ng-container *transloco="let t; prefix: 'settingsView.metaCenter'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-cog"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Series View Mode</label>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('displayMode') }}</label>
</div>
<p class="setting-description">{{ t('displayModeDesc') }}</p>
<div class="setting-options">
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="viewMode === 'route'"
(click)="onViewModeChange('route')">
<i class="pi pi-window-maximize"></i>
<span class="option-text">{{ t('openInPage') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="viewMode === 'dialog'"
(click)="onViewModeChange('dialog')">
<i class="pi pi-external-link"></i>
<span class="option-text">{{ t('openInDialog') }}</span>
</button>
</div>
</div>
</div>
<p class="setting-description">Enable or disable the series view mode for displaying series information.</p>
<div class="setting-options">
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="seriesViewMode === true"
(click)="onSeriesViewModeChange(true)">
<i class="pi pi-check-circle"></i>
<span class="option-text">Enabled</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="seriesViewMode === false"
(click)="onSeriesViewModeChange(false)">
<i class="pi pi-times-circle"></i>
<span class="option-text">Disabled</span>
</button>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('seriesViewMode') }}</label>
</div>
<p class="setting-description">{{ t('seriesViewModeDesc') }}</p>
<div class="setting-options">
<div class="button-group">
<button
type="button"
class="option-button"
[class.selected]="seriesViewMode === true"
(click)="onSeriesViewModeChange(true)">
<i class="pi pi-check-circle"></i>
<span class="option-text">{{ t('enabled') }}</span>
</button>
<button
type="button"
class="option-button"
[class.selected]="seriesViewMode === false"
(click)="onSeriesViewModeChange(false)">
<i class="pi pi-times-circle"></i>
<span class="option-text">{{ t('disabled') }}</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -4,11 +4,13 @@ import {UserService} from '../../user-management/user.service';
import {MessageService} from 'primeng/api';
import {filter, take, takeUntil} from 'rxjs/operators';
import {Subject} from 'rxjs';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-meta-center-view-mode-component',
imports: [
FormsModule
FormsModule,
TranslocoDirective
],
templateUrl: './meta-center-view-mode-component.html',
styleUrl: './meta-center-view-mode-component.scss'
@@ -19,6 +21,7 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
private userService = inject(UserService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
ngOnInit(): void {
@@ -62,8 +65,8 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
this.messageService.add({
severity: 'success',
summary: 'Preferences Updated',
detail: 'Your metadata center view preference has been saved.',
summary: this.t.translate('settingsView.metaCenter.prefsUpdated'),
detail: this.t.translate('settingsView.metaCenter.metaCenterSaved'),
life: 1500,
});
}
@@ -77,8 +80,8 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
this.messageService.add({
severity: 'success',
summary: 'Preferences Updated',
detail: 'Your series view mode preference has been saved.',
summary: this.t.translate('settingsView.metaCenter.prefsUpdated'),
detail: this.t.translate('settingsView.metaCenter.seriesViewSaved'),
life: 1500,
});
}
@@ -1,64 +1,72 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sort-alt"></i>
Sidebar Library and Shelf Sorting Preference
</h3>
<p class="section-description">
Configure sorting options for your library and shelves names shown in the left menu sidebar.
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Library</label>
</div>
<p class="setting-description">Choose how library names are sorted and displayed in the sidebar.</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedLibrarySorting"
(ngModelChange)="onLibrarySortingChange()"
appendTo="body"
placeholder="Select Sorting">
</p-select>
</div>
<ng-container *transloco="let t; prefix: 'settingsView.sidebarSort'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-sort-alt"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Shelf</label>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('library') }}</label>
</div>
<p class="setting-description">{{ t('libraryDesc') }}</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedLibrarySorting"
(ngModelChange)="onLibrarySortingChange()"
appendTo="body"
optionLabel="label"
optionValue="value"
[placeholder]="t('selectSorting')">
</p-select>
</div>
</div>
<p class="setting-description">Choose how shelf names are sorted and displayed in the sidebar.</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedShelfSorting"
(ngModelChange)="onShelfSortingChange()"
appendTo="body"
placeholder="Select Sorting">
</p-select>
</div>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Magic Shelf</label>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('shelf') }}</label>
</div>
<p class="setting-description">{{ t('shelfDesc') }}</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedShelfSorting"
(ngModelChange)="onShelfSortingChange()"
appendTo="body"
optionLabel="label"
optionValue="value"
[placeholder]="t('selectSorting')">
</p-select>
</div>
</div>
<p class="setting-description">Choose how magic shelf names are sorted and displayed in the sidebar.</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedMagicShelfSorting"
(ngModelChange)="onMagicShelfSortingChange()"
appendTo="body"
placeholder="Select Sorting">
</p-select>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('magicShelf') }}</label>
</div>
<p class="setting-description">{{ t('magicShelfDesc') }}</p>
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedMagicShelfSorting"
(ngModelChange)="onMagicShelfSortingChange()"
appendTo="body"
optionLabel="label"
optionValue="value"
[placeholder]="t('selectSorting')">
</p-select>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -5,12 +5,14 @@ import {MessageService} from 'primeng/api';
import {Observable, Subject} from 'rxjs';
import {FormsModule} from '@angular/forms';
import {filter, takeUntil} from 'rxjs/operators';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-sidebar-sorting-preferences',
imports: [
Select,
FormsModule
FormsModule,
TranslocoDirective
],
templateUrl: './sidebar-sorting-preferences.component.html',
styleUrl: './sidebar-sorting-preferences.component.scss'
@@ -18,10 +20,10 @@ import {filter, takeUntil} from 'rxjs/operators';
export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
readonly sortingOptions = [
{label: 'Name | Ascending', value: {field: 'name', order: 'asc'}},
{label: 'Name | Descending', value: {field: 'name', order: 'desc'}},
{label: 'Creation Date | Ascending', value: {field: 'id', order: 'asc'}},
{label: 'Creation Date | Descending', value: {field: 'id', order: 'desc'}},
{label: 'Name | Ascending', value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'},
{label: 'Name | Descending', value: {field: 'name', order: 'desc'}, translationKey: 'nameDesc'},
{label: 'Creation Date | Ascending', value: {field: 'id', order: 'asc'}, translationKey: 'creationAsc'},
{label: 'Creation Date | Descending', value: {field: 'id', order: 'desc'}, translationKey: 'creationDesc'},
];
selectedLibrarySorting: SidebarLibrarySorting = {field: 'id', order: 'asc'};
@@ -30,6 +32,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
private readonly userService = inject(UserService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
userData$: Observable<UserState> = this.userService.userState$;
@@ -69,8 +72,8 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
this.userService.updateUserSetting(this.currentUser.id, rootKey, updatedValue);
this.messageService.add({
severity: 'success',
summary: 'Preferences Updated',
detail: 'Your preferences have been saved successfully.',
summary: this.t.translate('settingsView.sidebarSort.prefsUpdated'),
detail: this.t.translate('settingsView.sidebarSort.prefsUpdatedDetail'),
life: 1500
});
}
@@ -1,19 +1,21 @@
<div class="preferences-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-eye"></i>
View Preferences
</h2>
<p class="settings-description">
Customize how books are displayed in your library, including grid layout, sorting options, and sidebar behavior.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsView'">
<div class="preferences-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-eye"></i>
{{ t('title') }}
</h2>
<p class="settings-description">
{{ t('description') }}
</p>
</div>
<app-view-preferences></app-view-preferences>
<div class="section-divider"><hr></div>
<app-filter-preferences></app-filter-preferences>
<div class="section-divider"><hr></div>
<app-sidebar-sorting-preferences></app-sidebar-sorting-preferences>
<div class="section-divider"><hr></div>
<app-meta-center-view-mode-component></app-meta-center-view-mode-component>
</div>
<app-view-preferences></app-view-preferences>
<div class="section-divider"><hr></div>
<app-filter-preferences></app-filter-preferences>
<div class="section-divider"><hr></div>
<app-sidebar-sorting-preferences></app-sidebar-sorting-preferences>
<div class="section-divider"><hr></div>
<app-meta-center-view-mode-component></app-meta-center-view-mode-component>
</div>
</ng-container>
@@ -6,6 +6,7 @@ import {ViewPreferencesComponent} from './view-preferences/view-preferences.comp
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-view-preferences-parent',
@@ -18,6 +19,7 @@ import {FilterPreferencesComponent} from './filter-preferences/filter-preference
SidebarSortingPreferencesComponent,
MetaCenterViewModeComponent,
FilterPreferencesComponent,
TranslocoDirective,
],
templateUrl: './view-preferences-parent.component.html',
styleUrl: './view-preferences-parent.component.scss'
@@ -1,149 +1,155 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-table"></i>
Library and Shelf View & Sort Preferences
</h3>
<p class="section-description">
Configure default and per-library/shelf preferences for sorting and view mode (grid or table) in the browser.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsView.librarySort'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-table"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Default Preferences</label>
</div>
<p class="setting-description">Configure the default view mode and multi-field sorting for all libraries and shelves. Drag to reorder sort priority.</p>
<div class="setting-options">
<div class="select-group">
<p-select size="small" [options]="viewModeOptions" [(ngModel)]="selectedView"
placeholder="View Mode" appendTo="body"></p-select>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('defaultPreferences') }}</label>
</div>
<p class="setting-description">{{ t('defaultPreferencesDesc') }}</p>
<div class="setting-options">
<div class="select-group">
<p-select size="small" [options]="viewModeOptions" [(ngModel)]="selectedView"
optionLabel="label" optionValue="value"
[placeholder]="t('tableViewMode')" appendTo="body"></p-select>
</div>
</div>
</div>
<div class="multi-sort-editor">
<label class="multi-sort-label">Sort Order (drag to reorder)</label>
<div
class="sort-criteria-list"
cdkDropList
[cdkDropListData]="sortCriteria"
(cdkDropListDropped)="onSortCriteriaDrop($event)">
@for (criterion of sortCriteria; track criterion.field; let i = $index) {
<div class="sort-criterion-row" cdkDrag>
<div class="criterion-drag-handle" cdkDragHandle>
<i class="pi pi-bars"></i>
<div class="multi-sort-editor">
<label class="multi-sort-label">{{ t('sortOrderLabel') }}</label>
<div
class="sort-criteria-list"
cdkDropList
[cdkDropListData]="sortCriteria"
(cdkDropListDropped)="onSortCriteriaDrop($event)">
@for (criterion of sortCriteria; track criterion.field; let i = $index) {
<div class="sort-criterion-row" cdkDrag>
<div class="criterion-drag-handle" cdkDragHandle>
<i class="pi pi-bars"></i>
</div>
<span class="criterion-rank">{{ i + 1 }}.</span>
<span class="criterion-label">{{ getSortLabel(criterion.field) }}</span>
<button
type="button"
class="direction-toggle-btn"
(click)="toggleSortDirection(i)"
[pTooltip]="criterion.direction === 'ASC' ? t('ascending') : t('descending')"
tooltipPosition="top">
<i [class]="criterion.direction === 'ASC' ? 'pi pi-arrow-up' : 'pi pi-arrow-down'"></i>
</button>
<button
type="button"
class="remove-criterion-btn"
(click)="removeSortCriterion(i)"
[disabled]="sortCriteria.length === 1"
[pTooltip]="t('remove')"
tooltipPosition="top">
<i class="pi pi-times"></i>
</button>
</div>
<span class="criterion-rank">{{ i + 1 }}.</span>
<span class="criterion-label">{{ getSortLabel(criterion.field) }}</span>
<button
type="button"
class="direction-toggle-btn"
(click)="toggleSortDirection(i)"
[pTooltip]="criterion.direction === 'ASC' ? 'Ascending' : 'Descending'"
tooltipPosition="top">
<i [class]="criterion.direction === 'ASC' ? 'pi pi-arrow-up' : 'pi pi-arrow-down'"></i>
</button>
<button
type="button"
class="remove-criterion-btn"
(click)="removeSortCriterion(i)"
[disabled]="sortCriteria.length === 1"
pTooltip="Remove"
tooltipPosition="top">
<i class="pi pi-times"></i>
</button>
}
</div>
@if (availableSortFields.length > 0) {
<div class="add-sort-row">
<p-select
size="small"
[options]="availableSortFields"
[(ngModel)]="selectedAddField"
optionLabel="label"
optionValue="field"
[placeholder]="t('addSortField')"
[style]="{ width: '200px' }"
appendTo="body"
(onChange)="addSortCriterion()">
</p-select>
</div>
}
</div>
@if (availableSortFields.length > 0) {
<div class="add-sort-row">
<p-select
size="small"
[options]="availableSortFields"
[(ngModel)]="selectedAddField"
optionLabel="label"
optionValue="field"
placeholder="Add sort field..."
[style]="{ width: '200px' }"
appendTo="body"
(onChange)="addSortCriterion()">
</p-select>
</div>
}
</div>
</div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="autoSaveMetadata"></p-toggleswitch>
<label class="setting-label">Auto-save on Navigation</label>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="autoSaveMetadata"></p-toggleswitch>
<label class="setting-label">{{ t('autoSave') }}</label>
</div>
<p class="setting-description">{{ t('autoSaveDesc') }}</p>
</div>
<p class="setting-description">Automatically save changes when navigating to the next or previous book in the metadata editor.</p>
</div>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">Override Management</label>
<div class="setting-item">
<div class="setting-header-standalone">
<label class="setting-label">{{ t('overrideManagement') }}</label>
</div>
<p class="setting-description">{{ t('overrideManagementDesc') }}</p>
<div class="setting-options">
<p-button [label]="t('addOverride')" outlined size="small" (onClick)="addOverride()" icon="pi pi-plus" [disabled]="availableLibraries.length === 0"></p-button>
</div>
</div>
<p class="setting-description">Add custom preferences for specific libraries or shelves. These will override your default settings.</p>
<div class="setting-options">
<p-button label="Add Override" outlined size="small" (onClick)="addOverride()" icon="pi pi-plus" [disabled]="availableLibraries.length === 0"></p-button>
</div>
</div>
@if (overrides.length > 0) {
<div class="overrides-table">
<p-table [value]="overrides" [tableStyle]="{'width': '100%'}">
<ng-template pTemplate="header">
<tr>
<th style="min-width: 150px; max-width: 220px;">Type</th>
<th style="min-width: 220px; max-width: 280px;">Name</th>
<th style="min-width: 190px; max-width: 250px;">Sort By</th>
<th style="min-width: 125px;">Direction</th>
<th style="min-width: 125px;">View Mode</th>
<th style="width: 75px; text-align: center;">Actions</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-override let-rowIndex="rowIndex">
<tr>
<td>
<p-select size="small" [options]="entityTypeOptions" [(ngModel)]="override.entityType"
[style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td>
@if (override.entityType) {
<p-select size="small"
[options]="getAvailableEntities(rowIndex, override.entityType)"
[(ngModel)]="override.library"
@if (overrides.length > 0) {
<div class="overrides-table">
<p-table [value]="overrides" [tableStyle]="{'width': '100%'}">
<ng-template pTemplate="header">
<tr>
<th style="min-width: 150px; max-width: 220px;">{{ t('tableType') }}</th>
<th style="min-width: 220px; max-width: 280px;">{{ t('tableName') }}</th>
<th style="min-width: 190px; max-width: 250px;">{{ t('tableSortBy') }}</th>
<th style="min-width: 125px;">{{ t('tableDirection') }}</th>
<th style="min-width: 125px;">{{ t('tableViewMode') }}</th>
<th style="width: 75px; text-align: center;">{{ t('tableActions') }}</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-override let-rowIndex="rowIndex">
<tr>
<td>
<p-select size="small" [options]="entityTypeOptions" [(ngModel)]="override.entityType"
optionLabel="label" optionValue="value"
[style]="{'width': '100%'}" appendTo="body"></p-select>
}
</td>
<td>
<p-select size="small" [options]="sortOptions" optionLabel="label" optionValue="field"
[(ngModel)]="override.sort" [style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td>
<p-select size="small" [options]="sortDirectionOptions" [(ngModel)]="override.sortDir"
[style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td>
<p-select size="small" [options]="viewModeOptions" [(ngModel)]="override.view"
[style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td style="text-align: center;">
<p-button icon="pi pi-trash" severity="danger" size="small" [outlined]="true"
(onClick)="removeOverride(rowIndex)" [pTooltip]="'Remove override'" tooltipPosition="left"></p-button>
</td>
</tr>
</ng-template>
</p-table>
</div>
}
</td>
<td>
@if (override.entityType) {
<p-select size="small"
[options]="getAvailableEntities(rowIndex, override.entityType)"
[(ngModel)]="override.library"
optionLabel="label" optionValue="value"
[style]="{'width': '100%'}" appendTo="body"></p-select>
}
</td>
<td>
<p-select size="small" [options]="sortOptions" optionLabel="label" optionValue="field"
[(ngModel)]="override.sort" [style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td>
<p-select size="small" [options]="sortDirectionOptions" [(ngModel)]="override.sortDir"
optionLabel="label" optionValue="value"
[style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td>
<p-select size="small" [options]="viewModeOptions" [(ngModel)]="override.view"
optionLabel="label" optionValue="value"
[style]="{'width': '100%'}" appendTo="body"></p-select>
</td>
<td style="text-align: center;">
<p-button icon="pi pi-trash" severity="danger" size="small" [outlined]="true"
(onClick)="removeOverride(rowIndex)" [pTooltip]="t('removeOverride')" tooltipPosition="left"></p-button>
</td>
</tr>
</ng-template>
</p-table>
</div>
}
<div class="setting-actions">
<p-button label="Save Settings" icon="pi pi-save" outlined severity="success" (onClick)="saveSettings()"></p-button>
<div class="setting-actions">
<p-button [label]="t('saveSettings')" icon="pi pi-save" outlined severity="success" (onClick)="saveSettings()"></p-button>
</div>
</div>
</div>
</div>
</ng-container>
@@ -15,6 +15,7 @@ import {Tooltip} from 'primeng/tooltip';
import {filter, take, takeUntil} from 'rxjs/operators';
import {ToggleSwitch} from 'primeng/toggleswitch';
import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-view-preferences',
@@ -29,52 +30,55 @@ import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from
ToggleSwitch,
CdkDropList,
CdkDrag,
CdkDragHandle
CdkDragHandle,
TranslocoDirective
],
templateUrl: './view-preferences.component.html',
styleUrl: './view-preferences.component.scss'
})
export class ViewPreferencesComponent implements OnInit, OnDestroy {
sortOptions = [
{label: 'Title', field: 'title'},
{label: 'Title + Series', field: 'titleSeries'},
{label: 'File Name', field: 'fileName'},
{label: 'File Path', field: 'filePath'},
{label: 'Author', field: 'author'},
{label: 'Author (Surname)', field: 'authorSurnameVorname'},
{label: 'Author + Series', field: 'authorSeries'},
{label: 'Last Read', field: 'lastReadTime'},
{label: 'Personal Rating', field: 'personalRating'},
{label: 'Added On', field: 'addedOn'},
{label: 'File Size', field: 'fileSizeKb'},
{label: 'Locked', field: 'locked'},
{label: 'Publisher', field: 'publisher'},
{label: 'Published Date', field: 'publishedDate'},
{label: 'Amazon Rating', field: 'amazonRating'},
{label: 'Amazon #', field: 'amazonReviewCount'},
{label: 'Goodreads Rating', field: 'goodreadsRating'},
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
{label: 'Hardcover Rating', field: 'hardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
{label: 'Ranobedb Rating', field: 'ranobedbRating'},
{label: 'Pages', field: 'pageCount'},
{label: 'Random', field: 'random'},
private t = inject(TranslocoService);
sortOptions: {label: string; field: string; translationKey: string}[] = [
{label: 'Title', field: 'title', translationKey: 'sortTitle'},
{label: 'Title + Series', field: 'titleSeries', translationKey: 'sortTitleSeries'},
{label: 'File Name', field: 'fileName', translationKey: 'sortFileName'},
{label: 'File Path', field: 'filePath', translationKey: 'sortFilePath'},
{label: 'Author', field: 'author', translationKey: 'sortAuthor'},
{label: 'Author (Surname)', field: 'authorSurnameVorname', translationKey: 'sortAuthorSurname'},
{label: 'Author + Series', field: 'authorSeries', translationKey: 'sortAuthorSeries'},
{label: 'Last Read', field: 'lastReadTime', translationKey: 'sortLastRead'},
{label: 'Personal Rating', field: 'personalRating', translationKey: 'sortPersonalRating'},
{label: 'Added On', field: 'addedOn', translationKey: 'sortAddedOn'},
{label: 'File Size', field: 'fileSizeKb', translationKey: 'sortFileSize'},
{label: 'Locked', field: 'locked', translationKey: 'sortLocked'},
{label: 'Publisher', field: 'publisher', translationKey: 'sortPublisher'},
{label: 'Published Date', field: 'publishedDate', translationKey: 'sortPublishedDate'},
{label: 'Amazon Rating', field: 'amazonRating', translationKey: 'sortAmazonRating'},
{label: 'Amazon #', field: 'amazonReviewCount', translationKey: 'sortAmazonCount'},
{label: 'Goodreads Rating', field: 'goodreadsRating', translationKey: 'sortGoodreadsRating'},
{label: 'Goodreads #', field: 'goodreadsReviewCount', translationKey: 'sortGoodreadsCount'},
{label: 'Hardcover Rating', field: 'hardcoverRating', translationKey: 'sortHardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount', translationKey: 'sortHardcoverCount'},
{label: 'Ranobedb Rating', field: 'ranobedbRating', translationKey: 'sortRanobedbRating'},
{label: 'Pages', field: 'pageCount', translationKey: 'sortPages'},
{label: 'Random', field: 'random', translationKey: 'sortRandom'},
];
entityTypeOptions = [
{label: 'Library', value: 'LIBRARY'},
{label: 'Shelf', value: 'SHELF'},
{label: 'Magic Shelf', value: 'MAGIC_SHELF'}
entityTypeOptions: {label: string; value: string; translationKey: string}[] = [
{label: 'Library', value: 'LIBRARY', translationKey: 'entityLibrary'},
{label: 'Shelf', value: 'SHELF', translationKey: 'entityShelf'},
{label: 'Magic Shelf', value: 'MAGIC_SHELF', translationKey: 'entityMagicShelf'}
];
sortDirectionOptions = [
{label: 'Ascending', value: 'ASC'},
{label: 'Descending', value: 'DESC'}
sortDirectionOptions: {label: string; value: string; translationKey: string}[] = [
{label: 'Ascending', value: 'ASC', translationKey: 'ascending'},
{label: 'Descending', value: 'DESC', translationKey: 'descending'}
];
viewModeOptions = [
{label: 'Grid', value: 'GRID'},
{label: 'Table', value: 'TABLE'}
viewModeOptions: {label: string; value: string; translationKey: string}[] = [
{label: 'Grid', value: 'GRID', translationKey: 'viewGrid'},
{label: 'Table', value: 'TABLE', translationKey: 'viewTable'}
];
libraryOptions: { label: string; value: number }[] = [];
@@ -209,13 +213,14 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
}
// Multi-sort criteria methods
get availableSortFields(): {label: string; field: string}[] {
get availableSortFields(): {label: string; field: string; translationKey: string}[] {
const usedFields = new Set(this.sortCriteria.map(c => c.field));
return this.sortOptions.filter(opt => !usedFields.has(opt.field));
}
getSortLabel(field: string): string {
return this.sortOptions.find(opt => opt.field === field)?.label ?? field;
const key = this.sortOptions.find(opt => opt.field === field)?.translationKey;
return key ? this.t.translate('settingsView.librarySort.' + key) : field;
}
addSortCriterion(): void {
@@ -289,8 +294,8 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
this.messageService.add({
severity: 'success',
summary: 'Preferences Saved',
detail: 'Your sorting and view preferences were saved successfully.'
summary: this.t.translate('settingsView.librarySort.saveSuccess'),
detail: this.t.translate('settingsView.librarySort.saveSuccessDetail')
});
}
}