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
+115 -21
View File
@@ -19,6 +19,7 @@
"@angular/router": "^21.1.2",
"@angular/service-worker": "^21.1.2",
"@iharbeck/ngx-virtual-scroller": "^19.0.1",
"@jsverse/transloco": "^8.2.1",
"@primeng/themes": "^21.0.3",
"@stomp/rx-stomp": "^2.3.0",
"@stomp/stompjs": "^7.2.1",
@@ -917,7 +918,6 @@
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz",
"integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/helper-validator-identifier": "^7.28.5",
@@ -1112,7 +1112,6 @@
"version": "7.28.5",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
"integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -2581,6 +2580,40 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@jsverse/transloco": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/@jsverse/transloco/-/transloco-8.2.1.tgz",
"integrity": "sha512-uuapT1vNi/P9wqklO2VY/sIj8HPVQJ1h+IJFhPbiQvk1FP/vgn2LLwGz/iIcet2bAMJVKKxO8FXytdrwRXXyvg==",
"license": "MIT",
"dependencies": {
"@jsverse/transloco-utils": "^8.2.1",
"@jsverse/utils": "1.0.0-beta.5",
"tslib": "^2.2.0"
},
"peerDependencies": {
"@angular/core": ">=16.0.0",
"rxjs": ">=6.0.0"
}
},
"node_modules/@jsverse/transloco-utils": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/@jsverse/transloco-utils/-/transloco-utils-8.2.1.tgz",
"integrity": "sha512-sAKJQuGgAYRYwndM8X1xVbwOrjENBxKxOwhXE7gFnS8fWUEwBGMswp3wbAOS5jZlLDhyaReesU16ToXLegBCjg==",
"license": "MIT",
"dependencies": {
"cosmiconfig": "^8.1.3",
"tslib": "^2.3.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@jsverse/utils": {
"version": "1.0.0-beta.5",
"resolved": "https://registry.npmjs.org/@jsverse/utils/-/utils-1.0.0-beta.5.tgz",
"integrity": "sha512-z7IdlV6BdSeF3Veii8Yyk64KuyTjNIQnFaW5PAhmDx0wN29lB2BFp8WO6+tJPLPjtlz2yKeNrjkp1XqnMPaeHA==",
"license": "MIT"
},
"node_modules/@kurkle/color": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz",
@@ -5263,7 +5296,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0"
},
"node_modules/aria-query": {
@@ -5536,7 +5568,6 @@
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -5892,6 +5923,32 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/cosmiconfig": {
"version": "8.3.6",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz",
"integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==",
"license": "MIT",
"dependencies": {
"import-fresh": "^3.3.0",
"js-yaml": "^4.1.0",
"parse-json": "^5.2.0",
"path-type": "^4.0.0"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/d-fischer"
},
"peerDependencies": {
"typescript": ">=4.9.5"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@@ -6237,6 +6294,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/error-ex": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz",
"integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==",
"license": "MIT",
"dependencies": {
"is-arrayish": "^0.2.1"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
@@ -7173,17 +7239,6 @@
"node": ">= 0.4"
}
},
"node_modules/hono": {
"version": "4.11.5",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.11.5.tgz",
"integrity": "sha512-WemPi9/WfyMwZs+ZUXdiwcCh9Y+m7L+8vki9MzDw3jJ+W9Lc+12HGsd368Qc1vZi1xwW8BWMMsnK5efYKPdt4g==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=16.9.0"
}
},
"node_modules/hosted-git-info": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.2.tgz",
@@ -7383,7 +7438,6 @@
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"parent-module": "^1.0.0",
@@ -7443,6 +7497,12 @@
"node": ">= 0.10"
}
},
"node_modules/is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
"integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==",
"license": "MIT"
},
"node_modules/is-core-module": {
"version": "2.16.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
@@ -7625,14 +7685,12 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true,
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -7795,6 +7853,12 @@
"node": ">= 0.8.0"
}
},
"node_modules/lines-and-columns": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
"license": "MIT"
},
"node_modules/listr2": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/listr2/-/listr2-9.0.5.tgz",
@@ -8995,7 +9059,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"license": "MIT",
"dependencies": {
"callsites": "^3.0.0"
@@ -9004,6 +9067,30 @@
"node": ">=6"
}
},
"node_modules/parse-json": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
"integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==",
"license": "MIT",
"dependencies": {
"@babel/code-frame": "^7.0.0",
"error-ex": "^1.3.1",
"json-parse-even-better-errors": "^2.3.0",
"lines-and-columns": "^1.1.6"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/parse-json/node_modules/json-parse-even-better-errors": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
"integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
"license": "MIT"
},
"node_modules/parse5": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz",
@@ -9151,6 +9238,15 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
@@ -9162,7 +9258,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true,
"license": "ISC"
},
"node_modules/picomatch": {
@@ -9471,7 +9566,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
+1
View File
@@ -23,6 +23,7 @@
"@angular/router": "^21.1.2",
"@angular/service-worker": "^21.1.2",
"@iharbeck/ngx-virtual-scroller": "^19.0.1",
"@jsverse/transloco": "^8.2.1",
"@primeng/themes": "^21.0.3",
"@stomp/rx-stomp": "^2.3.0",
"@stomp/stompjs": "^7.2.1",
+10 -8
View File
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'app'">
@if (loading) {
<div class="splash-screen">
<div class="splash-content">
@@ -6,12 +7,12 @@
<path d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z" fill="white"/>
</svg>
@if (offline) {
<h1>You're Offline</h1>
<p>BookLore needs a connection to the server to load.</p>
<p>Check your network and try again.</p>
<h1>{{ t('offline') }}</h1>
<p>{{ t('offlineLoadingDescription') }}</p>
<p>{{ t('offlineDescription') }}</p>
} @else {
<h1>Loading Booklore…</h1>
<p>Please wait while we get things ready.</p>
<h1>{{ t('loading') }}</h1>
<p>{{ t('loadingDescription') }}</p>
<div class="loader"></div>
}
</div>
@@ -23,9 +24,9 @@
<path d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z" fill="#818cf8"/>
<path d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z" fill="white"/>
</svg>
<h1>You're Offline</h1>
<p>Your connection was lost. Some features may not work.</p>
<button class="retry-btn" (click)="reload()">Retry</button>
<h1>{{ t('offline') }}</h1>
<p>{{ t('connectionLost') }}</p>
<button class="retry-btn" (click)="reload()">{{ 'common.retry' | transloco }}</button>
</div>
</div>
} @else {
@@ -33,3 +34,4 @@
<p-toast></p-toast>
<router-outlet></router-outlet>
}
</ng-container>
+2 -1
View File
@@ -6,6 +6,7 @@ import {parseLogNotification} from './shared/websocket/model/log-notification.mo
import {ConfirmDialog} from 'primeng/confirmdialog';
import {Toast} from 'primeng/toast';
import {RouterOutlet} from '@angular/router';
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
import {AuthInitializationService} from './core/security/auth-initialization-service';
import {AppConfigService} from './shared/service/app-config.service';
import {MetadataBatchProgressNotification} from './shared/model/metadata-batch-progress.model';
@@ -22,7 +23,7 @@ import {scan, withLatestFrom} from 'rxjs/operators';
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
standalone: true,
imports: [ConfirmDialog, Toast, RouterOutlet]
imports: [ConfirmDialog, Toast, RouterOutlet, TranslocoDirective, TranslocoPipe]
})
export class AppComponent implements OnInit, OnDestroy {
@@ -0,0 +1,34 @@
import {inject} from '@angular/core';
import {TranslocoService} from '@jsverse/transloco';
import {firstValueFrom} from 'rxjs';
import {AVAILABLE_LANGS} from './transloco-loader';
export const LANG_STORAGE_KEY = 'booklore-lang';
function detectLanguage(available: string[]): string {
const saved = localStorage.getItem(LANG_STORAGE_KEY);
if (saved && available.includes(saved)) {
return saved;
}
const browserLocale = navigator.language;
if (browserLocale && available.includes(browserLocale)) {
return browserLocale;
}
const baseLang = browserLocale?.split('-')[0];
if (baseLang && available.includes(baseLang)) {
return baseLang;
}
return 'en';
}
export function initializeLanguage() {
return () => {
const translocoService = inject(TranslocoService);
const lang = detectLanguage(AVAILABLE_LANGS);
translocoService.setActiveLang(lang);
return firstValueFrom(translocoService.load(lang));
};
}
@@ -0,0 +1,59 @@
import {Injectable} from '@angular/core';
import {Translation, TranslocoLoader} from '@jsverse/transloco';
import {from, of, Observable} from 'rxjs';
import en from '../../../i18n/en';
export const EN_TRANSLATIONS: Translation = en;
// To add a new language: create src/i18n/<lang>/ with domain JSONs + index.ts, then add an entry here.
const LAZY_LANG_LOADERS: Record<string, () => Promise<{default: Translation}>> = {
es: () => import('../../../i18n/es'),
it: () => import('../../../i18n/it'),
de: () => import('../../../i18n/de'),
fr: () => import('../../../i18n/fr'),
nl: () => import('../../../i18n/nl'),
pl: () => import('../../../i18n/pl'),
pt: () => import('../../../i18n/pt'),
ru: () => import('../../../i18n/ru'),
};
export const AVAILABLE_LANGS = ['en', ...Object.keys(LAZY_LANG_LOADERS)];
export const LANG_LABELS: Record<string, string> = {
en: 'English',
es: 'Español',
it: 'Italiano',
de: 'Deutsch',
fr: 'Français',
nl: 'Nederlands',
pl: 'Polski',
pt: 'Português',
ru: 'Русский',
};
function deepMerge(base: Record<string, any>, override: Record<string, any>): Record<string, any> {
const result = {...base};
for (const key of Object.keys(override)) {
if (override[key] && typeof override[key] === 'object' && !Array.isArray(override[key])
&& base[key] && typeof base[key] === 'object' && !Array.isArray(base[key])) {
result[key] = deepMerge(base[key], override[key]);
} else {
result[key] = override[key];
}
}
return result;
}
@Injectable({providedIn: 'root'})
export class TranslocoInlineLoader implements TranslocoLoader {
getTranslation(lang: string): Observable<Translation> {
if (lang === 'en') {
return of(EN_TRANSLATIONS);
}
const loader = LAZY_LANG_LOADERS[lang];
if (loader) {
return from(loader().then(m => deepMerge(EN_TRANSLATIONS, m.default)));
}
return of(EN_TRANSLATIONS);
}
}
@@ -1,12 +1,12 @@
<ng-container *transloco="let t; prefix: 'settingsAuth'">
<div class="main-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-lock"></i>
Authentication Settings
{{ t('title') }}
</h2>
<p class="settings-description">
Configure authentication methods for your Booklore instance. Internal authentication is always enabled,
and you can optionally enable OIDC for external authentication providers.
{{ t('description') }}
</p>
</div>
@@ -14,10 +14,10 @@
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-shield"></i>
Authentication Methods
{{ t('methods.sectionTitle') }}
</h3>
<p class="section-description">
Choose which authentication methods are available for users to sign in.
{{ t('methods.sectionDesc') }}
</p>
</div>
@@ -30,12 +30,12 @@
<i class="pi pi-user"></i>
</div>
<div class="auth-method-info">
<span class="auth-method-label">Internal Authentication</span>
<span class="auth-method-status active">Always Enabled</span>
<span class="auth-method-label">{{ t('internal.label') }}</span>
<span class="auth-method-status active">{{ t('internal.status') }}</span>
</div>
</div>
<p class="auth-method-description">
Built-in username and password authentication. This is the default method and cannot be disabled.
{{ t('internal.description') }}
</p>
</div>
<p-checkbox
@@ -53,19 +53,19 @@
</div>
<div class="auth-method-info">
<span class="auth-method-label">
OIDC Authentication
<span class="experimental-badge">Experimental</span>
{{ t('oidc.label') }}
<span class="experimental-badge">{{ t('oidc.experimental') }}</span>
</span>
<span class="auth-method-status" [class.active]="oidcEnabled">
{{ oidcEnabled ? 'Enabled' : 'Disabled' }}
{{ oidcEnabled ? t('oidc.enabled') : t('oidc.disabled') }}
</span>
</div>
</div>
<p class="auth-method-description">
OpenID Connect for single sign-on with external providers (Authentik, Keycloak, etc.).
{{ t('oidc.description') }}
<app-external-doc-link docType="authentication"></app-external-doc-link>
@if (!isOidcFormComplete() && !oidcEnabled) {
<span class="config-hint">Configure settings below to enable.</span>
<span class="config-hint">{{ t('oidc.configHint') }}</span>
}
</p>
</div>
@@ -85,15 +85,15 @@
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-cog"></i>
OIDC Provider Configuration
{{ t('providerConfig.sectionTitle') }}
</h3>
<p class="section-description">
Configure your OIDC provider settings. All fields are required to enable OIDC authentication.
{{ t('providerConfig.sectionDesc') }}
</p>
</div>
<p-button
[outlined]="true"
label="Save"
[label]="'common.save' | transloco"
icon="pi pi-save"
severity="success"
size="small"
@@ -106,73 +106,73 @@
<div class="section-body">
<div class="config-grid">
<div class="config-item">
<label for="providerName">Provider Name</label>
<label for="providerName">{{ t('providerConfig.providerName') }}</label>
<input
pInputText
id="providerName"
[(ngModel)]="oidcProvider.providerName"
placeholder="e.g. Authentik, Keycloak"/>
[placeholder]="t('providerConfig.providerPlaceholder')"/>
</div>
<div class="config-item">
<label for="clientId">Client ID</label>
<label for="clientId">{{ t('providerConfig.clientId') }}</label>
<input
pInputText
id="clientId"
[(ngModel)]="oidcProvider.clientId"
placeholder="Your OIDC client ID"/>
[placeholder]="t('providerConfig.clientIdPlaceholder')"/>
</div>
<div class="config-item full-width">
<label for="issuerUri">Issuer URI</label>
<label for="issuerUri">{{ t('providerConfig.issuerUri') }}</label>
<input
pInputText
id="issuerUri"
[(ngModel)]="oidcProvider.issuerUri"
placeholder="e.g. https://auth.example.com/realms/booklore"/>
[placeholder]="t('providerConfig.issuerPlaceholder')"/>
</div>
<div class="config-item full-width">
<label for="scope">Scope</label>
<label for="scope">{{ t('providerConfig.scope') }}</label>
<input
pInputText
id="scope"
[readonly]="true"
disabled="disabled"
value="openid profile email offline_access"/>
<span class="field-hint">Required scopes for OIDC login. Must be supported by your provider.</span>
<span class="field-hint">{{ t('providerConfig.scopeHint') }}</span>
</div>
</div>
<div class="claims-section">
<h4 class="subsection-title">Claim Mappings</h4>
<h4 class="subsection-title">{{ t('providerConfig.claimMappings') }}</h4>
<p class="subsection-description">
Map OIDC token claims to Booklore user fields. These must match your provider's token claims.
{{ t('providerConfig.claimDesc') }}
</p>
<div class="claims-grid">
<div class="config-item">
<label for="claimUsername">Username Claim</label>
<label for="claimUsername">{{ t('providerConfig.usernameClaim') }}</label>
<input
pInputText
id="claimUsername"
[(ngModel)]="oidcProvider.claimMapping.username"
placeholder="e.g. preferred_username"/>
[placeholder]="t('providerConfig.usernamePlaceholder')"/>
</div>
<div class="config-item">
<label for="claimEmail">Email Claim</label>
<label for="claimEmail">{{ t('providerConfig.emailClaim') }}</label>
<input
pInputText
id="claimEmail"
[(ngModel)]="oidcProvider.claimMapping.email"
placeholder="e.g. email"/>
[placeholder]="t('providerConfig.emailPlaceholder')"/>
</div>
<div class="config-item">
<label for="claimName">Display Name Claim</label>
<label for="claimName">{{ t('providerConfig.nameClaim') }}</label>
<input
pInputText
id="claimName"
[(ngModel)]="oidcProvider.claimMapping.name"
placeholder="e.g. name"/>
[placeholder]="t('providerConfig.namePlaceholder')"/>
</div>
</div>
</div>
@@ -186,15 +186,15 @@
<div class="section-header-text">
<h3 class="section-title">
<i class="pi pi-users"></i>
User Provisioning
{{ t('provisioning.sectionTitle') }}
</h3>
<p class="section-description">
Configure how new OIDC users are created and what permissions they receive.
{{ t('provisioning.sectionDesc') }}
</p>
</div>
<p-button
icon="pi pi-save"
label="Save"
[label]="'common.save' | transloco"
[outlined]="true"
severity="success"
size="small"
@@ -207,14 +207,13 @@
<div class="provisioning-toggle">
<div class="toggle-content">
<div class="toggle-info">
<span class="toggle-label">Automatic User Provisioning</span>
<span class="toggle-label">{{ t('provisioning.autoLabel') }}</span>
<span class="toggle-status" [class.active]="autoUserProvisioningEnabled">
{{ autoUserProvisioningEnabled ? 'Enabled' : 'Disabled' }}
{{ autoUserProvisioningEnabled ? t('provisioning.autoEnabled') : t('provisioning.autoDisabled') }}
</span>
</div>
<p class="toggle-description">
When enabled, new users are automatically created on first OIDC login with the permissions below.
When disabled, users must be manually created in Booklore before they can log in via OIDC.
{{ t('provisioning.autoDesc') }}
</p>
</div>
<p-toggleswitch
@@ -227,7 +226,7 @@
@if (autoUserProvisioningEnabled) {
<div class="default-settings">
<div class="permissions-group">
<h4 class="group-title">Default Permissions</h4>
<h4 class="group-title">{{ t('provisioning.defaultPerms') }}</h4>
<div class="permissions-grid">
<div class="permission-item">
<p-checkbox
@@ -236,7 +235,7 @@
[ngModel]="true"
inputId="permissionRead">
</p-checkbox>
<label for="permissionRead">Read Books</label>
<label for="permissionRead">{{ t('provisioning.readBooks') }}</label>
</div>
@for (perm of availablePermissions; track perm) {
<div class="permission-item">
@@ -245,20 +244,20 @@
[binary]="true"
[inputId]="perm.value">
</p-checkbox>
<label [for]="perm.value">{{ perm.label }}</label>
<label [for]="perm.value">{{ t(perm.translationKey) }}</label>
</div>
}
</div>
</div>
<div class="libraries-group">
<h4 class="group-title">Default Library Access</h4>
<h4 class="group-title">{{ t('provisioning.defaultLibraryAccess') }}</h4>
<p-multiSelect
[options]="allLibraries"
optionLabel="name"
optionValue="id"
[(ngModel)]="editingLibraryIds"
placeholder="Select libraries new users can access"
[placeholder]="t('provisioning.selectLibraries')"
appendTo="body"
class="libraries-select">
</p-multiSelect>
@@ -269,3 +268,4 @@
</div>
}
</div>
</ng-container>
@@ -14,6 +14,7 @@ import {MultiSelect} from 'primeng/multiselect';
import {Library} from '../../../features/book/model/library.model';
import {LibraryService} from '../../../features/book/service/library.service';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-authentication-settings',
@@ -27,21 +28,23 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
Button,
MultiSelect,
ReactiveFormsModule,
ExternalDocLinkComponent
ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
],
styleUrls: ['./authentication-settings.component.scss']
})
export class AuthenticationSettingsComponent implements OnInit {
availablePermissions = [
{label: 'Upload Books', value: 'permissionUpload', selected: false},
{label: 'Download Books', value: 'permissionDownload', selected: false},
{label: 'Edit Book Metadata', value: 'permissionEditMetadata', selected: false},
{label: 'Manage Library', value: 'permissionManipulateLibrary', selected: false},
{label: 'Email Book', value: 'permissionEmailBook', selected: false},
{label: 'Delete Book', value: 'permissionDeleteBook', selected: false},
{label: 'KOReader Sync', value: 'permissionSyncKoreader', selected: false},
{label: 'Kobo Sync', value: 'permissionSyncKobo', selected: false},
{label: 'Access OPDS', value: 'permissionAccessOpds', selected: false}
{label: 'Upload Books', value: 'permissionUpload', selected: false, translationKey: 'perms.uploadBooks'},
{label: 'Download Books', value: 'permissionDownload', selected: false, translationKey: 'perms.downloadBooks'},
{label: 'Edit Book Metadata', value: 'permissionEditMetadata', selected: false, translationKey: 'perms.editMetadata'},
{label: 'Manage Library', value: 'permissionManipulateLibrary', selected: false, translationKey: 'perms.manageLibrary'},
{label: 'Email Book', value: 'permissionEmailBook', selected: false, translationKey: 'perms.emailBook'},
{label: 'Delete Book', value: 'permissionDeleteBook', selected: false, translationKey: 'perms.deleteBook'},
{label: 'KOReader Sync', value: 'permissionSyncKoreader', selected: false, translationKey: 'perms.koreaderSync'},
{label: 'Kobo Sync', value: 'permissionSyncKobo', selected: false, translationKey: 'perms.koboSync'},
{label: 'Access OPDS', value: 'permissionAccessOpds', selected: false, translationKey: 'perms.accessOpds'}
];
internalAuthEnabled = true;
@@ -65,6 +68,7 @@ export class AuthenticationSettingsComponent 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$;
@@ -118,13 +122,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.toggleOidcEnabled(this.oidcEnabled).subscribe({
next: () => this.messageService.add({
severity: 'success',
summary: 'Saved',
detail: 'OIDC setting updated.'
summary: this.t.translate('settingsAuth.toast.saved'),
detail: this.t.translate('settingsAuth.toast.oidcUpdated')
}),
error: () => this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update OIDC setting.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsAuth.toast.oidcError')
})
});
}
@@ -139,13 +143,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(payload).subscribe({
next: () => this.messageService.add({
severity: 'success',
summary: 'Saved',
detail: 'OIDC provider settings saved.'
summary: this.t.translate('settingsAuth.toast.saved'),
detail: this.t.translate('settingsAuth.toast.providerSaved')
}),
error: () => this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to save OIDC provider settings.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsAuth.toast.providerError')
})
});
}
@@ -170,13 +174,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(payload).subscribe({
next: () => this.messageService.add({
severity: 'success',
summary: 'Saved',
detail: 'OIDC auto-provisioning settings saved.'
summary: this.t.translate('settingsAuth.toast.saved'),
detail: this.t.translate('settingsAuth.toast.provisionSaved')
}),
error: () => this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to save OIDC auto-provisioning settings.'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsAuth.toast.provisionError')
})
});
}
@@ -0,0 +1,14 @@
import {TranslocoTestingModule, TranslocoTestingOptions} from '@jsverse/transloco';
import {EN_TRANSLATIONS} from '../config/transloco-loader';
export function getTranslocoModule(options: TranslocoTestingOptions = {}) {
return TranslocoTestingModule.forRoot({
langs: {en: EN_TRANSLATIONS, ...options.langs},
translocoConfig: {
availableLangs: ['en'],
defaultLang: 'en',
...options.translocoConfig,
},
...options,
});
}
@@ -1,13 +1,14 @@
<ng-container *transloco="let t; prefix: 'bookdrop.bulkEdit'">
<div class="bulk-edit-container">
<div class="info-banner">
<i class="pi pi-info-circle"></i>
<span>Select which fields to apply to <strong>{{ fileCount }}</strong> selected file(s). Only checked fields will be updated.</span>
<span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></span>
</div>
<p-divider></p-divider>
<div class="fields-section">
<h4>Text Fields</h4>
<h4>{{ t('textFieldsTitle') }}</h4>
<div class="field-grid">
@for (field of textFields; track field.name) {
<div class="field-row">
@@ -15,7 +16,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input
@@ -32,7 +33,7 @@
<p-divider></p-divider>
<div class="fields-section">
<h4>Number Fields</h4>
<h4>{{ t('numberFieldsTitle') }}</h4>
<div class="field-grid">
@for (field of numberFields; track field.name) {
<div class="field-row">
@@ -40,7 +41,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input
@@ -59,9 +60,9 @@
<div class="fields-section">
<div class="section-header">
<h4>Array Fields</h4>
<h4>{{ t('arrayFieldsTitle') }}</h4>
<div class="merge-toggle">
<span class="merge-label" id="merge-mode-label">Mode:</span>
<span class="merge-label" id="merge-mode-label">{{ t('modeLabel') }}</span>
<p-selectButton
[options]="mergeOptions"
[(ngModel)]="mergeArrays"
@@ -71,7 +72,7 @@
</p-selectButton>
</div>
</div>
<p class="helper-text"><i class="pi pi-info-circle"></i> Type and press Enter to add each item.</p>
<p class="helper-text"><i class="pi pi-info-circle"></i> {{ t('helperText') }}</p>
<div class="field-grid">
@for (field of chipFields; track field.name) {
<div class="field-row">
@@ -79,7 +80,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<p-autoComplete
@@ -102,13 +103,13 @@
<div class="dialog-footer">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
(click)="cancel()">
</p-button>
<p-button
label="Apply to Selected"
[label]="t('applyToSelected')"
icon="pi pi-check"
severity="success"
[disabled]="!hasEnabledFields"
@@ -116,3 +117,4 @@
</p-button>
</div>
</div>
</ng-container>
@@ -8,6 +8,7 @@ import {AutoComplete} from 'primeng/autocomplete';
import {Divider} from 'primeng/divider';
import {SelectButton} from 'primeng/selectbutton';
import {BookMetadata} from '../../../book/model/book.model';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export interface BulkEditResult {
fields: Partial<BookMetadata>;
@@ -34,6 +35,8 @@ interface BulkEditField {
AutoComplete,
Divider,
SelectButton,
TranslocoDirective,
TranslocoPipe,
],
templateUrl: './bookdrop-bulk-edit-dialog.component.html',
styleUrl: './bookdrop-bulk-edit-dialog.component.scss'
@@ -43,6 +46,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
private readonly dialogRef = inject(DynamicDialogRef);
private readonly config = inject(DynamicDialogConfig);
private readonly cdr = inject(ChangeDetectorRef);
private readonly t = inject(TranslocoService);
fileCount: number = 0;
mergeArrays = true;
@@ -61,25 +65,25 @@ export class BookdropBulkEditDialogComponent implements OnInit {
});
textFields: BulkEditField[] = [
{name: 'seriesName', label: 'Series Name', type: 'text', controlName: 'seriesName'},
{name: 'publisher', label: 'Publisher', type: 'text', controlName: 'publisher'},
{name: 'language', label: 'Language', type: 'text', controlName: 'language'},
{name: 'seriesName', label: this.t.translate('bookdrop.bulkEdit.seriesName'), type: 'text', controlName: 'seriesName'},
{name: 'publisher', label: this.t.translate('bookdrop.bulkEdit.publisher'), type: 'text', controlName: 'publisher'},
{name: 'language', label: this.t.translate('bookdrop.bulkEdit.language'), type: 'text', controlName: 'language'},
];
numberFields: BulkEditField[] = [
{name: 'seriesTotal', label: 'Series Total', type: 'number', controlName: 'seriesTotal'},
{name: 'seriesTotal', label: this.t.translate('bookdrop.bulkEdit.seriesTotal'), type: 'number', controlName: 'seriesTotal'},
];
chipFields: BulkEditField[] = [
{name: 'authors', label: 'Authors', type: 'chips', controlName: 'authors'},
{name: 'categories', label: 'Genres', type: 'chips', controlName: 'categories'},
{name: 'moods', label: 'Moods', type: 'chips', controlName: 'moods'},
{name: 'tags', label: 'Tags', type: 'chips', controlName: 'tags'},
{name: 'authors', label: this.t.translate('bookdrop.bulkEdit.authors'), type: 'chips', controlName: 'authors'},
{name: 'categories', label: this.t.translate('bookdrop.bulkEdit.genres'), type: 'chips', controlName: 'categories'},
{name: 'moods', label: this.t.translate('bookdrop.bulkEdit.moods'), type: 'chips', controlName: 'moods'},
{name: 'tags', label: this.t.translate('bookdrop.bulkEdit.tags'), type: 'chips', controlName: 'tags'},
];
mergeOptions = [
{label: 'Merge', value: true},
{label: 'Replace', value: false},
{label: this.t.translate('bookdrop.bulkEdit.mergeOption'), value: true},
{label: this.t.translate('bookdrop.bulkEdit.replaceOption'), value: false},
];
ngOnInit(): void {
@@ -113,7 +117,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
target.value = '';
}
}
if (!this.enabledFields.has(fieldName)) {
const control = this.bulkEditForm.get(fieldName);
const value = control?.value;
@@ -1,17 +1,18 @@
<ng-container *transloco="let t; prefix: 'bookdrop.metadataPicker'">
@if (fetchedMetadata && fetchedMetadata.title) {
<form [formGroup]="metadataForm" class="metapicker">
<div class="form-scroll">
<div class="metaheader">
<label class="field-label"></label>
<div class="header-fields-row">
<p class="header-column">File Data</p>
<p class="header-column">{{ t('fileData') }}</p>
<div class="midbuttons">
<p-button
size="small"
icon="pi pi-angle-left"
class="btn-margin"
[outlined]="true"
pTooltip="Copy missing fields from fetched metadata"
[pTooltip]="t('copyMissingTooltip')"
tooltipPosition="bottom"
(onClick)="copyMissing()"
></p-button>
@@ -20,7 +21,7 @@
icon="pi pi-angle-double-left"
class="btn-margin"
[outlined]="true"
pTooltip="Overwrite all fields with fetched metadata"
[pTooltip]="t('overwriteAllTooltip')"
tooltipPosition="bottom"
(onClick)="copyAll()"
></p-button>
@@ -30,12 +31,12 @@
icon="pi pi-refresh"
class="btn-margin"
[outlined]="true"
pTooltip="Reset all fields to original values"
[pTooltip]="t('resetAllTooltip')"
tooltipPosition="bottom"
(onClick)="confirmReset()"
></p-button>
</div>
<p class="header-column">Fetched Data</p>
<p class="header-column">{{ t('fetchedData') }}</p>
</div>
</div>
<div class="metacontent">
@@ -57,7 +58,7 @@
></p-image>
}
@else {
<div class="thumbnail no-cover-text">No cover image</div>
<div class="thumbnail no-cover-text">{{ t('noCoverImage') }}</div>
}
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl"/>
</div>
@@ -82,7 +83,7 @@
></p-image>
}
@else {
<div class="thumbnail no-cover-text">Cover image not found</div>
<div class="thumbnail no-cover-text">{{ t('coverImageNotFound') }}</div>
}
<input type="hidden" [value]="fetchedMetadata.thumbnailUrl" readonly/>
</div>
@@ -317,14 +318,14 @@
<div class="form-scroll">
<div class="metaheader">
<p class="missingmd">
Unable to fetch metadata for this file
{{ t('unableToFetchMetadata') }}
</p>
<p-button
size="small"
severity="warn"
icon="pi pi-refresh"
[outlined]="true"
pTooltip="Reset all fields to original values"
[pTooltip]="t('resetAllTooltip')"
tooltipPosition="left"
(onClick)="confirmReset()"
></p-button>
@@ -490,3 +491,4 @@
</div>
</form>
}
</ng-container>
@@ -14,6 +14,7 @@ import {ConfirmationService} from 'primeng/api';
import {DatePicker} from 'primeng/datepicker';
import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields, MetadataFieldConfig} from '../../../../shared/metadata';
import {MetadataUtilsService} from '../../../../shared/metadata';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-file-metadata-picker-component',
@@ -29,6 +30,7 @@ import {MetadataUtilsService} from '../../../../shared/metadata';
Image,
LazyLoadImageModule,
DatePicker,
TranslocoDirective,
],
templateUrl: './bookdrop-file-metadata-picker.component.html',
styleUrl: './bookdrop-file-metadata-picker.component.scss'
@@ -38,6 +40,7 @@ export class BookdropFileMetadataPickerComponent {
private readonly confirmationService = inject(ConfirmationService);
private readonly metadataUtils = inject(MetadataUtilsService);
protected readonly urlHelper = inject(UrlHelperService);
private readonly t = inject(TranslocoService);
@Input() fetchedMetadata!: BookMetadata;
@Input() originalMetadata?: BookMetadata;
@@ -130,8 +133,8 @@ export class BookdropFileMetadataPickerComponent {
confirmReset(): void {
this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to this file?',
header: 'Reset Metadata Changes?',
message: this.t.translate('bookdrop.metadataPicker.confirmResetMessage'),
header: this.t.translate('bookdrop.metadataPicker.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle',
acceptButtonStyleClass: 'p-button-danger',
accept: () => this.resetAll()
@@ -1,31 +1,28 @@
<ng-container *transloco="let t; prefix: 'bookdrop.fileReview'">
<div class="main-card">
<div class="header">
<div class="header-content">
<h2>
Review Bookdrop Files
{{ t('title') }}
<a href="https://booklore.org/docs/bookdrop" target="_blank" rel="noopener noreferrer">
<i
class="pi pi-external-link external-link-icon"
pTooltip="View documentation"
[pTooltip]="t('viewDocumentationTooltip')"
tooltipPosition="top"></i>
</a>
</h2>
<p>
These files were uploaded to the
<strong>Bookdrop Folder</strong>.
Review their fetched metadata, assign a library and subpath, and finalize where they belong in your collection.
</p>
<p [innerHTML]="t('description')"></p>
</div>
<div class="header-actions">
<p-button
label="Rescan"
[label]="t('rescan')"
size="small"
icon="pi pi-refresh"
severity="primary"
outlined
(click)="rescanBookdrop()"
pTooltip="Manually trigger a rescan of the Bookdrop folder"
[pTooltip]="t('rescanTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -36,7 +33,7 @@
<div class="loading-overlay">
<div class="loading-content">
<p-progressSpinner strokeWidth="4"/>
<span>Loading Bookdrop files. Please wait...</span>
<span>{{ t('loadingMessage') }}</span>
</div>
</div>
@@ -48,7 +45,7 @@
<p-progressSpinner strokeWidth="4"/>
<div class="saving-message">
<span>
Organizing and moving files to their designated libraries. Please wait...
{{ t('savingMessage') }}
</span>
</div>
</div>
@@ -62,14 +59,14 @@
size="small"
outlined
severity="info"
label="Import&nbsp;Metadata"
[label]="t('importMetadata')"
icon="pi pi-copy"
[disabled]="!hasSelectedFiles"
(click)="copyMetadata()"
pTooltip="Import fetched metadata for selected files"
[pTooltip]="t('importMetadataTooltip')"
tooltipPosition="top">
</p-button>
<p-inputgroup-addon pTooltip="Include book covers when importing fetched metadata" tooltipPosition="top">
<p-inputgroup-addon [pTooltip]="t('includeCoversTooltip')" tooltipPosition="top">
<p-checkbox
inputId="includecovers"
[disabled]="!hasSelectedFiles"
@@ -85,11 +82,11 @@
class="bulkedit"
outlined
severity="help"
label="Bulk&nbsp;Edit"
[label]="t('bulkEdit')"
icon="pi pi-pencil"
[disabled]="!hasSelectedFiles"
(click)="openBulkEditDialog()"
pTooltip="Edit metadata fields in bulk for selected files"
[pTooltip]="t('bulkEditTooltip')"
tooltipPosition="top">
</p-button>
@@ -98,18 +95,18 @@
class="extractpattern"
outlined
severity="warn"
label="Extract&nbsp;Pattern"
[label]="t('extractPattern')"
icon="pi pi-sliders-h"
[disabled]="!hasSelectedFiles"
(click)="openPatternExtractDialog()"
pTooltip="Extract metadata from selected filenames using a pattern"
[pTooltip]="t('extractPatternTooltip')"
tooltipPosition="top">
</p-button>
</div>
<div class="default-controls">
<i class="pi pi-book"
pTooltip="Specify library and subpath for selected files"
[pTooltip]="t('specifyLibraryTooltip')"
tooltipPosition="left"></i>
<p-select
@@ -117,7 +114,7 @@
[options]="libraryOptions"
optionLabel="label"
optionValue="value"
placeholder="Library"
[placeholder]="t('libraryPlaceholder')"
appendTo="body"
[(ngModel)]="defaultLibraryId">
</p-select>
@@ -127,7 +124,7 @@
[options]="selectedLibraryPaths"
optionLabel="label"
optionValue="value"
placeholder="Subpath"
[placeholder]="t('subpathPlaceholder')"
appendTo="body"
[(ngModel)]="defaultPathId">
</p-select>
@@ -138,7 +135,7 @@
severity="info"
[disabled]="!canApplyDefaults"
(click)="applyLibraryDefaults()"
pTooltip="Apply library and subpath to selected files"
[pTooltip]="t('applyLibraryTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -149,7 +146,7 @@
<div class="content-area">
@if (bookdropFileUis.length === 0) {
<div class="empty-state">
No bookdrop files to review.
{{ t('emptyState') }}
</div>
} @else {
@for (file of bookdropFileUis; track file) {
@@ -166,22 +163,22 @@
<img
[src]="file.metadataForm.get('thumbnailUrl')?.value"
alt="Cover"
title="Original cover"
[title]="t('originalCoverTitle')"
class="cover-image"
(click)="file.showDetails = !file.showDetails"/>
} @else {
<div title="No cover found" class="cover-image cover-placeholder">?</div>
<div [title]="t('noCoverFoundTitle')" class="cover-image cover-placeholder">?</div>
}
@if (file.file.fetchedMetadata?.thumbnailUrl) {
<img
[src]="file.file.fetchedMetadata?.thumbnailUrl"
alt="Fetched Cover"
title="Fetched cover"
[title]="t('fetchedCoverTitle')"
class="cover-image"
(click)="file.showDetails = !file.showDetails"/>
} @else {
<div title="No cover fetched" class="cover-image cover-placeholder">?</div>
<div [title]="t('noCoverFetchedTitle')" class="cover-image cover-placeholder">?</div>
}
<div class="file-name" (click)="file.showDetails = !file.showDetails">
@@ -197,10 +194,10 @@
'pi-exclamation-triangle not-applied': file.file.fetchedMetadata && !copiedFlags[file.file.id]
}"
[pTooltip]="copiedFlags[file.file.id]
? 'Fetched metadata has been applied.'
? t('metadataAppliedTooltip')
: (!file.file.fetchedMetadata || !file.file.fetchedMetadata.title)
? 'No fetched metadata available. Original metadata will be used.'
: 'Fetched metadata hasn’t been applied yet. Open metadata picker to review.'"
? t('noMetadataTooltip')
: t('metadataNotAppliedTooltip')"
tooltipPosition="top">
</i>
@@ -209,7 +206,7 @@
[options]="libraryOptions"
optionLabel="label"
optionValue="value"
placeholder="Library"
[placeholder]="t('libraryPlaceholder')"
class="library-select"
appendTo="body"
[(ngModel)]="file.selectedLibraryId"
@@ -221,7 +218,7 @@
[options]="file.availablePaths"
optionLabel="name"
optionValue="id"
placeholder="Subpath"
[placeholder]="t('subpathPlaceholder')"
class="path-select"
appendTo="body"
[(ngModel)]="file.selectedPathId">
@@ -233,10 +230,10 @@
[icon]="file.showDetails ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
(click)="file.showDetails = !file.showDetails"
[pTooltip]="file.showDetails
? 'Hide metadata'
? t('hideMetadataTooltip')
: file.file.fetchedMetadata?.title
? 'Review and copy fetched metadata'
: 'Show file metadata (no fetched metadata)'"
? t('reviewMetadataTooltip')
: t('showMetadataTooltip')"
tooltipPosition="left">
</p-button>
</div>
@@ -270,27 +267,27 @@
@if (bookdropFileUis.length > 0) {
<p-inputgroup class="selectall">
<p-inputgroup-addon>
<label class="selected-count-label" pTooltip="Number of files selected" tooltipPosition="top">{{ selectedCount }}</label>
<label class="selected-count-label" [pTooltip]="t('selectedCountTooltip')" tooltipPosition="top">{{ selectedCount }}</label>
</p-inputgroup-addon>
<p-button
label="Select&nbsp;All"
[label]="t('selectAll')"
icon="pi pi-check-square"
severity="info"
(click)="selectAll(true)"
outlined
pTooltip="Select all files across all pages"
[pTooltip]="t('selectAllTooltip')"
tooltipPosition="top">
</p-button>
</p-inputgroup>
<p-button
label="Clear"
[label]="t('clear')"
icon="pi pi-times-circle"
severity="warn"
[disabled]="!hasSelectedFiles"
(click)="selectAll(false)"
outlined
pTooltip="Deselect all files across all pages"
[pTooltip]="t('clearTooltip')"
tooltipPosition="top">
</p-button>
} @else {
@@ -315,33 +312,33 @@
<div class="footer-right">
<p-button
label="Reset"
[label]="t('reset')"
icon="pi pi-refresh"
severity="warn"
[disabled]="!hasSelectedFiles"
outlined
(click)="confirmReset()"
pTooltip="Discard all changes made to metadata of selected files"
[pTooltip]="t('resetTooltip')"
tooltipPosition="top">
</p-button>
<p-button
label="Delete"
[label]="t('delete')"
icon="pi pi-times"
severity="danger"
[disabled]="!hasSelectedFiles"
outlined
(click)="confirmDelete()"
pTooltip="Permanently delete selected Bookdrop files and discard any changes"
[pTooltip]="t('deleteTooltip')"
tooltipPosition="top">
</p-button>
<p-button
label="Finalize"
[label]="t('finalize')"
[icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'"
severity="success"
outlined
[disabled]="!canFinalize || saving"
(click)="confirmFinalize()"
pTooltip="Move selected files into the chosen library and subpath"
[pTooltip]="t('finalizeTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -349,3 +346,4 @@
</div>
}
</div>
</ng-container>
@@ -29,6 +29,7 @@ import {BookdropFileMetadataPickerComponent} from '../bookdrop-file-metadata-pic
import {BookdropBulkEditDialogComponent, BulkEditResult} from '../bookdrop-bulk-edit-dialog/bookdrop-bulk-edit-dialog.component';
import {BookdropPatternExtractDialogComponent} from '../bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
export interface BookdropFileUI {
file: BookdropFile;
@@ -60,6 +61,7 @@ export interface BookdropFileUI {
Paginator,
InputGroup,
InputGroupAddonModule,
TranslocoDirective,
],
})
export class BookdropFileReviewComponent implements OnInit {
@@ -73,6 +75,7 @@ export class BookdropFileReviewComponent implements OnInit {
private readonly urlHelper = inject(UrlHelperService);
private readonly activatedRoute = inject(ActivatedRoute);
private readonly pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
@ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>;
@@ -99,7 +102,7 @@ export class BookdropFileReviewComponent implements OnInit {
excludedFiles = new Set<number>();
ngOnInit(): void {
this.pageTitle.setPageTitle('Review Bookdrop Files');
this.pageTitle.setPageTitle(this.t.translate('bookdrop.fileReview.title'));
this.activatedRoute.queryParams
.pipe(startWith({}), tap(() => {
@@ -374,18 +377,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to reset metadata.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesResetDetail'),
});
return;
}
this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to the selected files?',
header: 'Confirm Reset',
message: this.t.translate('bookdrop.fileReview.toast.confirmResetMessage'),
header: this.t.translate('bookdrop.fileReview.toast.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Reset',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmResetAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -403,18 +406,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to finalize.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesFinalizeDetail'),
});
return;
}
this.confirmationService.confirm({
message: `Are you sure you want to finalize the import of ${selectedCount} file${selectedCount !== 1 ? 's' : ''}?`,
header: 'Confirm Finalize',
message: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeMessage', {count: selectedCount}),
header: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Finalize',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -432,18 +435,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to delete.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesDeleteDetail'),
});
return;
}
this.confirmationService.confirm({
message: `Are you sure you want to delete ${selectedCount} selected Bookdrop file${selectedCount !== 1 ? 's' : ''}? This action cannot be undone.`,
header: 'Confirm Delete',
message: this.t.translate('bookdrop.fileReview.toast.confirmDeleteMessage', {count: selectedCount}),
header: this.t.translate('bookdrop.fileReview.toast.confirmDeleteHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Delete',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmDeleteAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -469,8 +472,8 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Files Deleted',
detail: 'Selected Bookdrop files were deleted successfully.',
summary: this.t.translate('bookdrop.fileReview.toast.filesDeletedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.filesDeletedDetail'),
});
this.getSelectedFiles().forEach(file => delete this.fileUiCache[file.file.id]);
@@ -483,8 +486,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error deleting files:', err);
this.messageService.add({
severity: 'error',
summary: 'Delete Failed',
detail: 'An error occurred while deleting Bookdrop files.',
summary: this.t.translate('bookdrop.fileReview.toast.deleteFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.deleteFailedDetail'),
});
},
});
@@ -549,8 +552,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Import Complete',
detail: 'Import process finished. See details below.',
summary: this.t.translate('bookdrop.fileReview.toast.importCompleteSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.importCompleteDetail'),
});
this.dialogLauncherService.openBookdropFinalizeResultDialog(result);
@@ -569,8 +572,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error finalizing import:', err);
this.messageService.add({
severity: 'error',
summary: 'Import Failed',
detail: 'Some files could not be moved. Please check the console for more details.',
summary: this.t.translate('bookdrop.fileReview.toast.importFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.importFailedDetail'),
});
this.saving = false;
}
@@ -635,15 +638,15 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Rescan Triggered',
detail: 'Bookdrop rescan has been started successfully.',
summary: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredDetail'),
});
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Rescan Failed',
detail: 'Unable to trigger bookdrop rescan. Please try again.',
summary: this.t.translate('bookdrop.fileReview.toast.rescanFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.rescanFailedDetail'),
});
console.error(err);
}
@@ -659,14 +662,14 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to bulk edit.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesBulkEditDetail'),
});
return;
}
const dialogRef = this.dialogLauncherService.openDialog(BookdropBulkEditDialogComponent, {
header: `Bulk Edit ${totalCount} Files`,
header: this.t.translate('bookdrop.fileReview.toast.bulkEditDialogHeader', {count: totalCount}),
width: '600px',
modal: true,
closable: true,
@@ -689,8 +692,8 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to extract metadata from.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesExtractDetail'),
});
return;
}
@@ -699,7 +702,7 @@ export class BookdropFileReviewComponent implements OnInit {
const selectedIds = selectedFiles.map(f => f.file.id);
const dialogRef = this.dialogLauncherService.openDialog(BookdropPatternExtractDialogComponent, {
header: 'Extract Metadata from Filenames',
header: this.t.translate('bookdrop.fileReview.toast.extractMetadataDialogHeader'),
width: '700px',
modal: true,
closable: true,
@@ -736,8 +739,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error loading pages into cache:', err);
this.messageService.add({
severity: 'error',
summary: 'Bulk Edit Failed',
detail: 'An error occurred while loading files into cache.',
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditCacheFailedDetail'),
});
return;
}
@@ -763,16 +766,16 @@ export class BookdropFileReviewComponent implements OnInit {
next: (backendResult: BackendBulkEditResult) => {
this.messageService.add({
severity: 'success',
summary: 'Bulk Edit Applied',
detail: `Updated metadata for ${backendResult.successfullyUpdated} of ${backendResult.totalFiles} file(s).`,
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedDetail', {success: backendResult.successfullyUpdated, total: backendResult.totalFiles}),
});
},
error: (err) => {
console.error('Error applying bulk edit:', err);
this.messageService.add({
severity: 'error',
summary: 'Bulk Edit Failed',
detail: 'An error occurred while applying bulk edits.',
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedDetail'),
});
},
});
@@ -814,8 +817,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error loading pages into cache:', err);
this.messageService.add({
severity: 'error',
summary: 'Pattern Extraction Failed',
detail: 'An error occurred while loading files into cache.',
summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedDetail'),
});
return;
}
@@ -849,8 +852,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Pattern Extraction Applied',
detail: `Applied extracted metadata to ${appliedCount} file(s).`,
summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionAppliedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.patternExtractionAppliedDetail', {count: appliedCount}),
});
}
}
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'bookdrop.filesWidget'">
<div class="staging-border">
<div class="widget-row">
<div class="widget-info">
<p class="widget-title">Pending Bookdrop Files</p>
<p class="widget-title">{{ t('title') }}</p>
<p class="widget-count">{{ pendingCount }}</p>
@if (lastUpdatedAt) {
<p class="widget-date">
Last updated: {{ lastUpdatedAt | date: 'short' }}
{{ t('lastUpdated') }} {{ lastUpdatedAt | date: 'short' }}
</p>
}
</div>
@@ -17,8 +18,9 @@
outlined
severity="info"
(click)="openReviewDialog()">
Review
{{ t('reviewBtn') }}
</p-button>
</div>
</div>
</div>
</ng-container>
@@ -5,6 +5,7 @@ import {BookdropFileNotification, BookdropFileService} from '../../service/bookd
import {DatePipe} from '@angular/common';
import {Router} from '@angular/router';
import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-files-widget-component',
@@ -13,7 +14,8 @@ import {Button} from 'primeng/button';
styleUrl: './bookdrop-files-widget.component.scss',
imports: [
DatePipe,
Button
Button,
TranslocoDirective
]
})
export class BookdropFilesWidgetComponent implements OnInit, OnDestroy {
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'bookdrop.finalizeResult'">
<div class="import-result-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-file-import header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Import Summary</h2>
<p class="panel-description">Results of your book import</p>
<h2 class="panel-title">{{ t('panelTitle') }}</h2>
<p class="panel-description">{{ t('panelDescription') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -21,20 +22,20 @@
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value total">{{ result.totalFiles }}</div>
<div class="stat-label">Total Files</div>
<div class="stat-label">{{ t('totalFiles') }}</div>
</div>
<div class="stat-card">
<div class="stat-value success">{{ result.successfullyImported }}</div>
<div class="stat-label">Successfully Imported</div>
<div class="stat-label">{{ t('successfullyImported') }}</div>
</div>
<div class="stat-card">
<div class="stat-value failed">{{ result.failed }}</div>
<div class="stat-label">Failed</div>
<div class="stat-label">{{ t('failed') }}</div>
</div>
</div>
<div class="processed-info">
<div class="processed-label">Processed at</div>
<div class="processed-label">{{ t('processedAt') }}</div>
<div class="processed-time">{{ result.processedAt | date:'medium' }}</div>
</div>
@@ -65,3 +66,4 @@
</div>
</div>
</div>
</ng-container>
@@ -3,13 +3,15 @@ import {DatePipe, NgClass} from '@angular/common';
import {BookdropFinalizeResult} from '../../service/bookdrop.service';
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog";
import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-finalize-result-dialog',
imports: [
NgClass,
DatePipe,
Button
Button,
TranslocoDirective
],
templateUrl: './bookdrop-finalize-result-dialog.component.html',
styleUrl: './bookdrop-finalize-result-dialog.component.scss'
@@ -1,39 +1,37 @@
<ng-container *transloco="let t; prefix: 'bookdrop.patternExtract'">
<div class="pattern-extract-container">
<div class="info-banner">
<i class="pi pi-info-circle"></i>
<span>
Enter a pattern to extract metadata from filenames of <strong>{{ fileCount }}</strong> selected file(s).
Use placeholders like <code>{{ '{' }}SeriesName{{ '}' }}</code> to capture values.
</span>
<span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></span>
</div>
<p-divider></p-divider>
<div class="pattern-section">
<h4>Pattern</h4>
<h4>{{ t('patternTitle') }}</h4>
<div class="pattern-input-row">
<input
#patternInput
pInputText
[formControl]="patternControl"
[placeholder]="patternPlaceholderText"
[placeholder]="t('patternPlaceholder')"
id="pattern-input"
aria-label="Filename pattern for metadata extraction"
[attr.aria-label]="t('patternAriaLabel')"
class="pattern-input"
(input)="previewPattern()"/>
<p-button
icon="pi pi-eye"
label="Preview"
[label]="t('preview')"
severity="secondary"
[disabled]="!hasValidPattern"
[ariaLabel]="'Preview pattern extraction on sample files'"
[ariaLabel]="t('previewAriaLabel')"
(click)="previewPattern()">
</p-button>
</div>
</div>
<div class="placeholders-section">
<h4>Available Placeholders</h4>
<h4>{{ t('availablePlaceholdersTitle') }}</h4>
<div class="placeholder-chips">
@for (placeholder of availablePlaceholders; track placeholder.name) {
<p-chip
@@ -48,11 +46,11 @@
</div>
<div class="common-patterns-section">
<h4>Common Patterns</h4>
<h4>{{ t('commonPatternsTitle') }}</h4>
<div class="common-pattern-buttons">
@for (commonPattern of commonPatterns; track commonPattern.pattern) {
<p-button
[label]="commonPattern.label"
[label]="getCommonPatternLabel(commonPattern.labelKey)"
severity="secondary"
size="small"
outlined
@@ -66,7 +64,7 @@
@if (previewResults.length > 0) {
<div class="preview-section">
<h4>Preview (Sample Files)</h4>
<h4>{{ t('previewTitle') }}</h4>
<div class="preview-list">
@for (preview of previewResults; track preview.fileName) {
<div class="preview-item" [ngClass]="getPreviewClass(preview)">
@@ -102,18 +100,18 @@
@if (isExtracting) {
<div class="extracting-indicator">
<p-progressSpinner strokeWidth="4" [style]="spinnerStyle"></p-progressSpinner>
<span>Extracting metadata...</span>
<span>{{ t('extractingMessage') }}</span>
</div>
}
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
[disabled]="isExtracting"
(click)="cancel()">
</p-button>
<p-button
label="Extract and Apply"
[label]="t('extractAndApply')"
icon="pi pi-check"
severity="success"
[disabled]="!hasValidPattern || isExtracting"
@@ -121,3 +119,4 @@
</p-button>
</div>
</div>
</ng-container>
@@ -10,11 +10,12 @@ import {BookdropService, PatternExtractResult} from '../../service/bookdrop.serv
import {MessageService} from 'primeng/api';
import {NgClass} from '@angular/common';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface PatternPlaceholder {
name: string;
description: string;
example: string;
descriptionKey: string;
exampleKey: string;
}
interface PreviewResult {
@@ -24,6 +25,22 @@ interface PreviewResult {
errorMessage?: string;
}
const PLACEHOLDER_KEY_MAP: Record<string, string> = {
'*': 'wildcard',
'SeriesName': 'seriesName',
'Title': 'title',
'Subtitle': 'subtitle',
'Authors': 'authors',
'SeriesNumber': 'seriesNumber',
'Published': 'published',
'Publisher': 'publisher',
'Language': 'language',
'SeriesTotal': 'seriesTotal',
'ISBN10': 'isbn10',
'ISBN13': 'isbn13',
'ASIN': 'asin',
};
@Component({
selector: 'app-bookdrop-pattern-extract-dialog',
standalone: true,
@@ -36,6 +53,8 @@ interface PreviewResult {
ProgressSpinner,
NgClass,
Tooltip,
TranslocoDirective,
TranslocoPipe,
],
templateUrl: './bookdrop-pattern-extract-dialog.component.html',
styleUrl: './bookdrop-pattern-extract-dialog.component.scss'
@@ -46,6 +65,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private readonly config = inject(DynamicDialogConfig);
private readonly bookdropService = inject(BookdropService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
@ViewChild('patternInput', {static: false}) patternInput?: ElementRef<HTMLInputElement>;
@@ -57,7 +77,6 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
isExtracting = false;
previewResults: PreviewResult[] = [];
patternPlaceholderText = 'e.g., {SeriesName} - Ch {SeriesNumber}';
spinnerStyle = {width: '24px', height: '24px'};
patternForm = new FormGroup({
@@ -65,32 +84,32 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
});
availablePlaceholders: PatternPlaceholder[] = [
{name: '*', description: 'Wildcard - skips any text (not a metadata field)', example: 'anything'},
{name: 'SeriesName', description: 'Series or comic name', example: 'Chronicles of Earth'},
{name: 'Title', description: 'Book title', example: 'The Lost City'},
{name: 'Subtitle', description: 'Book subtitle', example: 'A Tale of Adventure'},
{name: 'Authors', description: 'Author name(s)', example: 'John Smith'},
{name: 'SeriesNumber', description: 'Book number in series', example: '25'},
{name: 'Published', description: 'Full date with format', example: '{Published:yyyy-MM-dd}'},
{name: 'Publisher', description: 'Publisher name', example: 'Epic Press'},
{name: 'Language', description: 'Language code', example: 'en'},
{name: 'SeriesTotal', description: 'Total books in series', example: '50'},
{name: 'ISBN10', description: 'ISBN-10 identifier', example: '1234567890'},
{name: 'ISBN13', description: 'ISBN-13 identifier', example: '1234567890123'},
{name: 'ASIN', description: 'Amazon ASIN', example: 'B012345678'},
{name: '*', descriptionKey: 'placeholders.wildcard', exampleKey: 'placeholderExamples.wildcard'},
{name: 'SeriesName', descriptionKey: 'placeholders.seriesName', exampleKey: 'placeholderExamples.seriesName'},
{name: 'Title', descriptionKey: 'placeholders.title', exampleKey: 'placeholderExamples.title'},
{name: 'Subtitle', descriptionKey: 'placeholders.subtitle', exampleKey: 'placeholderExamples.subtitle'},
{name: 'Authors', descriptionKey: 'placeholders.authors', exampleKey: 'placeholderExamples.authors'},
{name: 'SeriesNumber', descriptionKey: 'placeholders.seriesNumber', exampleKey: 'placeholderExamples.seriesNumber'},
{name: 'Published', descriptionKey: 'placeholders.published', exampleKey: 'placeholderExamples.published'},
{name: 'Publisher', descriptionKey: 'placeholders.publisher', exampleKey: 'placeholderExamples.publisher'},
{name: 'Language', descriptionKey: 'placeholders.language', exampleKey: 'placeholderExamples.language'},
{name: 'SeriesTotal', descriptionKey: 'placeholders.seriesTotal', exampleKey: 'placeholderExamples.seriesTotal'},
{name: 'ISBN10', descriptionKey: 'placeholders.isbn10', exampleKey: 'placeholderExamples.isbn10'},
{name: 'ISBN13', descriptionKey: 'placeholders.isbn13', exampleKey: 'placeholderExamples.isbn13'},
{name: 'ASIN', descriptionKey: 'placeholders.asin', exampleKey: 'placeholderExamples.asin'},
];
commonPatterns = [
{label: 'Author - Title', pattern: '{Authors} - {Title}'},
{label: 'Title - Author', pattern: '{Title} - {Authors}'},
{label: 'Title (Year)', pattern: '{Title} ({Published:yyyy})'},
{label: 'Author - Title (Year)', pattern: '{Authors} - {Title} ({Published:yyyy})'},
{label: 'Series #Number', pattern: '{SeriesName} #{SeriesNumber}'},
{label: 'Series - Chapter Number', pattern: '{SeriesName} - Chapter {SeriesNumber}'},
{label: 'Series - Vol Number', pattern: '{SeriesName} - Vol {SeriesNumber}'},
{label: '[Tag] Series - Chapter Number', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'},
{label: 'Title by Author', pattern: '{Title} by {Authors}'},
{label: 'Series vX (of Total)', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'},
{labelKey: 'commonPatternLabels.authorTitle', pattern: '{Authors} - {Title}'},
{labelKey: 'commonPatternLabels.titleAuthor', pattern: '{Title} - {Authors}'},
{labelKey: 'commonPatternLabels.titleYear', pattern: '{Title} ({Published:yyyy})'},
{labelKey: 'commonPatternLabels.authorTitleYear', pattern: '{Authors} - {Title} ({Published:yyyy})'},
{labelKey: 'commonPatternLabels.seriesNumber', pattern: '{SeriesName} #{SeriesNumber}'},
{labelKey: 'commonPatternLabels.seriesChapter', pattern: '{SeriesName} - Chapter {SeriesNumber}'},
{labelKey: 'commonPatternLabels.seriesVol', pattern: '{SeriesName} - Vol {SeriesNumber}'},
{labelKey: 'commonPatternLabels.tagSeriesChapter', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'},
{labelKey: 'commonPatternLabels.titleByAuthor', pattern: '{Title} by {Authors}'},
{labelKey: 'commonPatternLabels.seriesVTotal', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'},
];
ngOnInit(): void {
@@ -104,23 +123,23 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
const patternControl = this.patternForm.get('pattern');
const currentPattern = patternControl?.value ?? '';
const inputElement = this.patternInput?.nativeElement;
const textToInsert = placeholderName === '*' ? '*' : `{${placeholderName}}`;
const patternToModify = placeholderName === '*'
? currentPattern
const patternToModify = placeholderName === '*'
? currentPattern
: this.removeExistingPlaceholder(currentPattern, placeholderName);
if (inputElement) {
const cursorPosition = this.calculateCursorPosition(inputElement, currentPattern, patternToModify);
const newPattern = this.insertTextAtCursor(patternToModify, textToInsert, cursorPosition);
patternControl?.setValue(newPattern);
this.focusInputAfterInsertion(inputElement, cursorPosition, textToInsert.length);
} else {
patternControl?.setValue(patternToModify + textToInsert);
}
this.previewPattern();
}
@@ -131,7 +150,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private calculateCursorPosition(inputElement: HTMLInputElement, originalPattern: string, modifiedPattern: string): number {
let cursorPosition = inputElement.selectionStart ?? modifiedPattern.length;
if (originalPattern !== modifiedPattern) {
const existingPlaceholderRegex = new RegExp(`\\{\\w+(?::[^}]*)?\\}`, 'g');
const matchBefore = originalPattern.substring(0, cursorPosition).match(existingPlaceholderRegex);
@@ -140,7 +159,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
cursorPosition = Math.max(0, cursorPosition);
}
return cursorPosition;
}
@@ -218,8 +237,11 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
this.isExtracting = false;
this.messageService.add({
severity: 'success',
summary: 'Extraction Complete',
detail: `Successfully extracted metadata from ${result.successfullyExtracted} of ${result.totalFiles} files.`,
summary: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteSummary'),
detail: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteDetail', {
success: result.successfullyExtracted,
total: result.totalFiles
}),
});
this.dialogRef.close(result);
},
@@ -228,8 +250,8 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
console.error('Pattern extraction failed:', err);
this.messageService.add({
severity: 'error',
summary: 'Extraction Failed',
detail: 'An error occurred during pattern extraction.',
summary: this.t.translate('bookdrop.patternExtract.toast.extractionFailedSummary'),
detail: this.t.translate('bookdrop.patternExtract.toast.extractionFailedDetail'),
});
},
});
@@ -253,7 +275,13 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
getPlaceholderTooltip(placeholder: PatternPlaceholder): string {
return `${placeholder.description} (e.g., ${placeholder.example})`;
const description = this.t.translate(`bookdrop.patternExtract.${placeholder.descriptionKey}`);
const example = this.t.translate(`bookdrop.patternExtract.${placeholder.exampleKey}`);
return `${description} (e.g., ${example})`;
}
getCommonPatternLabel(labelKey: string): string {
return this.t.translate(`bookdrop.patternExtract.${labelKey}`);
}
getPreviewClass(preview: PreviewResult): Record<string, boolean> {
@@ -272,10 +300,10 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
getErrorMessage(preview: PreviewResult): string {
return preview.errorMessage || 'Pattern did not match';
return preview.errorMessage || this.t.translate('bookdrop.patternExtract.patternDidNotMatch');
}
getErrorTooltip(preview: PreviewResult): string {
return preview.success ? '' : (preview.errorMessage || 'Pattern did not match filename structure');
return preview.success ? '' : (preview.errorMessage || this.t.translate('bookdrop.patternExtract.patternDidNotMatchStructure'));
}
}
@@ -1,47 +1,49 @@
<div class="dashboard-scroller-container">
<h2 class="dashboard-scroller-title">
{{ title }}
@if (isMagicShelf) {
<i class="pi pi-sparkles magic-shelf-icon"></i>
}
</h2>
@if (!books || books.length === 0) {
<div class="dashboard-scroller-no-books">
<div class="empty-state-icon">
<i class="pi pi-book"></i>
</div>
<p>No books found for this scroller.</p>
</div>
}
@if (books) {
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
#scrollContainer
[horizontal]="true">
@for (book of books; track book.id) {
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="false"
[forceEbookMode]="forceEbookMode"
(menuToggled)="handleMenuToggle(book.id, $event)"
[overlayPreferenceService]="bookCardOverlayPreferenceService"
></app-book-card>
</div>
<ng-container *transloco="let t; prefix: 'dashboard.scroller'">
<div class="dashboard-scroller-container">
<h2 class="dashboard-scroller-title">
{{ title }}
@if (isMagicShelf) {
<i class="pi pi-sparkles magic-shelf-icon"></i>
}
</div>
}
</h2>
@if (books === null) {
<div class="dashboard-scroller-error">
<div class="error-icon">
<i class="pi pi-exclamation-triangle"></i>
@if (!books || books.length === 0) {
<div class="dashboard-scroller-no-books">
<div class="empty-state-icon">
<i class="pi pi-book"></i>
</div>
<p>{{ t('noBooksFound') }}</p>
</div>
<p>Failed to load books! Please try refreshing the page.</p>
</div>
}
</div>
}
@if (books) {
<div class="dashboard-scroller-infinite"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
#scrollContainer
[horizontal]="true">
@for (book of books; track book.id) {
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="false"
[forceEbookMode]="forceEbookMode"
(menuToggled)="handleMenuToggle(book.id, $event)"
[overlayPreferenceService]="bookCardOverlayPreferenceService"
></app-book-card>
</div>
}
</div>
}
@if (books === null) {
<div class="dashboard-scroller-error">
<div class="error-icon">
<i class="pi pi-exclamation-triangle"></i>
</div>
<p>{{ t('loadError') }}</p>
</div>
}
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {Book} from '../../../book/model/book.model';
import {ScrollerType} from '../../models/dashboard-config.model';
import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-dashboard-scroller',
@@ -16,7 +17,8 @@ import { BookCardOverlayPreferenceService } from '../../../book/components/book-
InfiniteScrollDirective,
BookCardComponent,
ProgressSpinnerModule,
NgClass
NgClass,
TranslocoDirective
],
standalone: true
})
@@ -1,154 +1,156 @@
<div class="dashboard-settings">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-sliders-h header-icon"></i>
<ng-container *transloco="let t; prefix: 'dashboard.settings'">
<div class="dashboard-settings">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-sliders-h header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
[text]="true"
[rounded]="true"
severity="secondary"
(onClick)="cancel()"
class="close-button"
/>
</div>
<div class="header-text">
<h2 class="panel-title">Dashboard Configuration</h2>
<p class="panel-description">Add up to 5 scrollers from different book collections and customize their behavior</p>
</div>
<p-button
icon="pi pi-times"
[text]="true"
[rounded]="true"
severity="secondary"
(onClick)="cancel()"
class="close-button"
/>
</div>
<div class="scrollers-container">
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
<div class="scroller-item">
<div class="scroller-content">
<div class="scroller-controls-left">
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
</div>
<div class="scroller-fields">
<div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
<label>Type</label>
<p-select
fluid
[options]="availableScrollerTypes"
[(ngModel)]="scroller.type"
(onChange)="onScrollerTypeChange(scroller)"
placeholder="Select type"
appendTo="body">
</p-select>
<div class="scrollers-container">
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
<div class="scroller-item">
<div class="scroller-content">
<div class="scroller-controls-left">
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
</div>
@if (scroller.type === 'magicShelf') {
<div class="scroller-field">
<label>Magic Shelf</label>
<div class="scroller-fields">
<div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
<label>{{ t('type') }}</label>
<p-select
fluid
[options]="(magicShelves$ | async)!"
[(ngModel)]="scroller.magicShelfId"
placeholder="Select magic shelf"
[options]="availableScrollerTypes"
[(ngModel)]="scroller.type"
(onChange)="onScrollerTypeChange(scroller)"
[placeholder]="t('selectType')"
appendTo="body">
</p-select>
</div>
<div class="scroller-field">
<label>Sort Field</label>
<p-select
fluid
[options]="sortFieldOptions"
[(ngModel)]="scroller.sortField"
placeholder="Select field"
appendTo="body">
</p-select>
</div>
@if (scroller.type === 'magicShelf') {
<div class="scroller-field">
<label>{{ t('magicShelf') }}</label>
<p-select
fluid
[options]="(magicShelves$ | async)!"
[(ngModel)]="scroller.magicShelfId"
[placeholder]="t('selectMagicShelf')"
appendTo="body">
</p-select>
</div>
<div class="scroller-field">
<label>Direction</label>
<p-select
fluid
[options]="sortDirectionOptions"
[(ngModel)]="scroller.sortDirection"
placeholder="Select direction"
appendTo="body">
</p-select>
</div>
}
</div>
<div class="scroller-field">
<label>{{ t('sortField') }}</label>
<p-select
fluid
[options]="sortFieldOptions"
[(ngModel)]="scroller.sortField"
[placeholder]="t('selectField')"
appendTo="body">
</p-select>
</div>
<div class="scroller-field max-items-field">
<label>Max Items</label>
<p-inputNumber
fluid
[(ngModel)]="scroller.maxItems"
[min]="MIN_ITEMS"
[max]="MAX_ITEMS"
[showButtons]="true">
</p-inputNumber>
</div>
<div class="scroller-field">
<label>{{ t('direction') }}</label>
<p-select
fluid
[options]="sortDirectionOptions"
[(ngModel)]="scroller.sortDirection"
[placeholder]="t('selectDirection')"
appendTo="body">
</p-select>
</div>
}
</div>
<div class="scroller-controls-right">
<p-button
icon="pi pi-arrow-up"
outlined
rounded
severity="info"
size="small"
[disabled]="i === 0"
(click)="moveUp(i)">
</p-button>
<p-button
icon="pi pi-arrow-down"
outlined
rounded
severity="info"
size="small"
[disabled]="i === config.scrollers.length - 1"
(click)="moveDown(i)">
</p-button>
<p-button
icon="pi pi-trash"
outlined
rounded
size="small"
severity="danger"
(click)="removeScroller(i)"
[disabled]="config.scrollers.length === 1">
</p-button>
<div class="scroller-field max-items-field">
<label>{{ t('maxItems') }}</label>
<p-inputNumber
fluid
[(ngModel)]="scroller.maxItems"
[min]="MIN_ITEMS"
[max]="MAX_ITEMS"
[showButtons]="true">
</p-inputNumber>
</div>
<div class="scroller-controls-right">
<p-button
icon="pi pi-arrow-up"
outlined
rounded
severity="info"
size="small"
[disabled]="i === 0"
(click)="moveUp(i)">
</p-button>
<p-button
icon="pi pi-arrow-down"
outlined
rounded
severity="info"
size="small"
[disabled]="i === config.scrollers.length - 1"
(click)="moveDown(i)">
</p-button>
<p-button
icon="pi pi-trash"
outlined
rounded
size="small"
severity="danger"
(click)="removeScroller(i)"
[disabled]="config.scrollers.length === 1">
</p-button>
</div>
</div>
</div>
</div>
}
</div>
}
</div>
<div class="dialog-footer">
<div class="footer-left">
<p-button
label="Add Scroller"
icon="pi pi-plus"
severity="primary"
(click)="addScroller()"
[disabled]="config.scrollers.length >= 5">
</p-button>
<p-button
label="Reset to Default"
icon="pi pi-refresh"
severity="secondary"
text
(click)="resetToDefault()">
</p-button>
</div>
<div class="footer-actions">
<p-button
label="Cancel"
[outlined]="true"
severity="secondary"
(click)="cancel()">
</p-button>
<p-button
label="Save"
icon="pi pi-check"
severity="success"
(click)="save()">
</p-button>
<div class="dialog-footer">
<div class="footer-left">
<p-button
[label]="t('addScroller')"
icon="pi pi-plus"
severity="primary"
(click)="addScroller()"
[disabled]="config.scrollers.length >= 5">
</p-button>
<p-button
[label]="t('resetToDefault')"
icon="pi pi-refresh"
severity="secondary"
text
(click)="resetToDefault()">
</p-button>
</div>
<div class="footer-actions">
<p-button
[label]="'common.cancel' | transloco"
[outlined]="true"
severity="secondary"
(click)="cancel()">
</p-button>
<p-button
[label]="'common.save' | transloco"
icon="pi pi-check"
severity="success"
(click)="save()">
</p-button>
</div>
</div>
</div>
</div>
</ng-container>
@@ -1,4 +1,5 @@
import {Component, inject, OnInit} from '@angular/core';
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
@@ -11,6 +12,7 @@ import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashbo
import {DashboardConfigService} from '../../services/dashboard-config.service';
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
import {map} from 'rxjs/operators';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export const MAX_SCROLLERS = 5;
export const DEFAULT_MAX_ITEMS = 20;
@@ -27,7 +29,9 @@ export const MAX_ITEMS = 20;
CheckboxModule,
InputTextModule,
SelectModule,
InputNumberModule
InputNumberModule,
TranslocoDirective,
TranslocoPipe
],
templateUrl: './dashboard-settings.component.html',
styleUrls: ['./dashboard-settings.component.scss']
@@ -36,16 +40,14 @@ export class DashboardSettingsComponent implements OnInit {
private configService = inject(DashboardConfigService);
private dialogRef = inject(DynamicDialogRef);
private magicShelfService = inject(MagicShelfService);
private translocoService = inject(TranslocoService);
private destroyRef = inject(DestroyRef);
config!: DashboardConfig;
availableScrollerTypes = [
{label: 'Continue Reading', value: ScrollerType.LAST_READ},
{label: 'Continue Listening', value: ScrollerType.LAST_LISTENED},
{label: 'Recently Added', value: ScrollerType.LATEST_ADDED},
{label: 'Discover Something New', value: ScrollerType.RANDOM},
{label: 'Magic Shelf', value: ScrollerType.MAGIC_SHELF}
];
availableScrollerTypes: {label: string; value: ScrollerType}[] = [];
sortFieldOptions: {label: string; value: string}[] = [];
sortDirectionOptions: {label: string; value: string}[] = [];
magicShelves$ = this.magicShelfService.shelvesState$.pipe(
map(state => (state.shelves || []).map(shelf => ({
@@ -54,33 +56,16 @@ export class DashboardSettingsComponent implements OnInit {
})))
);
sortFieldOptions = [
{label: 'Title', value: 'title'},
{label: 'Title + Series', value: 'titleSeries'},
{label: 'File Name', value: 'fileName'},
{label: 'File Path', value: 'filePath'},
{label: 'Date Added', value: 'addedOn'},
{label: 'Author', value: 'author'},
{label: 'Author (Surname)', value: 'authorSurnameVorname'},
{label: 'Author + Series', value: 'authorSeries'},
{label: 'Personal Rating', value: 'personalRating'},
{label: 'Publisher', value: 'publisher'},
{label: 'Published Date', value: 'publishedDate'},
{label: 'Last Read', value: 'lastReadTime'},
{label: 'Pages', value: 'pageCount'}
];
sortDirectionOptions = [
{label: 'Ascending', value: 'asc'},
{label: 'Descending', value: 'desc'}
];
private magicShelvesMap = new Map<number, string>();
readonly MIN_ITEMS = MIN_ITEMS;
readonly MAX_ITEMS = MAX_ITEMS;
ngOnInit(): void {
this.translocoService.langChanges$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.buildTranslatedOptions());
this.configService.config$.subscribe(config => {
this.config = JSON.parse(JSON.stringify(config));
});
@@ -95,22 +80,57 @@ export class DashboardSettingsComponent implements OnInit {
});
}
private buildTranslatedOptions(): void {
const t = (key: string) => this.translocoService.translate(`dashboard.settings.${key}`);
this.availableScrollerTypes = [
{label: t('scrollerTypes.lastRead'), value: ScrollerType.LAST_READ},
{label: t('scrollerTypes.lastListened'), value: ScrollerType.LAST_LISTENED},
{label: t('scrollerTypes.latestAdded'), value: ScrollerType.LATEST_ADDED},
{label: t('scrollerTypes.random'), value: ScrollerType.RANDOM},
{label: t('scrollerTypes.magicShelf'), value: ScrollerType.MAGIC_SHELF}
];
this.sortFieldOptions = [
{label: t('sortFields.title'), value: 'title'},
{label: t('sortFields.titleSeries'), value: 'titleSeries'},
{label: t('sortFields.fileName'), value: 'fileName'},
{label: t('sortFields.filePath'), value: 'filePath'},
{label: t('sortFields.addedOn'), value: 'addedOn'},
{label: t('sortFields.author'), value: 'author'},
{label: t('sortFields.authorSurnameVorname'), value: 'authorSurnameVorname'},
{label: t('sortFields.authorSeries'), value: 'authorSeries'},
{label: t('sortFields.personalRating'), value: 'personalRating'},
{label: t('sortFields.publisher'), value: 'publisher'},
{label: t('sortFields.publishedDate'), value: 'publishedDate'},
{label: t('sortFields.lastReadTime'), value: 'lastReadTime'},
{label: t('sortFields.pageCount'), value: 'pageCount'}
];
this.sortDirectionOptions = [
{label: t('sortDirections.asc'), value: 'asc'},
{label: t('sortDirections.desc'), value: 'desc'}
];
}
getScrollerTitle(scroller: ScrollerConfig): string {
const t = (key: string) => this.translocoService.translate(`dashboard.settings.scrollerTypes.${key}`);
if (scroller.type === ScrollerType.MAGIC_SHELF && scroller.magicShelfId) {
return this.magicShelvesMap.get(scroller.magicShelfId) || 'Magic Shelf';
return this.magicShelvesMap.get(scroller.magicShelfId) || t('magicShelf');
}
switch (scroller.type) {
case ScrollerType.LAST_READ:
return 'Continue Reading';
return t('lastRead');
case ScrollerType.LAST_LISTENED:
return 'Continue Listening';
return t('lastListened');
case ScrollerType.LATEST_ADDED:
return 'Recently Added';
return t('latestAdded');
case ScrollerType.RANDOM:
return 'Discover Something New';
return t('random');
default:
return 'Scroller';
return t('default');
}
}
@@ -1,70 +1,72 @@
<div class="dashboard-container">
@if ((bookState$ | async)?.loaded === false) {
<div class="loading-state">
<p-progressSpinner
class="spinner center-spinner"
[style]="{'width': '60px', 'height': '60px'}"
strokeWidth="3"
fill="transparent"
animationDuration="1.5s">
</p-progressSpinner>
</div>
}
@if ((bookState$ | async)?.loaded === true) {
<div class="dashboard">
<div class="dashboard-inner">
@if (isLibrariesEmpty$ | async) {
<div class="dashboard-no-library">
@if ((userService.userState$ | async)?.user?.permissions; as permissions) {
<div>
@if (permissions.admin || permissions.canManageLibrary) {
<div>
<h1 class="no-library-header">
Welcome to BookLore!<br>
Let's create your first library
</h1>
<p class="welcome-description">
A library is where all your books live. Start building your digital collection today!
</p>
<p-button
label="Create Your Library"
icon="pi pi-plus"
class="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
</div>
}
</div>
}
</div>
} @else {
<div class="dashboard-settings-button">
<p-button
icon="pi pi-cog"
severity="info"
rounded
text
[pTooltip]="'Customize Dashboard'"
tooltipPosition="left"
(click)="openDashboardSettings()">
</p-button>
</div>
<ng-container *transloco="let t; prefix: 'dashboard.main'">
<div class="dashboard-container">
@if ((bookState$ | async)?.loaded === false) {
<div class="loading-state">
<p-progressSpinner
class="spinner center-spinner"
[style]="{'width': '60px', 'height': '60px'}"
strokeWidth="3"
fill="transparent"
animationDuration="1.5s">
</p-progressSpinner>
</div>
}
@if ((bookState$ | async)?.loaded === true) {
<div class="dashboard">
<div class="dashboard-inner">
@if (isLibrariesEmpty$ | async) {
<div class="dashboard-no-library">
@if ((userService.userState$ | async)?.user?.permissions; as permissions) {
<div>
@if (permissions.admin || permissions.canManageLibrary) {
<div>
<h1 class="no-library-header">
{{ t('welcomeTitle') }}<br>
{{ t('welcomeSubtitle') }}
</h1>
<p class="welcome-description">
{{ t('welcomeDescription') }}
</p>
<p-button
[label]="t('createLibrary')"
icon="pi pi-plus"
class="p-button-rounded p-button-outlined"
(click)="createNewLibrary()">
</p-button>
</div>
}
</div>
}
</div>
} @else {
<div class="dashboard-settings-button">
<p-button
icon="pi pi-cog"
severity="info"
rounded
text
[pTooltip]="t('customizeDashboard')"
tooltipPosition="left"
(click)="openDashboardSettings()">
</p-button>
</div>
@if (dashboardConfig$ | async; as config) {
@for (scroller of config.scrollers; track scroller.id) {
@if (scroller.enabled) {
<app-dashboard-scroller
[bookListType]="scroller.type"
[title]="scroller.title"
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
[books]="getBooksForScroller(scroller) | async">
</app-dashboard-scroller>
@if (dashboardConfig$ | async; as config) {
@for (scroller of config.scrollers; track scroller.id) {
@if (scroller.enabled) {
<app-dashboard-scroller
[bookListType]="scroller.type"
[title]="scroller.title"
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
[books]="getBooksForScroller(scroller) | async">
</app-dashboard-scroller>
}
}
}
}
}
</div>
</div>
</div>
}
</div>
}
</div>
</ng-container>
@@ -12,6 +12,7 @@ import {Book, ReadStatus} from '../../../book/model/book.model';
import {UserService} from '../../../settings/user-management/user.service';
import {ProgressSpinner} from 'primeng/progressspinner';
import {TooltipModule} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {DashboardConfigService} from '../../services/dashboard-config.service';
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
@@ -33,7 +34,8 @@ const DEFAULT_MAX_ITEMS = 20;
DashboardScrollerComponent,
AsyncPipe,
ProgressSpinner,
TooltipModule
TooltipModule,
TranslocoDirective
],
standalone: true
})
@@ -47,6 +49,7 @@ export class MainDashboardComponent implements OnInit {
private ruleEvaluatorService = inject(BookRuleEvaluatorService);
private sortService = inject(SortService);
private pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
bookState$ = this.bookService.bookState$;
dashboardConfig$ = this.dashboardConfigService.config$;
@@ -60,7 +63,7 @@ export class MainDashboardComponent implements OnInit {
ScrollerType = ScrollerType;
ngOnInit(): void {
this.pageTitle.setPageTitle('Dashboard');
this.pageTitle.setPageTitle(this.t.translate('dashboard.main.pageTitle'));
this.dashboardConfig$.subscribe(() => {
this.scrollerBooksCache.clear();
@@ -1,273 +1,275 @@
<div class="library-creator">
<header class="dialog-header">
<div class="header-content">
<div class="header-icon">
<i class="pi pi-book"></i>
<ng-container *transloco="let t; prefix: 'libraryCreator.creator'">
<div class="library-creator">
<header class="dialog-header">
<div class="header-content">
<div class="header-icon">
<i class="pi pi-book"></i>
</div>
<div class="header-text">
<h1>{{ mode === 'edit' ? t('titleEdit') : t('titleNew') }}</h1>
<p>{{ t('subtitle') }}</p>
</div>
</div>
<div class="header-text">
<h1>{{ mode === 'edit' ? 'Edit Library' : 'New Library' }}</h1>
<p>Configure your book collection</p>
</div>
</div>
<p-button
icon="pi pi-times"
[text]="true"
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
/>
</header>
<p-button
icon="pi pi-times"
[text]="true"
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
/>
</header>
<div class="dialog-body">
<section class="form-section">
<div class="section-header">
<i class="pi pi-info-circle"></i>
<span>Library Details</span>
</div>
<div class="form-row two-col">
<div class="form-field">
<label>
Name <span class="required">*</span>
</label>
<div class="input-container">
<input
pInputText
[(ngModel)]="chosenLibraryName"
placeholder="My Library"
class="input-full"
/>
@if (chosenLibraryName.trim()) {
<i class="pi pi-check-circle field-status success"></i>
}
</div>
<div class="dialog-body">
<section class="form-section">
<div class="section-header">
<i class="pi pi-info-circle"></i>
<span>{{ t('libraryDetails') }}</span>
</div>
<div class="form-field">
<label>
Icon (Optional)
</label>
@if (!selectedIcon) {
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
<i class="pi pi-plus"></i>
<span>Choose icon</span>
</button>
} @else {
<div class="icon-selected">
<div class="icon-preview">
<app-icon-display [icon]="selectedIcon" size="16px" />
</div>
<span class="icon-value">
@if (selectedIcon.type === 'PRIME_NG') {
{{ selectedIcon.value }}
} @else {
Custom SVG
}
</span>
<button class="icon-clear" (click)="clearSelectedIcon()" type="button">
<i class="pi pi-times"></i>
</button>
<div class="form-row two-col">
<div class="form-field">
<label>
{{ t('nameLabel') }} <span class="required">*</span>
</label>
<div class="input-container">
<input
pInputText
[(ngModel)]="chosenLibraryName"
[placeholder]="t('namePlaceholder')"
class="input-full"
/>
@if (chosenLibraryName.trim()) {
<i class="pi pi-check-circle field-status success"></i>
}
</div>
}
</div>
</div>
</section>
</div>
<section class="form-section">
<div class="section-header">
<i class="pi pi-folder-open"></i>
<span>Book Folders</span>
<span class="section-badge">{{ folders.length }}</span>
</div>
<div class="folders-zone">
<button class="add-folder-trigger" (click)="openDirectoryPicker()" type="button">
<i class="pi pi-plus-circle"></i>
<span>Add folder</span>
</button>
@if (folders.length > 0) {
<div class="folders-list">
@for (folder of folders; track folder; let i = $index) {
<div class="folder-item">
<div class="folder-info">
<i class="pi pi-folder"></i>
<span class="folder-path" [pTooltip]="folder" tooltipPosition="top">
{{ folder }}
</span>
<div class="form-field">
<label>
{{ t('iconLabel') }}
</label>
@if (!selectedIcon) {
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
<i class="pi pi-plus"></i>
<span>{{ t('chooseIcon') }}</span>
</button>
} @else {
<div class="icon-selected">
<div class="icon-preview">
<app-icon-display [icon]="selectedIcon" size="16px" />
</div>
<button class="folder-remove" (click)="removeFolder(i)" type="button">
<span class="icon-value">
@if (selectedIcon.type === 'PRIME_NG') {
{{ selectedIcon.value }}
} @else {
{{ t('customSvg') }}
}
</span>
<button class="icon-clear" (click)="clearSelectedIcon()" type="button">
<i class="pi pi-times"></i>
</button>
</div>
}
</div>
} @else {
<div class="empty-hint">
<i class="pi pi-info-circle"></i>
<span>Add folders containing your book files</span>
</div>
}
</div>
</section>
</div>
</section>
<section class="form-section">
<div class="section-header">
<i class="pi pi-cog"></i>
<span>Options</span>
</div>
<div class="options-list">
<div class="option-row">
<div class="option-label">
<span>Watch folders</span>
<i
class="pi pi-question-circle info-icon"
pTooltip="Automatically detect new books added to folders"
tooltipPosition="top"
></i>
</div>
<p-toggleswitch [(ngModel)]="watch" />
<section class="form-section">
<div class="section-header">
<i class="pi pi-folder-open"></i>
<span>{{ t('bookFolders') }}</span>
<span class="section-badge">{{ folders.length }}</span>
</div>
<div class="option-row">
<div class="option-label">
<span>Metadata source</span>
<i
class="pi pi-question-circle info-icon"
pTooltip="Choose where to read metadata from when scanning books"
tooltipPosition="top"
></i>
</div>
<p-select
[(ngModel)]="metadataSource"
[options]="metadataSourceOptions"
optionLabel="label"
optionValue="value"
placeholder="Select source"
class="metadata-source-select"
appendTo="body"
/>
</div>
<div class="folders-zone">
<button class="add-folder-trigger" (click)="openDirectoryPicker()" type="button">
<i class="pi pi-plus-circle"></i>
<span>{{ t('addFolder') }}</span>
</button>
<div class="option-divider"></div>
<div class="option-row option-row-stacked">
<div class="option-label">
<span>Format priority</span>
<i
class="pi pi-question-circle info-icon"
pTooltip="Drag to reorder preferred format when a book has multiple files"
tooltipPosition="top"
></i>
</div>
<div
class="format-chips"
cdkDropList
cdkDropListOrientation="mixed"
[cdkDropListData]="formatPriority"
(cdkDropListDropped)="onFormatPriorityDrop($event)"
>
@for (format of formatPriority; track format.type; let i = $index) {
<div class="format-chip" cdkDrag>
<span class="chip-rank">{{ i + 1 }}</span>
<span class="chip-label">{{ format.type }}</span>
<i class="pi pi-arrows-alt drag-indicator" cdkDragHandle></i>
</div>
}
</div>
</div>
<div class="option-row">
<div class="option-label">
<span>Allowed formats</span>
<i
class="pi pi-question-circle info-icon"
pTooltip="Select which book formats to include in scans"
tooltipPosition="top"
></i>
</div>
<div class="allow-all-toggle">
<p-checkbox
[(ngModel)]="allowAllFormats"
[binary]="true"
inputId="allowAll"
(onChange)="onAllowAllFormatsChange()"
/>
<label for="allowAll" class="allow-all-label">Allow all</label>
</div>
</div>
@if (!allowAllFormats) {
<div class="format-checkboxes">
@for (format of allBookFormats; track format.type) {
<div class="format-checkbox-item" [class.has-warning]="getFormatWarning(format.type)">
<p-checkbox
[ngModel]="isFormatSelected(format.type)"
[binary]="true"
[inputId]="'format-' + format.type"
(onChange)="onFormatCheckboxChange(format.type, $event.checked)"
/>
<label [for]="'format-' + format.type" class="format-checkbox-label">
{{ format.label }}
</label>
@if (getFormatWarning(format.type); as warning) {
<i
class="pi pi-exclamation-triangle warning-icon"
[pTooltip]="warning"
tooltipPosition="top"
></i>
}
</div>
}
</div>
@if (hasAnyFormatWarning()) {
<div class="format-warning-message">
@if (folders.length > 0) {
<div class="folders-list">
@for (folder of folders; track folder; let i = $index) {
<div class="folder-item">
<div class="folder-info">
<i class="pi pi-folder"></i>
<span class="folder-path" [pTooltip]="folder" tooltipPosition="top">
{{ folder }}
</span>
</div>
<button class="folder-remove" (click)="removeFolder(i)" type="button">
<i class="pi pi-times"></i>
</button>
</div>
}
</div>
} @else {
<div class="empty-hint">
<i class="pi pi-info-circle"></i>
<span>Deselected formats won't appear in future scans</span>
<span>{{ t('emptyFoldersHint') }}</span>
</div>
}
</div>
</section>
<section class="form-section">
<div class="section-header">
<i class="pi pi-cog"></i>
<span>{{ t('options') }}</span>
</div>
<div class="options-list">
<div class="option-row">
<div class="option-label">
<span>{{ t('watchFolders') }}</span>
<i
class="pi pi-question-circle info-icon"
[pTooltip]="t('watchFoldersTooltip')"
tooltipPosition="top"
></i>
</div>
<p-toggleswitch [(ngModel)]="watch" />
</div>
<div class="option-row">
<div class="option-label">
<span>{{ t('metadataSource') }}</span>
<i
class="pi pi-question-circle info-icon"
[pTooltip]="t('metadataSourceTooltip')"
tooltipPosition="top"
></i>
</div>
<p-select
[(ngModel)]="metadataSource"
[options]="metadataSourceOptions"
optionLabel="label"
optionValue="value"
[placeholder]="t('metadataSourcePlaceholder')"
class="metadata-source-select"
appendTo="body"
/>
</div>
<div class="option-divider"></div>
<div class="option-row option-row-stacked">
<div class="option-label">
<span>{{ t('formatPriority') }}</span>
<i
class="pi pi-question-circle info-icon"
[pTooltip]="t('formatPriorityTooltip')"
tooltipPosition="top"
></i>
</div>
<div
class="format-chips"
cdkDropList
cdkDropListOrientation="mixed"
[cdkDropListData]="formatPriority"
(cdkDropListDropped)="onFormatPriorityDrop($event)"
>
@for (format of formatPriority; track format.type; let i = $index) {
<div class="format-chip" cdkDrag>
<span class="chip-rank">{{ i + 1 }}</span>
<span class="chip-label">{{ format.type }}</span>
<i class="pi pi-arrows-alt drag-indicator" cdkDragHandle></i>
</div>
}
</div>
</div>
<div class="option-row">
<div class="option-label">
<span>{{ t('allowedFormats') }}</span>
<i
class="pi pi-question-circle info-icon"
[pTooltip]="t('allowedFormatsTooltip')"
tooltipPosition="top"
></i>
</div>
<div class="allow-all-toggle">
<p-checkbox
[(ngModel)]="allowAllFormats"
[binary]="true"
inputId="allowAll"
(onChange)="onAllowAllFormatsChange()"
/>
<label for="allowAll" class="allow-all-label">{{ t('allowAll') }}</label>
</div>
</div>
@if (!allowAllFormats) {
<div class="format-checkboxes">
@for (format of allBookFormats; track format.type) {
<div class="format-checkbox-item" [class.has-warning]="getFormatWarning(format.type)">
<p-checkbox
[ngModel]="isFormatSelected(format.type)"
[binary]="true"
[inputId]="'format-' + format.type"
(onChange)="onFormatCheckboxChange(format.type, $event.checked)"
/>
<label [for]="'format-' + format.type" class="format-checkbox-label">
{{ format.label }}
</label>
@if (getFormatWarning(format.type); as warning) {
<i
class="pi pi-exclamation-triangle warning-icon"
[pTooltip]="warning"
tooltipPosition="top"
></i>
}
</div>
}
</div>
@if (hasAnyFormatWarning()) {
<div class="format-warning-message">
<i class="pi pi-info-circle"></i>
<span>{{ t('deselectedFormatsWarning') }}</span>
</div>
}
}
</div>
</section>
</div>
<footer class="dialog-footer">
<div class="validation-status">
@if (!isLibraryDetailsValid() || !isDirectorySelectionValid()) {
<div class="status-message warning">
<i class="pi pi-exclamation-circle"></i>
<span>
@if (!chosenLibraryName.trim()) {
{{ t('validation.enterName') }}
} @else if (!selectedIcon) {
{{ t('validation.selectIcon') }}
} @else {
{{ t('validation.addFolder') }}
}
</span>
</div>
} @else {
<div class="status-message ready">
<i class="pi pi-check-circle"></i>
<span>{{ mode === 'edit' ? t('validation.readyUpdate') : t('validation.readyCreate') }}</span>
</div>
}
</div>
</section>
<div class="footer-actions">
<p-button
[label]="'common.cancel' | transloco"
severity="secondary"
[outlined]="true"
(onClick)="closeDialog()"
/>
<p-button
[label]="mode === 'edit' ? t('buttonUpdate') : t('buttonCreate')"
[icon]="mode === 'edit' ? 'pi pi-save' : 'pi pi-check'"
severity="primary"
[disabled]="!isLibraryDetailsValid() || !isDirectorySelectionValid()"
(onClick)="createOrUpdateLibrary()"
/>
</div>
</footer>
</div>
<footer class="dialog-footer">
<div class="validation-status">
@if (!isLibraryDetailsValid() || !isDirectorySelectionValid()) {
<div class="status-message warning">
<i class="pi pi-exclamation-circle"></i>
<span>
@if (!chosenLibraryName.trim()) {
Enter library name
} @else if (!selectedIcon) {
Select an icon
} @else {
Add at least one folder
}
</span>
</div>
} @else {
<div class="status-message ready">
<i class="pi pi-check-circle"></i>
<span>Ready to {{ mode === 'edit' ? 'update' : 'create' }}</span>
</div>
}
</div>
<div class="footer-actions">
<p-button
label="Cancel"
severity="secondary"
[outlined]="true"
(onClick)="closeDialog()"
/>
<p-button
[label]="mode === 'edit' ? 'Update' : 'Create'"
[icon]="mode === 'edit' ? 'pi pi-save' : 'pi pi-check'"
severity="primary"
[disabled]="!isLibraryDetailsValid() || !isDirectorySelectionValid()"
(onClick)="createOrUpdateLibrary()"
/>
</div>
</footer>
</div>
</ng-container>
@@ -18,12 +18,13 @@ import {map} from 'rxjs';
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
import {Checkbox} from 'primeng/checkbox';
import {Select} from 'primeng/select';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-library-creator',
standalone: true,
templateUrl: './library-creator.component.html',
imports: [FormsModule, InputText, ToggleSwitch, Tooltip, Button, IconDisplayComponent, DragDropModule, Checkbox, Select],
imports: [FormsModule, InputText, ToggleSwitch, Tooltip, Button, IconDisplayComponent, DragDropModule, Checkbox, Select, TranslocoDirective, TranslocoPipe],
styleUrl: './library-creator.component.scss'
})
export class LibraryCreatorComponent implements OnInit {
@@ -41,13 +42,7 @@ export class LibraryCreatorComponent implements OnInit {
formatCounts: Record<string, number> = {};
metadataSource: MetadataSource = 'EMBEDDED';
readonly metadataSourceOptions = [
{label: 'Embedded Only', value: 'EMBEDDED', description: 'Use only embedded file metadata'},
{label: 'Sidecar Only', value: 'SIDECAR', description: 'Use only sidecar JSON files'},
{label: 'Prefer Sidecar', value: 'PREFER_SIDECAR', description: 'Use sidecar if available, fallback to embedded'},
{label: 'Prefer Embedded', value: 'PREFER_EMBEDDED', description: 'Use embedded if available, fallback to sidecar'},
{label: 'None', value: 'NONE', description: 'Don\'t read metadata from files'}
];
metadataSourceOptions: {label: string, value: string}[] = [];
readonly allBookFormats: {type: BookType, label: string}[] = [
{type: 'EPUB', label: 'EPUB'},
@@ -66,8 +61,16 @@ export class LibraryCreatorComponent implements OnInit {
private messageService = inject(MessageService);
private router = inject(Router);
private iconPicker = inject(IconPickerService);
private readonly t = inject(TranslocoService);
ngOnInit(): void {
this.metadataSourceOptions = [
{label: this.t.translate('libraryCreator.creator.metadataSourceEmbedded'), value: 'EMBEDDED'},
{label: this.t.translate('libraryCreator.creator.metadataSourceSidecar'), value: 'SIDECAR'},
{label: this.t.translate('libraryCreator.creator.metadataSourcePreferSidecar'), value: 'PREFER_SIDECAR'},
{label: this.t.translate('libraryCreator.creator.metadataSourcePreferEmbedded'), value: 'PREFER_EMBEDDED'},
{label: this.t.translate('libraryCreator.creator.metadataSourceNone'), value: 'NONE'}
];
this.initializeFormatPriority();
this.initializeAllowedFormats();
@@ -154,7 +157,7 @@ export class LibraryCreatorComponent implements OnInit {
if (this.mode !== 'edit') return null;
const count = this.formatCounts[formatType];
if (count && count > 0 && !this.selectedAllowedFormats.has(formatType)) {
return `${count} existing book${count > 1 ? 's' : ''} will not appear in future scans`;
return this.t.translate('libraryCreator.creator.formatWarning', {count});
}
return null;
}
@@ -216,8 +219,8 @@ export class LibraryCreatorComponent implements OnInit {
if (exists) {
this.messageService.add({
severity: 'error',
summary: 'Library Name Exists',
detail: 'This library name is already taken.',
summary: this.t.translate('libraryCreator.creator.toast.nameExistsSummary'),
detail: this.t.translate('libraryCreator.creator.toast.nameExistsDetail'),
});
return;
}
@@ -240,11 +243,11 @@ export class LibraryCreatorComponent implements OnInit {
if (this.mode === 'edit') {
this.libraryService.updateLibrary(library, this.library?.id).subscribe({
next: () => {
this.messageService.add({severity: 'success', summary: 'Library Updated', detail: 'The library was updated successfully.'});
this.messageService.add({severity: 'success', summary: this.t.translate('libraryCreator.creator.toast.updatedSummary'), detail: this.t.translate('libraryCreator.creator.toast.updatedDetail')});
this.dynamicDialogRef.close();
},
error: (e) => {
this.messageService.add({severity: 'error', summary: 'Update Failed', detail: 'An error occurred while updating the library. Please try again.'});
this.messageService.add({severity: 'error', summary: this.t.translate('libraryCreator.creator.toast.updateFailedSummary'), detail: this.t.translate('libraryCreator.creator.toast.updateFailedDetail')});
console.error(e);
}
});
@@ -269,17 +272,17 @@ export class LibraryCreatorComponent implements OnInit {
this.router.navigate(['/library', createdLibrary.id, 'books']);
this.messageService.add({
severity: 'success',
summary: 'Library Created',
summary: this.t.translate('libraryCreator.creator.toast.createdSummary'),
detail: count >= 500
? `Library created with ${count} files. Loading in progress...`
: 'The library was created successfully.'
? this.t.translate('libraryCreator.creator.toast.createdLargeDetail', {count})
: this.t.translate('libraryCreator.creator.toast.createdDetail')
});
this.dynamicDialogRef.close();
}
},
error: (e) => {
this.libraryService.setLargeLibraryLoading(false, 0);
this.messageService.add({severity: 'error', summary: 'Creation Failed', detail: 'An error occurred while creating the library. Please try again.'});
this.messageService.add({severity: 'error', summary: this.t.translate('libraryCreator.creator.toast.createFailedSummary'), detail: this.t.translate('libraryCreator.creator.toast.createFailedDetail')});
console.error(e);
}
});
@@ -1,50 +1,52 @@
<div class="fullscreen-loader">
<div class="library-loader-content">
<div class="library-loader-header">
<i class="pi pi-book"></i>
<h2>Loading Library</h2>
</div>
<ng-container *transloco="let t; prefix: 'libraryCreator.loading'">
<div class="fullscreen-loader">
<div class="library-loader-content">
<div class="library-loader-header">
<i class="pi pi-book"></i>
<h2>{{ t('title') }}</h2>
</div>
<div class="library-loader-body">
<div class="book-title">
@if (!isComplete) {
<ng-container>
{{ t('processing') }} <strong>{{ truncatedTitle }}</strong>
</ng-container>
}
@if (isComplete) {
<strong class="complete-message">
<i class="pi pi-check-circle"></i>
{{ t('complete') }}
</strong>
}
</div>
<div class="progress-info">
<span>{{ current }} / {{ total }}</span>
<span>{{ percentage }}%</span>
</div>
<div class="progress-bar-container">
<div class="progress-bar-fill" [style.width.%]="percentage"></div>
</div>
<div class="library-loader-body">
<div class="book-title">
@if (!isComplete) {
<ng-container>
Processing: <strong>{{ truncatedTitle }}</strong>
</ng-container>
}
@if (isComplete) {
<strong class="complete-message">
<i class="pi pi-check-circle"></i>
Library Loading Complete!
</strong>
<div class="loader-animation">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
}
</div>
<div class="progress-info">
<span>{{ current }} / {{ total }}</span>
<span>{{ percentage }}%</span>
</div>
<div class="progress-bar-container">
<div class="progress-bar-fill" [style.width.%]="percentage"></div>
</div>
@if (!isComplete) {
<div class="loader-animation">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
@if (isComplete) {
<div class="library-loader-footer">
<button class="reload-button" (click)="onReload()">
<i class="pi pi-bookmark"></i>
{{ t('openLibrary') }}
</button>
</div>
}
</div>
@if (isComplete) {
<div class="library-loader-footer">
<button class="reload-button" (click)="onReload()">
<i class="pi pi-bookmark"></i>
Open Library
</button>
</div>
}
</div>
</div>
</ng-container>
@@ -1,10 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-library-loading',
standalone: true,
imports: [CommonModule],
imports: [CommonModule, TranslocoDirective],
templateUrl: './library-loading.component.html',
styleUrl: './library-loading.component.scss'
})
@@ -1,12 +1,12 @@
<div class="book-metadata-center-container">
<div class="book-metadata-center-container" *transloco="let t; prefix: 'metadata.center'">
@if (config) {
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-book header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Book Details</h2>
<p class="panel-description">View and edit book metadata</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -23,24 +23,24 @@
<p-tablist>
<p-tab value="view">
<i [class]="'pi pi-book'"></i>
Book Details
{{ t('tabView') }}
</p-tab>
@if (admin || canEditMetadata) {
<p-tab value="edit">
<i [class]="'pi pi-pencil'"></i>
Edit Metadata
{{ t('tabEdit') }}
</p-tab>
}
@if (admin || canEditMetadata) {
<p-tab value="match">
<i [class]="'pi pi-search'"></i>
Search Metadata
{{ t('tabSearch') }}
</p-tab>
}
@if (admin || canEditMetadata) {
<p-tab value="sidecar">
<i [class]="'pi pi-file'"></i>
Sidecar
{{ t('tabSidecar') }}
</p-tab>
}
</p-tablist>
@@ -10,6 +10,7 @@ import {Tab, TabList, TabPanel, TabPanels, Tabs,} from 'primeng/tabs';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {Button} from 'primeng/button';
import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service';
import {TranslocoDirective} from '@jsverse/transloco';
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
@@ -29,7 +30,8 @@ import {SidecarViewerComponent} from './sidecar-viewer/sidecar-viewer.component'
MetadataEditorComponent,
MetadataSearcherComponent,
SidecarViewerComponent,
Button
Button,
TranslocoDirective
],
styleUrls: ['./book-metadata-center.component.scss'],
})
@@ -1,13 +1,13 @@
<div class="reading-sessions-container">
<div class="reading-sessions-container" *transloco="let t; prefix: 'metadata.readingSessions'">
@if (loading && sessions.length === 0) {
<div class="loading-state">
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s"></p-progressSpinner>
<p class="loading-text">Loading reading sessions...</p>
<p class="loading-text">{{ t('loading') }}</p>
</div>
} @else if (sessions.length === 0) {
<div class="empty-state">
<i class="pi pi-clock" style="font-size: 3rem; color: var(--text-color-secondary);"></i>
<p>No reading sessions recorded yet</p>
<p>{{ t('emptyState') }}</p>
</div>
} @else {
<p-table
@@ -20,16 +20,16 @@
[first]="first"
(onLazyLoad)="onPageChange($event)"
[showCurrentPageReport]="true"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} sessions"
[currentPageReportTemplate]="t('pageReport')"
class="p-datatable-sm">
<ng-template #header>
<tr>
<th>Session</th>
<th>Type</th>
<th>Duration</th>
<th>Progress</th>
<th>Progress Delta</th>
<th>Location</th>
<th>{{ t('headerSession') }}</th>
<th>{{ t('headerType') }}</th>
<th>{{ t('headerDuration') }}</th>
<th>{{ t('headerProgress') }}</th>
<th>{{ t('headerProgressDelta') }}</th>
<th>{{ t('headerLocation') }}</th>
</tr>
</ng-template>
<ng-template #body let-session>
@@ -3,10 +3,11 @@ import {CommonModule} from '@angular/common';
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
import {TableModule} from 'primeng/table';
import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-book-reading-sessions',
standalone: true,
imports: [CommonModule, TableModule, ProgressSpinnerModule],
imports: [CommonModule, TableModule, ProgressSpinnerModule, TranslocoDirective],
templateUrl: './book-reading-sessions.component.html',
styleUrls: ['./book-reading-sessions.component.scss']
})
@@ -14,6 +15,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
@Input() bookId!: number;
private readonly readingSessionService = inject(ReadingSessionApiService);
private readonly t = inject(TranslocoService);
sessions: ReadingSessionResponse[] = [];
totalRecords = 0;
@@ -121,7 +123,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
}
formatBookType(bookType: string): string {
if (bookType === 'AUDIOBOOK') return 'Audio';
if (bookType === 'AUDIOBOOK') return this.t.translate('metadata.readingSessions.audio');
return bookType;
}
@@ -159,7 +161,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
}
if (this.isPageNumber(start)) {
return `Page ${start} → ${end}`;
return `${this.t.translate('metadata.readingSessions.page')} ${start} → ${end}`;
}
return '-';
@@ -1,5 +1,5 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" class="metadata-form">
<form [formGroup]="metadataForm" class="metadata-form" *transloco="let t; prefix: 'metadata.editor'">
@if (isLoading) {
<div class="loading-overlay"></div>
}
@@ -14,7 +14,7 @@
<div class="cover-section">
@if (supportsDualCovers(book)) {
<div class="cover-type-label ebook">
<i class="pi pi-book"></i> Ebook Cover
<i class="pi pi-book"></i> {{ t('ebookCover') }}
</div>
}
<p-image
@@ -33,7 +33,7 @@
<p-button
icon="pi pi-refresh"
(onClick)="regenerateCover(book.id)"
pTooltip="Regenerate cover (From File)"
[pTooltip]="t('regenerateCoverTooltip')"
tooltipPosition="top"
[outlined]="true"
severity="warn"
@@ -44,7 +44,7 @@
<p-button
icon="pi pi-palette"
(onClick)="generateCustomCover(book.id)"
pTooltip="Generate Custom Cover"
[pTooltip]="t('generateCustomCoverTooltip')"
tooltipPosition="top"
[outlined]="true"
severity="help"
@@ -58,13 +58,13 @@
size="small"
icon="pi pi-search"
(onClick)="openCoverSearch()"
pTooltip="Search for cover"
[pTooltip]="t('searchCoverTooltip')"
tooltipPosition="top"
severity="info">
</p-button>
<p-fileupload
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
pTooltip="Upload cover"
[pTooltip]="t('uploadCoverTooltip')"
tooltipPosition="top"
[disabled]="book.metadata!['coverLocked']"
name="file"
@@ -79,10 +79,10 @@
(onBeforeUpload)="onBeforeSend()">
</p-fileupload>
@if (!book.metadata!['coverLocked']) {
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
<p-button [pTooltip]="t('lockCoverTooltip')" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
}
@if (book.metadata!['coverLocked']) {
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
<p-button [pTooltip]="t('unlockCoverTooltip')" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
}
</div>
</div>
@@ -92,7 +92,7 @@
@if (hasAudiobookFormat(book)) {
<div class="cover-section audiobook-cover-section">
<div class="cover-type-label audiobook">
<i class="pi pi-headphones"></i> Audiobook Cover
<i class="pi pi-headphones"></i> {{ t('audiobookCover') }}
</div>
<p-image
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
@@ -110,7 +110,7 @@
<p-button
icon="pi pi-refresh"
(onClick)="regenerateAudiobookCover(book.id)"
pTooltip="Regenerate cover (From File)"
[pTooltip]="t('regenerateAudiobookCoverTooltip')"
tooltipPosition="top"
[outlined]="true"
severity="warn"
@@ -120,7 +120,7 @@
<p-button
icon="pi pi-palette"
(onClick)="generateCustomAudiobookCover(book.id)"
pTooltip="Generate Custom Cover"
[pTooltip]="t('generateCustomAudiobookCoverTooltip')"
tooltipPosition="top"
[outlined]="true"
severity="help"
@@ -134,13 +134,13 @@
size="small"
icon="pi pi-search"
(onClick)="openAudiobookCoverSearch()"
pTooltip="Search for audiobook cover"
[pTooltip]="t('searchAudiobookCoverTooltip')"
tooltipPosition="top"
severity="info">
</p-button>
<p-fileupload
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
pTooltip="Upload audiobook cover"
[pTooltip]="t('uploadAudiobookCoverTooltip')"
tooltipPosition="top"
[disabled]="book.metadata!['audiobookCoverLocked']"
name="file"
@@ -155,10 +155,10 @@
(onBeforeUpload)="onBeforeSend()">
</p-fileupload>
@if (!book.metadata!['audiobookCoverLocked']) {
<p-button pTooltip="Lock Cover" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="success"></p-button>
<p-button [pTooltip]="t('lockCoverTooltip')" tooltipPosition="top" size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="success"></p-button>
}
@if (book.metadata!['audiobookCoverLocked']) {
<p-button pTooltip="Unlock Cover" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="warn"></p-button>
<p-button [pTooltip]="t('unlockCoverTooltip')" tooltipPosition="top" size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('audiobookCover')" severity="warn"></p-button>
}
</div>
`
@@ -169,7 +169,7 @@
<div class="field-row">
<div class="field-group title-field">
<label for="title">Title</label>
<label for="title">{{ t('title') }}</label>
<div class="field-with-lock">
<input pInputText id="title" formControlName="title"/>
@if (!book.metadata!['titleLocked']) {
@@ -182,7 +182,7 @@
</div>
<div class="field-group subtitle-field">
<label for="subtitle">Subtitle</label>
<label for="subtitle">{{ t('subtitle') }}</label>
<div class="field-with-lock">
<input pInputText id="subtitle" formControlName="subtitle"/>
@if (!book.metadata!['subtitleLocked']) {
@@ -195,7 +195,7 @@
</div>
<div class="field-group language-field">
<label for="language">Language</label>
<label for="language">{{ t('language') }}</label>
<div class="field-with-lock">
<input pInputText id="language" formControlName="language"/>
@if (!book.metadata!['languageLocked']) {
@@ -210,7 +210,7 @@
<div class="field-row">
<div class="field-group authors-field">
<label for="authors">Authors</label>
<label for="authors">{{ t('authors') }}</label>
<div class="field-with-lock">
<p-autoComplete
formControlName="authors"
@@ -233,7 +233,7 @@
</div>
</div>
<div class="field-group publisher-field">
<label for="publisher">Publisher</label>
<label for="publisher">{{ t('publisher') }}</label>
<div class="field-with-lock">
<p-autoComplete
[fluid]="true"
@@ -255,7 +255,7 @@
</div>
</div>
<div class="field-group date-field">
<label for="publishedDate">Publish Date</label>
<label for="publishedDate">{{ t('publishDate') }}</label>
<div class="field-with-lock">
<p-datepicker
formControlName="publishedDate"
@@ -280,7 +280,7 @@
<div class="field-row">
<div class="field-group full-width">
<label for="categories">Genres</label>
<label for="categories">{{ t('genres') }}</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
@@ -307,7 +307,7 @@
<div class="field-row">
<div class="field-group half-width">
<label for="moods">Moods</label>
<label for="moods">{{ t('moods') }}</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
@@ -331,7 +331,7 @@
</div>
</div>
<div class="field-group half-width">
<label for="tags">Tags</label>
<label for="tags">{{ t('tags') }}</label>
<div class="field-with-lock">
<div class="autocomplete-wrapper">
<p-autoComplete
@@ -358,7 +358,7 @@
<div class="field-row">
<div class="field-group series-name-field">
<label for="seriesName">Series Name</label>
<label for="seriesName">{{ t('seriesName') }}</label>
<div class="field-with-lock">
<p-autoComplete
[fluid]="true"
@@ -381,7 +381,7 @@
</div>
<div class="field-group small-field">
<label for="seriesNumber">Series #</label>
<label for="seriesNumber">{{ t('seriesNumber') }}</label>
<div class="field-with-lock">
<input pInputText id="seriesNumber" formControlName="seriesNumber"/>
@if (!book.metadata!['seriesNumberLocked']) {
@@ -394,7 +394,7 @@
</div>
<div class="field-group small-field">
<label for="seriesTotal">Series Total</label>
<label for="seriesTotal">{{ t('seriesTotal') }}</label>
<div class="field-with-lock">
<input pInputText id="seriesTotal" formControlName="seriesTotal"/>
@if (!book.metadata!['seriesTotalLocked']) {
@@ -406,9 +406,9 @@
</div>
</div>
<div class="field-group small-field">
<label>Public Reviews</label>
<label>{{ t('publicReviews') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText [disabled]="true" value="No Value"/>
<input pSize="small" pInputText [disabled]="true" [value]="t('noValue')"/>
@if (!book.metadata!['reviewsLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviews')" severity="success"></p-button>
}
@@ -421,7 +421,7 @@
<div class="field-row">
<div class="field-group small-field">
<label for="isbn10">ISBN 10</label>
<label for="isbn10">{{ t('isbn10') }}</label>
<div class="field-with-lock">
<input pInputText id="isbn10" formControlName="isbn10"/>
@if (!book.metadata!['isbn10Locked']) {
@@ -433,7 +433,7 @@
</div>
</div>
<div class="field-group small-field">
<label for="isbn13">ISBN 13</label>
<label for="isbn13">{{ t('isbn13') }}</label>
<div class="field-with-lock">
<input pInputText id="isbn13" formControlName="isbn13"/>
@if (!book.metadata!['isbn13Locked']) {
@@ -445,7 +445,7 @@
</div>
</div>
<div class="field-group small-field">
<label for="ageRating">Age Rating</label>
<label for="ageRating">{{ t('ageRating') }}</label>
<div class="field-with-lock">
<p-select
id="ageRating"
@@ -466,7 +466,7 @@
</div>
</div>
<div class="field-group small-field">
<label for="contentRating">Content Rating</label>
<label for="contentRating">{{ t('contentRating') }}</label>
<div class="field-with-lock">
<p-select
id="contentRating"
@@ -487,7 +487,7 @@
</div>
</div>
<div class="field-group small-field">
<label for="pageCount">Pages</label>
<label for="pageCount">{{ t('pages') }}</label>
<div class="field-with-lock">
<input pInputText id="pageCount" formControlName="pageCount"/>
@if (!book.metadata!['pageCountLocked']) {
@@ -508,7 +508,7 @@
<div class="collapsible-section" [class.expanded]="audiobookSectionExpanded">
<div class="collapsible-header" (click)="audiobookSectionExpanded = !audiobookSectionExpanded">
<i class="pi pi-headphones"></i>
<span>Audiobook Details</span>
<span>{{ t('audiobookDetails') }}</span>
<i [class]="audiobookSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (audiobookSectionExpanded) {
@@ -543,7 +543,7 @@
<div class="collapsible-section" [class.expanded]="comicSectionExpanded">
<div class="collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i>
<span>Comic Book Details</span>
<span>{{ t('comicBookDetails') }}</span>
<i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (comicSectionExpanded) {
@@ -625,7 +625,7 @@
<div class="collapsible-section" [class.expanded]="providerSectionExpanded">
<div class="collapsible-header" (click)="providerSectionExpanded = !providerSectionExpanded">
<i class="pi pi-database"></i>
<span>Provider Metadata</span>
<span>{{ t('providerMetadata') }}</span>
<i [class]="providerSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@if (providerSectionExpanded) {
@@ -633,7 +633,7 @@
<div class="field-row metadata-ids-row">
@if (isFieldVisible('asin')) {
<div class="field-group metadata-id-field">
<label for="asin">Amazon ASIN</label>
<label for="asin">{{ t('amazonAsin') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="asin" formControlName="asin"/>
@if (!book.metadata!['asinLocked']) {
@@ -647,7 +647,7 @@
}
@if (isFieldVisible('amazonRating')) {
<div class="field-group metadata-id-field">
<label for="amazonRating">Amazon ★</label>
<label for="amazonRating">{{ t('amazonRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/>
@if (!book.metadata!['amazonRatingLocked']) {
@@ -661,7 +661,7 @@
}
@if (isFieldVisible('amazonReviewCount')) {
<div class="field-group metadata-id-field">
<label for="amazonRatingCount">Amazon #</label>
<label for="amazonRatingCount">{{ t('amazonReviewCount') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/>
@if (!book.metadata!['amazonReviewCountLocked']) {
@@ -675,7 +675,7 @@
}
@if (isFieldVisible('googleId')) {
<div class="field-group metadata-id-field">
<label for="googleId">Google Books ID</label>
<label for="googleId">{{ t('googleBooksId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="googleId" formControlName="googleId"/>
@if (!book.metadata!['googleIdLocked']) {
@@ -689,7 +689,7 @@
}
@if (isFieldVisible('goodreadsId')) {
<div class="field-group metadata-id-field">
<label for="goodreadsId">Goodreads ID</label>
<label for="goodreadsId">{{ t('goodreadsId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/>
@if (!book.metadata!['goodreadsIdLocked']) {
@@ -703,7 +703,7 @@
}
@if (isFieldVisible('goodreadsRating')) {
<div class="field-group metadata-id-field">
<label for="goodreadsRating">Goodreads ★</label>
<label for="goodreadsRating">{{ t('goodreadsRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/>
@if (!book.metadata!['goodreadsRatingLocked']) {
@@ -717,7 +717,7 @@
}
@if (isFieldVisible('goodreadsReviewCount')) {
<div class="field-group metadata-id-field">
<label for="goodreadsReviewCount">Goodreads #</label>
<label for="goodreadsReviewCount">{{ t('goodreadsReviewCount') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/>
@if (!book.metadata!['goodreadsReviewCountLocked']) {
@@ -731,7 +731,7 @@
}
@if (isFieldVisible('hardcoverId')) {
<div class="field-group metadata-id-field">
<label for="hardcoverId">Hardcover ID</label>
<label for="hardcoverId">{{ t('hardcoverId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/>
@if (!book.metadata!['hardcoverIdLocked']) {
@@ -745,7 +745,7 @@
}
@if (isFieldVisible('hardcoverBookId')) {
<div class="field-group metadata-id-field">
<label for="hardcoverBookId">Hardcover Book ID</label>
<label for="hardcoverBookId">{{ t('hardcoverBookId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/>
@if (!book.metadata!['hardcoverBookIdLocked']) {
@@ -759,7 +759,7 @@
}
@if (isFieldVisible('hardcoverRating')) {
<div class="field-group metadata-id-field">
<label for="hardcoverRating">Hardcover ★</label>
<label for="hardcoverRating">{{ t('hardcoverRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/>
@if (!book.metadata!['hardcoverRatingLocked']) {
@@ -773,7 +773,7 @@
}
@if (isFieldVisible('hardcoverReviewCount')) {
<div class="field-group metadata-id-field">
<label for="hardcoverReviewCount">Hardcover #</label>
<label for="hardcoverReviewCount">{{ t('hardcoverReviewCount') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/>
@if (!book.metadata!['hardcoverReviewCountLocked']) {
@@ -787,7 +787,7 @@
}
@if (isFieldVisible('lubimyczytacId')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacId">Lubimyczytac ID</label>
<label for="lubimyczytacId">{{ t('lubimyczytacId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/>
@if (!book.metadata!['lubimyczytacIdLocked']) {
@@ -801,7 +801,7 @@
}
@if (isFieldVisible('lubimyczytacRating')) {
<div class="field-group metadata-id-field">
<label for="lubimyczytacRating">Lubimyczytac ★</label>
<label for="lubimyczytacRating">{{ t('lubimyczytacRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/>
@if (!book.metadata!['lubimyczytacRatingLocked']) {
@@ -815,7 +815,7 @@
}
@if (isFieldVisible('comicvineId')) {
<div class="field-group metadata-id-field">
<label for="comicvineId">Comicvine ID</label>
<label for="comicvineId">{{ t('comicvineId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/>
@if (!book.metadata!['comicvineIdLocked']) {
@@ -829,7 +829,7 @@
}
@if (isFieldVisible('ranobedbId')) {
<div class="field-group metadata-id-field">
<label for="ranobedbId">Ranobedb ID</label>
<label for="ranobedbId">{{ t('ranobedbId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/>
@if (!book.metadata!['ranobedbIdLocked']) {
@@ -843,7 +843,7 @@
}
@if (isFieldVisible('ranobedbRating')) {
<div class="field-group metadata-id-field">
<label for="ranobedbRating">Ranobedb ★</label>
<label for="ranobedbRating">{{ t('ranobedbRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/>
@if (!book.metadata!['ranobedbRatingLocked']) {
@@ -857,7 +857,7 @@
}
@if (isFieldVisible('audibleId')) {
<div class="field-group metadata-id-field">
<label for="audibleId">Audible ID</label>
<label for="audibleId">{{ t('audibleId') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleId" formControlName="audibleId"/>
@if (!book.metadata!['audibleIdLocked']) {
@@ -871,7 +871,7 @@
}
@if (isFieldVisible('audibleRating')) {
<div class="field-group metadata-id-field">
<label for="audibleRating">Audible ★</label>
<label for="audibleRating">{{ t('audibleRating') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleRating" formControlName="audibleRating"/>
@if (!book.metadata!['audibleRatingLocked']) {
@@ -885,7 +885,7 @@
}
@if (isFieldVisible('audibleReviewCount')) {
<div class="field-group metadata-id-field">
<label for="audibleReviewCount">Audible #</label>
<label for="audibleReviewCount">{{ t('audibleReviewCount') }}</label>
<div class="field-with-lock">
<input pSize="small" pInputText id="audibleReviewCount" formControlName="audibleReviewCount"/>
@if (!book.metadata!['audibleReviewCountLocked']) {
@@ -904,7 +904,7 @@
<div class="description-section">
<div class="field-group description-field">
<label for="description">Description</label>
<label for="description">{{ t('description') }}</label>
<div class="field-with-lock description-with-lock">
<textarea
id="description"
@@ -930,10 +930,10 @@
<div class="desktop-actions">
@if (showNavigationButtons) {
<div class="navigation-left">
<p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
<p-button [label]="t('closeBtn')" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
<p-divider layout="vertical"/>
<p-button label="Previous Book" [disabled]="disablePrevious" icon="pi pi-arrow-left" [outlined]="true" severity="info" (onClick)="onPrevious()"></p-button>
<p-button label="Next Book" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
<p-button [label]="t('previousBookBtn')" [disabled]="disablePrevious" icon="pi pi-arrow-left" [outlined]="true" severity="info" (onClick)="onPrevious()"></p-button>
<p-button [label]="t('nextBookBtn')" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
</div>
}
@@ -946,7 +946,7 @@
rounded
outlined
severity="info"
pTooltip="Go to previous book"
[pTooltip]="t('previousBookTooltip')"
tooltipPosition="bottom">
</p-button>
<span class="navigation-position">
@@ -960,7 +960,7 @@
severity="info"
rounded
outlined
pTooltip="Go to next book"
[pTooltip]="t('nextBookTooltip')"
tooltipPosition="bottom">
</p-button>
</div>
@@ -968,20 +968,20 @@
<div class="actions-right">
<p-button
[label]="isAutoFetching ? 'Fetching…' : 'Auto Fetch'"
[label]="isAutoFetching ? t('fetchingBtn') : t('autoFetchBtn')"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true"
severity="info"
(onClick)="autoFetch(book.id)"
[disabled]="isAutoFetching"
pTooltip="Automatically fetch metadata using default sources"
[pTooltip]="t('autoFetchTooltip')"
tooltipPosition="top">
</p-button>
<p-divider layout="vertical"/>
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" pTooltip="Unlock all metadata fields for editing" tooltipPosition="top"></p-button>
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" pTooltip="Lock all metadata fields to prevent changes" tooltipPosition="top"></p-button>
<p-button [label]="t('unlockAllBtn')" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" [pTooltip]="t('unlockAllTooltip')" tooltipPosition="top"></p-button>
<p-button [label]="t('lockAllBtn')" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" [pTooltip]="t('lockAllTooltip')" tooltipPosition="top"></p-button>
<p-divider layout="vertical"/>
<p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" (onClick)="onSave()"></p-button>
<p-button [label]="t('saveBtn')" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" (onClick)="onSave()"></p-button>
</div>
</div>
@@ -989,9 +989,9 @@
<div class="mobile-actions">
@if (showNavigationButtons) {
<div class="mobile-nav-buttons">
<p-button size="small" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" pTooltip="Close" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" pTooltip="Previous Book" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" pTooltip="Next Book" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()" [pTooltip]="t('closeBtn')" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-left" [disabled]="disablePrevious" [outlined]="true" severity="info" (onClick)="onPrevious()" [pTooltip]="t('previousBookBtn')" tooltipPosition="top"></p-button>
<p-button size="small" icon="pi pi-arrow-right" [disabled]="disableNext" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()" [pTooltip]="t('nextBookBtn')" tooltipPosition="top"></p-button>
</div>
}
@@ -1005,7 +1005,7 @@
rounded
outlined
severity="info"
pTooltip="Go to previous book"
[pTooltip]="t('previousBookTooltip')"
tooltipPosition="bottom">
</p-button>
<span class="navigation-position">
@@ -1019,7 +1019,7 @@
severity="info"
rounded
outlined
pTooltip="Go to next book"
[pTooltip]="t('nextBookTooltip')"
tooltipPosition="bottom">
</p-button>
</div>
@@ -1031,7 +1031,7 @@
severity="info"
(onClick)="autoFetch(book.id)"
[disabled]="isAutoFetching"
pTooltip="Auto Fetch"
[pTooltip]="t('autoFetchBtn')"
tooltipPosition="top">
</p-button>
@@ -1040,7 +1040,7 @@
[outlined]="true"
severity="success"
(onClick)="unlockAll()"
pTooltip="Unlock All"
[pTooltip]="t('unlockAllBtn')"
tooltipPosition="top">
</p-button>
@@ -1049,14 +1049,14 @@
[outlined]="true"
severity="warn"
(onClick)="lockAll()"
pTooltip="Lock All"
[pTooltip]="t('lockAllBtn')"
tooltipPosition="top">
</p-button>
</div>
<div class="mobile-save-action">
<p-button
label="Save"
[label]="t('saveBtn')"
icon="pi pi-check"
[loading]="isSaving"
[disabled]="isSaving"
@@ -31,6 +31,7 @@ import {Router} from '@angular/router';
import {UserService} from '../../../../settings/user-management/user.service';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: "app-metadata-editor",
@@ -53,6 +54,7 @@ import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-se
Image,
LazyLoadImageModule,
Select,
TranslocoDirective,
],
})
export class MetadataEditorComponent implements OnInit {
@@ -76,6 +78,7 @@ export class MetadataEditorComponent implements OnInit {
private userService = inject(UserService);
private destroyRef = inject(DestroyRef);
private appSettingsService = inject(AppSettingsService);
private readonly t = inject(TranslocoService);
metadataForm: FormGroup;
currentBookId!: number;
@@ -107,11 +110,7 @@ export class MetadataEditorComponent implements OnInit {
contentRatingOptions: {label: string, value: string}[] = [];
ageRatingOptions: {label: string, value: number}[] = [];
booleanOptions: {label: string, value: boolean | null}[] = [
{label: 'Unknown', value: null},
{label: 'Yes', value: true},
{label: 'No', value: false},
];
booleanOptions: {label: string, value: boolean | null}[] = [];
comicSectionExpanded = true;
audiobookSectionExpanded = true;
@@ -272,16 +271,22 @@ export class MetadataEditorComponent implements OnInit {
contentRatingLocked: new FormControl(false),
});
this.booleanOptions = [
{label: this.t.translate('metadata.editor.booleanUnknown'), value: null},
{label: this.t.translate('metadata.editor.booleanYes'), value: true},
{label: this.t.translate('metadata.editor.booleanNo'), value: false},
];
this.contentRatingOptions = [
{label: 'Everyone', value: 'EVERYONE'},
{label: 'Teen', value: 'TEEN'},
{label: 'Mature', value: 'MATURE'},
{label: 'Adult', value: 'ADULT'},
{label: 'Explicit', value: 'EXPLICIT'}
{label: this.t.translate('metadata.editor.contentRatingEveryone'), value: 'EVERYONE'},
{label: this.t.translate('metadata.editor.contentRatingTeen'), value: 'TEEN'},
{label: this.t.translate('metadata.editor.contentRatingMature'), value: 'MATURE'},
{label: this.t.translate('metadata.editor.contentRatingAdult'), value: 'ADULT'},
{label: this.t.translate('metadata.editor.contentRatingExplicit'), value: 'EXPLICIT'}
];
this.ageRatingOptions = [
{label: 'All Ages', value: 0},
{label: this.t.translate('metadata.editor.ageRatingAllAges'), value: 0},
{label: '6+', value: 6},
{label: '10+', value: 10},
{label: '13+', value: 13},
@@ -601,8 +606,8 @@ export class MetadataEditorComponent implements OnInit {
this.isSaving = false;
this.messageService.add({
severity: "info",
summary: "Success",
detail: "Book metadata updated",
summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: this.t.translate('metadata.editor.toast.metadataUpdated'),
});
this.prepareAutoComplete();
this.metadataForm.markAsPristine();
@@ -611,8 +616,8 @@ export class MetadataEditorComponent implements OnInit {
this.isSaving = false;
this.messageService.add({
severity: "error",
summary: "Error",
detail: err?.error?.message || "Failed to update book metadata",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || this.t.translate('metadata.editor.toast.metadataUpdateFailed'),
});
},
})
@@ -855,19 +860,19 @@ export class MetadataEditorComponent implements OnInit {
this.messageService.add({
severity: "success",
summary: shouldLockAllFields
? "Metadata Locked"
: "Metadata Unlocked",
? this.t.translate('metadata.editor.toast.metadataLocked')
: this.t.translate('metadata.editor.toast.metadataUnlocked'),
detail: shouldLockAllFields
? "All fields have been successfully locked."
: "All fields have been successfully unlocked.",
? this.t.translate('metadata.editor.toast.allFieldsLocked')
: this.t.translate('metadata.editor.toast.allFieldsUnlocked'),
});
}
},
error: () => {
this.messageService.add({
severity: "error",
summary: "Error",
detail: "Failed to update lock state",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: this.t.translate('metadata.editor.toast.lockStateFailed'),
});
},
});
@@ -890,8 +895,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false;
this.messageService.add({
severity: "error",
summary: "Upload Failed",
detail: "An error occurred while uploading the cover",
summary: this.t.translate('metadata.editor.toast.uploadFailedSummary'),
detail: this.t.translate('metadata.editor.toast.uploadFailedDetail'),
life: 3000,
});
}
@@ -901,8 +906,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false;
this.messageService.add({
severity: "error",
summary: "Upload Error",
detail: "An error occurred while uploading the cover",
summary: this.t.translate('metadata.editor.toast.uploadErrorSummary'),
detail: this.t.translate('metadata.editor.toast.uploadErrorDetail'),
life: 3000,
});
}
@@ -915,15 +920,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({
severity: "success",
summary: "Success",
detail: "Book cover regenerated successfully.",
summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: this.t.translate('metadata.editor.toast.coverRegenerated'),
});
},
error: () => {
this.messageService.add({
severity: "warning",
summary: "Partial Success",
detail: "Cover regenerated but failed to refresh display. Please refresh the page.",
summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: this.t.translate('metadata.editor.toast.coverRegenPartialDetail'),
});
},
});
@@ -931,8 +936,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => {
this.messageService.add({
severity: "error",
summary: "Error",
detail: err?.error?.message || "Failed to regenerate cover",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || this.t.translate('metadata.editor.toast.coverRegenFailed'),
});
}
});
@@ -949,15 +954,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({
severity: "success",
summary: "Success",
detail: "Custom cover generated successfully.",
summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: this.t.translate('metadata.editor.toast.customCoverGenerated'),
});
},
error: () => {
this.messageService.add({
severity: "warning",
summary: "Partial Success",
detail: "Cover generated but failed to refresh display. Please refresh the page.",
summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: this.t.translate('metadata.editor.toast.customCoverPartialDetail'),
});
},
});
@@ -965,8 +970,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => {
this.messageService.add({
severity: "error",
summary: "Error",
detail: "Failed to generate custom cover",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: this.t.translate('metadata.editor.toast.customCoverFailed'),
});
}
});
@@ -980,15 +985,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({
severity: "success",
summary: "Success",
detail: "Audiobook cover regenerated successfully.",
summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: this.t.translate('metadata.editor.toast.audiobookCoverRegenerated'),
});
},
error: () => {
this.messageService.add({
severity: "warning",
summary: "Partial Success",
detail: "Cover regenerated but failed to refresh display. Please refresh the page.",
summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: this.t.translate('metadata.editor.toast.audiobookCoverRegenPartialDetail'),
});
},
});
@@ -996,8 +1001,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => {
this.messageService.add({
severity: "error",
summary: "Error",
detail: err?.error?.message || "Failed to regenerate audiobook cover",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || this.t.translate('metadata.editor.toast.audiobookCoverRegenFailed'),
});
}
});
@@ -1014,15 +1019,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({
severity: "success",
summary: "Success",
detail: "Custom audiobook cover generated successfully.",
summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: this.t.translate('metadata.editor.toast.customAudiobookCoverGenerated'),
});
},
error: () => {
this.messageService.add({
severity: "warning",
summary: "Partial Success",
detail: "Cover generated but failed to refresh display. Please refresh the page.",
summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: this.t.translate('metadata.editor.toast.customAudiobookCoverPartialDetail'),
});
},
});
@@ -1030,8 +1035,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => {
this.messageService.add({
severity: "error",
summary: "Error",
detail: "Failed to generate custom audiobook cover",
summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: this.t.translate('metadata.editor.toast.customAudiobookCoverFailed'),
});
}
});
@@ -1131,7 +1136,7 @@ export class MetadataEditorComponent implements OnInit {
getNavigationPosition(): string {
const position = this.bookNavigationService.getCurrentPosition();
return position ? `${position.current} of ${position.total}` : '';
return position ? this.t.translate('metadata.editor.navigationPosition', {current: position.current, total: position.total}) : '';
}
isFieldVisible(field: keyof MetadataProviderSpecificFields): boolean {
@@ -1201,8 +1206,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false;
this.messageService.add({
severity: 'error',
summary: 'Upload Failed',
detail: 'An error occurred while uploading the audiobook cover',
summary: this.t.translate('metadata.editor.toast.uploadFailedSummary'),
detail: this.t.translate('metadata.editor.toast.audiobookUploadFailed'),
life: 3000,
});
}
@@ -1,10 +1,10 @@
@if (book$ | async; as book) {
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="metadata-picker">
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="metadata-picker" *transloco="let t; prefix: 'metadata.picker'">
<div class="dialog-body">
@if (detailLoading) {
<div class="detail-loading-banner">
<i class="pi pi-spin pi-spinner"></i>
<span>Loading complete metadata...</span>
<span>{{ t('loadingMetadata') }}</span>
</div>
}
@@ -12,7 +12,7 @@
<div class="column-headers desktop-only">
<div class="column-label current">
<i class="pi pi-file-edit"></i>
<span>Current</span>
<span>{{ t('columnCurrent') }}</span>
</div>
<div class="column-actions">
<p-button
@@ -20,7 +20,7 @@
[rounded]="true"
[outlined]="true"
severity="secondary"
pTooltip="Copy missing fields"
[pTooltip]="t('copyMissingTooltip')"
tooltipPosition="bottom"
(onClick)="copyMissing()"
/>
@@ -29,14 +29,14 @@
[rounded]="true"
[outlined]="true"
severity="primary"
pTooltip="Copy all fields"
[pTooltip]="t('copyAllTooltip')"
tooltipPosition="bottom"
(onClick)="copyAll()"
/>
</div>
<div class="column-label fetched">
<i class="pi pi-cloud-download"></i>
<span>Fetched</span>
<span>{{ t('columnFetched') }}</span>
</div>
</div>
@@ -44,7 +44,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-image"></i>
<span>Cover Image</span>
<span>{{ t('sectionCoverImage') }}</span>
</div>
<div class="section-content" [class.dual-covers-section]="currentBook && supportsDualCovers(currentBook)">
@@ -53,19 +53,19 @@
<div class="field-row cover-field-row">
<label class="field-label">
@if (currentBook && supportsDualCovers(currentBook)) {
<i class="pi pi-book cover-type-icon"></i> Ebook
<i class="pi pi-book cover-type-icon"></i> {{ t('coverLabelEbook') }}
} @else {
Cover
{{ t('coverLabel') }}
}
</label>
<div class="field-content">
<div class="field-side current cover-side">
<span class="cover-label mobile-only">Current</span>
<span class="cover-label mobile-only">{{ t('mobileCurrentLabel') }}</span>
<div class="cover-wrapper">
<p-image
class="cover-image"
[src]="metadataForm.get('thumbnailUrl')?.value"
alt="Current cover"
[alt]="t('currentCoverAlt')"
appendTo="body"
lazyLoad
[preview]="true"
@@ -75,7 +75,7 @@
class="lock-badge"
[class.locked]="metadataForm.get('coverLocked')?.value"
(click)="toggleLock('thumbnailUrl')"
[pTooltip]="metadataForm.get('coverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
[pTooltip]="metadataForm.get('coverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
tooltipPosition="top"
>
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
@@ -97,12 +97,12 @@
</button>
<div class="field-side fetched cover-side">
<span class="cover-label mobile-only">Fetched</span>
<span class="cover-label mobile-only">{{ t('mobileFetchedLabel') }}</span>
<div class="cover-wrapper">
<p-image
class="cover-image"
[src]="fetchedMetadata.thumbnailUrl!"
alt="Fetched cover"
[alt]="t('fetchedCoverAlt')"
appendTo="body"
lazyLoad
[preview]="true"
@@ -117,16 +117,16 @@
@if (currentBook && hasAudiobookFormat(currentBook)) {
<div class="field-row cover-field-row audiobook-cover-row">
<label class="field-label">
<i class="pi pi-headphones cover-type-icon"></i> Audiobook
<i class="pi pi-headphones cover-type-icon"></i> {{ t('coverLabelAudiobook') }}
</label>
<div class="field-content">
<div class="field-side current cover-side">
<span class="cover-label mobile-only">Current</span>
<span class="cover-label mobile-only">{{ t('mobileCurrentLabel') }}</span>
<div class="cover-wrapper">
<p-image
class="cover-image square-cover"
[src]="metadataForm.get('audiobookThumbnailUrl')?.value"
alt="Current audiobook cover"
[alt]="t('currentAudiobookCoverAlt')"
appendTo="body"
lazyLoad
[preview]="true"
@@ -136,7 +136,7 @@
class="lock-badge"
[class.locked]="metadataForm.get('audiobookCoverLocked')?.value"
(click)="toggleLock('audiobookThumbnailUrl')"
[pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? 'Unlock cover' : 'Lock cover'"
[pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
tooltipPosition="top"
>
<i [class]="metadataForm.get('audiobookCoverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
@@ -162,13 +162,13 @@
}
<div class="field-side fetched cover-side">
<span class="cover-label mobile-only">Fetched</span>
<span class="cover-label mobile-only">{{ t('mobileFetchedLabel') }}</span>
<div class="cover-wrapper">
@if (isAudibleProvider()) {
<p-image
class="cover-image square-cover"
[src]="fetchedMetadata.thumbnailUrl!"
alt="Fetched audiobook cover"
[alt]="t('fetchedAudiobookCoverAlt')"
appendTo="body"
lazyLoad
[preview]="true"
@@ -176,7 +176,7 @@
} @else {
<div class="no-cover-placeholder">
<i class="pi pi-image"></i>
<span>N/A</span>
<span>{{ t('na') }}</span>
</div>
}
</div>
@@ -191,7 +191,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-info-circle"></i>
<span>Basic Information</span>
<span>{{ t('sectionBasicInfo') }}</span>
</div>
<div class="section-content">
@@ -241,7 +241,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-tags"></i>
<span>Tags & Categories</span>
<span>{{ t('sectionTagsCategories') }}</span>
</div>
<div class="section-content">
@@ -307,7 +307,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-align-left"></i>
<span>Description</span>
<span>{{ t('sectionDescription') }}</span>
</div>
<div class="section-content">
@@ -353,7 +353,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-book"></i>
<span>Series Information</span>
<span>{{ t('sectionSeriesInfo') }}</span>
</div>
<div class="section-content">
@@ -399,7 +399,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-id-card"></i>
<span>Book Details</span>
<span>{{ t('sectionBookDetails') }}</span>
</div>
<div class="section-content">
@@ -446,9 +446,9 @@
<section class="form-section">
<div class="section-header collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i>
<span>Comic Book Details</span>
<span>{{ t('sectionComicDetails') }}</span>
@if (!hasAnyFetchedComicData() && !hasAnyCurrentComicData()) {
<span class="section-empty-badge">none present</span>
<span class="section-empty-badge">{{ t('nonePresent') }}</span>
}
<i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div>
@@ -613,7 +613,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-headphones"></i>
<span>Audiobook Details</span>
<span>{{ t('sectionAudiobookDetails') }}</span>
</div>
<div class="section-content">
@@ -679,7 +679,7 @@
<section class="form-section">
<div class="section-header">
<i class="pi pi-cloud"></i>
<span>Provider Metadata</span>
<span>{{ t('sectionProviderMetadata') }}</span>
</div>
<div class="section-content">
@@ -727,7 +727,7 @@
<footer class="dialog-footer">
<div class="footer-left">
<p-button
label="Back to List"
[label]="t('backToListBtn')"
icon="pi pi-arrow-left"
severity="info"
[outlined]="true"
@@ -739,7 +739,7 @@
icon="pi pi-lock-open"
severity="success"
[outlined]="true"
pTooltip="Unlock all fields"
[pTooltip]="t('unlockAllTooltip')"
tooltipPosition="top"
(onClick)="unlockAll()"
/>
@@ -747,13 +747,13 @@
icon="pi pi-lock"
severity="warn"
[outlined]="true"
pTooltip="Lock all fields"
[pTooltip]="t('lockAllTooltip')"
tooltipPosition="top"
(onClick)="lockAll()"
/>
<div class="footer-divider"></div>
<p-button
label="Save Changes"
[label]="t('saveChangesBtn')"
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="isSaving"
[disabled]="isSaving"
@@ -19,6 +19,7 @@ import {LazyLoadImageModule} from 'ng-lazyload-image';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
import {ALL_COMIC_METADATA_FIELDS, ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, COMIC_ARRAY_METADATA_FIELDS, COMIC_FORM_TO_MODEL_LOCK, COMIC_TEXT_METADATA_FIELDS, COMIC_TEXTAREA_METADATA_FIELDS, getArrayFields, getBookDetailsFields, getBottomFields, getProviderFields, getSeriesFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-picker',
@@ -36,7 +37,8 @@ import {ALL_COMIC_METADATA_FIELDS, ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELD
AutoComplete,
Image,
LazyLoadImageModule,
Checkbox
Checkbox,
TranslocoDirective
]
})
export class MetadataPickerComponent implements OnInit {
@@ -81,6 +83,7 @@ export class MetadataPickerComponent implements OnInit {
private appSettingsService = inject(AppSettingsService);
private formBuilder = inject(MetadataFormBuilder);
private metadataUtils = inject(MetadataUtilsService);
private readonly t = inject(TranslocoService);
private enabledProviderFields: MetadataProviderSpecificFields | null = null;
@@ -303,11 +306,11 @@ export class MetadataPickerComponent implements OnInit {
this.savedFields[field] = true;
}
}
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
this.messageService.add({severity: 'info', summary: this.t.translate('metadata.picker.toast.successSummary'), detail: this.t.translate('metadata.picker.toast.metadataUpdated')});
},
error: () => {
this.isSaving = false;
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book metadata'});
this.messageService.add({severity: 'error', summary: this.t.translate('metadata.picker.toast.errorSummary'), detail: this.t.translate('metadata.picker.toast.metadataUpdateFailed')});
}
});
}
@@ -517,18 +520,18 @@ export class MetadataPickerComponent implements OnInit {
if (shouldLockAllFields !== undefined) {
this.messageService.add({
severity: 'success',
summary: shouldLockAllFields ? 'Metadata Locked' : 'Metadata Unlocked',
summary: shouldLockAllFields ? this.t.translate('metadata.picker.toast.metadataLocked') : this.t.translate('metadata.picker.toast.metadataUnlocked'),
detail: shouldLockAllFields
? 'All fields have been successfully locked.'
: 'All fields have been successfully unlocked.',
? this.t.translate('metadata.picker.toast.allFieldsLocked')
: this.t.translate('metadata.picker.toast.allFieldsUnlocked'),
});
}
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to update lock state',
summary: this.t.translate('metadata.picker.toast.errorSummary'),
detail: this.t.translate('metadata.picker.toast.lockStateFailed'),
});
}
});
@@ -603,8 +606,8 @@ export class MetadataPickerComponent implements OnInit {
if (isLocked) {
this.messageService.add({
severity: 'warn',
summary: 'Action Blocked',
detail: `${comicConfig.label} is locked and cannot be updated.`
summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: comicConfig.label})
});
return;
}
@@ -627,8 +630,8 @@ export class MetadataPickerComponent implements OnInit {
if (isLocked) {
this.messageService.add({
severity: 'warn',
summary: 'Action Blocked',
detail: `${lockField} is locked and cannot be updated.`
summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: lockField})
});
return;
}
@@ -8,20 +8,20 @@
</app-metadata-picker>
</div>
} @else {
<div class="searcher-container">
<div class="searcher-container" *transloco="let t; prefix: 'metadata.searcher'">
<form [formGroup]="form" (ngSubmit)="onSubmit()" class="search-card">
<div class="search-grid">
<div class="search-field search-field-provider">
<label>
<i class="pi pi-globe"></i>
Providers
{{ t('providers') }}
</label>
<p-multiselect
[filter]="false"
showToggleAll="false"
[options]="providers"
formControlName="provider"
placeholder="Select providers"
[placeholder]="t('selectProviders')"
class="'custom-multiselect'">
</p-multiselect>
</div>
@@ -29,10 +29,10 @@
<div class="search-field">
<label>
<i class="pi pi-barcode"></i>
ISBN
{{ t('isbn') }}
<i
class="pi pi-info-circle"
pTooltip="ISBN takes priority. Without ISBN, search uses Title and Author."
[pTooltip]="t('isbnTooltip')"
tooltipPosition="right"
style="margin-left: 0.25rem; color: var(--primary-color); cursor: pointer;"
></i>
@@ -40,37 +40,37 @@
<input
pInputText
formControlName="isbn"
placeholder="ISBN-10 or ISBN-13"
[placeholder]="t('isbnPlaceholder')"
class="custom-input"/>
</div>
<div class="search-field">
<label>
<i class="pi pi-book"></i>
Title
{{ t('title') }}
</label>
<input
pInputText
formControlName="title"
placeholder="Book title"
[placeholder]="t('titlePlaceholder')"
class="custom-input"/>
</div>
<div class="search-field">
<label>
<i class="pi pi-user"></i>
Author
{{ t('author') }}
</label>
<input
pInputText
formControlName="author"
placeholder="Author name"
[placeholder]="t('authorPlaceholder')"
class="custom-input"/>
</div>
<div class="search-field search-button-field">
<p-button
label="Search"
[label]="t('search')"
type="submit"
[disabled]="!isSearchEnabled || loading"
icon="pi pi-search"
@@ -86,14 +86,14 @@
<div class="results-info">
<h3>
<i class="pi pi-list"></i>
Search Results
{{ t('searchResults') }}
</h3>
<span class="results-count">{{ filteredMetadata.length }} books found</span>
<span class="results-count">{{ t('booksFound', { count: filteredMetadata.length }) }}</span>
</div>
@if (loading) {
<span class="fetching-badge">
<i class="pi pi-spin pi-spinner"></i>
Fetching...
{{ t('fetching') }}
</span>
}
</div>
@@ -127,8 +127,8 @@
<div class="empty-icon">
<i class="pi pi-search"></i>
</div>
<h3>Ready to Search</h3>
<p>Enter your search criteria above and click Search to find metadata</p>
<h3>{{ t('readyToSearch') }}</h3>
<p>{{ t('readyToSearchDescription') }}</p>
</div>
}
@@ -137,8 +137,8 @@
<div class="empty-icon no-results">
<i class="pi pi-inbox"></i>
</div>
<h3>No Results Found</h3>
<p>Try adjusting your search criteria or selecting different providers</p>
<h3>{{ t('noResultsFound') }}</h3>
<p>{{ t('noResultsDescription') }}</p>
</div>
}
@@ -154,7 +154,7 @@
loading="lazy"/>
<div class="card-overlay">
<i class="pi pi-eye"></i>
<span>Select</span>
<span>{{ t('select') }}</span>
</div>
</div>
@@ -16,6 +16,7 @@ import {AsyncPipe} from '@angular/common';
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
import {BookMetadataService} from '../../../../book/service/book-metadata.service';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-searcher',
@@ -29,7 +30,8 @@ import {Tooltip} from 'primeng/tooltip';
MetadataPickerComponent,
MultiSelect,
AsyncPipe,
Tooltip
Tooltip,
TranslocoDirective
],
standalone: true
})
@@ -1,29 +1,30 @@
<ng-container *transloco="let t; prefix: 'metadata.tabs'">
<p-tabs lazy class="custom-p-tabs" [value]="defaultTabValue" scrollable>
<p-tablist>
@if (bookInSeries.length > 1) {
<p-tab value="series">
<i class="pi pi-ethereum"></i> More in Series
<i class="pi pi-ethereum"></i> {{ t('moreInSeries') }}
</p-tab>
}
<p-tab value="similar">
<i class="pi pi-bookmark"></i> Similar Books
<i class="pi pi-bookmark"></i> {{ t('similarBooks') }}
</p-tab>
@if (supportsDualCovers()) {
<p-tab value="covers">
<i class="pi pi-images"></i> Covers
<i class="pi pi-images"></i> {{ t('covers') }}
</p-tab>
}
<p-tab value="files">
<i class="pi pi-folder-open"></i> Files
<i class="pi pi-folder-open"></i> {{ t('files') }}
</p-tab>
<p-tab value="notes">
<i class="pi pi-pen-to-square"></i> Notes
<i class="pi pi-pen-to-square"></i> {{ t('notes') }}
</p-tab>
<p-tab value="sessions">
<i class="pi pi-clock"></i> Reading Sessions
<i class="pi pi-clock"></i> {{ t('readingSessions') }}
</p-tab>
<p-tab value="reviews">
<i class="pi pi-comments"></i> Reviews
<i class="pi pi-comments"></i> {{ t('reviews') }}
</p-tab>
</p-tablist>
<p-tabpanels>
@@ -65,11 +66,11 @@
<div class="covers-grid">
<div class="cover-item">
<div class="cover-label">
<i class="pi pi-book"></i> Ebook Cover
<i class="pi pi-book"></i> {{ t('ebookCover') }}
</div>
<p-image
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
alt="Ebook Cover"
[alt]="t('ebookCover')"
width="200"
appendTo="body"
[preview]="true">
@@ -77,11 +78,11 @@
</div>
<div class="cover-item">
<div class="cover-label audiobook">
<i class="pi pi-headphones"></i> Audiobook Cover
<i class="pi pi-headphones"></i> {{ t('audiobookCover') }}
</div>
<p-image
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
alt="Audiobook Cover"
[alt]="t('audiobookCover')"
width="200"
appendTo="body"
[preview]="true"
@@ -113,27 +114,27 @@
@if (isPhysicalBook()) {
<div class="empty-state">
<i class="pi pi-book empty-state-icon"></i>
<h4 class="empty-state-title">Physical Book</h4>
<p class="empty-state-message">This is a physical book. No digital files are associated with this book.</p>
<p class="empty-state-hint">You can upload a digital version using the "Upload File" option in the menu.</p>
<h4 class="empty-state-title">{{ t('physicalBook') }}</h4>
<p class="empty-state-message">{{ t('physicalBookMessage') }}</p>
<p class="empty-state-hint">{{ t('physicalBookHint') }}</p>
</div>
} @else {
@if (hasMultipleFiles(book)) {
<div class="files-section download-all-section">
<p-button
label="Download All ({{ getTotalFileCount(book) }} files)"
[label]="t('downloadAll', { count: getTotalFileCount(book) })"
icon="pi pi-download"
severity="info"
outlined
(onClick)="downloadAll(book)"
pTooltip="Download all files as a ZIP archive"
[pTooltip]="t('downloadAllTooltip')"
tooltipPosition="top">
</p-button>
</div>
}
@if (book.primaryFile) {
<div class="files-section">
<h4 class="files-section-title">Primary File</h4>
<h4 class="files-section-title">{{ t('primaryFile') }}</h4>
<div class="files-list">
<div class="file-item primary-file">
<div class="file-info">
@@ -150,7 +151,7 @@
size="small"
text
severity="primary"
pTooltip="Read"
[pTooltip]="t('read')"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
@@ -159,7 +160,7 @@
size="small"
text
severity="info"
pTooltip="Streaming Reader"
[pTooltip]="t('streamingReader')"
tooltipPosition="top"
(onClick)="read(book.id, 'pdf-streaming')">
</p-button>
@@ -169,7 +170,7 @@
size="small"
text
severity="primary"
pTooltip="Read"
[pTooltip]="t('read')"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
@@ -178,7 +179,7 @@
size="small"
text
severity="info"
pTooltip="Streaming Reader"
[pTooltip]="t('streamingReader')"
tooltipPosition="top"
(onClick)="read(book.id, 'epub-streaming')">
</p-button>
@@ -188,7 +189,7 @@
size="small"
text
severity="primary"
pTooltip="Read"
[pTooltip]="t('read')"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
@@ -198,7 +199,7 @@
size="small"
text
severity="primary"
pTooltip="Play"
[pTooltip]="t('play')"
tooltipPosition="top"
(onClick)="read(book.id)">
</p-button>
@@ -208,7 +209,7 @@
size="small"
text
severity="success"
pTooltip="Download"
[pTooltip]="t('download')"
tooltipPosition="top"
(onClick)="download(book)">
</p-button>
@@ -217,7 +218,7 @@
size="small"
text
severity="danger"
pTooltip="Delete"
[pTooltip]="t('delete')"
tooltipPosition="top"
(onClick)="deleteFile(book, book.primaryFile!.id, book.primaryFile!.fileName || 'file', true)">
</p-button>
@@ -228,7 +229,7 @@
}
@if (book.alternativeFormats && book.alternativeFormats.length > 0) {
<div class="files-section">
<h4 class="files-section-title">Alternative Formats</h4>
<h4 class="files-section-title">{{ t('alternativeFormats') }}</h4>
<div class="files-list">
@for (format of book.alternativeFormats; track format.id) {
<div class="file-item">
@@ -246,7 +247,7 @@
size="small"
text
severity="primary"
pTooltip="Read"
[pTooltip]="t('read')"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
@@ -255,7 +256,7 @@
size="small"
text
severity="info"
pTooltip="Streaming Reader"
[pTooltip]="t('streamingReader')"
tooltipPosition="top"
(onClick)="read(book.id, format.bookType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', format.bookType)">
</p-button>
@@ -265,7 +266,7 @@
size="small"
text
severity="primary"
pTooltip="Read"
[pTooltip]="t('read')"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
@@ -275,7 +276,7 @@
size="small"
text
severity="primary"
pTooltip="Play"
[pTooltip]="t('play')"
tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)">
</p-button>
@@ -285,7 +286,7 @@
size="small"
text
severity="success"
pTooltip="Download"
[pTooltip]="t('download')"
tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, format.id)">
</p-button>
@@ -294,7 +295,7 @@
size="small"
text
severity="danger"
pTooltip="Delete"
[pTooltip]="t('delete')"
tooltipPosition="top"
(onClick)="deleteFile(book, format.id, format.fileName || 'file', false)">
</p-button>
@@ -306,7 +307,7 @@
}
@if (book.supplementaryFiles && book.supplementaryFiles.length > 0) {
<div class="files-section">
<h4 class="files-section-title">Supplementary Files</h4>
<h4 class="files-section-title">{{ t('supplementaryFiles') }}</h4>
<div class="files-list">
@for (file of book.supplementaryFiles; track file.id) {
<div class="file-item">
@@ -321,7 +322,7 @@
size="small"
text
severity="success"
pTooltip="Download"
[pTooltip]="t('download')"
tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, file.id)">
</p-button>
@@ -330,7 +331,7 @@
size="small"
text
severity="danger"
pTooltip="Delete"
[pTooltip]="t('delete')"
tooltipPosition="top"
(onClick)="deleteSupplementary(book.id, file.id, file.fileName || 'file')">
</p-button>
@@ -346,3 +347,4 @@
</p-tabpanel>
</p-tabpanels>
</p-tabs>
</ng-container>
@@ -12,6 +12,7 @@ import {Tooltip} from 'primeng/tooltip';
import {Image} from 'primeng/image';
import {UrlHelperService} from '../../../../../../shared/service/url-helper.service';
import {BookService} from '../../../../../book/service/book.service';
import {TranslocoDirective} from '@jsverse/transloco';
export interface ReadEvent {
bookId: number;
@@ -63,7 +64,8 @@ export interface DeleteSupplementaryFileEvent {
Button,
Tooltip,
UpperCasePipe,
Image
Image,
TranslocoDirective
],
templateUrl: './metadata-tabs.component.html',
styleUrl: './metadata-tabs.component.scss'
@@ -1,5 +1,5 @@
@if (book$ | async; as book) {
<div class="metadata-viewer-container">
<div class="metadata-viewer-container" *transloco="let t; prefix: 'metadata.viewer'">
<div class="metadata-header">
<div class="cover-section">
@@ -70,7 +70,7 @@
rounded
outlined
severity="info"
pTooltip="Go to previous book"
[pTooltip]="t('goToPreviousBook')"
tooltipPosition="bottom">
</p-button>
<span class="navigation-position">
@@ -84,7 +84,7 @@
severity="info"
rounded
outlined
pTooltip="Go to next book"
[pTooltip]="t('goToNextBook')"
tooltipPosition="bottom">
</p-button>
</div>
@@ -114,7 +114,7 @@
<i
class="pi lock-icon"
[ngClass]="isMetadataFullyLocked(book?.metadata!) ? 'pi-lock locked' : 'pi-lock-open unlocked'"
[pTooltip]="isMetadataFullyLocked(book?.metadata!) ? 'This book metadata is locked.' : 'This book metadata is unlocked.'"
[pTooltip]="isMetadataFullyLocked(book?.metadata!) ? t('metadataLocked') : t('metadataUnlocked')"
tooltipPosition="top"
></i>
</div>
@@ -134,7 +134,7 @@
<div class="personal-rating">
<div class="rating-group">
<i class="pi pi-thumbs-up-fill rating-icon" pTooltip="Personal Rating" tooltipPosition="top"></i>
<i class="pi pi-thumbs-up-fill rating-icon" [pTooltip]="t('personalRating')" tooltipPosition="top"></i>
<p-rating
[ngModel]="book?.personalRating"
(onRate)="onPersonalRatingChange(book, $event)"
@@ -148,7 +148,7 @@
icon="pi pi-undo"
severity="warn"
(onClick)="resetPersonalRating(book)"
pTooltip="Reset Rating"
[pTooltip]="t('resetRating')"
tooltipPosition="top"
class="reset-button">
</p-button>
@@ -270,7 +270,7 @@
<div class="tags-section">
@if (book?.metadata?.categories?.length) {
<div class="tag-row">
<span class="tag-label">Genres:</span>
<span class="tag-label">{{ t('genres') }}</span>
<div class="tag-scroll">
<div class="tag-container">
@for (category of book.metadata!.categories; track category) {
@@ -285,7 +285,7 @@
@if (book?.metadata?.moods?.length) {
<div class="tag-row">
<span class="tag-label">Moods:</span>
<span class="tag-label">{{ t('moods') }}</span>
<div class="tag-scroll">
<div class="tag-container">
@for (mood of book.metadata!.moods; track mood) {
@@ -300,7 +300,7 @@
@if (book?.metadata?.tags?.length) {
<div class="tag-row">
<span class="tag-label">Tags:</span>
<span class="tag-label">{{ t('tags') }}</span>
<div class="tag-scroll">
<div class="tag-container">
@for (tag of book.metadata!.tags; track tag) {
@@ -316,7 +316,7 @@
<div class="metadata-grid">
<div class="metadata-item">
<span class="metadata-key">Library:</span>
<span class="metadata-key">{{ t('library') }}</span>
@if (book?.libraryName) {
<span class="metadata-value metadata-link" (click)="goToLibrary(book.libraryId!)">
{{ book?.libraryName }}
@@ -327,7 +327,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Publisher:</span>
<span class="metadata-key">{{ t('publisher') }}</span>
@if (book?.metadata?.publisher) {
<span class="metadata-value metadata-link" (click)="goToPublisher(book?.metadata?.publisher!)">
{{ book?.metadata?.publisher }}
@@ -338,7 +338,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Published:</span>
<span class="metadata-key">{{ t('published') }}</span>
@if (book?.metadata!.publishedDate) {
<span class="metadata-value metadata-link" (click)="goToPublishedYear(book?.metadata!.publishedDate!)">
{{ book?.metadata!.publishedDate }}
@@ -349,7 +349,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Language:</span>
<span class="metadata-key">{{ t('language') }}</span>
@if (book?.metadata!.language) {
<span class="metadata-value metadata-link" (click)="goToLanguage(book?.metadata!.language!)">
{{ book?.metadata!.language }}
@@ -360,14 +360,14 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Formats:</span>
<span class="metadata-key">{{ t('formats') }}</span>
<span class="metadata-value-group format-tags">
@if (getDisplayFormat(book?.primaryFile); as displayFormat) {
<span class="format-tag-wrapper primary-format" (click)="goToFileType(book?.primaryFile?.filePath)" [pTooltip]="book?.primaryFile?.fileName ?? ''" tooltipPosition="top">
<app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(displayFormat)" customTextColor="#fff">
{{ displayFormat }}
</app-tag>
<span class="format-badge">PRIMARY</span>
<span class="format-badge">{{ t('primary') }}</span>
</span>
}
@for (formatExt of getUniqueAlternativeFormats(book); track formatExt) {
@@ -378,20 +378,20 @@
</span>
}
@if (!book?.primaryFile?.filePath && !book?.alternativeFormats?.length) {
<app-tag size="3xs" variant="pill" [customBgColor]="'var(--book-type-physical-color)'" customTextColor="#fff">PHYSICAL</app-tag>
<app-tag size="3xs" variant="pill" [customBgColor]="'var(--book-type-physical-color)'" customTextColor="#fff">{{ t('physical') }}</app-tag>
}
</span>
</div>
<div class="metadata-item">
<span class="metadata-key">BookLore Progress:</span>
<span class="metadata-key">{{ t('bookloreProgress') }}</span>
<span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getProgressColor(getProgressPercent(book))">
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
</app-tag>
@if (getProgressPercent(book) !== null) {
<p-button
pTooltip="Reset progress"
[pTooltip]="t('resetProgress')"
tooltipPosition="bottom"
icon="pi pi-refresh"
size="small"
@@ -405,7 +405,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Metadata Match:</span>
<span class="metadata-key">{{ t('metadataMatch') }}</span>
@if (book?.metadataMatchScore != null) {
<span (click)="goToMatchScoreRange(book?.metadataMatchScore!)" style="cursor: pointer;">
<app-tag size="3xs" variant="pill" [color]="getMatchScoreColor(book?.metadataMatchScore!)">
@@ -418,7 +418,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">ISBN:</span>
<span class="metadata-key">{{ t('isbnLabel') }}</span>
@if (book?.metadata?.isbn13 || book?.metadata?.isbn10) {
<span class="metadata-value">
{{ book.metadata!.isbn13 }}
@@ -433,7 +433,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Read Status:</span>
<span class="metadata-key">{{ t('readStatus') }}</span>
<span class="metadata-value-group">
<span (click)="goToReadStatus(selectedReadStatus)" style="cursor: pointer;">
<app-tag size="3xs" variant="pill" [color]="getStatusColor(selectedReadStatus)">
@@ -447,13 +447,13 @@
@if (book?.koreaderProgress && book.koreaderProgress?.percentage != null) {
<div class="metadata-item">
<span class="metadata-key">KOReader Progress:</span>
<span class="metadata-key">{{ t('koreaderProgress') }}</span>
<span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(getKOReaderPercentage(book))">
{{ getKOReaderPercentage(book) + '%' }}
</app-tag>
<p-button
pTooltip="Reset progress"
[pTooltip]="t('resetProgress')"
tooltipPosition="bottom"
icon="pi pi-refresh"
size="small"
@@ -468,13 +468,13 @@
@if (book?.koboProgress && book.koboProgress?.percentage != null) {
<div class="metadata-item">
<span class="metadata-key">Kobo Progress:</span>
<span class="metadata-key">{{ t('koboProgress') }}</span>
<span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(book.koboProgress?.percentage)">
{{ book.koboProgress?.percentage | number:'1.0-1' }}%
</app-tag>
<p-button
pTooltip="Reset progress"
[pTooltip]="t('resetProgress')"
tooltipPosition="bottom"
icon="pi pi-refresh"
size="small"
@@ -490,7 +490,7 @@
@if (selectedReadStatus === ReadStatus.READ) {
<div class="metadata-item">
@if (book?.dateFinished) {
<span class="metadata-key">Finished On:</span>
<span class="metadata-key">{{ t('finishedOn') }}</span>
@if (!isEditingDateFinished) {
<span class="metadata-value-group">
<span class="metadata-value">{{ formatDate(book.dateFinished) }}</span>
@@ -506,8 +506,8 @@
iconDisplay="input"
[style]="{ 'width': '125px', 'font-size': '12px' }">
</p-datepicker>
<p-button rounded icon="pi pi-check" size="small" severity="success" text (onClick)="saveDateFinished(book)" pTooltip="Save date"></p-button>
<p-button rounded icon="pi pi-times" size="small" severity="danger" text (onClick)="cancelDateFinishedEdit()" pTooltip="Cancel"></p-button>
<p-button rounded icon="pi pi-check" size="small" severity="success" text (onClick)="saveDateFinished(book)" [pTooltip]="t('saveDate')"></p-button>
<p-button rounded icon="pi pi-times" size="small" severity="danger" text (onClick)="cancelDateFinishedEdit()" [pTooltip]="'common.cancel' | transloco"></p-button>
</span>
}
}
@@ -515,7 +515,7 @@
}
<div class="metadata-item">
<span class="metadata-key">Page Count:</span>
<span class="metadata-key">{{ t('pageCount') }}</span>
@if (book?.metadata!.pageCount) {
<span class="metadata-value metadata-link" (click)="goToPageCountRange(book?.metadata!.pageCount!)">
{{ book?.metadata!.pageCount }}
@@ -526,7 +526,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Age Rating:</span>
<span class="metadata-key">{{ t('ageRating') }}</span>
@if (book?.metadata?.ageRating != null) {
<span class="metadata-value metadata-link" (click)="goToAgeRating(book?.metadata?.ageRating!)">
{{ getAgeRatingLabel(book?.metadata?.ageRating) }}
@@ -537,7 +537,7 @@
</div>
<div class="metadata-item">
<span class="metadata-key">Content Rating:</span>
<span class="metadata-key">{{ t('contentRating') }}</span>
@if (book?.metadata?.contentRating) {
<span class="metadata-value metadata-link" (click)="goToContentRating(book?.metadata?.contentRating!)">
{{ getContentRatingLabel(book?.metadata?.contentRating) }}
@@ -549,7 +549,7 @@
@if (hasDigitalFile(book)) {
<div class="metadata-item">
<span class="metadata-key">File Size:</span>
<span class="metadata-key">{{ t('fileSize') }}</span>
@if (book?.primaryFile?.fileSizeKb) {
<span class="metadata-value metadata-link" (click)="goToFileSizeRange(book?.primaryFile?.fileSizeKb!)">
{{ formatFileSize(book?.primaryFile) }}
@@ -563,7 +563,7 @@
@if (hasDigitalFile(book)) {
<div class="file-path-section">
<span class="metadata-key">File Path:</span>
<span class="metadata-key">{{ t('filePath') }}</span>
<i class="pi eye-icon" [ngClass]="showFilePath ? 'pi-eye-slash' : 'pi-eye'" (click)="showFilePath = !showFilePath"></i>
@if (showFilePath) {
<code class="file-path-code">{{ book?.primaryFile?.filePath }}</code>
@@ -584,7 +584,7 @@
rounded
text
severity="secondary"
pTooltip="Go to previous book"
[pTooltip]="t('goToPreviousBook')"
tooltipPosition="bottom">
</p-button>
<span class="navigation-position">
@@ -598,7 +598,7 @@
severity="secondary"
rounded
text
pTooltip="Go to next book"
[pTooltip]="t('goToNextBook')"
tooltipPosition="bottom">
</p-button>
</div>
@@ -628,13 +628,13 @@
}
@if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) {
<p-button
[label]="isAutoFetching ? 'Fetching...' : 'Fetch Metadata'"
[label]="isAutoFetching ? t('fetchingMetadata') : t('fetchMetadata')"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true"
severity="warn"
(onClick)="quickRefresh(book!.id)"
[disabled]="isAutoFetching"
pTooltip="Automatically fetch metadata using default sources"
[pTooltip]="t('fetchMetadataTooltip')"
tooltipPosition="top"
class="mobile-icon-only">
</p-button>
@@ -655,7 +655,7 @@
<div class="description-section">
<div class="section-header">
<i class="pi pi-align-left"></i>
<span>Synopsis</span>
<span>{{ t('synopsis') }}</span>
</div>
<div class="description-body">
<div [ngClass]="{ 'line-clamp-7': !isExpanded }" class="description-content">
@@ -667,7 +667,7 @@
</div>
@if (book.metadata!.description && book.metadata!.description.length > 500) {
<button class="expand-toggle" (click)="toggleExpand()">
{{ isExpanded ? 'Show less' : 'Show more' }}
{{ isExpanded ? t('showLess') : t('showMore') }}
<i class="pi" [ngClass]="isExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</button>
}
@@ -679,7 +679,7 @@
<div class="section-header clickable" (click)="isComicSectionExpanded = !isComicSectionExpanded">
<div class="section-header-left">
<i class="pi pi-images"></i>
<span>Comic Details</span>
<span>{{ t('comicDetails') }}</span>
</div>
<i class="pi section-toggle-icon" [ngClass]="isComicSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</div>
@@ -690,13 +690,13 @@
<div class="comic-info-grid">
@if (comic.issueNumber) {
<div class="comic-info-item">
<span class="comic-info-label">Issue</span>
<span class="comic-info-label">{{ t('issue') }}</span>
<span class="comic-info-value">#{{ comic.issueNumber }}</span>
</div>
}
@if (comic.volumeName) {
<div class="comic-info-item">
<span class="comic-info-label">Volume</span>
<span class="comic-info-label">{{ t('volume') }}</span>
<span class="comic-info-value">
{{ comic.volumeName }}
@if (comic.volumeNumber) {
@@ -707,7 +707,7 @@
}
@if (comic.storyArc) {
<div class="comic-info-item">
<span class="comic-info-label">Story Arc</span>
<span class="comic-info-label">{{ t('storyArc') }}</span>
<span class="comic-info-value">
{{ comic.storyArc }}
@if (comic.storyArcNumber) {
@@ -718,7 +718,7 @@
}
@if (comic.alternateSeries) {
<div class="comic-info-item">
<span class="comic-info-label">Alt. Series</span>
<span class="comic-info-label">{{ t('altSeries') }}</span>
<span class="comic-info-value">
{{ comic.alternateSeries }}
@if (comic.alternateIssue) {
@@ -729,13 +729,13 @@
}
@if (comic.format) {
<div class="comic-info-item">
<span class="comic-info-label">Format</span>
<span class="comic-info-label">{{ t('format') }}</span>
<span class="comic-info-value">{{ comic.format }}</span>
</div>
}
@if (comic.imprint) {
<div class="comic-info-item">
<span class="comic-info-label">Imprint</span>
<span class="comic-info-label">{{ t('imprint') }}</span>
<span class="comic-info-value">{{ comic.imprint }}</span>
</div>
}
@@ -745,12 +745,12 @@
<div class="comic-subsection">
<div class="comic-subsection-title">
<i class="pi pi-users"></i>
<span>Creators</span>
<span>{{ t('creators') }}</span>
</div>
<div class="comic-creators-grid">
@if (comic.pencillers?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Pencillers</span>
<span class="comic-creator-role">{{ t('pencillers') }}</span>
<div class="comic-creator-names">
@for (name of comic.pencillers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'penciller')">{{ name }}</a>
@@ -760,7 +760,7 @@
}
@if (comic.inkers?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Inkers</span>
<span class="comic-creator-role">{{ t('inkers') }}</span>
<div class="comic-creator-names">
@for (name of comic.inkers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'inker')">{{ name }}</a>
@@ -770,7 +770,7 @@
}
@if (comic.colorists?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Colorists</span>
<span class="comic-creator-role">{{ t('colorists') }}</span>
<div class="comic-creator-names">
@for (name of comic.colorists; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'colorist')">{{ name }}</a>
@@ -780,7 +780,7 @@
}
@if (comic.letterers?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Letterers</span>
<span class="comic-creator-role">{{ t('letterers') }}</span>
<div class="comic-creator-names">
@for (name of comic.letterers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'letterer')">{{ name }}</a>
@@ -790,7 +790,7 @@
}
@if (comic.coverArtists?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Cover Artists</span>
<span class="comic-creator-role">{{ t('coverArtists') }}</span>
<div class="comic-creator-names">
@for (name of comic.coverArtists; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'coverArtist')">{{ name }}</a>
@@ -800,7 +800,7 @@
}
@if (comic.editors?.length) {
<div class="comic-creator-row">
<span class="comic-creator-role">Editors</span>
<span class="comic-creator-role">{{ t('editors') }}</span>
<div class="comic-creator-names">
@for (name of comic.editors; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'editor')">{{ name }}</a>
@@ -816,12 +816,12 @@
<div class="comic-subsection">
<div class="comic-subsection-title">
<i class="pi pi-globe"></i>
<span>Universe</span>
<span>{{ t('universe') }}</span>
</div>
<div class="comic-tags-container">
@if (comic.characters?.length) {
<div class="comic-tag-row">
<span class="comic-tag-label">Characters</span>
<span class="comic-tag-label">{{ t('characters') }}</span>
<div class="comic-tag-list">
@for (character of comic.characters; track character) {
<a class="comic-tag-clickable" (click)="goToCharacter(character)">
@@ -833,7 +833,7 @@
}
@if (comic.teams?.length) {
<div class="comic-tag-row">
<span class="comic-tag-label">Teams</span>
<span class="comic-tag-label">{{ t('teams') }}</span>
<div class="comic-tag-list">
@for (team of comic.teams; track team) {
<a class="comic-tag-clickable" (click)="goToTeam(team)">
@@ -845,7 +845,7 @@
}
@if (comic.locations?.length) {
<div class="comic-tag-row">
<span class="comic-tag-label">Locations</span>
<span class="comic-tag-label">{{ t('locations') }}</span>
<div class="comic-tag-list">
@for (location of comic.locations; track location) {
<a class="comic-tag-clickable" (click)="goToLocation(location)">
@@ -863,17 +863,17 @@
<div class="comic-properties">
@if (comic.manga) {
<span class="comic-property-badge manga">
<i class="pi pi-book"></i> Manga
<i class="pi pi-book"></i> {{ t('manga') }}
</span>
}
@if (comic.blackAndWhite) {
<span class="comic-property-badge bw">
<i class="pi pi-palette"></i> B&W
<i class="pi pi-palette"></i> {{ t('bw') }}
</span>
}
@if (comic.readingDirection === 'rtl') {
<span class="comic-property-badge rtl">
<i class="pi pi-arrow-left"></i> RTL
<i class="pi pi-arrow-left"></i> {{ t('rtl') }}
</span>
}
</div>
@@ -892,7 +892,7 @@
<div class="comic-notes">
<div class="comic-notes-label">
<i class="pi pi-file-edit"></i>
<span>Notes</span>
<span>{{ t('comicNotes') }}</span>
</div>
<p class="comic-notes-content">{{ comic.notes }}</p>
</div>
@@ -906,7 +906,7 @@
<div class="section-header clickable" (click)="isAudiobookSectionExpanded = !isAudiobookSectionExpanded">
<div class="section-header-left">
<i class="pi pi-headphones"></i>
<span>Audiobook Details</span>
<span>{{ t('audiobookDetails') }}</span>
</div>
<i class="pi section-toggle-icon" [ngClass]="isAudiobookSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</div>
@@ -917,13 +917,13 @@
<div class="audiobook-info-grid">
@if (audio.durationSeconds) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Duration</span>
<span class="audiobook-info-label">{{ t('duration') }}</span>
<span class="audiobook-info-value">{{ formatDuration(audio.durationSeconds) }}</span>
</div>
}
@if (book.metadata?.narrator) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Narrator</span>
<span class="audiobook-info-label">{{ t('narrator') }}</span>
<a class="audiobook-info-value audiobook-link" (click)="goToNarrator(book.metadata!.narrator!)">
{{ book.metadata?.narrator }}
</a>
@@ -931,31 +931,31 @@
}
@if (audio.chapterCount) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Chapters</span>
<span class="audiobook-info-label">{{ t('chapters') }}</span>
<span class="audiobook-info-value">{{ audio.chapterCount }}</span>
</div>
}
@if (audio.bitrate) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Bitrate</span>
<span class="audiobook-info-label">{{ t('bitrate') }}</span>
<span class="audiobook-info-value">{{ audio.bitrate }} kbps</span>
</div>
}
@if (audio.sampleRate) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Sample Rate</span>
<span class="audiobook-info-label">{{ t('sampleRate') }}</span>
<span class="audiobook-info-value">{{ formatSampleRate(audio.sampleRate) }}</span>
</div>
}
@if (audio.channels) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Channels</span>
<span class="audiobook-info-label">{{ t('channels') }}</span>
<span class="audiobook-info-value">{{ getChannelLabel(audio.channels) }}</span>
</div>
}
@if (audio.codec) {
<div class="audiobook-info-item">
<span class="audiobook-info-label">Codec</span>
<span class="audiobook-info-label">{{ t('codec') }}</span>
<span class="audiobook-info-value">{{ audio.codec.toUpperCase() }}</span>
</div>
}
@@ -965,7 +965,7 @@
<div class="audiobook-properties">
<span class="audiobook-property-badge" [ngClass]="book.metadata?.abridged ? 'abridged' : 'unabridged'">
<i class="pi" [ngClass]="book.metadata?.abridged ? 'pi-minus-circle' : 'pi-check-circle'"></i>
{{ book.metadata?.abridged ? 'Abridged' : 'Unabridged' }}
{{ book.metadata?.abridged ? t('abridged') : t('unabridged') }}
</span>
</div>
}
@@ -986,8 +986,8 @@
</app-metadata-tabs>
</div>
} @else {
<div class="loading-state">
<div class="loading-state" *transloco="let t; prefix: 'metadata.viewer'">
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s"></p-progressSpinner>
<p class="loading-text">Loading book details...</p>
<p class="loading-text">{{ t('loadingBookDetails') }}</p>
</div>
}
@@ -33,6 +33,7 @@ import {BookNavigationService} from '../../../../book/service/book-navigation.se
import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFileEvent, DownloadAllFilesEvent, DownloadEvent, MetadataTabsComponent, ReadEvent} from './metadata-tabs/metadata-tabs.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
@@ -40,7 +41,7 @@ import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFil
standalone: true,
templateUrl: './metadata-viewer.component.html',
styleUrl: './metadata-viewer.component.scss',
imports: [Button, AsyncPipe, Rating, FormsModule, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, DatePicker, ProgressSpinner, TieredMenu, Image, TagComponent, MetadataTabsComponent]
imports: [Button, AsyncPipe, Rating, FormsModule, SplitButton, NgClass, Tooltip, DecimalPipe, Editor, ProgressBar, Menu, DatePicker, ProgressSpinner, TieredMenu, Image, TagComponent, MetadataTabsComponent, TranslocoDirective, TranslocoPipe]
})
export class MetadataViewerComponent implements OnInit, OnChanges {
@Input() book$!: Observable<Book | null>;
@@ -48,6 +49,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
@ViewChild(Editor) quillEditor!: Editor;
private originalRecommendedBooks: BookRecommendation[] = [];
private readonly t = inject(TranslocoService);
private bookDialogHelperService = inject(BookDialogHelperService)
private emailService = inject(EmailService);
private messageService = inject(MessageService);
@@ -103,13 +105,13 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const primaryType = book.primaryFile?.bookType;
if (primaryType === 'PDF') {
items.push({
label: 'Streaming Reader',
label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play',
command: () => this.read(book.id, 'pdf-streaming')
});
} else if (primaryType === 'EPUB') {
items.push({
label: 'Streaming Reader',
label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play',
command: () => this.read(book.id, 'epub-streaming')
});
@@ -136,12 +138,12 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
icon: this.getFileIcon(formatType),
items: [
{
label: 'Standard Reader',
label: this.t.translate('metadata.viewer.standardReader'),
icon: 'pi pi-book',
command: () => this.read(book.id, undefined, formatType)
},
{
label: 'Streaming Reader',
label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play',
command: () => this.read(book.id, formatType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', formatType)
}
@@ -214,7 +216,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const items: MenuItem[] = [];
items.push({
label: 'Shelf',
label: this.t.translate('metadata.viewer.shelf'),
icon: 'pi pi-folder',
command: () => this.assignShelf(book.id)
});
@@ -223,7 +225,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (userState?.user?.permissions.canUpload || userState?.user?.permissions.admin) {
items.push({
label: 'Upload File',
label: this.t.translate('metadata.viewer.uploadFile'),
icon: 'pi pi-upload',
command: () => {
this.bookDialogHelperService.openAdditionalFileUploaderDialog(book);
@@ -235,7 +237,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (hasFiles && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin) && appSettings?.diskType === 'LOCAL') {
items.push({
label: 'Organize Files',
label: this.t.translate('metadata.viewer.organizeFiles'),
icon: 'pi pi-arrows-h',
command: () => {
this.openFileMoverDialog(book.id);
@@ -245,16 +247,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (hasFiles && (userState?.user?.permissions.canEmailBook || userState?.user?.permissions.admin)) {
items.push({
label: 'Send Book',
label: this.t.translate('metadata.viewer.sendBook'),
icon: 'pi pi-send',
items: [
{
label: 'Quick Send',
label: this.t.translate('metadata.viewer.quickSend'),
icon: 'pi pi-bolt',
command: () => this.quickSend(book.id)
},
{
label: 'Custom Send',
label: this.t.translate('metadata.viewer.customSend'),
icon: 'pi pi-cog',
command: () => {
this.bookDialogHelperService.openCustomSendDialog(book);
@@ -268,7 +270,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const isSingleFileBook = hasFiles && !book.alternativeFormats?.length;
if (isSingleFileBook && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin)) {
items.push({
label: 'Attach to Another Book',
label: this.t.translate('metadata.viewer.attachToAnotherBook'),
icon: 'pi pi-link',
command: () => {
this.bookDialogHelperService.openBookFileAttacherDialog(book);
@@ -310,7 +312,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (deleteFormatItems.length > 0) {
items.push({
label: 'Delete File Formats',
label: this.t.translate('metadata.viewer.deleteFileFormats'),
icon: 'pi pi-file',
items: deleteFormatItems
});
@@ -331,7 +333,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
});
items.push({
label: 'Delete Supplementary Files',
label: this.t.translate('metadata.viewer.deleteSupplementaryFiles'),
icon: 'pi pi-paperclip',
items: deleteSupplementaryItems
});
@@ -354,11 +356,11 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
? `\n\nThe following files will be permanently deleted:\n• ${allFormats.join('\n• ')}`
: '';
const deleteLabel = isPhysical ? 'Delete Book' : 'Delete Book & All Files';
const deleteLabel = isPhysical ? this.t.translate('metadata.viewer.deleteBook') : this.t.translate('metadata.viewer.deleteBookAndAllFiles');
const deleteMessage = isPhysical
? `Are you sure you want to delete "${book.metadata?.title}"?\n\nThis will permanently remove the book record from your library.\n\nThis action cannot be undone.`
: `Are you sure you want to delete "${book.metadata?.title}"?\n\nThis will permanently remove the book record AND all associated files from your filesystem.${fileListMessage}\n\nThis action cannot be undone.`;
const deleteAcceptLabel = isPhysical ? 'Delete' : 'Delete Everything';
? this.t.translate('metadata.viewer.confirm.deleteBookMessage', { title: book.metadata?.title })
: this.t.translate('metadata.viewer.confirm.deleteBookAndFilesMessage', { title: book.metadata?.title, fileList: fileListMessage });
const deleteAcceptLabel = isPhysical ? this.t.translate('common.delete') : this.t.translate('metadata.viewer.deleteEverything');
items.push({
label: deleteLabel,
@@ -371,7 +373,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
acceptLabel: deleteAcceptLabel,
rejectLabel: 'Cancel',
rejectLabel: this.t.translate('common.cancel'),
acceptButtonStyleClass: 'p-button-danger',
rejectButtonStyleClass: 'p-button-outlined',
accept: () => {
@@ -478,9 +480,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
getReadButtonLabel(book: Book): string {
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
if (this.isInProgressStatus()) {
return isAudiobook ? 'Continue' : 'Continue Reading';
return isAudiobook ? this.t.translate('metadata.viewer.continue') : this.t.translate('metadata.viewer.continueReading');
}
return isAudiobook ? 'Play' : 'Read';
return isAudiobook ? this.t.translate('metadata.viewer.playAction') : this.t.translate('metadata.viewer.readAction');
}
getReadButtonIcon(book: Book): string {
@@ -523,8 +525,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
deleteAdditionalFile(bookId: number, fileId: number, fileName: string) {
this.confirmationService.confirm({
message: `Are you sure you want to delete the supplementary file "${fileName}"?\n\nThis file will be permanently removed from your filesystem.`,
header: 'Delete Supplementary File',
message: this.t.translate('metadata.viewer.confirm.deleteSupplementaryMessage', { fileName }),
header: this.t.translate('metadata.viewer.confirm.deleteSupplementaryHeader'),
icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
@@ -535,15 +537,15 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Supplementary file "${fileName}" deleted successfully`
summary: this.t.translate('metadata.viewer.toast.deleteSupplementarySuccessSummary'),
detail: this.t.translate('metadata.viewer.toast.deleteSupplementarySuccessDetail', { fileName })
});
},
error: (error) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: `Failed to delete supplementary file: ${error.message || 'Unknown error'}`
summary: this.t.translate('metadata.viewer.toast.deleteSupplementaryErrorSummary'),
detail: this.t.translate('metadata.viewer.toast.deleteSupplementaryErrorDetail', { error: error.message || 'Unknown error' })
});
}
});
@@ -556,17 +558,14 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
let header: string;
if (isOnlyFormat) {
// This is the only book format file - warn user strongly
message = `Are you sure you want to delete "${fileName}"?\n\nThis is the ONLY book format file for this book. After deletion, the book will have no readable content.\n\nConsider using "Delete Book & All Files" instead to completely remove the book.\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Only Book Format';
message = this.t.translate('metadata.viewer.confirm.deleteOnlyFormatMessage', { fileName });
header = this.t.translate('metadata.viewer.confirm.deleteOnlyFormatHeader');
} else if (isPrimary) {
// This is the primary format but there are alternatives
message = `Are you sure you want to delete "${fileName}"?\n\nThis is currently the PRIMARY format for this book. After deletion, an alternative format will become the new primary.\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Primary Format';
message = this.t.translate('metadata.viewer.confirm.deletePrimaryFormatMessage', { fileName });
header = this.t.translate('metadata.viewer.confirm.deletePrimaryFormatHeader');
} else {
// This is an alternative format
message = `Are you sure you want to delete "${fileName}"?\n\nThis file will be permanently removed from your filesystem.`;
header = 'Delete Book Format';
message = this.t.translate('metadata.viewer.confirm.deleteAlternativeFormatMessage', { fileName });
header = this.t.translate('metadata.viewer.confirm.deleteAlternativeFormatHeader');
}
this.confirmationService.confirm({
@@ -575,8 +574,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times',
acceptLabel: 'Delete File',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('metadata.viewer.confirm.deleteFile'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonStyleClass: 'p-button-secondary',
acceptButtonStyleClass: 'p-button-danger',
accept: () => {
@@ -584,15 +583,15 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Book format "${fileName}" deleted successfully`
summary: this.t.translate('metadata.viewer.toast.deleteFormatSuccessSummary'),
detail: this.t.translate('metadata.viewer.toast.deleteFormatSuccessDetail', { fileName })
});
},
error: (error) => {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: `Failed to delete book format: ${error.message || 'Unknown error'}`
summary: this.t.translate('metadata.viewer.toast.deleteFormatErrorSummary'),
detail: this.t.translate('metadata.viewer.toast.deleteFormatErrorDetail', { error: error.message || 'Unknown error' })
});
}
});
@@ -617,13 +616,13 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
this.emailService.emailBookQuick(bookId).subscribe({
next: () => this.messageService.add({
severity: 'info',
summary: 'Success',
detail: 'The book sending has been scheduled.',
summary: this.t.translate('metadata.viewer.toast.quickSendSuccessSummary'),
detail: this.t.translate('metadata.viewer.toast.quickSendSuccessDetail'),
}),
error: (err) => this.messageService.add({
severity: 'error',
summary: 'Error',
detail: err?.error?.message || 'An error occurred while sending the book.',
summary: this.t.translate('metadata.viewer.toast.quickSendErrorSummary'),
detail: err?.error?.message || this.t.translate('metadata.viewer.toast.quickSendErrorDetailFallback'),
})
});
}
@@ -647,8 +646,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
this.selectedReadStatus = status;
this.messageService.add({
severity: 'success',
summary: 'Read Status Updated',
detail: `Marked as "${this.getStatusLabel(status)}"`,
summary: this.t.translate('metadata.viewer.toast.readStatusUpdatedSummary'),
detail: this.t.translate('metadata.viewer.toast.readStatusUpdatedDetail', { status: this.getStatusLabel(status) }),
life: 2000
});
},
@@ -656,8 +655,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
console.error('Failed to update read status:', err);
this.messageService.add({
severity: 'error',
summary: 'Update Failed',
detail: 'Could not update read status.',
summary: this.t.translate('metadata.viewer.toast.readStatusFailedSummary'),
detail: this.t.translate('metadata.viewer.toast.readStatusFailedDetail'),
life: 3000
});
}
@@ -667,27 +666,27 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
resetProgress(book: Book, type: ResetProgressType): void {
this.confirmationService.confirm({
message: `Reset reading progress for "${book.metadata?.title}"?`,
header: 'Confirm Reset',
message: this.t.translate('metadata.viewer.confirm.resetProgressMessage', { title: book.metadata?.title }),
header: this.t.translate('metadata.viewer.confirm.resetProgressHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Yes',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('common.yes'),
rejectLabel: this.t.translate('common.cancel'),
acceptButtonStyleClass: 'p-button-danger',
accept: () => {
this.bookService.resetProgress(book.id, type).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Progress Reset',
detail: 'Reading progress has been reset.',
summary: this.t.translate('metadata.viewer.toast.progressResetSummary'),
detail: this.t.translate('metadata.viewer.toast.progressResetDetail'),
life: 1500
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Failed',
detail: 'Could not reset progress.',
summary: this.t.translate('metadata.viewer.toast.progressResetFailedSummary'),
detail: this.t.translate('metadata.viewer.toast.progressResetFailedDetail'),
life: 1500
});
}
@@ -701,16 +700,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Rating Saved',
detail: 'Personal rating updated successfully'
summary: this.t.translate('metadata.viewer.toast.ratingSavedSummary'),
detail: this.t.translate('metadata.viewer.toast.ratingSavedDetail')
});
},
error: err => {
console.error('Failed to update personal rating:', err);
this.messageService.add({
severity: 'error',
summary: 'Update Failed',
detail: 'Could not update personal rating'
summary: this.t.translate('metadata.viewer.toast.ratingFailedSummary'),
detail: this.t.translate('metadata.viewer.toast.ratingFailedDetail')
});
}
});
@@ -721,16 +720,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => {
this.messageService.add({
severity: 'info',
summary: 'Rating Reset',
detail: 'Personal rating has been cleared.'
summary: this.t.translate('metadata.viewer.toast.ratingResetSummary'),
detail: this.t.translate('metadata.viewer.toast.ratingResetDetail')
});
},
error: err => {
console.error('Failed to reset personal rating:', err);
this.messageService.add({
severity: 'error',
summary: 'Reset Failed',
detail: 'Could not reset personal rating'
summary: this.t.translate('metadata.viewer.toast.ratingResetFailedSummary'),
detail: this.t.translate('metadata.viewer.toast.ratingResetFailedDetail')
});
}
});
@@ -1161,8 +1160,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Date Updated',
detail: 'Book finish date has been updated.',
summary: this.t.translate('metadata.viewer.toast.dateUpdatedSummary'),
detail: this.t.translate('metadata.viewer.toast.dateUpdatedDetail'),
life: 1500
});
this.isEditingDateFinished = false;
@@ -1171,8 +1170,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Update Failed',
detail: 'Could not update book finish date.',
summary: this.t.translate('metadata.viewer.toast.dateFailedSummary'),
detail: this.t.translate('metadata.viewer.toast.dateFailedDetail'),
life: 3000
});
}
@@ -1226,7 +1225,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
getNavigationPosition(): string {
const position = this.bookNavigationService.getCurrentPosition();
return position ? `${position.current} of ${position.total}` : '';
return position ? this.t.translate('metadata.viewer.navigationOf', { current: position.current, total: position.total }) : '';
}
hasDigitalFile(book: Book): boolean {
@@ -1,9 +1,10 @@
<ng-container *transloco="let t; prefix: 'metadata.sidecar'">
<div class="sidecar-viewer">
<div class="sidecar-header">
<div class="header-info">
<h3>Sidecar Metadata</h3>
<h3>{{ t('title') }}</h3>
<p class="header-description">
View and manage the .metadata.json file stored alongside your book file.
{{ t('description') }}
</p>
</div>
<div class="header-actions">
@@ -18,29 +19,29 @@
@if (loading) {
<div class="loading-state">
<i class="pi pi-spin pi-spinner"></i>
<span>Loading sidecar data...</span>
<span>{{ t('loading') }}</span>
</div>
} @else {
<div class="sidecar-actions">
<p-button
label="Export to Sidecar"
[label]="t('exportToSidecar')"
icon="pi pi-upload"
[loading]="exporting"
(onClick)="exportToSidecar()"
severity="primary"
size="small"
pTooltip="Create or update the sidecar JSON file with current database metadata"
[pTooltip]="t('exportTooltip')"
tooltipPosition="top"
/>
<p-button
label="Import from Sidecar"
[label]="t('importFromSidecar')"
icon="pi pi-download"
[loading]="importing"
[disabled]="syncStatus === 'MISSING'"
(onClick)="importFromSidecar()"
severity="secondary"
size="small"
pTooltip="Import metadata from the sidecar JSON file into the database"
[pTooltip]="t('importTooltip')"
tooltipPosition="top"
/>
</div>
@@ -48,10 +49,9 @@
@if (syncStatus === 'MISSING') {
<div class="empty-state">
<i class="pi pi-file"></i>
<h4>No Sidecar File Found</h4>
<h4>{{ t('noSidecarFile') }}</h4>
<p>
No .metadata.json file exists for this book yet.
Click "Export to Sidecar" to create one with the current metadata.
{{ t('noSidecarDescription') }}
</p>
</div>
} @else if (sidecarContent) {
@@ -60,15 +60,15 @@
<div class="content-meta">
<span class="meta-item">
<i class="pi pi-clock"></i>
Generated: {{ sidecarContent.generatedAt | date:'medium' }}
{{ t('generated') }} {{ sidecarContent.generatedAt | date:'medium' }}
</span>
<span class="meta-item">
<i class="pi pi-tag"></i>
Version: {{ sidecarContent.version }}
{{ t('version') }} {{ sidecarContent.version }}
</span>
<span class="meta-item">
<i class="pi pi-cog"></i>
By: {{ sidecarContent.generatedBy }}
{{ t('generatedBy') }} {{ sidecarContent.generatedBy }}
</span>
</div>
</div>
@@ -80,10 +80,11 @@
@if (sidecarContent.cover) {
<div class="cover-info">
<i class="pi pi-image"></i>
<span>Cover file: {{ sidecarContent.cover.path }}</span>
<span>{{ t('coverFile') }} {{ sidecarContent.cover.path }}</span>
</div>
}
</div>
}
}
</div>
</ng-container>
@@ -8,19 +8,21 @@ import {Button} from 'primeng/button';
import {Tag} from 'primeng/tag';
import {Tooltip} from 'primeng/tooltip';
import {DatePipe, JsonPipe} from '@angular/common';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-sidecar-viewer',
standalone: true,
templateUrl: './sidecar-viewer.component.html',
styleUrls: ['./sidecar-viewer.component.scss'],
imports: [Button, Tag, Tooltip, JsonPipe, DatePipe]
imports: [Button, Tag, Tooltip, JsonPipe, DatePipe, TranslocoDirective]
})
export class SidecarViewerComponent implements OnInit, OnDestroy {
@Input() book$!: Observable<Book>;
private sidecarService = inject(SidecarService);
private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private destroy$ = new Subject<void>();
sidecarContent: SidecarMetadata | null = null;
@@ -95,8 +97,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Export Successful',
detail: 'Sidecar metadata file has been created.'
summary: this.t.translate('metadata.sidecar.toast.exportSuccessSummary'),
detail: this.t.translate('metadata.sidecar.toast.exportSuccessDetail')
});
this.loadSidecarData(this.currentBookId!);
this.exporting = false;
@@ -104,8 +106,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Export Failed',
detail: 'Failed to create sidecar metadata file.'
summary: this.t.translate('metadata.sidecar.toast.exportFailedSummary'),
detail: this.t.translate('metadata.sidecar.toast.exportFailedDetail')
});
this.exporting = false;
console.error('Export failed:', err);
@@ -123,8 +125,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Import Successful',
detail: 'Metadata has been imported from sidecar file.'
summary: this.t.translate('metadata.sidecar.toast.importSuccessSummary'),
detail: this.t.translate('metadata.sidecar.toast.importSuccessDetail')
});
this.loadSidecarData(this.currentBookId!);
this.importing = false;
@@ -132,8 +134,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Import Failed',
detail: 'Failed to import metadata from sidecar file.'
summary: this.t.translate('metadata.sidecar.toast.importFailedSummary'),
detail: this.t.translate('metadata.sidecar.toast.importFailedDetail')
});
this.importing = false;
console.error('Import failed:', err);
@@ -159,17 +161,17 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
getSyncStatusLabel(): string {
switch (this.syncStatus) {
case 'IN_SYNC':
return 'In Sync';
return this.t.translate('metadata.sidecar.syncStatus.inSync');
case 'OUTDATED':
return 'Outdated';
return this.t.translate('metadata.sidecar.syncStatus.outdated');
case 'CONFLICT':
return 'Conflict';
return this.t.translate('metadata.sidecar.syncStatus.conflict');
case 'MISSING':
return 'Missing';
return this.t.translate('metadata.sidecar.syncStatus.missing');
case 'NOT_APPLICABLE':
return 'N/A';
return this.t.translate('metadata.sidecar.syncStatus.notApplicable');
default:
return 'Unknown';
return this.t.translate('metadata.sidecar.syncStatus.unknown');
}
}
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'metadata.coverSearch'">
<div class="cover-search-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi {{ coverType === 'audiobook' ? 'pi-headphones' : 'pi-image' }} header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Search {{ coverType === 'audiobook' ? 'Audiobook' : 'Ebook' }} Cover</h2>
<p class="panel-description">Find and select a cover for your book</p>
<h2 class="panel-title">{{ coverType === 'audiobook' ? t('searchAudiobookCover') : t('searchEbookCover') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -25,19 +26,19 @@
<div class="form-field title-field">
<label for="title">
<i class="pi pi-book"></i>
Title
{{ t('titleLabel') }}
<span class="required">*</span>
</label>
<input
pInputText
id="title"
formControlName="title"
placeholder="Enter book title"
[placeholder]="t('titlePlaceholder')"
/>
@if (searchForm.get('title')?.invalid && searchForm.get('title')?.touched) {
<small class="error-message">
<i class="pi pi-exclamation-circle"></i>
Title is required
{{ t('titleRequired') }}
</small>
}
</div>
@@ -45,20 +46,20 @@
<div class="form-field author-field">
<label for="author">
<i class="pi pi-user"></i>
Author
{{ t('authorLabel') }}
</label>
<input
pInputText
id="author"
formControlName="author"
placeholder="Enter author name (optional)"
[placeholder]="t('authorPlaceholder')"
/>
</div>
<div class="form-actions">
<p-button
type="submit"
label="Search"
[label]="t('searchBtn')"
icon="pi pi-search"
[loading]="loading"
[disabled]="searchForm.invalid">
@@ -70,7 +71,7 @@
[rounded]="true"
severity="secondary"
(click)="onClear()"
pTooltip="Reset search"
[pTooltip]="t('resetSearchTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -86,14 +87,14 @@
<div class="empty-state-icon">
<i class="pi pi-images"></i>
</div>
<h3>Search for Book Covers</h3>
<p>Enter a book title above to find cover images from various sources.</p>
<h3>{{ t('searchForCovers') }}</h3>
<p>{{ t('searchForCoversDescription') }}</p>
</div>
} @else if (loading) {
<!-- Loading State -->
<div class="loading-state">
<p-progressSpinner strokeWidth="3" animationDuration="1s"></p-progressSpinner>
<p>Searching for covers...</p>
<p>{{ t('searchingForCovers') }}</p>
</div>
} @else if (coverImages.length === 0) {
<!-- No Results State -->
@@ -101,19 +102,19 @@
<div class="empty-state-icon warning">
<i class="pi pi-search"></i>
</div>
<h3>No Covers Found</h3>
<p>Try adjusting your search terms or check the spelling.</p>
<h3>{{ t('noCoversFound') }}</h3>
<p>{{ t('noCoversFoundDescription') }}</p>
</div>
} @else {
<!-- Results Grid -->
<div class="results-header">
<span class="results-count">
<i class="pi pi-images"></i>
{{ coverImages.length }} cover{{ coverImages.length !== 1 ? 's' : '' }} found
{{ coverImages.length === 1 ? t('coversFoundSingular', { count: coverImages.length }) : t('coversFoundPlural', { count: coverImages.length }) }}
</span>
<span class="results-hint">
<i class="pi pi-info-circle"></i>
Click on an image to preview, or select to apply
{{ t('resultsHint') }}
</span>
</div>
@@ -123,7 +124,7 @@
<div class="cover-image-wrapper">
<p-image
[src]="cover.url"
[alt]="'Book cover ' + (i + 1)"
[alt]="t('bookCoverAlt', { index: i + 1 })"
appendTo="body"
[preview]="true">
</p-image>
@@ -135,7 +136,7 @@
<div class="cover-overlay">
<p-button
(click)="selectAndSave(cover)"
label="Select Cover"
[label]="t('selectCover')"
icon="pi pi-check"
size="small">
</p-button>
@@ -148,3 +149,4 @@
</div>
</div>
</div>
</ng-container>
@@ -10,6 +10,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {BookService} from '../../../book/service/book.service';
import {Image} from 'primeng/image';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-cover-search',
@@ -21,7 +22,8 @@ import {Tooltip} from 'primeng/tooltip';
InputText,
ProgressSpinner,
Image,
Tooltip
Tooltip,
TranslocoDirective
],
styleUrls: ['./cover-search.component.scss']
})
@@ -39,6 +41,7 @@ export class CoverSearchComponent implements OnInit {
protected dynamicDialogRef = inject(DynamicDialogRef);
protected bookService = inject(BookService);
private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
constructor() {
this.searchForm = this.fb.group({
@@ -111,16 +114,18 @@ export class CoverSearchComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Cover Updated',
detail: `${this.coverType === 'audiobook' ? 'Audiobook' : 'Ebook'} cover image updated successfully.`
summary: this.t.translate('metadata.coverSearch.toast.coverUpdatedSummary'),
detail: this.coverType === 'audiobook'
? this.t.translate('metadata.coverSearch.toast.audiobookCoverUpdatedDetail')
: this.t.translate('metadata.coverSearch.toast.ebookCoverUpdatedDetail')
});
this.dynamicDialogRef.close(true);
},
error: err => {
this.messageService.add({
severity: 'error',
summary: 'Cover Update Failed',
detail: err?.message || 'Failed to update cover image.'
summary: this.t.translate('metadata.coverSearch.toast.coverUpdateFailedSummary'),
detail: err?.message || this.t.translate('metadata.coverSearch.toast.coverUpdateFailedDetail')
});
}
});
@@ -1,15 +1,16 @@
<ng-container *transloco="let t; prefix: 'metadata.manager'">
<div class="main-container enclosing-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-sitemap"></i>
Metadata Manager
{{ t('title') }}
<app-external-doc-link docType="metadataManager"></app-external-doc-link>
</h2>
<p class="settings-description">
Organize, merge, split, rename, and standardize authors, genres, moods, and tags across your library.
{{ t('description') }}
<i
class="pi pi-exclamation-triangle info-icon"
pTooltip="Important: If 'Write to file' is enabled in settings, operations will modify all relevant files. For libraries with thousands of books, disable 'Write to file' before using this feature to prevent performance issues and potential data corruption."
[pTooltip]="t('writeToFileWarning')"
tooltipPosition="right"
[escape]="false"></i>
</p>
@@ -20,7 +21,7 @@
<p-tablist>
@for (tab of tabConfigs; track tab.type) {
<p-tab [value]="tab.type">
<i class="pi {{ tab.icon }}"></i> {{ tab.label.endsWith('s') ? tab.label : tab.label + 's' }} ({{ getMetadataItems(tab.type).length }})
<i class="pi {{ tab.icon }}"></i> {{ t(tab.labelKey).endsWith('s') ? t(tab.labelKey) : t(tab.labelKey) + 's' }} ({{ getMetadataItems(tab.type).length }})
</p-tab>
}
</p-tablist>
@@ -35,11 +36,11 @@
type="text"
#tableFilter
(input)="filterGlobal($event, dataTable)"
[placeholder]="tab.placeholder"/>
[placeholder]="t(tab.placeholderKey)"/>
</p-iconfield>
<div class="actions">
<p-button
label="Clear Selection"
[label]="t('clearSelection')"
icon="pi pi-times"
[disabled]="getSelectedItems(tab.type).length === 0"
(onClick)="clearSelection(tab.type)"
@@ -47,7 +48,7 @@
size="small"
outlined></p-button>
<p-button
label="Delete Selected"
[label]="t('deleteSelected')"
icon="pi pi-trash"
[disabled]="getSelectedItems(tab.type).length === 0"
(onClick)="openDeleteDialog(tab.type)"
@@ -55,7 +56,7 @@
size="small"
outlined></p-button>
<p-button
label="Merge/Split Selected"
[label]="t('mergeSplitSelected')"
icon="pi pi-sitemap"
[disabled]="getSelectedItems(tab.type).length < 2"
(onClick)="openMergeDialog(tab.type)"
@@ -89,21 +90,21 @@
<th pSortableColumn="value">
<div class="header-content">
<i class="pi {{ tab.icon }}"></i>
<span>{{ tab.label }}</span>
<span>{{ t(tab.labelKey) }}</span>
<p-sortIcon field="value"></p-sortIcon>
</div>
</th>
<th pSortableColumn="count">
<div class="header-content">
<i class="pi pi-book"></i>
<span>Books</span>
<span>{{ t('booksColumn') }}</span>
<p-sortIcon field="count"></p-sortIcon>
</div>
</th>
<th class="actions-header">
<div class="header-content">
<i class="pi pi-cog"></i>
<span>Actions</span>
<span>{{ t('actionsColumn') }}</span>
</div>
</th>
</tr>
@@ -129,7 +130,7 @@
size="small"
[outlined]="true"
[rounded]="true"
pTooltip="Select similar"
[pTooltip]="t('selectSimilarTooltip')"
(onClick)="selectSimilar(tab.type, item.value)"></p-button>
<p-button
icon="pi pi-pencil"
@@ -137,7 +138,7 @@
size="small"
[outlined]="true"
[rounded]="true"
pTooltip="Rename/Split"
[pTooltip]="t('renameSplitTooltip')"
(onClick)="openRenameDialog(tab.type, item)"></p-button>
<p-button
icon="pi pi-trash"
@@ -145,7 +146,7 @@
size="small"
[outlined]="true"
[rounded]="true"
pTooltip="Delete"
[pTooltip]="t('deleteTooltip')"
(onClick)="openDeleteDialog(tab.type, item)"></p-button>
</td>
</tr>
@@ -159,57 +160,40 @@
</div>
<p-dialog
header="Merge/Split {{ currentMergeType | titlecase }}"
[header]="t('mergeSplitDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showMergeDialog"
[modal]="true"
class="user-dialog"
[style]="{width: '50rem'}">
<div class="dialog-form">
<p>You are merging/splitting {{ getSelectedItems(currentMergeType).length }} {{ currentMergeType }}:</p>
<p>{{ t('mergeSplitDescription', { count: getSelectedItems(currentMergeType).length, type: currentMergeType }) }}</p>
<ul class="selected-items">
@for (item of getSelectedItems(currentMergeType); track item.value) {
<li>
• {{ item.value }} <span class="count">({{ item.count }} books)</span>
&#8226; {{ item.value }} <span class="count">{{ t('booksCount', { count: item.count }) }}</span>
</li>
}
</ul>
<div class="form-field">
<label for="mergeTarget">Target Value{{ isSingleValueField(currentMergeType) ? '' : '(s)' }}:</label>
<label for="mergeTarget">{{ isSingleValueField(currentMergeType) ? t('targetValueLabel') : t('targetValuesLabel') }}</label>
<input
id="mergeTarget"
type="text"
pInputText
[(ngModel)]="mergeTarget"
class="full-width-input"
[placeholder]="isSingleValueField(currentMergeType) ? 'e.g., English' : 'e.g., Fiction, Mystery, Thriller'"/>
[placeholder]="isSingleValueField(currentMergeType) ? t('singleValuePlaceholder') : t('multiValuePlaceholder')"/>
@if (isSingleValueField(currentMergeType)) {
<small class="help-text">
<strong>How it works:</strong><br/>
• Enter the standardized value you want all selected items to merge into<br/>
• All books with any of the selected {{ currentMergeType }} will be updated to use this single value<br/>
<br/>
<strong>Example:</strong> When merging "En", "English", "en-US"<br/>
• Enter "English" → All books will have their {{ currentMergeType.slice(0, -1) }} merged to "English"<br/>
<br/>
<strong>Note:</strong> Each book can only have one {{ currentMergeType.slice(0, -1) }}, so only enter one target value.
</small>
<small class="help-text" [innerHTML]="t('singleMergeHowItWorks', { type: currentMergeType, singular: currentMergeType.slice(0, -1) })"></small>
} @else {
<small class="help-text">
<strong>How it works:</strong><br/>
• Enter a single value to merge all selected {{ currentMergeType }} into one<br/>
• Enter multiple values separated by commas to split into multiple {{ currentMergeType }}<br/>
<br/>
<strong>Example:</strong> When merging/splitting "Sci-Fi", "SciFi", "Science Fiction"<br/>
• Merge: Enter "Science Fiction" → All books get one standardized tag<br/>
• Split: Enter "Science Fiction, Sci-Fi" → All books get both the formal name and common abbreviation
</small>
<small class="help-text" [innerHTML]="t('multiMergeHowItWorks', { type: currentMergeType })"></small>
}
</div>
@if (mergingInProgress) {
<div class="processing-note">
<i class="pi pi-info-circle"></i>
<span>This process may take longer if "Write to file" is enabled in the settings.</span>
<span>{{ t('processingNote') }}</span>
</div>
}
</div>
@@ -217,14 +201,14 @@
<ng-template pTemplate="footer">
<div class="dialog-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
(onClick)="showMergeDialog = false"
[disabled]="mergingInProgress"
severity="secondary"
outlined></p-button>
<p-button
[label]="mergingInProgress ? 'Processing...' : 'Confirm'"
[label]="mergingInProgress ? t('processing') : ('common.confirm' | transloco)"
[icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="mergingInProgress"
[disabled]="mergingInProgress"
@@ -235,51 +219,38 @@
</p-dialog>
<p-dialog
header="Rename/Split {{ currentMergeType | titlecase }}"
[header]="t('renameSplitDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showRenameDialog"
[modal]="true"
class="user-dialog"
[style]="{width: '40rem'}">
<div class="dialog-form">
<p>You are renaming/splitting:</p>
<p>{{ t('renameSplitDescription') }}</p>
<div class="current-value">
<strong>{{ currentRenameItem?.value }}</strong>
<span class="count">({{ currentRenameItem?.count }} books)</span>
<span class="count">{{ t('booksCount', { count: currentRenameItem?.count }) }}</span>
</div>
<div class="form-field">
<label for="renameTarget">New Name(s):</label>
<label for="renameTarget">{{ t('newNamesLabel') }}</label>
<input
id="renameTarget"
type="text"
pInputText
[(ngModel)]="renameTarget"
class="full-width-input"
[placeholder]="isSingleValueField(currentMergeType) ? 'e.g., Mystery' : 'e.g., Mystery, Detective'"
[placeholder]="isSingleValueField(currentMergeType) ? t('singleRenamePlaceholder') : t('multiRenamePlaceholder')"
(keyup.enter)="confirmRename()"/>
@if (isSingleValueField(currentMergeType)) {
<small class="help-text">
<strong>How it works:</strong><br/>
• Enter a new value to rename this {{ currentMergeType.slice(0, -1) }}<br/>
<br/>
<strong>Note:</strong> Each book can only have one {{ currentMergeType.slice(0, -1) }}, so splitting into multiple values is not allowed.
</small>
<small class="help-text" [innerHTML]="t('singleRenameHowItWorks', { singular: currentMergeType.slice(0, -1) })"></small>
} @else {
<small class="help-text">
<strong>How it works:</strong><br/>
• Enter a single value to rename the {{ currentMergeType.slice(0, -1) }}<br/>
• Enter multiple values separated by commas to split into multiple {{ currentMergeType }}<br/>
<br/>
<strong>Example:</strong> When renaming/splitting "Mystery & Detective"<br/>
• Rename: Enter "Mystery" → Renames to just "Mystery"<br/>
• Split: Enter "Mystery, Detective" → Splits into two separate {{ currentMergeType }}
</small>
<small class="help-text" [innerHTML]="t('multiRenameHowItWorks', { singular: currentMergeType.slice(0, -1), type: currentMergeType })"></small>
}
</div>
@if (mergingInProgress) {
<div class="processing-note">
<i class="pi pi-info-circle"></i>
<span>This process may take some time if "Write to file" is enabled in settings.</span>
<span>{{ t('renameProcessingNote') }}</span>
</div>
}
</div>
@@ -287,14 +258,14 @@
<ng-template pTemplate="footer">
<div class="dialog-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
(onClick)="showRenameDialog = false"
[disabled]="mergingInProgress"
severity="secondary"
outlined></p-button>
<p-button
[label]="mergingInProgress ? 'Processing...' : 'Confirm'"
[label]="mergingInProgress ? t('processing') : ('common.confirm' | transloco)"
[icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="mergingInProgress"
[disabled]="mergingInProgress"
@@ -305,7 +276,7 @@
</p-dialog>
<p-dialog
header="Delete {{ currentMergeType | titlecase }}"
[header]="t('deleteDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showDeleteDialog"
[modal]="true"
class="user-dialog"
@@ -313,36 +284,36 @@
<div class="dialog-form">
<div class="warning-message">
<i class="pi pi-exclamation-triangle"></i>
<p>You are about to delete {{ currentDeleteItem ? '1' : getSelectedItems(currentMergeType).length }} {{ currentMergeType }}:</p>
<p>{{ t('deleteWarning', { count: currentDeleteItem ? 1 : getSelectedItems(currentMergeType).length, type: currentMergeType }) }}</p>
</div>
@if (currentDeleteItem) {
<div class="current-value">
<strong>{{ currentDeleteItem.value }}</strong>
<span class="count">({{ currentDeleteItem.count }} books)</span>
<span class="count">{{ t('booksCount', { count: currentDeleteItem.count }) }}</span>
</div>
} @else {
<ul class="selected-items">
@for (item of getSelectedItems(currentMergeType); track item.value) {
<li>
• {{ item.value }} <span class="count">({{ item.count }} books)</span>
&#8226; {{ item.value }} <span class="count">{{ t('booksCount', { count: item.count }) }}</span>
</li>
}
</ul>
}
<div class="delete-info">
<p><strong>What will happen:</strong></p>
<p><strong>{{ t('whatWillHappen') }}</strong></p>
<ul>
<li>The {{ currentMergeType.slice(0, -1) }} will be removed from all affected books</li>
<li>This action cannot be undone</li>
<li>Total books affected: <strong>{{ currentDeleteItem ? currentDeleteItem.count : getTotalAffectedBooks(getSelectedItems(currentMergeType)) }}</strong></li>
<li>{{ t('deleteItemRemoved', { singular: currentMergeType.slice(0, -1) }) }}</li>
<li>{{ t('deleteCannotUndo') }}</li>
<li>{{ t('totalBooksAffected') }} <strong>{{ currentDeleteItem ? currentDeleteItem.count : getTotalAffectedBooks(getSelectedItems(currentMergeType)) }}</strong></li>
</ul>
</div>
@if (deletingInProgress) {
<div class="processing-note">
<i class="pi pi-info-circle"></i>
<span>This process may take some time if "Write to file" is enabled in settings.</span>
<span>{{ t('renameProcessingNote') }}</span>
</div>
}
</div>
@@ -350,14 +321,14 @@
<ng-template pTemplate="footer">
<div class="dialog-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
(onClick)="showDeleteDialog = false"
[disabled]="deletingInProgress"
severity="secondary"
outlined></p-button>
<p-button
[label]="deletingInProgress ? 'Deleting...' : 'Delete'"
[label]="deletingInProgress ? t('deleting') : ('common.delete' | transloco)"
[icon]="deletingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-trash'"
[loading]="deletingInProgress"
[disabled]="deletingInProgress"
@@ -367,3 +338,4 @@
</ng-template>
</p-dialog>
</div>
</ng-container>
@@ -18,6 +18,7 @@ import {InputIcon} from 'primeng/inputicon';
import {ActivatedRoute, Router} from '@angular/router';
import {Subscription} from 'rxjs';
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface MetadataItem {
value: string;
@@ -30,8 +31,8 @@ type MetadataType = 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'pu
interface TabConfig {
type: MetadataType;
label: string;
placeholder: string;
labelKey: string;
placeholderKey: string;
selectAllKey: 'selectAllAuthors' | 'selectAllCategories' | 'selectAllMoods' | 'selectAllTags' | 'selectAllSeries' | 'selectAllPublishers' | 'selectAllLanguages';
icon: string;
}
@@ -56,7 +57,9 @@ interface TabConfig {
Tooltip,
IconField,
InputIcon,
ExternalDocLinkComponent
ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
],
providers: [ConfirmationService],
templateUrl: './metadata-manager.component.html',
@@ -68,6 +71,7 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
private router = inject(Router);
private route = inject(ActivatedRoute);
private pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
private routeSub!: Subscription;
@@ -119,13 +123,13 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
}
tabConfigs: TabConfig[] = [
{type: 'authors', label: 'Author', placeholder: 'Search authors...', selectAllKey: 'selectAllAuthors', icon: 'pi-user'},
{type: 'categories', label: 'Genre', placeholder: 'Search genres...', selectAllKey: 'selectAllCategories', icon: 'pi-tag'},
{type: 'moods', label: 'Mood', placeholder: 'Search moods...', selectAllKey: 'selectAllMoods', icon: 'pi-heart'},
{type: 'tags', label: 'Tag', placeholder: 'Search tags...', selectAllKey: 'selectAllTags', icon: 'pi-tags'},
{type: 'series', label: 'Series', placeholder: 'Search series...', selectAllKey: 'selectAllSeries', icon: 'pi-book'},
{type: 'publishers', label: 'Publisher', placeholder: 'Search publishers...', selectAllKey: 'selectAllPublishers', icon: 'pi-building'},
{type: 'languages', label: 'Language', placeholder: 'Search languages...', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'}
{type: 'authors', labelKey: 'tabs.author', placeholderKey: 'placeholders.searchAuthors', selectAllKey: 'selectAllAuthors', icon: 'pi-user'},
{type: 'categories', labelKey: 'tabs.genre', placeholderKey: 'placeholders.searchGenres', selectAllKey: 'selectAllCategories', icon: 'pi-tag'},
{type: 'moods', labelKey: 'tabs.mood', placeholderKey: 'placeholders.searchMoods', selectAllKey: 'selectAllMoods', icon: 'pi-heart'},
{type: 'tags', labelKey: 'tabs.tag', placeholderKey: 'placeholders.searchTags', selectAllKey: 'selectAllTags', icon: 'pi-tags'},
{type: 'series', labelKey: 'tabs.series', placeholderKey: 'placeholders.searchSeries', selectAllKey: 'selectAllSeries', icon: 'pi-book'},
{type: 'publishers', labelKey: 'tabs.publisher', placeholderKey: 'placeholders.searchPublishers', selectAllKey: 'selectAllPublishers', icon: 'pi-building'},
{type: 'languages', labelKey: 'tabs.language', placeholderKey: 'placeholders.searchLanguages', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'}
];
ngOnInit() {
@@ -149,7 +153,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
updatePageTitle() {
const currentTab = this.tabConfigs.find((tab) => tab.type === this._activeTab);
this.pageTitle.setPageTitle(`Metadata Manager: ${currentTab?.label ?? this._activeTab}`);
const label = currentTab ? this.t.translate('metadata.manager.' + currentTab.labelKey) : this._activeTab;
this.pageTitle.setPageTitle(`${this.t.translate('metadata.manager.title')}: ${label}`);
}
ngOnDestroy(): void {
@@ -232,8 +237,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (selected.length < 2) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Selection',
detail: 'Please select at least 2 items to merge.'
summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: this.t.translate('metadata.manager.toast.mergeMinDetail')
});
return;
}
@@ -260,8 +265,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (selected.length === 0) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Selection',
detail: 'Please select at least 1 item to delete.'
summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: this.t.translate('metadata.manager.toast.deleteMinDetail')
});
return;
}
@@ -275,8 +280,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (!this.currentRenameItem || !this.renameTarget.trim()) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: 'Please enter a valid name.'
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.enterValidName')
});
return;
}
@@ -286,8 +291,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (targetValues.length === 0) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: 'Please enter at least one valid target value.'
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.enterValidTarget')
});
return;
}
@@ -295,8 +300,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one value.`
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.singleValueOnly', {singular: this.currentMergeType.slice(0, -1)})
});
return;
}
@@ -325,8 +330,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Successful`,
detail: `Successfully ${action} "${oldValue}" ${action === 'renamed' ? 'to' : 'into'} ${resultText}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
summary: action === 'renamed'
? this.t.translate('metadata.manager.toast.renameSuccessfulSummary')
: this.t.translate('metadata.manager.toast.splitSuccessfulSummary'),
detail: action === 'renamed'
? this.t.translate('metadata.manager.toast.renameSuccessfulDetail', {oldValue, resultText, count: affectedBooks})
: this.t.translate('metadata.manager.toast.splitSuccessfulDetail', {oldValue, resultText, count: affectedBooks}),
life: 5000
});
this.showRenameDialog = false;
@@ -339,8 +348,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => {
this.messageService.add({
severity: 'error',
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Failed`,
detail: error?.error?.message || `An error occurred during ${action === 'renamed' ? 'rename' : 'split'}.`
summary: action === 'renamed'
? this.t.translate('metadata.manager.toast.renameFailedSummary')
: this.t.translate('metadata.manager.toast.splitFailedSummary'),
detail: error?.error?.message || (action === 'renamed'
? this.t.translate('metadata.manager.toast.renameFailedDetail')
: this.t.translate('metadata.manager.toast.splitFailedDetail'))
});
this.loading = false;
this.mergingInProgress = false;
@@ -353,8 +366,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (!this.mergeTarget.trim()) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: 'Please enter a target value for merging.'
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.enterMergeTarget')
});
return;
}
@@ -364,8 +377,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (targetValues.length === 0) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: 'Please enter at least one valid target value.'
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.enterValidTarget')
});
return;
}
@@ -373,8 +386,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Target',
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one target value to standardize to.`
summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: this.t.translate('metadata.manager.toast.singleMergeValueOnly', {singular: this.currentMergeType.slice(0, -1)})
});
return;
}
@@ -387,7 +400,6 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
const valuesToMerge = selected.map(s => s.value);
const affectedBooks = this.getTotalAffectedBooks(selected);
const operation = targetValues.length === 1 ? 'merge' : 'merge/split';
const operationPast = targetValues.length === 1 ? 'merged' : 'merged/split';
this.loading = true;
this.mergingInProgress = true;
@@ -395,8 +407,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Successful`,
detail: `Successfully ${operationPast} ${selected.length} ${this.currentMergeType} into ${targetValues.length} value(s). ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
summary: operation === 'merge'
? this.t.translate('metadata.manager.toast.mergeSuccessfulSummary')
: this.t.translate('metadata.manager.toast.mergeSplitSuccessfulSummary'),
detail: operation === 'merge'
? this.t.translate('metadata.manager.toast.mergeSuccessfulDetail', {selectedCount: selected.length, type: this.currentMergeType, targetCount: targetValues.length, bookCount: affectedBooks})
: this.t.translate('metadata.manager.toast.mergeSplitSuccessfulDetail', {selectedCount: selected.length, type: this.currentMergeType, targetCount: targetValues.length, bookCount: affectedBooks}),
life: 5000
});
this.showMergeDialog = false;
@@ -409,8 +425,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => {
this.messageService.add({
severity: 'error',
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Failed`,
detail: error?.error?.message || `An error occurred during ${operation}.`
summary: operation === 'merge'
? this.t.translate('metadata.manager.toast.mergeFailedSummary')
: this.t.translate('metadata.manager.toast.mergeSplitFailedSummary'),
detail: error?.error?.message || (operation === 'merge'
? this.t.translate('metadata.manager.toast.mergeFailedDetail')
: this.t.translate('metadata.manager.toast.mergeSplitFailedDetail'))
});
this.loading = false;
this.mergingInProgress = false;
@@ -426,8 +446,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (itemsToDelete.length === 0) {
this.messageService.add({
severity: 'warn',
summary: 'Invalid Selection',
detail: 'Please select at least one item to delete.'
summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: this.t.translate('metadata.manager.toast.deleteSelectMinDetail')
});
return;
}
@@ -447,8 +467,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Delete Successful',
detail: `Successfully deleted ${itemCount} ${this.currentMergeType.slice(0, -1)}${itemCount > 1 ? 's' : ''}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`,
summary: this.t.translate('metadata.manager.toast.deleteSuccessfulSummary'),
detail: this.t.translate('metadata.manager.toast.deleteSuccessfulDetail', {count: itemCount, type: this.currentMergeType.slice(0, -1) + (itemCount > 1 ? 's' : ''), bookCount: affectedBooks}),
life: 5000
});
this.showDeleteDialog = false;
@@ -461,8 +481,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => {
this.messageService.add({
severity: 'error',
summary: 'Delete Failed',
detail: error?.error?.message || 'An error occurred during deletion.'
summary: this.t.translate('metadata.manager.toast.deleteFailedSummary'),
detail: error?.error?.message || this.t.translate('metadata.manager.toast.deleteFailedDetail')
});
this.loading = false;
this.deletingInProgress = false;
@@ -1,62 +1,63 @@
<ng-container *transloco="let t; prefix: 'metadata.advancedFetchOptions'">
<div class="options-container">
<table class="custom-table">
<thead>
<tr>
<th class="table-header" style="max-width: 70px; width: 70px;">Enabled</th>
<th class="table-header" style="max-width: 127px; width: 127px;">Field</th>
<th class="table-header" style="max-width: 70px; width: 70px;">{{ t('enabledHeader') }}</th>
<th class="table-header" style="max-width: 127px; width: 127px;">{{ t('fieldHeader') }}</th>
<th class="table-header">
1st Priority
{{ t('firstPriority') }}
<i class="pi pi-question-circle help-icon"
pTooltip="First choice - always tried first for this field"
[pTooltip]="t('firstPriorityTooltip')"
tooltipPosition="top"></i>
</th>
<th class="table-header">
2nd Priority
{{ t('secondPriority') }}
<i class="pi pi-question-circle help-icon"
pTooltip="Second choice - used if 1st priority doesn't have data"
[pTooltip]="t('secondPriorityTooltip')"
tooltipPosition="top"></i>
</th>
<th class="table-header">
3rd Priority
{{ t('thirdPriority') }}
<i class="pi pi-question-circle help-icon"
pTooltip="Third choice - used if 1st and 2nd priorities don't have data"
[pTooltip]="t('thirdPriorityTooltip')"
tooltipPosition="top"></i>
</th>
<th class="table-header">
4th Priority
{{ t('fourthPriority') }}
<i class="pi pi-question-circle help-icon"
pTooltip="Last fallback option - only used if 1st, 2nd, and 3rd priorities fail or are empty"
[pTooltip]="t('fourthPriorityTooltip')"
tooltipPosition="top"></i>
</th>
</tr>
<tr>
<td class="table-cell" style="max-width: 70px; width: 70px;"></td>
<td class="table-cell set-all-label" style="max-width: 127px; width: 127px;">Set All:</td>
<td class="table-cell set-all-label" style="max-width: 127px; width: 127px;">{{ t('setAll') }}</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP1"
(ngModelChange)="setBulkProvider('p1', $event)"
placeholder="Set all P1" appendTo="body"
[placeholder]="t('setAllP1')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP2"
(ngModelChange)="setBulkProvider('p2', $event)"
placeholder="Set all P2" appendTo="body"
[placeholder]="t('setAllP2')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP3"
(ngModelChange)="setBulkProvider('p3', $event)"
placeholder="Set all P3" appendTo="body"
[placeholder]="t('setAllP3')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP4"
(ngModelChange)="setBulkProvider('p4', $event)"
placeholder="Set all P4" appendTo="body"
[placeholder]="t('setAllP4')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
@@ -67,35 +68,35 @@
<tr [hidden]="field === 'cover' && !refreshCovers" [class.row-disabled]="!enabledFields[field]">
<td class="table-cell-sm" style="max-width: 70px; width: 70px;">
<p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true"
pTooltip="Enable this field during metadata fetch"
[pTooltip]="t('enableFieldTooltip')"
tooltipPosition="top"></p-checkbox>
</td>
<td class="table-cell-sm field-label" style="max-width: 127px; width: 127px;">{{ formatLabel(field) }}</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
[placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
[placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
[placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
<td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
[disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body"
[placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small">
</p-select>
</td>
@@ -105,13 +106,13 @@
</table>
<div class="provider-specific-section">
<h3 class="section-title">Provider-Specific Fields</h3>
<p class="section-description">These fields are unique to specific providers and cannot have custom priority settings. Use the checkboxes to enable/disable fetching these fields.</p>
<h3 class="section-title">{{ t('providerSpecificFields') }}</h3>
<p class="section-description">{{ t('providerSpecificDescription') }}</p>
<div class="fields-grid">
@for (field of providerSpecificFields; track field) {
<div class="field-card">
<p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true"
pTooltip="Enable this field during metadata fetch"
[pTooltip]="t('enableFieldTooltip')"
tooltipPosition="top"></p-checkbox>
<span class="field-card-label">{{ formatLabel(field) }}</span>
</div>
@@ -123,29 +124,30 @@
<div class="options-group">
<div class="option-item">
<p pTooltip="Controls how fetched metadata replaces existing values. 'Replace Missing Only' only fills empty fields, 'Replace All Fields' overwrites existing values." tooltipPosition="top">Replace Mode:</p>
<p [pTooltip]="t('replaceModeTooltip')" tooltipPosition="top">{{ t('replaceModeLabel') }}</p>
<p-select [options]="replaceModeOptions" [(ngModel)]="replaceMode" optionLabel="label" optionValue="value"
appendTo="body" size="small" class="select-mode">
</p-select>
</div>
<div class="option-item">
<p pTooltip="Fetch and update new book cover images" tooltipPosition="top">Update covers:</p>
<p [pTooltip]="t('updateCoversTooltip')" tooltipPosition="top">{{ t('updateCoversLabel') }}</p>
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
</div>
<div class="option-item">
<p pTooltip="Combine new genres with existing ones" tooltipPosition="top">Merge genres:</p>
<p [pTooltip]="t('mergeGenresTooltip')" tooltipPosition="top">{{ t('mergeGenresLabel') }}</p>
<p-checkbox [(ngModel)]="mergeCategories" [binary]="true"></p-checkbox>
</div>
<div class="option-item">
<p pTooltip="Review and approve metadata changes before saving" tooltipPosition="top">Manual review:</p>
<p [pTooltip]="t('manualReviewTooltip')" tooltipPosition="top">{{ t('manualReviewLabel') }}</p>
<p-checkbox [(ngModel)]="reviewBeforeApply" [binary]="true"></p-checkbox>
</div>
</div>
<div class="action-buttons">
<p-button severity="warn" outlined="true" label="Reset Form" (onClick)="reset()"></p-button>
<p-button severity="warn" outlined="true" [label]="t('resetForm')" (onClick)="reset()"></p-button>
<p-button [label]="submitButtonLabel" severity="success" icon="pi pi-save" outlined="true" (onClick)="submit()"></p-button>
</div>
</div>
</div>
</ng-container>
@@ -11,11 +11,12 @@ import {
MetadataReplaceMode
} from '../../../model/request/metadata-refresh-options.model';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-advanced-fetch-options',
templateUrl: './metadata-advanced-fetch-options.component.html',
imports: [Select, FormsModule, Checkbox, Button, Tooltip],
imports: [Select, FormsModule, Checkbox, Button, Tooltip, TranslocoDirective],
styleUrl: './metadata-advanced-fetch-options.component.scss',
standalone: true
})
@@ -64,11 +65,13 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
reviewBeforeApply: boolean = false;
replaceMode: MetadataReplaceMode = 'REPLACE_MISSING';
replaceModeOptions: { label: string; value: MetadataReplaceMode }[] = [
{ label: 'Replace Missing Only', value: 'REPLACE_MISSING' },
{ label: 'Replace All Fields', value: 'REPLACE_ALL' },
{ label: 'Replace When Provided', value: 'REPLACE_WHEN_PROVIDED' }
];
get replaceModeOptions(): { label: string; value: MetadataReplaceMode }[] {
return [
{ label: this.t.translate('metadata.advancedFetchOptions.replaceMissingOnly'), value: 'REPLACE_MISSING' },
{ label: this.t.translate('metadata.advancedFetchOptions.replaceAllFields'), value: 'REPLACE_ALL' },
{ label: this.t.translate('metadata.advancedFetchOptions.replaceWhenProvided'), value: 'REPLACE_WHEN_PROVIDED' }
];
}
fieldOptions: FieldOptions = this.initializeFieldOptions();
enabledFields: Record<keyof FieldOptions, boolean> = this.initializeEnabledFields();
@@ -79,6 +82,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
bulkP4: string | null = null;
private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private justSubmitted = false;
@@ -191,8 +195,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
} else {
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'At least one provider (P1–P4) must be selected for each enabled book field.',
summary: this.t.translate('metadata.advancedFetchOptions.toast.providerRequiredSummary'),
detail: this.t.translate('metadata.advancedFetchOptions.toast.providerRequiredDetail'),
life: 5000
});
}
@@ -1,9 +1,11 @@
<ng-container *transloco="let t; prefix: 'metadata.fetchOptions'">
<div class="metadata-fetch-options-container">
<div class="dialog-content">
<app-metadata-advanced-fetch-options
(metadataOptionsSubmitted)="onMetadataSubmit($event)"
[currentMetadataOptions]="currentMetadataOptions"
[submitButtonLabel]="'Start Refresh'">
[submitButtonLabel]="t('startRefresh')">
</app-metadata-advanced-fetch-options>
</div>
</div>
</ng-container>
@@ -7,13 +7,15 @@ import {AppSettingsService} from '../../../../../shared/service/app-settings.ser
import {filter, take} from 'rxjs/operators';
import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-fetch-options',
standalone: true,
templateUrl: './metadata-fetch-options.component.html',
imports: [
MetadataAdvancedFetchOptionsComponent
MetadataAdvancedFetchOptionsComponent,
TranslocoDirective
],
styleUrl: './metadata-fetch-options.component.scss'
})
@@ -1,36 +1,38 @@
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-list"></i>
Enabled Fields in Metadata Editor & Picker
</h3>
<p class="section-description">
Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface.
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsMeta.fieldSelector'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-list"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">
{{ t('sectionDesc') }}
</p>
</div>
<div class="section-body">
<div class="provider-groups-container">
@for (group of providerGroups; track group.label) {
<div class="provider-group">
<div class="group-header">
<span class="group-icon pi pi-database"></span>
<h4 class="group-label">{{ group.label }}</h4>
<div class="section-body">
<div class="provider-groups-container">
@for (group of providerGroups; track group.label) {
<div class="provider-group">
<div class="group-header">
<span class="group-icon pi pi-database"></span>
<h4 class="group-label">{{ group.label }}</h4>
</div>
<div class="field-list">
@for (field of group.fields; track field) {
<div class="field-item">
<p-toggleswitch
[inputId]="field"
[ngModel]="selectedFields.includes(field)"
(ngModelChange)="toggleField(field, $event)">
</p-toggleswitch>
<label [for]="field">{{ fieldLabels[field] || field }}</label>
</div>
}
</div>
</div>
<div class="field-list">
@for (field of group.fields; track field) {
<div class="field-item">
<p-toggleswitch
[inputId]="field"
[ngModel]="selectedFields.includes(field)"
(ngModelChange)="toggleField(field, $event)">
</p-toggleswitch>
<label [for]="field">{{ fieldLabels[field] || field }}</label>
</div>
}
</div>
</div>
}
}
</div>
</div>
</div>
</div>
</ng-container>
@@ -4,11 +4,12 @@ import {FormsModule} from '@angular/forms';
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model';
import {filter, take} from 'rxjs/operators';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-metadata-provider-field-selector',
standalone: true,
imports: [ToggleSwitchModule, FormsModule],
imports: [ToggleSwitchModule, FormsModule, TranslocoDirective],
templateUrl: './metadata-provider-field-selector.component.html',
styleUrl: './metadata-provider-field-selector.component.scss'
})
@@ -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>

Some files were not shown because too many files have changed in this diff Show More