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/router": "^21.1.2",
"@angular/service-worker": "^21.1.2", "@angular/service-worker": "^21.1.2",
"@iharbeck/ngx-virtual-scroller": "^19.0.1", "@iharbeck/ngx-virtual-scroller": "^19.0.1",
"@jsverse/transloco": "^8.2.1",
"@primeng/themes": "^21.0.3", "@primeng/themes": "^21.0.3",
"@stomp/rx-stomp": "^2.3.0", "@stomp/rx-stomp": "^2.3.0",
"@stomp/stompjs": "^7.2.1", "@stomp/stompjs": "^7.2.1",
@@ -917,7 +918,6 @@
"version": "7.28.6", "version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz",
"integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==", "integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/helper-validator-identifier": "^7.28.5", "@babel/helper-validator-identifier": "^7.28.5",
@@ -1112,7 +1112,6 @@
"version": "7.28.5", "version": "7.28.5",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
"integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
"dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@@ -2581,6 +2580,40 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@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": { "node_modules/@kurkle/color": {
"version": "0.3.4", "version": "0.3.4",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz", "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz",
@@ -5263,7 +5296,6 @@
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0" "license": "Python-2.0"
}, },
"node_modules/aria-query": { "node_modules/aria-query": {
@@ -5536,7 +5568,6 @@
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
@@ -5892,6 +5923,32 @@
"url": "https://opencollective.com/express" "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": { "node_modules/cross-spawn": {
"version": "7.0.6", "version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@@ -6237,6 +6294,15 @@
"dev": true, "dev": true,
"license": "MIT" "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": { "node_modules/es-define-property": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
@@ -7173,17 +7239,6 @@
"node": ">= 0.4" "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": { "node_modules/hosted-git-info": {
"version": "9.0.2", "version": "9.0.2",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.2.tgz", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.2.tgz",
@@ -7383,7 +7438,6 @@
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"parent-module": "^1.0.0", "parent-module": "^1.0.0",
@@ -7443,6 +7497,12 @@
"node": ">= 0.10" "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": { "node_modules/is-core-module": {
"version": "2.16.1", "version": "2.16.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz",
@@ -7625,14 +7685,12 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/js-yaml": { "node_modules/js-yaml": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"argparse": "^2.0.1" "argparse": "^2.0.1"
@@ -7795,6 +7853,12 @@
"node": ">= 0.8.0" "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": { "node_modules/listr2": {
"version": "9.0.5", "version": "9.0.5",
"resolved": "https://registry.npmjs.org/listr2/-/listr2-9.0.5.tgz", "resolved": "https://registry.npmjs.org/listr2/-/listr2-9.0.5.tgz",
@@ -8995,7 +9059,6 @@
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"callsites": "^3.0.0" "callsites": "^3.0.0"
@@ -9004,6 +9067,30 @@
"node": ">=6" "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": { "node_modules/parse5": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz",
@@ -9151,6 +9238,15 @@
"url": "https://opencollective.com/express" "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": { "node_modules/pathe": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
@@ -9162,7 +9258,6 @@
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true,
"license": "ISC" "license": "ISC"
}, },
"node_modules/picomatch": { "node_modules/picomatch": {
@@ -9471,7 +9566,6 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=4" "node": ">=4"
+1
View File
@@ -23,6 +23,7 @@
"@angular/router": "^21.1.2", "@angular/router": "^21.1.2",
"@angular/service-worker": "^21.1.2", "@angular/service-worker": "^21.1.2",
"@iharbeck/ngx-virtual-scroller": "^19.0.1", "@iharbeck/ngx-virtual-scroller": "^19.0.1",
"@jsverse/transloco": "^8.2.1",
"@primeng/themes": "^21.0.3", "@primeng/themes": "^21.0.3",
"@stomp/rx-stomp": "^2.3.0", "@stomp/rx-stomp": "^2.3.0",
"@stomp/stompjs": "^7.2.1", "@stomp/stompjs": "^7.2.1",
+10 -8
View File
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'app'">
@if (loading) { @if (loading) {
<div class="splash-screen"> <div class="splash-screen">
<div class="splash-content"> <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"/> <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> </svg>
@if (offline) { @if (offline) {
<h1>You're Offline</h1> <h1>{{ t('offline') }}</h1>
<p>BookLore needs a connection to the server to load.</p> <p>{{ t('offlineLoadingDescription') }}</p>
<p>Check your network and try again.</p> <p>{{ t('offlineDescription') }}</p>
} @else { } @else {
<h1>Loading Booklore…</h1> <h1>{{ t('loading') }}</h1>
<p>Please wait while we get things ready.</p> <p>{{ t('loadingDescription') }}</p>
<div class="loader"></div> <div class="loader"></div>
} }
</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="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"/> <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> </svg>
<h1>You're Offline</h1> <h1>{{ t('offline') }}</h1>
<p>Your connection was lost. Some features may not work.</p> <p>{{ t('connectionLost') }}</p>
<button class="retry-btn" (click)="reload()">Retry</button> <button class="retry-btn" (click)="reload()">{{ 'common.retry' | transloco }}</button>
</div> </div>
</div> </div>
} @else { } @else {
@@ -33,3 +34,4 @@
<p-toast></p-toast> <p-toast></p-toast>
<router-outlet></router-outlet> <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 {ConfirmDialog} from 'primeng/confirmdialog';
import {Toast} from 'primeng/toast'; import {Toast} from 'primeng/toast';
import {RouterOutlet} from '@angular/router'; import {RouterOutlet} from '@angular/router';
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
import {AuthInitializationService} from './core/security/auth-initialization-service'; import {AuthInitializationService} from './core/security/auth-initialization-service';
import {AppConfigService} from './shared/service/app-config.service'; import {AppConfigService} from './shared/service/app-config.service';
import {MetadataBatchProgressNotification} from './shared/model/metadata-batch-progress.model'; import {MetadataBatchProgressNotification} from './shared/model/metadata-batch-progress.model';
@@ -22,7 +23,7 @@ import {scan, withLatestFrom} from 'rxjs/operators';
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrl: './app.component.scss', styleUrl: './app.component.scss',
standalone: true, standalone: true,
imports: [ConfirmDialog, Toast, RouterOutlet] imports: [ConfirmDialog, Toast, RouterOutlet, TranslocoDirective, TranslocoPipe]
}) })
export class AppComponent implements OnInit, OnDestroy { 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="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-lock"></i> <i class="pi pi-lock"></i>
Authentication Settings {{ t('title') }}
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Configure authentication methods for your Booklore instance. Internal authentication is always enabled, {{ t('description') }}
and you can optionally enable OIDC for external authentication providers.
</p> </p>
</div> </div>
@@ -14,10 +14,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-shield"></i> <i class="pi pi-shield"></i>
Authentication Methods {{ t('methods.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Choose which authentication methods are available for users to sign in. {{ t('methods.sectionDesc') }}
</p> </p>
</div> </div>
@@ -30,12 +30,12 @@
<i class="pi pi-user"></i> <i class="pi pi-user"></i>
</div> </div>
<div class="auth-method-info"> <div class="auth-method-info">
<span class="auth-method-label">Internal Authentication</span> <span class="auth-method-label">{{ t('internal.label') }}</span>
<span class="auth-method-status active">Always Enabled</span> <span class="auth-method-status active">{{ t('internal.status') }}</span>
</div> </div>
</div> </div>
<p class="auth-method-description"> <p class="auth-method-description">
Built-in username and password authentication. This is the default method and cannot be disabled. {{ t('internal.description') }}
</p> </p>
</div> </div>
<p-checkbox <p-checkbox
@@ -53,19 +53,19 @@
</div> </div>
<div class="auth-method-info"> <div class="auth-method-info">
<span class="auth-method-label"> <span class="auth-method-label">
OIDC Authentication {{ t('oidc.label') }}
<span class="experimental-badge">Experimental</span> <span class="experimental-badge">{{ t('oidc.experimental') }}</span>
</span> </span>
<span class="auth-method-status" [class.active]="oidcEnabled"> <span class="auth-method-status" [class.active]="oidcEnabled">
{{ oidcEnabled ? 'Enabled' : 'Disabled' }} {{ oidcEnabled ? t('oidc.enabled') : t('oidc.disabled') }}
</span> </span>
</div> </div>
</div> </div>
<p class="auth-method-description"> <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> <app-external-doc-link docType="authentication"></app-external-doc-link>
@if (!isOidcFormComplete() && !oidcEnabled) { @if (!isOidcFormComplete() && !oidcEnabled) {
<span class="config-hint">Configure settings below to enable.</span> <span class="config-hint">{{ t('oidc.configHint') }}</span>
} }
</p> </p>
</div> </div>
@@ -85,15 +85,15 @@
<div class="section-header-text"> <div class="section-header-text">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-cog"></i> <i class="pi pi-cog"></i>
OIDC Provider Configuration {{ t('providerConfig.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Configure your OIDC provider settings. All fields are required to enable OIDC authentication. {{ t('providerConfig.sectionDesc') }}
</p> </p>
</div> </div>
<p-button <p-button
[outlined]="true" [outlined]="true"
label="Save" [label]="'common.save' | transloco"
icon="pi pi-save" icon="pi pi-save"
severity="success" severity="success"
size="small" size="small"
@@ -106,73 +106,73 @@
<div class="section-body"> <div class="section-body">
<div class="config-grid"> <div class="config-grid">
<div class="config-item"> <div class="config-item">
<label for="providerName">Provider Name</label> <label for="providerName">{{ t('providerConfig.providerName') }}</label>
<input <input
pInputText pInputText
id="providerName" id="providerName"
[(ngModel)]="oidcProvider.providerName" [(ngModel)]="oidcProvider.providerName"
placeholder="e.g. Authentik, Keycloak"/> [placeholder]="t('providerConfig.providerPlaceholder')"/>
</div> </div>
<div class="config-item"> <div class="config-item">
<label for="clientId">Client ID</label> <label for="clientId">{{ t('providerConfig.clientId') }}</label>
<input <input
pInputText pInputText
id="clientId" id="clientId"
[(ngModel)]="oidcProvider.clientId" [(ngModel)]="oidcProvider.clientId"
placeholder="Your OIDC client ID"/> [placeholder]="t('providerConfig.clientIdPlaceholder')"/>
</div> </div>
<div class="config-item full-width"> <div class="config-item full-width">
<label for="issuerUri">Issuer URI</label> <label for="issuerUri">{{ t('providerConfig.issuerUri') }}</label>
<input <input
pInputText pInputText
id="issuerUri" id="issuerUri"
[(ngModel)]="oidcProvider.issuerUri" [(ngModel)]="oidcProvider.issuerUri"
placeholder="e.g. https://auth.example.com/realms/booklore"/> [placeholder]="t('providerConfig.issuerPlaceholder')"/>
</div> </div>
<div class="config-item full-width"> <div class="config-item full-width">
<label for="scope">Scope</label> <label for="scope">{{ t('providerConfig.scope') }}</label>
<input <input
pInputText pInputText
id="scope" id="scope"
[readonly]="true" [readonly]="true"
disabled="disabled" disabled="disabled"
value="openid profile email offline_access"/> 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> </div>
<div class="claims-section"> <div class="claims-section">
<h4 class="subsection-title">Claim Mappings</h4> <h4 class="subsection-title">{{ t('providerConfig.claimMappings') }}</h4>
<p class="subsection-description"> <p class="subsection-description">
Map OIDC token claims to Booklore user fields. These must match your provider's token claims. {{ t('providerConfig.claimDesc') }}
</p> </p>
<div class="claims-grid"> <div class="claims-grid">
<div class="config-item"> <div class="config-item">
<label for="claimUsername">Username Claim</label> <label for="claimUsername">{{ t('providerConfig.usernameClaim') }}</label>
<input <input
pInputText pInputText
id="claimUsername" id="claimUsername"
[(ngModel)]="oidcProvider.claimMapping.username" [(ngModel)]="oidcProvider.claimMapping.username"
placeholder="e.g. preferred_username"/> [placeholder]="t('providerConfig.usernamePlaceholder')"/>
</div> </div>
<div class="config-item"> <div class="config-item">
<label for="claimEmail">Email Claim</label> <label for="claimEmail">{{ t('providerConfig.emailClaim') }}</label>
<input <input
pInputText pInputText
id="claimEmail" id="claimEmail"
[(ngModel)]="oidcProvider.claimMapping.email" [(ngModel)]="oidcProvider.claimMapping.email"
placeholder="e.g. email"/> [placeholder]="t('providerConfig.emailPlaceholder')"/>
</div> </div>
<div class="config-item"> <div class="config-item">
<label for="claimName">Display Name Claim</label> <label for="claimName">{{ t('providerConfig.nameClaim') }}</label>
<input <input
pInputText pInputText
id="claimName" id="claimName"
[(ngModel)]="oidcProvider.claimMapping.name" [(ngModel)]="oidcProvider.claimMapping.name"
placeholder="e.g. name"/> [placeholder]="t('providerConfig.namePlaceholder')"/>
</div> </div>
</div> </div>
</div> </div>
@@ -186,15 +186,15 @@
<div class="section-header-text"> <div class="section-header-text">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-users"></i> <i class="pi pi-users"></i>
User Provisioning {{ t('provisioning.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Configure how new OIDC users are created and what permissions they receive. {{ t('provisioning.sectionDesc') }}
</p> </p>
</div> </div>
<p-button <p-button
icon="pi pi-save" icon="pi pi-save"
label="Save" [label]="'common.save' | transloco"
[outlined]="true" [outlined]="true"
severity="success" severity="success"
size="small" size="small"
@@ -207,14 +207,13 @@
<div class="provisioning-toggle"> <div class="provisioning-toggle">
<div class="toggle-content"> <div class="toggle-content">
<div class="toggle-info"> <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"> <span class="toggle-status" [class.active]="autoUserProvisioningEnabled">
{{ autoUserProvisioningEnabled ? 'Enabled' : 'Disabled' }} {{ autoUserProvisioningEnabled ? t('provisioning.autoEnabled') : t('provisioning.autoDisabled') }}
</span> </span>
</div> </div>
<p class="toggle-description"> <p class="toggle-description">
When enabled, new users are automatically created on first OIDC login with the permissions below. {{ t('provisioning.autoDesc') }}
When disabled, users must be manually created in Booklore before they can log in via OIDC.
</p> </p>
</div> </div>
<p-toggleswitch <p-toggleswitch
@@ -227,7 +226,7 @@
@if (autoUserProvisioningEnabled) { @if (autoUserProvisioningEnabled) {
<div class="default-settings"> <div class="default-settings">
<div class="permissions-group"> <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="permissions-grid">
<div class="permission-item"> <div class="permission-item">
<p-checkbox <p-checkbox
@@ -236,7 +235,7 @@
[ngModel]="true" [ngModel]="true"
inputId="permissionRead"> inputId="permissionRead">
</p-checkbox> </p-checkbox>
<label for="permissionRead">Read Books</label> <label for="permissionRead">{{ t('provisioning.readBooks') }}</label>
</div> </div>
@for (perm of availablePermissions; track perm) { @for (perm of availablePermissions; track perm) {
<div class="permission-item"> <div class="permission-item">
@@ -245,20 +244,20 @@
[binary]="true" [binary]="true"
[inputId]="perm.value"> [inputId]="perm.value">
</p-checkbox> </p-checkbox>
<label [for]="perm.value">{{ perm.label }}</label> <label [for]="perm.value">{{ t(perm.translationKey) }}</label>
</div> </div>
} }
</div> </div>
</div> </div>
<div class="libraries-group"> <div class="libraries-group">
<h4 class="group-title">Default Library Access</h4> <h4 class="group-title">{{ t('provisioning.defaultLibraryAccess') }}</h4>
<p-multiSelect <p-multiSelect
[options]="allLibraries" [options]="allLibraries"
optionLabel="name" optionLabel="name"
optionValue="id" optionValue="id"
[(ngModel)]="editingLibraryIds" [(ngModel)]="editingLibraryIds"
placeholder="Select libraries new users can access" [placeholder]="t('provisioning.selectLibraries')"
appendTo="body" appendTo="body"
class="libraries-select"> class="libraries-select">
</p-multiSelect> </p-multiSelect>
@@ -269,3 +268,4 @@
</div> </div>
} }
</div> </div>
</ng-container>
@@ -14,6 +14,7 @@ import {MultiSelect} from 'primeng/multiselect';
import {Library} from '../../../features/book/model/library.model'; import {Library} from '../../../features/book/model/library.model';
import {LibraryService} from '../../../features/book/service/library.service'; import {LibraryService} from '../../../features/book/service/library.service';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-authentication-settings', selector: 'app-authentication-settings',
@@ -27,21 +28,23 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
Button, Button,
MultiSelect, MultiSelect,
ReactiveFormsModule, ReactiveFormsModule,
ExternalDocLinkComponent ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
], ],
styleUrls: ['./authentication-settings.component.scss'] styleUrls: ['./authentication-settings.component.scss']
}) })
export class AuthenticationSettingsComponent implements OnInit { export class AuthenticationSettingsComponent implements OnInit {
availablePermissions = [ availablePermissions = [
{label: 'Upload Books', value: 'permissionUpload', selected: false}, {label: 'Upload Books', value: 'permissionUpload', selected: false, translationKey: 'perms.uploadBooks'},
{label: 'Download Books', value: 'permissionDownload', selected: false}, {label: 'Download Books', value: 'permissionDownload', selected: false, translationKey: 'perms.downloadBooks'},
{label: 'Edit Book Metadata', value: 'permissionEditMetadata', selected: false}, {label: 'Edit Book Metadata', value: 'permissionEditMetadata', selected: false, translationKey: 'perms.editMetadata'},
{label: 'Manage Library', value: 'permissionManipulateLibrary', selected: false}, {label: 'Manage Library', value: 'permissionManipulateLibrary', selected: false, translationKey: 'perms.manageLibrary'},
{label: 'Email Book', value: 'permissionEmailBook', selected: false}, {label: 'Email Book', value: 'permissionEmailBook', selected: false, translationKey: 'perms.emailBook'},
{label: 'Delete Book', value: 'permissionDeleteBook', selected: false}, {label: 'Delete Book', value: 'permissionDeleteBook', selected: false, translationKey: 'perms.deleteBook'},
{label: 'KOReader Sync', value: 'permissionSyncKoreader', selected: false}, {label: 'KOReader Sync', value: 'permissionSyncKoreader', selected: false, translationKey: 'perms.koreaderSync'},
{label: 'Kobo Sync', value: 'permissionSyncKobo', selected: false}, {label: 'Kobo Sync', value: 'permissionSyncKobo', selected: false, translationKey: 'perms.koboSync'},
{label: 'Access OPDS', value: 'permissionAccessOpds', selected: false} {label: 'Access OPDS', value: 'permissionAccessOpds', selected: false, translationKey: 'perms.accessOpds'}
]; ];
internalAuthEnabled = true; internalAuthEnabled = true;
@@ -65,6 +68,7 @@ export class AuthenticationSettingsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private libraryService = inject(LibraryService); private libraryService = inject(LibraryService);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -118,13 +122,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.toggleOidcEnabled(this.oidcEnabled).subscribe({ this.appSettingsService.toggleOidcEnabled(this.oidcEnabled).subscribe({
next: () => this.messageService.add({ next: () => this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Saved', summary: this.t.translate('settingsAuth.toast.saved'),
detail: 'OIDC setting updated.' detail: this.t.translate('settingsAuth.toast.oidcUpdated')
}), }),
error: () => this.messageService.add({ error: () => this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to update OIDC setting.' detail: this.t.translate('settingsAuth.toast.oidcError')
}) })
}); });
} }
@@ -139,13 +143,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(payload).subscribe({ this.appSettingsService.saveSettings(payload).subscribe({
next: () => this.messageService.add({ next: () => this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Saved', summary: this.t.translate('settingsAuth.toast.saved'),
detail: 'OIDC provider settings saved.' detail: this.t.translate('settingsAuth.toast.providerSaved')
}), }),
error: () => this.messageService.add({ error: () => this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to save OIDC provider settings.' detail: this.t.translate('settingsAuth.toast.providerError')
}) })
}); });
} }
@@ -170,13 +174,13 @@ export class AuthenticationSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(payload).subscribe({ this.appSettingsService.saveSettings(payload).subscribe({
next: () => this.messageService.add({ next: () => this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Saved', summary: this.t.translate('settingsAuth.toast.saved'),
detail: 'OIDC auto-provisioning settings saved.' detail: this.t.translate('settingsAuth.toast.provisionSaved')
}), }),
error: () => this.messageService.add({ error: () => this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to save OIDC auto-provisioning settings.' 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="bulk-edit-container">
<div class="info-banner"> <div class="info-banner">
<i class="pi pi-info-circle"></i> <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> </div>
<p-divider></p-divider> <p-divider></p-divider>
<div class="fields-section"> <div class="fields-section">
<h4>Text Fields</h4> <h4>{{ t('textFieldsTitle') }}</h4>
<div class="field-grid"> <div class="field-grid">
@for (field of textFields; track field.name) { @for (field of textFields; track field.name) {
<div class="field-row"> <div class="field-row">
@@ -15,7 +16,7 @@
[binary]="true" [binary]="true"
[ngModel]="isFieldEnabled(field.name)" [ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)" (ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label"> [ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox> </p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label> <label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input <input
@@ -32,7 +33,7 @@
<p-divider></p-divider> <p-divider></p-divider>
<div class="fields-section"> <div class="fields-section">
<h4>Number Fields</h4> <h4>{{ t('numberFieldsTitle') }}</h4>
<div class="field-grid"> <div class="field-grid">
@for (field of numberFields; track field.name) { @for (field of numberFields; track field.name) {
<div class="field-row"> <div class="field-row">
@@ -40,7 +41,7 @@
[binary]="true" [binary]="true"
[ngModel]="isFieldEnabled(field.name)" [ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)" (ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label"> [ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox> </p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label> <label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input <input
@@ -59,9 +60,9 @@
<div class="fields-section"> <div class="fields-section">
<div class="section-header"> <div class="section-header">
<h4>Array Fields</h4> <h4>{{ t('arrayFieldsTitle') }}</h4>
<div class="merge-toggle"> <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 <p-selectButton
[options]="mergeOptions" [options]="mergeOptions"
[(ngModel)]="mergeArrays" [(ngModel)]="mergeArrays"
@@ -71,7 +72,7 @@
</p-selectButton> </p-selectButton>
</div> </div>
</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"> <div class="field-grid">
@for (field of chipFields; track field.name) { @for (field of chipFields; track field.name) {
<div class="field-row"> <div class="field-row">
@@ -79,7 +80,7 @@
[binary]="true" [binary]="true"
[ngModel]="isFieldEnabled(field.name)" [ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)" (ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label"> [ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox> </p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label> <label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<p-autoComplete <p-autoComplete
@@ -102,13 +103,13 @@
<div class="dialog-footer"> <div class="dialog-footer">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
severity="secondary" severity="secondary"
(click)="cancel()"> (click)="cancel()">
</p-button> </p-button>
<p-button <p-button
label="Apply to Selected" [label]="t('applyToSelected')"
icon="pi pi-check" icon="pi pi-check"
severity="success" severity="success"
[disabled]="!hasEnabledFields" [disabled]="!hasEnabledFields"
@@ -116,3 +117,4 @@
</p-button> </p-button>
</div> </div>
</div> </div>
</ng-container>
@@ -8,6 +8,7 @@ import {AutoComplete} from 'primeng/autocomplete';
import {Divider} from 'primeng/divider'; import {Divider} from 'primeng/divider';
import {SelectButton} from 'primeng/selectbutton'; import {SelectButton} from 'primeng/selectbutton';
import {BookMetadata} from '../../../book/model/book.model'; import {BookMetadata} from '../../../book/model/book.model';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export interface BulkEditResult { export interface BulkEditResult {
fields: Partial<BookMetadata>; fields: Partial<BookMetadata>;
@@ -34,6 +35,8 @@ interface BulkEditField {
AutoComplete, AutoComplete,
Divider, Divider,
SelectButton, SelectButton,
TranslocoDirective,
TranslocoPipe,
], ],
templateUrl: './bookdrop-bulk-edit-dialog.component.html', templateUrl: './bookdrop-bulk-edit-dialog.component.html',
styleUrl: './bookdrop-bulk-edit-dialog.component.scss' styleUrl: './bookdrop-bulk-edit-dialog.component.scss'
@@ -43,6 +46,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
private readonly dialogRef = inject(DynamicDialogRef); private readonly dialogRef = inject(DynamicDialogRef);
private readonly config = inject(DynamicDialogConfig); private readonly config = inject(DynamicDialogConfig);
private readonly cdr = inject(ChangeDetectorRef); private readonly cdr = inject(ChangeDetectorRef);
private readonly t = inject(TranslocoService);
fileCount: number = 0; fileCount: number = 0;
mergeArrays = true; mergeArrays = true;
@@ -61,25 +65,25 @@ export class BookdropBulkEditDialogComponent implements OnInit {
}); });
textFields: BulkEditField[] = [ textFields: BulkEditField[] = [
{name: 'seriesName', label: 'Series Name', type: 'text', controlName: 'seriesName'}, {name: 'seriesName', label: this.t.translate('bookdrop.bulkEdit.seriesName'), type: 'text', controlName: 'seriesName'},
{name: 'publisher', label: 'Publisher', type: 'text', controlName: 'publisher'}, {name: 'publisher', label: this.t.translate('bookdrop.bulkEdit.publisher'), type: 'text', controlName: 'publisher'},
{name: 'language', label: 'Language', type: 'text', controlName: 'language'}, {name: 'language', label: this.t.translate('bookdrop.bulkEdit.language'), type: 'text', controlName: 'language'},
]; ];
numberFields: BulkEditField[] = [ 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[] = [ chipFields: BulkEditField[] = [
{name: 'authors', label: 'Authors', type: 'chips', controlName: 'authors'}, {name: 'authors', label: this.t.translate('bookdrop.bulkEdit.authors'), type: 'chips', controlName: 'authors'},
{name: 'categories', label: 'Genres', type: 'chips', controlName: 'categories'}, {name: 'categories', label: this.t.translate('bookdrop.bulkEdit.genres'), type: 'chips', controlName: 'categories'},
{name: 'moods', label: 'Moods', type: 'chips', controlName: 'moods'}, {name: 'moods', label: this.t.translate('bookdrop.bulkEdit.moods'), type: 'chips', controlName: 'moods'},
{name: 'tags', label: 'Tags', type: 'chips', controlName: 'tags'}, {name: 'tags', label: this.t.translate('bookdrop.bulkEdit.tags'), type: 'chips', controlName: 'tags'},
]; ];
mergeOptions = [ mergeOptions = [
{label: 'Merge', value: true}, {label: this.t.translate('bookdrop.bulkEdit.mergeOption'), value: true},
{label: 'Replace', value: false}, {label: this.t.translate('bookdrop.bulkEdit.replaceOption'), value: false},
]; ];
ngOnInit(): void { ngOnInit(): void {
@@ -113,7 +117,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
target.value = ''; target.value = '';
} }
} }
if (!this.enabledFields.has(fieldName)) { if (!this.enabledFields.has(fieldName)) {
const control = this.bulkEditForm.get(fieldName); const control = this.bulkEditForm.get(fieldName);
const value = control?.value; const value = control?.value;
@@ -1,17 +1,18 @@
<ng-container *transloco="let t; prefix: 'bookdrop.metadataPicker'">
@if (fetchedMetadata && fetchedMetadata.title) { @if (fetchedMetadata && fetchedMetadata.title) {
<form [formGroup]="metadataForm" class="metapicker"> <form [formGroup]="metadataForm" class="metapicker">
<div class="form-scroll"> <div class="form-scroll">
<div class="metaheader"> <div class="metaheader">
<label class="field-label"></label> <label class="field-label"></label>
<div class="header-fields-row"> <div class="header-fields-row">
<p class="header-column">File Data</p> <p class="header-column">{{ t('fileData') }}</p>
<div class="midbuttons"> <div class="midbuttons">
<p-button <p-button
size="small" size="small"
icon="pi pi-angle-left" icon="pi pi-angle-left"
class="btn-margin" class="btn-margin"
[outlined]="true" [outlined]="true"
pTooltip="Copy missing fields from fetched metadata" [pTooltip]="t('copyMissingTooltip')"
tooltipPosition="bottom" tooltipPosition="bottom"
(onClick)="copyMissing()" (onClick)="copyMissing()"
></p-button> ></p-button>
@@ -20,7 +21,7 @@
icon="pi pi-angle-double-left" icon="pi pi-angle-double-left"
class="btn-margin" class="btn-margin"
[outlined]="true" [outlined]="true"
pTooltip="Overwrite all fields with fetched metadata" [pTooltip]="t('overwriteAllTooltip')"
tooltipPosition="bottom" tooltipPosition="bottom"
(onClick)="copyAll()" (onClick)="copyAll()"
></p-button> ></p-button>
@@ -30,12 +31,12 @@
icon="pi pi-refresh" icon="pi pi-refresh"
class="btn-margin" class="btn-margin"
[outlined]="true" [outlined]="true"
pTooltip="Reset all fields to original values" [pTooltip]="t('resetAllTooltip')"
tooltipPosition="bottom" tooltipPosition="bottom"
(onClick)="confirmReset()" (onClick)="confirmReset()"
></p-button> ></p-button>
</div> </div>
<p class="header-column">Fetched Data</p> <p class="header-column">{{ t('fetchedData') }}</p>
</div> </div>
</div> </div>
<div class="metacontent"> <div class="metacontent">
@@ -57,7 +58,7 @@
></p-image> ></p-image>
} }
@else { @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"/> <input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl"/>
</div> </div>
@@ -82,7 +83,7 @@
></p-image> ></p-image>
} }
@else { @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/> <input type="hidden" [value]="fetchedMetadata.thumbnailUrl" readonly/>
</div> </div>
@@ -317,14 +318,14 @@
<div class="form-scroll"> <div class="form-scroll">
<div class="metaheader"> <div class="metaheader">
<p class="missingmd"> <p class="missingmd">
Unable to fetch metadata for this file {{ t('unableToFetchMetadata') }}
</p> </p>
<p-button <p-button
size="small" size="small"
severity="warn" severity="warn"
icon="pi pi-refresh" icon="pi pi-refresh"
[outlined]="true" [outlined]="true"
pTooltip="Reset all fields to original values" [pTooltip]="t('resetAllTooltip')"
tooltipPosition="left" tooltipPosition="left"
(onClick)="confirmReset()" (onClick)="confirmReset()"
></p-button> ></p-button>
@@ -490,3 +491,4 @@
</div> </div>
</form> </form>
} }
</ng-container>
@@ -14,6 +14,7 @@ import {ConfirmationService} from 'primeng/api';
import {DatePicker} from 'primeng/datepicker'; import {DatePicker} from 'primeng/datepicker';
import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields, MetadataFieldConfig} from '../../../../shared/metadata'; import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields, MetadataFieldConfig} from '../../../../shared/metadata';
import {MetadataUtilsService} from '../../../../shared/metadata'; import {MetadataUtilsService} from '../../../../shared/metadata';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-bookdrop-file-metadata-picker-component', selector: 'app-bookdrop-file-metadata-picker-component',
@@ -29,6 +30,7 @@ import {MetadataUtilsService} from '../../../../shared/metadata';
Image, Image,
LazyLoadImageModule, LazyLoadImageModule,
DatePicker, DatePicker,
TranslocoDirective,
], ],
templateUrl: './bookdrop-file-metadata-picker.component.html', templateUrl: './bookdrop-file-metadata-picker.component.html',
styleUrl: './bookdrop-file-metadata-picker.component.scss' styleUrl: './bookdrop-file-metadata-picker.component.scss'
@@ -38,6 +40,7 @@ export class BookdropFileMetadataPickerComponent {
private readonly confirmationService = inject(ConfirmationService); private readonly confirmationService = inject(ConfirmationService);
private readonly metadataUtils = inject(MetadataUtilsService); private readonly metadataUtils = inject(MetadataUtilsService);
protected readonly urlHelper = inject(UrlHelperService); protected readonly urlHelper = inject(UrlHelperService);
private readonly t = inject(TranslocoService);
@Input() fetchedMetadata!: BookMetadata; @Input() fetchedMetadata!: BookMetadata;
@Input() originalMetadata?: BookMetadata; @Input() originalMetadata?: BookMetadata;
@@ -130,8 +133,8 @@ export class BookdropFileMetadataPickerComponent {
confirmReset(): void { confirmReset(): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to this file?', message: this.t.translate('bookdrop.metadataPicker.confirmResetMessage'),
header: 'Reset Metadata Changes?', header: this.t.translate('bookdrop.metadataPicker.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptButtonStyleClass: 'p-button-danger', acceptButtonStyleClass: 'p-button-danger',
accept: () => this.resetAll() accept: () => this.resetAll()
@@ -1,31 +1,28 @@
<ng-container *transloco="let t; prefix: 'bookdrop.fileReview'">
<div class="main-card"> <div class="main-card">
<div class="header"> <div class="header">
<div class="header-content"> <div class="header-content">
<h2> <h2>
Review Bookdrop Files {{ t('title') }}
<a href="https://booklore.org/docs/bookdrop" target="_blank" rel="noopener noreferrer"> <a href="https://booklore.org/docs/bookdrop" target="_blank" rel="noopener noreferrer">
<i <i
class="pi pi-external-link external-link-icon" class="pi pi-external-link external-link-icon"
pTooltip="View documentation" [pTooltip]="t('viewDocumentationTooltip')"
tooltipPosition="top"></i> tooltipPosition="top"></i>
</a> </a>
</h2> </h2>
<p> <p [innerHTML]="t('description')"></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>
</div> </div>
<div class="header-actions"> <div class="header-actions">
<p-button <p-button
label="Rescan" [label]="t('rescan')"
size="small" size="small"
icon="pi pi-refresh" icon="pi pi-refresh"
severity="primary" severity="primary"
outlined outlined
(click)="rescanBookdrop()" (click)="rescanBookdrop()"
pTooltip="Manually trigger a rescan of the Bookdrop folder" [pTooltip]="t('rescanTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
@@ -36,7 +33,7 @@
<div class="loading-overlay"> <div class="loading-overlay">
<div class="loading-content"> <div class="loading-content">
<p-progressSpinner strokeWidth="4"/> <p-progressSpinner strokeWidth="4"/>
<span>Loading Bookdrop files. Please wait...</span> <span>{{ t('loadingMessage') }}</span>
</div> </div>
</div> </div>
@@ -48,7 +45,7 @@
<p-progressSpinner strokeWidth="4"/> <p-progressSpinner strokeWidth="4"/>
<div class="saving-message"> <div class="saving-message">
<span> <span>
Organizing and moving files to their designated libraries. Please wait... {{ t('savingMessage') }}
</span> </span>
</div> </div>
</div> </div>
@@ -62,14 +59,14 @@
size="small" size="small"
outlined outlined
severity="info" severity="info"
label="Import&nbsp;Metadata" [label]="t('importMetadata')"
icon="pi pi-copy" icon="pi pi-copy"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
(click)="copyMetadata()" (click)="copyMetadata()"
pTooltip="Import fetched metadata for selected files" [pTooltip]="t('importMetadataTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </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 <p-checkbox
inputId="includecovers" inputId="includecovers"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
@@ -85,11 +82,11 @@
class="bulkedit" class="bulkedit"
outlined outlined
severity="help" severity="help"
label="Bulk&nbsp;Edit" [label]="t('bulkEdit')"
icon="pi pi-pencil" icon="pi pi-pencil"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
(click)="openBulkEditDialog()" (click)="openBulkEditDialog()"
pTooltip="Edit metadata fields in bulk for selected files" [pTooltip]="t('bulkEditTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
@@ -98,18 +95,18 @@
class="extractpattern" class="extractpattern"
outlined outlined
severity="warn" severity="warn"
label="Extract&nbsp;Pattern" [label]="t('extractPattern')"
icon="pi pi-sliders-h" icon="pi pi-sliders-h"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
(click)="openPatternExtractDialog()" (click)="openPatternExtractDialog()"
pTooltip="Extract metadata from selected filenames using a pattern" [pTooltip]="t('extractPatternTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
<div class="default-controls"> <div class="default-controls">
<i class="pi pi-book" <i class="pi pi-book"
pTooltip="Specify library and subpath for selected files" [pTooltip]="t('specifyLibraryTooltip')"
tooltipPosition="left"></i> tooltipPosition="left"></i>
<p-select <p-select
@@ -117,7 +114,7 @@
[options]="libraryOptions" [options]="libraryOptions"
optionLabel="label" optionLabel="label"
optionValue="value" optionValue="value"
placeholder="Library" [placeholder]="t('libraryPlaceholder')"
appendTo="body" appendTo="body"
[(ngModel)]="defaultLibraryId"> [(ngModel)]="defaultLibraryId">
</p-select> </p-select>
@@ -127,7 +124,7 @@
[options]="selectedLibraryPaths" [options]="selectedLibraryPaths"
optionLabel="label" optionLabel="label"
optionValue="value" optionValue="value"
placeholder="Subpath" [placeholder]="t('subpathPlaceholder')"
appendTo="body" appendTo="body"
[(ngModel)]="defaultPathId"> [(ngModel)]="defaultPathId">
</p-select> </p-select>
@@ -138,7 +135,7 @@
severity="info" severity="info"
[disabled]="!canApplyDefaults" [disabled]="!canApplyDefaults"
(click)="applyLibraryDefaults()" (click)="applyLibraryDefaults()"
pTooltip="Apply library and subpath to selected files" [pTooltip]="t('applyLibraryTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
@@ -149,7 +146,7 @@
<div class="content-area"> <div class="content-area">
@if (bookdropFileUis.length === 0) { @if (bookdropFileUis.length === 0) {
<div class="empty-state"> <div class="empty-state">
No bookdrop files to review. {{ t('emptyState') }}
</div> </div>
} @else { } @else {
@for (file of bookdropFileUis; track file) { @for (file of bookdropFileUis; track file) {
@@ -166,22 +163,22 @@
<img <img
[src]="file.metadataForm.get('thumbnailUrl')?.value" [src]="file.metadataForm.get('thumbnailUrl')?.value"
alt="Cover" alt="Cover"
title="Original cover" [title]="t('originalCoverTitle')"
class="cover-image" class="cover-image"
(click)="file.showDetails = !file.showDetails"/> (click)="file.showDetails = !file.showDetails"/>
} @else { } @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) { @if (file.file.fetchedMetadata?.thumbnailUrl) {
<img <img
[src]="file.file.fetchedMetadata?.thumbnailUrl" [src]="file.file.fetchedMetadata?.thumbnailUrl"
alt="Fetched Cover" alt="Fetched Cover"
title="Fetched cover" [title]="t('fetchedCoverTitle')"
class="cover-image" class="cover-image"
(click)="file.showDetails = !file.showDetails"/> (click)="file.showDetails = !file.showDetails"/>
} @else { } @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"> <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] 'pi-exclamation-triangle not-applied': file.file.fetchedMetadata && !copiedFlags[file.file.id]
}" }"
[pTooltip]="copiedFlags[file.file.id] [pTooltip]="copiedFlags[file.file.id]
? 'Fetched metadata has been applied.' ? t('metadataAppliedTooltip')
: (!file.file.fetchedMetadata || !file.file.fetchedMetadata.title) : (!file.file.fetchedMetadata || !file.file.fetchedMetadata.title)
? 'No fetched metadata available. Original metadata will be used.' ? t('noMetadataTooltip')
: 'Fetched metadata hasn’t been applied yet. Open metadata picker to review.'" : t('metadataNotAppliedTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</i> </i>
@@ -209,7 +206,7 @@
[options]="libraryOptions" [options]="libraryOptions"
optionLabel="label" optionLabel="label"
optionValue="value" optionValue="value"
placeholder="Library" [placeholder]="t('libraryPlaceholder')"
class="library-select" class="library-select"
appendTo="body" appendTo="body"
[(ngModel)]="file.selectedLibraryId" [(ngModel)]="file.selectedLibraryId"
@@ -221,7 +218,7 @@
[options]="file.availablePaths" [options]="file.availablePaths"
optionLabel="name" optionLabel="name"
optionValue="id" optionValue="id"
placeholder="Subpath" [placeholder]="t('subpathPlaceholder')"
class="path-select" class="path-select"
appendTo="body" appendTo="body"
[(ngModel)]="file.selectedPathId"> [(ngModel)]="file.selectedPathId">
@@ -233,10 +230,10 @@
[icon]="file.showDetails ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" [icon]="file.showDetails ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
(click)="file.showDetails = !file.showDetails" (click)="file.showDetails = !file.showDetails"
[pTooltip]="file.showDetails [pTooltip]="file.showDetails
? 'Hide metadata' ? t('hideMetadataTooltip')
: file.file.fetchedMetadata?.title : file.file.fetchedMetadata?.title
? 'Review and copy fetched metadata' ? t('reviewMetadataTooltip')
: 'Show file metadata (no fetched metadata)'" : t('showMetadataTooltip')"
tooltipPosition="left"> tooltipPosition="left">
</p-button> </p-button>
</div> </div>
@@ -270,27 +267,27 @@
@if (bookdropFileUis.length > 0) { @if (bookdropFileUis.length > 0) {
<p-inputgroup class="selectall"> <p-inputgroup class="selectall">
<p-inputgroup-addon> <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-inputgroup-addon>
<p-button <p-button
label="Select&nbsp;All" [label]="t('selectAll')"
icon="pi pi-check-square" icon="pi pi-check-square"
severity="info" severity="info"
(click)="selectAll(true)" (click)="selectAll(true)"
outlined outlined
pTooltip="Select all files across all pages" [pTooltip]="t('selectAllTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</p-inputgroup> </p-inputgroup>
<p-button <p-button
label="Clear" [label]="t('clear')"
icon="pi pi-times-circle" icon="pi pi-times-circle"
severity="warn" severity="warn"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
(click)="selectAll(false)" (click)="selectAll(false)"
outlined outlined
pTooltip="Deselect all files across all pages" [pTooltip]="t('clearTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
} @else { } @else {
@@ -315,33 +312,33 @@
<div class="footer-right"> <div class="footer-right">
<p-button <p-button
label="Reset" [label]="t('reset')"
icon="pi pi-refresh" icon="pi pi-refresh"
severity="warn" severity="warn"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
outlined outlined
(click)="confirmReset()" (click)="confirmReset()"
pTooltip="Discard all changes made to metadata of selected files" [pTooltip]="t('resetTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
<p-button <p-button
label="Delete" [label]="t('delete')"
icon="pi pi-times" icon="pi pi-times"
severity="danger" severity="danger"
[disabled]="!hasSelectedFiles" [disabled]="!hasSelectedFiles"
outlined outlined
(click)="confirmDelete()" (click)="confirmDelete()"
pTooltip="Permanently delete selected Bookdrop files and discard any changes" [pTooltip]="t('deleteTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
<p-button <p-button
label="Finalize" [label]="t('finalize')"
[icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'" [icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'"
severity="success" severity="success"
outlined outlined
[disabled]="!canFinalize || saving" [disabled]="!canFinalize || saving"
(click)="confirmFinalize()" (click)="confirmFinalize()"
pTooltip="Move selected files into the chosen library and subpath" [pTooltip]="t('finalizeTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
@@ -349,3 +346,4 @@
</div> </div>
} }
</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 {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 {BookdropPatternExtractDialogComponent} from '../bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service'; import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
export interface BookdropFileUI { export interface BookdropFileUI {
file: BookdropFile; file: BookdropFile;
@@ -60,6 +61,7 @@ export interface BookdropFileUI {
Paginator, Paginator,
InputGroup, InputGroup,
InputGroupAddonModule, InputGroupAddonModule,
TranslocoDirective,
], ],
}) })
export class BookdropFileReviewComponent implements OnInit { export class BookdropFileReviewComponent implements OnInit {
@@ -73,6 +75,7 @@ export class BookdropFileReviewComponent implements OnInit {
private readonly urlHelper = inject(UrlHelperService); private readonly urlHelper = inject(UrlHelperService);
private readonly activatedRoute = inject(ActivatedRoute); private readonly activatedRoute = inject(ActivatedRoute);
private readonly pageTitle = inject(PageTitleService); private readonly pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
@ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>; @ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>;
@@ -99,7 +102,7 @@ export class BookdropFileReviewComponent implements OnInit {
excludedFiles = new Set<number>(); excludedFiles = new Set<number>();
ngOnInit(): void { ngOnInit(): void {
this.pageTitle.setPageTitle('Review Bookdrop Files'); this.pageTitle.setPageTitle(this.t.translate('bookdrop.fileReview.title'));
this.activatedRoute.queryParams this.activatedRoute.queryParams
.pipe(startWith({}), tap(() => { .pipe(startWith({}), tap(() => {
@@ -374,18 +377,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) { if (selectedCount === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No files selected', summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: 'Please select files to reset metadata.', detail: this.t.translate('bookdrop.fileReview.toast.noFilesResetDetail'),
}); });
return; return;
} }
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to the selected files?', message: this.t.translate('bookdrop.fileReview.toast.confirmResetMessage'),
header: 'Confirm Reset', header: this.t.translate('bookdrop.fileReview.toast.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Reset', acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmResetAccept'),
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: { rejectButtonProps: {
severity: 'secondary', severity: 'secondary',
outlined: true outlined: true
@@ -403,18 +406,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) { if (selectedCount === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No files selected', summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: 'Please select files to finalize.', detail: this.t.translate('bookdrop.fileReview.toast.noFilesFinalizeDetail'),
}); });
return; return;
} }
this.confirmationService.confirm({ this.confirmationService.confirm({
message: `Are you sure you want to finalize the import of ${selectedCount} file${selectedCount !== 1 ? 's' : ''}?`, message: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeMessage', {count: selectedCount}),
header: 'Confirm Finalize', header: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Finalize', acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeAccept'),
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: { rejectButtonProps: {
severity: 'secondary', severity: 'secondary',
outlined: true outlined: true
@@ -432,18 +435,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) { if (selectedCount === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No files selected', summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: 'Please select files to delete.', detail: this.t.translate('bookdrop.fileReview.toast.noFilesDeleteDetail'),
}); });
return; return;
} }
this.confirmationService.confirm({ this.confirmationService.confirm({
message: `Are you sure you want to delete ${selectedCount} selected Bookdrop file${selectedCount !== 1 ? 's' : ''}? This action cannot be undone.`, message: this.t.translate('bookdrop.fileReview.toast.confirmDeleteMessage', {count: selectedCount}),
header: 'Confirm Delete', header: this.t.translate('bookdrop.fileReview.toast.confirmDeleteHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Delete', acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmDeleteAccept'),
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: { rejectButtonProps: {
severity: 'secondary', severity: 'secondary',
outlined: true outlined: true
@@ -469,8 +472,8 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Files Deleted', summary: this.t.translate('bookdrop.fileReview.toast.filesDeletedSummary'),
detail: 'Selected Bookdrop files were deleted successfully.', detail: this.t.translate('bookdrop.fileReview.toast.filesDeletedDetail'),
}); });
this.getSelectedFiles().forEach(file => delete this.fileUiCache[file.file.id]); 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); console.error('Error deleting files:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Delete Failed', summary: this.t.translate('bookdrop.fileReview.toast.deleteFailedSummary'),
detail: 'An error occurred while deleting Bookdrop files.', detail: this.t.translate('bookdrop.fileReview.toast.deleteFailedDetail'),
}); });
}, },
}); });
@@ -549,8 +552,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Import Complete', summary: this.t.translate('bookdrop.fileReview.toast.importCompleteSummary'),
detail: 'Import process finished. See details below.', detail: this.t.translate('bookdrop.fileReview.toast.importCompleteDetail'),
}); });
this.dialogLauncherService.openBookdropFinalizeResultDialog(result); this.dialogLauncherService.openBookdropFinalizeResultDialog(result);
@@ -569,8 +572,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error finalizing import:', err); console.error('Error finalizing import:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Import Failed', summary: this.t.translate('bookdrop.fileReview.toast.importFailedSummary'),
detail: 'Some files could not be moved. Please check the console for more details.', detail: this.t.translate('bookdrop.fileReview.toast.importFailedDetail'),
}); });
this.saving = false; this.saving = false;
} }
@@ -635,15 +638,15 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Rescan Triggered', summary: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredSummary'),
detail: 'Bookdrop rescan has been started successfully.', detail: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredDetail'),
}); });
}, },
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Rescan Failed', summary: this.t.translate('bookdrop.fileReview.toast.rescanFailedSummary'),
detail: 'Unable to trigger bookdrop rescan. Please try again.', detail: this.t.translate('bookdrop.fileReview.toast.rescanFailedDetail'),
}); });
console.error(err); console.error(err);
} }
@@ -659,14 +662,14 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) { if (totalCount === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No files selected', summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: 'Please select files to bulk edit.', detail: this.t.translate('bookdrop.fileReview.toast.noFilesBulkEditDetail'),
}); });
return; return;
} }
const dialogRef = this.dialogLauncherService.openDialog(BookdropBulkEditDialogComponent, { const dialogRef = this.dialogLauncherService.openDialog(BookdropBulkEditDialogComponent, {
header: `Bulk Edit ${totalCount} Files`, header: this.t.translate('bookdrop.fileReview.toast.bulkEditDialogHeader', {count: totalCount}),
width: '600px', width: '600px',
modal: true, modal: true,
closable: true, closable: true,
@@ -689,8 +692,8 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) { if (totalCount === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No files selected', summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: 'Please select files to extract metadata from.', detail: this.t.translate('bookdrop.fileReview.toast.noFilesExtractDetail'),
}); });
return; return;
} }
@@ -699,7 +702,7 @@ export class BookdropFileReviewComponent implements OnInit {
const selectedIds = selectedFiles.map(f => f.file.id); const selectedIds = selectedFiles.map(f => f.file.id);
const dialogRef = this.dialogLauncherService.openDialog(BookdropPatternExtractDialogComponent, { const dialogRef = this.dialogLauncherService.openDialog(BookdropPatternExtractDialogComponent, {
header: 'Extract Metadata from Filenames', header: this.t.translate('bookdrop.fileReview.toast.extractMetadataDialogHeader'),
width: '700px', width: '700px',
modal: true, modal: true,
closable: true, closable: true,
@@ -736,8 +739,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error loading pages into cache:', err); console.error('Error loading pages into cache:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Bulk Edit Failed', summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: 'An error occurred while loading files into cache.', detail: this.t.translate('bookdrop.fileReview.toast.bulkEditCacheFailedDetail'),
}); });
return; return;
} }
@@ -763,16 +766,16 @@ export class BookdropFileReviewComponent implements OnInit {
next: (backendResult: BackendBulkEditResult) => { next: (backendResult: BackendBulkEditResult) => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Bulk Edit Applied', summary: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedSummary'),
detail: `Updated metadata for ${backendResult.successfullyUpdated} of ${backendResult.totalFiles} file(s).`, detail: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedDetail', {success: backendResult.successfullyUpdated, total: backendResult.totalFiles}),
}); });
}, },
error: (err) => { error: (err) => {
console.error('Error applying bulk edit:', err); console.error('Error applying bulk edit:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Bulk Edit Failed', summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: 'An error occurred while applying bulk edits.', 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); console.error('Error loading pages into cache:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Pattern Extraction Failed', summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedSummary'),
detail: 'An error occurred while loading files into cache.', detail: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedDetail'),
}); });
return; return;
} }
@@ -849,8 +852,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Pattern Extraction Applied', summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionAppliedSummary'),
detail: `Applied extracted metadata to ${appliedCount} file(s).`, 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="staging-border">
<div class="widget-row"> <div class="widget-row">
<div class="widget-info"> <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> <p class="widget-count">{{ pendingCount }}</p>
@if (lastUpdatedAt) { @if (lastUpdatedAt) {
<p class="widget-date"> <p class="widget-date">
Last updated: {{ lastUpdatedAt | date: 'short' }} {{ t('lastUpdated') }} {{ lastUpdatedAt | date: 'short' }}
</p> </p>
} }
</div> </div>
@@ -17,8 +18,9 @@
outlined outlined
severity="info" severity="info"
(click)="openReviewDialog()"> (click)="openReviewDialog()">
Review {{ t('reviewBtn') }}
</p-button> </p-button>
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -5,6 +5,7 @@ import {BookdropFileNotification, BookdropFileService} from '../../service/bookd
import {DatePipe} from '@angular/common'; import {DatePipe} from '@angular/common';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-bookdrop-files-widget-component', selector: 'app-bookdrop-files-widget-component',
@@ -13,7 +14,8 @@ import {Button} from 'primeng/button';
styleUrl: './bookdrop-files-widget.component.scss', styleUrl: './bookdrop-files-widget.component.scss',
imports: [ imports: [
DatePipe, DatePipe,
Button Button,
TranslocoDirective
] ]
}) })
export class BookdropFilesWidgetComponent implements OnInit, OnDestroy { 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="import-result-container">
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi pi-file-import header-icon"></i> <i class="pi pi-file-import header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Import Summary</h2> <h2 class="panel-title">{{ t('panelTitle') }}</h2>
<p class="panel-description">Results of your book import</p> <p class="panel-description">{{ t('panelDescription') }}</p>
</div> </div>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -21,20 +22,20 @@
<div class="stats-grid"> <div class="stats-grid">
<div class="stat-card"> <div class="stat-card">
<div class="stat-value total">{{ result.totalFiles }}</div> <div class="stat-value total">{{ result.totalFiles }}</div>
<div class="stat-label">Total Files</div> <div class="stat-label">{{ t('totalFiles') }}</div>
</div> </div>
<div class="stat-card"> <div class="stat-card">
<div class="stat-value success">{{ result.successfullyImported }}</div> <div class="stat-value success">{{ result.successfullyImported }}</div>
<div class="stat-label">Successfully Imported</div> <div class="stat-label">{{ t('successfullyImported') }}</div>
</div> </div>
<div class="stat-card"> <div class="stat-card">
<div class="stat-value failed">{{ result.failed }}</div> <div class="stat-value failed">{{ result.failed }}</div>
<div class="stat-label">Failed</div> <div class="stat-label">{{ t('failed') }}</div>
</div> </div>
</div> </div>
<div class="processed-info"> <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 class="processed-time">{{ result.processedAt | date:'medium' }}</div>
</div> </div>
@@ -65,3 +66,4 @@
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -3,13 +3,15 @@ import {DatePipe, NgClass} from '@angular/common';
import {BookdropFinalizeResult} from '../../service/bookdrop.service'; import {BookdropFinalizeResult} from '../../service/bookdrop.service';
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog"; import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog";
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-bookdrop-finalize-result-dialog', selector: 'app-bookdrop-finalize-result-dialog',
imports: [ imports: [
NgClass, NgClass,
DatePipe, DatePipe,
Button Button,
TranslocoDirective
], ],
templateUrl: './bookdrop-finalize-result-dialog.component.html', templateUrl: './bookdrop-finalize-result-dialog.component.html',
styleUrl: './bookdrop-finalize-result-dialog.component.scss' 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="pattern-extract-container">
<div class="info-banner"> <div class="info-banner">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
<span> <span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></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>
</div> </div>
<p-divider></p-divider> <p-divider></p-divider>
<div class="pattern-section"> <div class="pattern-section">
<h4>Pattern</h4> <h4>{{ t('patternTitle') }}</h4>
<div class="pattern-input-row"> <div class="pattern-input-row">
<input <input
#patternInput #patternInput
pInputText pInputText
[formControl]="patternControl" [formControl]="patternControl"
[placeholder]="patternPlaceholderText" [placeholder]="t('patternPlaceholder')"
id="pattern-input" id="pattern-input"
aria-label="Filename pattern for metadata extraction" [attr.aria-label]="t('patternAriaLabel')"
class="pattern-input" class="pattern-input"
(input)="previewPattern()"/> (input)="previewPattern()"/>
<p-button <p-button
icon="pi pi-eye" icon="pi pi-eye"
label="Preview" [label]="t('preview')"
severity="secondary" severity="secondary"
[disabled]="!hasValidPattern" [disabled]="!hasValidPattern"
[ariaLabel]="'Preview pattern extraction on sample files'" [ariaLabel]="t('previewAriaLabel')"
(click)="previewPattern()"> (click)="previewPattern()">
</p-button> </p-button>
</div> </div>
</div> </div>
<div class="placeholders-section"> <div class="placeholders-section">
<h4>Available Placeholders</h4> <h4>{{ t('availablePlaceholdersTitle') }}</h4>
<div class="placeholder-chips"> <div class="placeholder-chips">
@for (placeholder of availablePlaceholders; track placeholder.name) { @for (placeholder of availablePlaceholders; track placeholder.name) {
<p-chip <p-chip
@@ -48,11 +46,11 @@
</div> </div>
<div class="common-patterns-section"> <div class="common-patterns-section">
<h4>Common Patterns</h4> <h4>{{ t('commonPatternsTitle') }}</h4>
<div class="common-pattern-buttons"> <div class="common-pattern-buttons">
@for (commonPattern of commonPatterns; track commonPattern.pattern) { @for (commonPattern of commonPatterns; track commonPattern.pattern) {
<p-button <p-button
[label]="commonPattern.label" [label]="getCommonPatternLabel(commonPattern.labelKey)"
severity="secondary" severity="secondary"
size="small" size="small"
outlined outlined
@@ -66,7 +64,7 @@
@if (previewResults.length > 0) { @if (previewResults.length > 0) {
<div class="preview-section"> <div class="preview-section">
<h4>Preview (Sample Files)</h4> <h4>{{ t('previewTitle') }}</h4>
<div class="preview-list"> <div class="preview-list">
@for (preview of previewResults; track preview.fileName) { @for (preview of previewResults; track preview.fileName) {
<div class="preview-item" [ngClass]="getPreviewClass(preview)"> <div class="preview-item" [ngClass]="getPreviewClass(preview)">
@@ -102,18 +100,18 @@
@if (isExtracting) { @if (isExtracting) {
<div class="extracting-indicator"> <div class="extracting-indicator">
<p-progressSpinner strokeWidth="4" [style]="spinnerStyle"></p-progressSpinner> <p-progressSpinner strokeWidth="4" [style]="spinnerStyle"></p-progressSpinner>
<span>Extracting metadata...</span> <span>{{ t('extractingMessage') }}</span>
</div> </div>
} }
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
severity="secondary" severity="secondary"
[disabled]="isExtracting" [disabled]="isExtracting"
(click)="cancel()"> (click)="cancel()">
</p-button> </p-button>
<p-button <p-button
label="Extract and Apply" [label]="t('extractAndApply')"
icon="pi pi-check" icon="pi pi-check"
severity="success" severity="success"
[disabled]="!hasValidPattern || isExtracting" [disabled]="!hasValidPattern || isExtracting"
@@ -121,3 +119,4 @@
</p-button> </p-button>
</div> </div>
</div> </div>
</ng-container>
@@ -10,11 +10,12 @@ import {BookdropService, PatternExtractResult} from '../../service/bookdrop.serv
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
import {NgClass} from '@angular/common'; import {NgClass} from '@angular/common';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface PatternPlaceholder { interface PatternPlaceholder {
name: string; name: string;
description: string; descriptionKey: string;
example: string; exampleKey: string;
} }
interface PreviewResult { interface PreviewResult {
@@ -24,6 +25,22 @@ interface PreviewResult {
errorMessage?: string; 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({ @Component({
selector: 'app-bookdrop-pattern-extract-dialog', selector: 'app-bookdrop-pattern-extract-dialog',
standalone: true, standalone: true,
@@ -36,6 +53,8 @@ interface PreviewResult {
ProgressSpinner, ProgressSpinner,
NgClass, NgClass,
Tooltip, Tooltip,
TranslocoDirective,
TranslocoPipe,
], ],
templateUrl: './bookdrop-pattern-extract-dialog.component.html', templateUrl: './bookdrop-pattern-extract-dialog.component.html',
styleUrl: './bookdrop-pattern-extract-dialog.component.scss' styleUrl: './bookdrop-pattern-extract-dialog.component.scss'
@@ -46,6 +65,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private readonly config = inject(DynamicDialogConfig); private readonly config = inject(DynamicDialogConfig);
private readonly bookdropService = inject(BookdropService); private readonly bookdropService = inject(BookdropService);
private readonly messageService = inject(MessageService); private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
@ViewChild('patternInput', {static: false}) patternInput?: ElementRef<HTMLInputElement>; @ViewChild('patternInput', {static: false}) patternInput?: ElementRef<HTMLInputElement>;
@@ -57,7 +77,6 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
isExtracting = false; isExtracting = false;
previewResults: PreviewResult[] = []; previewResults: PreviewResult[] = [];
patternPlaceholderText = 'e.g., {SeriesName} - Ch {SeriesNumber}';
spinnerStyle = {width: '24px', height: '24px'}; spinnerStyle = {width: '24px', height: '24px'};
patternForm = new FormGroup({ patternForm = new FormGroup({
@@ -65,32 +84,32 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}); });
availablePlaceholders: PatternPlaceholder[] = [ availablePlaceholders: PatternPlaceholder[] = [
{name: '*', description: 'Wildcard - skips any text (not a metadata field)', example: 'anything'}, {name: '*', descriptionKey: 'placeholders.wildcard', exampleKey: 'placeholderExamples.wildcard'},
{name: 'SeriesName', description: 'Series or comic name', example: 'Chronicles of Earth'}, {name: 'SeriesName', descriptionKey: 'placeholders.seriesName', exampleKey: 'placeholderExamples.seriesName'},
{name: 'Title', description: 'Book title', example: 'The Lost City'}, {name: 'Title', descriptionKey: 'placeholders.title', exampleKey: 'placeholderExamples.title'},
{name: 'Subtitle', description: 'Book subtitle', example: 'A Tale of Adventure'}, {name: 'Subtitle', descriptionKey: 'placeholders.subtitle', exampleKey: 'placeholderExamples.subtitle'},
{name: 'Authors', description: 'Author name(s)', example: 'John Smith'}, {name: 'Authors', descriptionKey: 'placeholders.authors', exampleKey: 'placeholderExamples.authors'},
{name: 'SeriesNumber', description: 'Book number in series', example: '25'}, {name: 'SeriesNumber', descriptionKey: 'placeholders.seriesNumber', exampleKey: 'placeholderExamples.seriesNumber'},
{name: 'Published', description: 'Full date with format', example: '{Published:yyyy-MM-dd}'}, {name: 'Published', descriptionKey: 'placeholders.published', exampleKey: 'placeholderExamples.published'},
{name: 'Publisher', description: 'Publisher name', example: 'Epic Press'}, {name: 'Publisher', descriptionKey: 'placeholders.publisher', exampleKey: 'placeholderExamples.publisher'},
{name: 'Language', description: 'Language code', example: 'en'}, {name: 'Language', descriptionKey: 'placeholders.language', exampleKey: 'placeholderExamples.language'},
{name: 'SeriesTotal', description: 'Total books in series', example: '50'}, {name: 'SeriesTotal', descriptionKey: 'placeholders.seriesTotal', exampleKey: 'placeholderExamples.seriesTotal'},
{name: 'ISBN10', description: 'ISBN-10 identifier', example: '1234567890'}, {name: 'ISBN10', descriptionKey: 'placeholders.isbn10', exampleKey: 'placeholderExamples.isbn10'},
{name: 'ISBN13', description: 'ISBN-13 identifier', example: '1234567890123'}, {name: 'ISBN13', descriptionKey: 'placeholders.isbn13', exampleKey: 'placeholderExamples.isbn13'},
{name: 'ASIN', description: 'Amazon ASIN', example: 'B012345678'}, {name: 'ASIN', descriptionKey: 'placeholders.asin', exampleKey: 'placeholderExamples.asin'},
]; ];
commonPatterns = [ commonPatterns = [
{label: 'Author - Title', pattern: '{Authors} - {Title}'}, {labelKey: 'commonPatternLabels.authorTitle', pattern: '{Authors} - {Title}'},
{label: 'Title - Author', pattern: '{Title} - {Authors}'}, {labelKey: 'commonPatternLabels.titleAuthor', pattern: '{Title} - {Authors}'},
{label: 'Title (Year)', pattern: '{Title} ({Published:yyyy})'}, {labelKey: 'commonPatternLabels.titleYear', pattern: '{Title} ({Published:yyyy})'},
{label: 'Author - Title (Year)', pattern: '{Authors} - {Title} ({Published:yyyy})'}, {labelKey: 'commonPatternLabels.authorTitleYear', pattern: '{Authors} - {Title} ({Published:yyyy})'},
{label: 'Series #Number', pattern: '{SeriesName} #{SeriesNumber}'}, {labelKey: 'commonPatternLabels.seriesNumber', pattern: '{SeriesName} #{SeriesNumber}'},
{label: 'Series - Chapter Number', pattern: '{SeriesName} - Chapter {SeriesNumber}'}, {labelKey: 'commonPatternLabels.seriesChapter', pattern: '{SeriesName} - Chapter {SeriesNumber}'},
{label: 'Series - Vol Number', pattern: '{SeriesName} - Vol {SeriesNumber}'}, {labelKey: 'commonPatternLabels.seriesVol', pattern: '{SeriesName} - Vol {SeriesNumber}'},
{label: '[Tag] Series - Chapter Number', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'}, {labelKey: 'commonPatternLabels.tagSeriesChapter', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'},
{label: 'Title by Author', pattern: '{Title} by {Authors}'}, {labelKey: 'commonPatternLabels.titleByAuthor', pattern: '{Title} by {Authors}'},
{label: 'Series vX (of Total)', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'}, {labelKey: 'commonPatternLabels.seriesVTotal', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'},
]; ];
ngOnInit(): void { ngOnInit(): void {
@@ -104,23 +123,23 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
const patternControl = this.patternForm.get('pattern'); const patternControl = this.patternForm.get('pattern');
const currentPattern = patternControl?.value ?? ''; const currentPattern = patternControl?.value ?? '';
const inputElement = this.patternInput?.nativeElement; const inputElement = this.patternInput?.nativeElement;
const textToInsert = placeholderName === '*' ? '*' : `{${placeholderName}}`; const textToInsert = placeholderName === '*' ? '*' : `{${placeholderName}}`;
const patternToModify = placeholderName === '*' const patternToModify = placeholderName === '*'
? currentPattern ? currentPattern
: this.removeExistingPlaceholder(currentPattern, placeholderName); : this.removeExistingPlaceholder(currentPattern, placeholderName);
if (inputElement) { if (inputElement) {
const cursorPosition = this.calculateCursorPosition(inputElement, currentPattern, patternToModify); const cursorPosition = this.calculateCursorPosition(inputElement, currentPattern, patternToModify);
const newPattern = this.insertTextAtCursor(patternToModify, textToInsert, cursorPosition); const newPattern = this.insertTextAtCursor(patternToModify, textToInsert, cursorPosition);
patternControl?.setValue(newPattern); patternControl?.setValue(newPattern);
this.focusInputAfterInsertion(inputElement, cursorPosition, textToInsert.length); this.focusInputAfterInsertion(inputElement, cursorPosition, textToInsert.length);
} else { } else {
patternControl?.setValue(patternToModify + textToInsert); patternControl?.setValue(patternToModify + textToInsert);
} }
this.previewPattern(); this.previewPattern();
} }
@@ -131,7 +150,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private calculateCursorPosition(inputElement: HTMLInputElement, originalPattern: string, modifiedPattern: string): number { private calculateCursorPosition(inputElement: HTMLInputElement, originalPattern: string, modifiedPattern: string): number {
let cursorPosition = inputElement.selectionStart ?? modifiedPattern.length; let cursorPosition = inputElement.selectionStart ?? modifiedPattern.length;
if (originalPattern !== modifiedPattern) { if (originalPattern !== modifiedPattern) {
const existingPlaceholderRegex = new RegExp(`\\{\\w+(?::[^}]*)?\\}`, 'g'); const existingPlaceholderRegex = new RegExp(`\\{\\w+(?::[^}]*)?\\}`, 'g');
const matchBefore = originalPattern.substring(0, cursorPosition).match(existingPlaceholderRegex); const matchBefore = originalPattern.substring(0, cursorPosition).match(existingPlaceholderRegex);
@@ -140,7 +159,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
} }
cursorPosition = Math.max(0, cursorPosition); cursorPosition = Math.max(0, cursorPosition);
} }
return cursorPosition; return cursorPosition;
} }
@@ -218,8 +237,11 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
this.isExtracting = false; this.isExtracting = false;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Extraction Complete', summary: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteSummary'),
detail: `Successfully extracted metadata from ${result.successfullyExtracted} of ${result.totalFiles} files.`, detail: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteDetail', {
success: result.successfullyExtracted,
total: result.totalFiles
}),
}); });
this.dialogRef.close(result); this.dialogRef.close(result);
}, },
@@ -228,8 +250,8 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
console.error('Pattern extraction failed:', err); console.error('Pattern extraction failed:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Extraction Failed', summary: this.t.translate('bookdrop.patternExtract.toast.extractionFailedSummary'),
detail: 'An error occurred during pattern extraction.', detail: this.t.translate('bookdrop.patternExtract.toast.extractionFailedDetail'),
}); });
}, },
}); });
@@ -253,7 +275,13 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
} }
getPlaceholderTooltip(placeholder: PatternPlaceholder): string { 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> { getPreviewClass(preview: PreviewResult): Record<string, boolean> {
@@ -272,10 +300,10 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
} }
getErrorMessage(preview: PreviewResult): string { getErrorMessage(preview: PreviewResult): string {
return preview.errorMessage || 'Pattern did not match'; return preview.errorMessage || this.t.translate('bookdrop.patternExtract.patternDidNotMatch');
} }
getErrorTooltip(preview: PreviewResult): string { 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"> <ng-container *transloco="let t; prefix: 'dashboard.scroller'">
<h2 class="dashboard-scroller-title"> <div class="dashboard-scroller-container">
{{ title }} <h2 class="dashboard-scroller-title">
@if (isMagicShelf) { {{ title }}
<i class="pi pi-sparkles magic-shelf-icon"></i> @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>
} }
</div> </h2>
}
@if (books === null) { @if (!books || books.length === 0) {
<div class="dashboard-scroller-error"> <div class="dashboard-scroller-no-books">
<div class="error-icon"> <div class="empty-state-icon">
<i class="pi pi-exclamation-triangle"></i> <i class="pi pi-book"></i>
</div>
<p>{{ t('noBooksFound') }}</p>
</div> </div>
<p>Failed to load books! Please try refreshing the page.</p> }
</div>
} @if (books) {
</div> <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 {Book} from '../../../book/model/book.model';
import {ScrollerType} from '../../models/dashboard-config.model'; import {ScrollerType} from '../../models/dashboard-config.model';
import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service'; import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-dashboard-scroller', selector: 'app-dashboard-scroller',
@@ -16,7 +17,8 @@ import { BookCardOverlayPreferenceService } from '../../../book/components/book-
InfiniteScrollDirective, InfiniteScrollDirective,
BookCardComponent, BookCardComponent,
ProgressSpinnerModule, ProgressSpinnerModule,
NgClass NgClass,
TranslocoDirective
], ],
standalone: true standalone: true
}) })
@@ -1,154 +1,156 @@
<div class="dashboard-settings"> <ng-container *transloco="let t; prefix: 'dashboard.settings'">
<div class="panel-header"> <div class="dashboard-settings">
<div class="header-icon-wrapper"> <div class="panel-header">
<i class="pi pi-sliders-h header-icon"></i> <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>
<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"> <div class="scrollers-container">
@for (scroller of config.scrollers; track scroller.id; let i = $index) { @for (scroller of config.scrollers; track scroller.id; let i = $index) {
<div class="scroller-item"> <div class="scroller-item">
<div class="scroller-content"> <div class="scroller-content">
<div class="scroller-controls-left"> <div class="scroller-controls-left">
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox> <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> </div>
@if (scroller.type === 'magicShelf') { <div class="scroller-fields">
<div class="scroller-field"> <div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
<label>Magic Shelf</label> <label>{{ t('type') }}</label>
<p-select <p-select
fluid fluid
[options]="(magicShelves$ | async)!" [options]="availableScrollerTypes"
[(ngModel)]="scroller.magicShelfId" [(ngModel)]="scroller.type"
placeholder="Select magic shelf" (onChange)="onScrollerTypeChange(scroller)"
[placeholder]="t('selectType')"
appendTo="body"> appendTo="body">
</p-select> </p-select>
</div> </div>
<div class="scroller-field"> @if (scroller.type === 'magicShelf') {
<label>Sort Field</label> <div class="scroller-field">
<p-select <label>{{ t('magicShelf') }}</label>
fluid <p-select
[options]="sortFieldOptions" fluid
[(ngModel)]="scroller.sortField" [options]="(magicShelves$ | async)!"
placeholder="Select field" [(ngModel)]="scroller.magicShelfId"
appendTo="body"> [placeholder]="t('selectMagicShelf')"
</p-select> appendTo="body">
</div> </p-select>
</div>
<div class="scroller-field"> <div class="scroller-field">
<label>Direction</label> <label>{{ t('sortField') }}</label>
<p-select <p-select
fluid fluid
[options]="sortDirectionOptions" [options]="sortFieldOptions"
[(ngModel)]="scroller.sortDirection" [(ngModel)]="scroller.sortField"
placeholder="Select direction" [placeholder]="t('selectField')"
appendTo="body"> appendTo="body">
</p-select> </p-select>
</div> </div>
}
</div>
<div class="scroller-field max-items-field"> <div class="scroller-field">
<label>Max Items</label> <label>{{ t('direction') }}</label>
<p-inputNumber <p-select
fluid fluid
[(ngModel)]="scroller.maxItems" [options]="sortDirectionOptions"
[min]="MIN_ITEMS" [(ngModel)]="scroller.sortDirection"
[max]="MAX_ITEMS" [placeholder]="t('selectDirection')"
[showButtons]="true"> appendTo="body">
</p-inputNumber> </p-select>
</div> </div>
}
</div>
<div class="scroller-controls-right"> <div class="scroller-field max-items-field">
<p-button <label>{{ t('maxItems') }}</label>
icon="pi pi-arrow-up" <p-inputNumber
outlined fluid
rounded [(ngModel)]="scroller.maxItems"
severity="info" [min]="MIN_ITEMS"
size="small" [max]="MAX_ITEMS"
[disabled]="i === 0" [showButtons]="true">
(click)="moveUp(i)"> </p-inputNumber>
</p-button> </div>
<p-button
icon="pi pi-arrow-down" <div class="scroller-controls-right">
outlined <p-button
rounded icon="pi pi-arrow-up"
severity="info" outlined
size="small" rounded
[disabled]="i === config.scrollers.length - 1" severity="info"
(click)="moveDown(i)"> size="small"
</p-button> [disabled]="i === 0"
<p-button (click)="moveUp(i)">
icon="pi pi-trash" </p-button>
outlined <p-button
rounded icon="pi pi-arrow-down"
size="small" outlined
severity="danger" rounded
(click)="removeScroller(i)" severity="info"
[disabled]="config.scrollers.length === 1"> size="small"
</p-button> [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>
</div>
<div class="dialog-footer"> <div class="dialog-footer">
<div class="footer-left"> <div class="footer-left">
<p-button <p-button
label="Add Scroller" [label]="t('addScroller')"
icon="pi pi-plus" icon="pi pi-plus"
severity="primary" severity="primary"
(click)="addScroller()" (click)="addScroller()"
[disabled]="config.scrollers.length >= 5"> [disabled]="config.scrollers.length >= 5">
</p-button> </p-button>
<p-button <p-button
label="Reset to Default" [label]="t('resetToDefault')"
icon="pi pi-refresh" icon="pi pi-refresh"
severity="secondary" severity="secondary"
text text
(click)="resetToDefault()"> (click)="resetToDefault()">
</p-button> </p-button>
</div> </div>
<div class="footer-actions"> <div class="footer-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
[outlined]="true" [outlined]="true"
severity="secondary" severity="secondary"
(click)="cancel()"> (click)="cancel()">
</p-button> </p-button>
<p-button <p-button
label="Save" [label]="'common.save' | transloco"
icon="pi pi-check" icon="pi pi-check"
severity="success" severity="success"
(click)="save()"> (click)="save()">
</p-button> </p-button>
</div>
</div> </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 {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog'; import {DynamicDialogRef} from 'primeng/dynamicdialog';
@@ -11,6 +12,7 @@ import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashbo
import {DashboardConfigService} from '../../services/dashboard-config.service'; import {DashboardConfigService} from '../../services/dashboard-config.service';
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service'; import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
import {map} from 'rxjs/operators'; import {map} from 'rxjs/operators';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export const MAX_SCROLLERS = 5; export const MAX_SCROLLERS = 5;
export const DEFAULT_MAX_ITEMS = 20; export const DEFAULT_MAX_ITEMS = 20;
@@ -27,7 +29,9 @@ export const MAX_ITEMS = 20;
CheckboxModule, CheckboxModule,
InputTextModule, InputTextModule,
SelectModule, SelectModule,
InputNumberModule InputNumberModule,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './dashboard-settings.component.html', templateUrl: './dashboard-settings.component.html',
styleUrls: ['./dashboard-settings.component.scss'] styleUrls: ['./dashboard-settings.component.scss']
@@ -36,16 +40,14 @@ export class DashboardSettingsComponent implements OnInit {
private configService = inject(DashboardConfigService); private configService = inject(DashboardConfigService);
private dialogRef = inject(DynamicDialogRef); private dialogRef = inject(DynamicDialogRef);
private magicShelfService = inject(MagicShelfService); private magicShelfService = inject(MagicShelfService);
private translocoService = inject(TranslocoService);
private destroyRef = inject(DestroyRef);
config!: DashboardConfig; config!: DashboardConfig;
availableScrollerTypes = [ availableScrollerTypes: {label: string; value: ScrollerType}[] = [];
{label: 'Continue Reading', value: ScrollerType.LAST_READ}, sortFieldOptions: {label: string; value: string}[] = [];
{label: 'Continue Listening', value: ScrollerType.LAST_LISTENED}, sortDirectionOptions: {label: string; value: string}[] = [];
{label: 'Recently Added', value: ScrollerType.LATEST_ADDED},
{label: 'Discover Something New', value: ScrollerType.RANDOM},
{label: 'Magic Shelf', value: ScrollerType.MAGIC_SHELF}
];
magicShelves$ = this.magicShelfService.shelvesState$.pipe( magicShelves$ = this.magicShelfService.shelvesState$.pipe(
map(state => (state.shelves || []).map(shelf => ({ 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>(); private magicShelvesMap = new Map<number, string>();
readonly MIN_ITEMS = MIN_ITEMS; readonly MIN_ITEMS = MIN_ITEMS;
readonly MAX_ITEMS = MAX_ITEMS; readonly MAX_ITEMS = MAX_ITEMS;
ngOnInit(): void { ngOnInit(): void {
this.translocoService.langChanges$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.buildTranslatedOptions());
this.configService.config$.subscribe(config => { this.configService.config$.subscribe(config => {
this.config = JSON.parse(JSON.stringify(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 { getScrollerTitle(scroller: ScrollerConfig): string {
const t = (key: string) => this.translocoService.translate(`dashboard.settings.scrollerTypes.${key}`);
if (scroller.type === ScrollerType.MAGIC_SHELF && scroller.magicShelfId) { 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) { switch (scroller.type) {
case ScrollerType.LAST_READ: case ScrollerType.LAST_READ:
return 'Continue Reading'; return t('lastRead');
case ScrollerType.LAST_LISTENED: case ScrollerType.LAST_LISTENED:
return 'Continue Listening'; return t('lastListened');
case ScrollerType.LATEST_ADDED: case ScrollerType.LATEST_ADDED:
return 'Recently Added'; return t('latestAdded');
case ScrollerType.RANDOM: case ScrollerType.RANDOM:
return 'Discover Something New'; return t('random');
default: default:
return 'Scroller'; return t('default');
} }
} }
@@ -1,70 +1,72 @@
<div class="dashboard-container"> <ng-container *transloco="let t; prefix: 'dashboard.main'">
@if ((bookState$ | async)?.loaded === false) { <div class="dashboard-container">
<div class="loading-state"> @if ((bookState$ | async)?.loaded === false) {
<p-progressSpinner <div class="loading-state">
class="spinner center-spinner" <p-progressSpinner
[style]="{'width': '60px', 'height': '60px'}" class="spinner center-spinner"
strokeWidth="3" [style]="{'width': '60px', 'height': '60px'}"
fill="transparent" strokeWidth="3"
animationDuration="1.5s"> fill="transparent"
</p-progressSpinner> animationDuration="1.5s">
</div> </p-progressSpinner>
} </div>
@if ((bookState$ | async)?.loaded === true) { }
<div class="dashboard"> @if ((bookState$ | async)?.loaded === true) {
<div class="dashboard-inner"> <div class="dashboard">
@if (isLibrariesEmpty$ | async) { <div class="dashboard-inner">
<div class="dashboard-no-library"> @if (isLibrariesEmpty$ | async) {
@if ((userService.userState$ | async)?.user?.permissions; as permissions) { <div class="dashboard-no-library">
<div> @if ((userService.userState$ | async)?.user?.permissions; as permissions) {
@if (permissions.admin || permissions.canManageLibrary) { <div>
<div> @if (permissions.admin || permissions.canManageLibrary) {
<h1 class="no-library-header"> <div>
Welcome to BookLore!<br> <h1 class="no-library-header">
Let's create your first library {{ t('welcomeTitle') }}<br>
</h1> {{ t('welcomeSubtitle') }}
<p class="welcome-description"> </h1>
A library is where all your books live. Start building your digital collection today! <p class="welcome-description">
</p> {{ t('welcomeDescription') }}
<p-button </p>
label="Create Your Library" <p-button
icon="pi pi-plus" [label]="t('createLibrary')"
class="p-button-rounded p-button-outlined" icon="pi pi-plus"
(click)="createNewLibrary()"> class="p-button-rounded p-button-outlined"
</p-button> (click)="createNewLibrary()">
</div> </p-button>
} </div>
</div> }
} </div>
</div> }
} @else { </div>
<div class="dashboard-settings-button"> } @else {
<p-button <div class="dashboard-settings-button">
icon="pi pi-cog" <p-button
severity="info" icon="pi pi-cog"
rounded severity="info"
text rounded
[pTooltip]="'Customize Dashboard'" text
tooltipPosition="left" [pTooltip]="t('customizeDashboard')"
(click)="openDashboardSettings()"> tooltipPosition="left"
</p-button> (click)="openDashboardSettings()">
</div> </p-button>
</div>
@if (dashboardConfig$ | async; as config) { @if (dashboardConfig$ | async; as config) {
@for (scroller of config.scrollers; track scroller.id) { @for (scroller of config.scrollers; track scroller.id) {
@if (scroller.enabled) { @if (scroller.enabled) {
<app-dashboard-scroller <app-dashboard-scroller
[bookListType]="scroller.type" [bookListType]="scroller.type"
[title]="scroller.title" [title]="scroller.title"
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF" [isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED" [useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
[books]="getBooksForScroller(scroller) | async"> [books]="getBooksForScroller(scroller) | async">
</app-dashboard-scroller> </app-dashboard-scroller>
}
} }
} }
} }
} </div>
</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 {UserService} from '../../../settings/user-management/user.service';
import {ProgressSpinner} from 'primeng/progressspinner'; import {ProgressSpinner} from 'primeng/progressspinner';
import {TooltipModule} from 'primeng/tooltip'; import {TooltipModule} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {DashboardConfigService} from '../../services/dashboard-config.service'; import {DashboardConfigService} from '../../services/dashboard-config.service';
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model'; import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service'; import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
@@ -33,7 +34,8 @@ const DEFAULT_MAX_ITEMS = 20;
DashboardScrollerComponent, DashboardScrollerComponent,
AsyncPipe, AsyncPipe,
ProgressSpinner, ProgressSpinner,
TooltipModule TooltipModule,
TranslocoDirective
], ],
standalone: true standalone: true
}) })
@@ -47,6 +49,7 @@ export class MainDashboardComponent implements OnInit {
private ruleEvaluatorService = inject(BookRuleEvaluatorService); private ruleEvaluatorService = inject(BookRuleEvaluatorService);
private sortService = inject(SortService); private sortService = inject(SortService);
private pageTitle = inject(PageTitleService); private pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
bookState$ = this.bookService.bookState$; bookState$ = this.bookService.bookState$;
dashboardConfig$ = this.dashboardConfigService.config$; dashboardConfig$ = this.dashboardConfigService.config$;
@@ -60,7 +63,7 @@ export class MainDashboardComponent implements OnInit {
ScrollerType = ScrollerType; ScrollerType = ScrollerType;
ngOnInit(): void { ngOnInit(): void {
this.pageTitle.setPageTitle('Dashboard'); this.pageTitle.setPageTitle(this.t.translate('dashboard.main.pageTitle'));
this.dashboardConfig$.subscribe(() => { this.dashboardConfig$.subscribe(() => {
this.scrollerBooksCache.clear(); this.scrollerBooksCache.clear();
@@ -1,273 +1,275 @@
<div class="library-creator"> <ng-container *transloco="let t; prefix: 'libraryCreator.creator'">
<header class="dialog-header"> <div class="library-creator">
<div class="header-content"> <header class="dialog-header">
<div class="header-icon"> <div class="header-content">
<i class="pi pi-book"></i> <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>
<div class="header-text"> <p-button
<h1>{{ mode === 'edit' ? 'Edit Library' : 'New Library' }}</h1> icon="pi pi-times"
<p>Configure your book collection</p> [text]="true"
</div> [rounded]="true"
</div> severity="secondary"
<p-button (onClick)="closeDialog()"
icon="pi pi-times" />
[text]="true" </header>
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
/>
</header>
<div class="dialog-body"> <div class="dialog-body">
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
<span>Library Details</span> <span>{{ t('libraryDetails') }}</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> </div>
<div class="form-field"> <div class="form-row two-col">
<label> <div class="form-field">
Icon (Optional) <label>
</label> {{ t('nameLabel') }} <span class="required">*</span>
@if (!selectedIcon) { </label>
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button"> <div class="input-container">
<i class="pi pi-plus"></i> <input
<span>Choose icon</span> pInputText
</button> [(ngModel)]="chosenLibraryName"
} @else { [placeholder]="t('namePlaceholder')"
<div class="icon-selected"> class="input-full"
<div class="icon-preview"> />
<app-icon-display [icon]="selectedIcon" size="16px" /> @if (chosenLibraryName.trim()) {
</div> <i class="pi pi-check-circle field-status success"></i>
<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> </div>
} </div>
</div>
</div>
</section>
<section class="form-section"> <div class="form-field">
<div class="section-header"> <label>
<i class="pi pi-folder-open"></i> {{ t('iconLabel') }}
<span>Book Folders</span> </label>
<span class="section-badge">{{ folders.length }}</span> @if (!selectedIcon) {
</div> <button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
<i class="pi pi-plus"></i>
<div class="folders-zone"> <span>{{ t('chooseIcon') }}</span>
<button class="add-folder-trigger" (click)="openDirectoryPicker()" type="button"> </button>
<i class="pi pi-plus-circle"></i> } @else {
<span>Add folder</span> <div class="icon-selected">
</button> <div class="icon-preview">
<app-icon-display [icon]="selectedIcon" size="16px" />
@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> </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> <i class="pi pi-times"></i>
</button> </button>
</div> </div>
} }
</div> </div>
} @else { </div>
<div class="empty-hint"> </section>
<i class="pi pi-info-circle"></i>
<span>Add folders containing your book files</span>
</div>
}
</div>
</section>
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-cog"></i> <i class="pi pi-folder-open"></i>
<span>Options</span> <span>{{ t('bookFolders') }}</span>
</div> <span class="section-badge">{{ folders.length }}</span>
<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" />
</div> </div>
<div class="option-row"> <div class="folders-zone">
<div class="option-label"> <button class="add-folder-trigger" (click)="openDirectoryPicker()" type="button">
<span>Metadata source</span> <i class="pi pi-plus-circle"></i>
<i <span>{{ t('addFolder') }}</span>
class="pi pi-question-circle info-icon" </button>
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="option-divider"></div> @if (folders.length > 0) {
<div class="folders-list">
<div class="option-row option-row-stacked"> @for (folder of folders; track folder; let i = $index) {
<div class="option-label"> <div class="folder-item">
<span>Format priority</span> <div class="folder-info">
<i <i class="pi pi-folder"></i>
class="pi pi-question-circle info-icon" <span class="folder-path" [pTooltip]="folder" tooltipPosition="top">
pTooltip="Drag to reorder preferred format when a book has multiple files" {{ folder }}
tooltipPosition="top" </span>
></i> </div>
</div> <button class="folder-remove" (click)="removeFolder(i)" type="button">
<div <i class="pi pi-times"></i>
class="format-chips" </button>
cdkDropList </div>
cdkDropListOrientation="mixed" }
[cdkDropListData]="formatPriority" </div>
(cdkDropListDropped)="onFormatPriorityDrop($event)" } @else {
> <div class="empty-hint">
@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">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
<span>Deselected formats won't appear in future scans</span> <span>{{ t('emptyFoldersHint') }}</span>
</div> </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> </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> </div>
</ng-container>
<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>
@@ -18,12 +18,13 @@ import {map} from 'rxjs';
import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop'; import {CdkDragDrop, DragDropModule, moveItemInArray} from '@angular/cdk/drag-drop';
import {Checkbox} from 'primeng/checkbox'; import {Checkbox} from 'primeng/checkbox';
import {Select} from 'primeng/select'; import {Select} from 'primeng/select';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-library-creator', selector: 'app-library-creator',
standalone: true, standalone: true,
templateUrl: './library-creator.component.html', 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' styleUrl: './library-creator.component.scss'
}) })
export class LibraryCreatorComponent implements OnInit { export class LibraryCreatorComponent implements OnInit {
@@ -41,13 +42,7 @@ export class LibraryCreatorComponent implements OnInit {
formatCounts: Record<string, number> = {}; formatCounts: Record<string, number> = {};
metadataSource: MetadataSource = 'EMBEDDED'; metadataSource: MetadataSource = 'EMBEDDED';
readonly metadataSourceOptions = [ metadataSourceOptions: {label: string, value: string}[] = [];
{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'}
];
readonly allBookFormats: {type: BookType, label: string}[] = [ readonly allBookFormats: {type: BookType, label: string}[] = [
{type: 'EPUB', label: 'EPUB'}, {type: 'EPUB', label: 'EPUB'},
@@ -66,8 +61,16 @@ export class LibraryCreatorComponent implements OnInit {
private messageService = inject(MessageService); private messageService = inject(MessageService);
private router = inject(Router); private router = inject(Router);
private iconPicker = inject(IconPickerService); private iconPicker = inject(IconPickerService);
private readonly t = inject(TranslocoService);
ngOnInit(): void { 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.initializeFormatPriority();
this.initializeAllowedFormats(); this.initializeAllowedFormats();
@@ -154,7 +157,7 @@ export class LibraryCreatorComponent implements OnInit {
if (this.mode !== 'edit') return null; if (this.mode !== 'edit') return null;
const count = this.formatCounts[formatType]; const count = this.formatCounts[formatType];
if (count && count > 0 && !this.selectedAllowedFormats.has(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; return null;
} }
@@ -216,8 +219,8 @@ export class LibraryCreatorComponent implements OnInit {
if (exists) { if (exists) {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Library Name Exists', summary: this.t.translate('libraryCreator.creator.toast.nameExistsSummary'),
detail: 'This library name is already taken.', detail: this.t.translate('libraryCreator.creator.toast.nameExistsDetail'),
}); });
return; return;
} }
@@ -240,11 +243,11 @@ export class LibraryCreatorComponent implements OnInit {
if (this.mode === 'edit') { if (this.mode === 'edit') {
this.libraryService.updateLibrary(library, this.library?.id).subscribe({ this.libraryService.updateLibrary(library, this.library?.id).subscribe({
next: () => { 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(); this.dynamicDialogRef.close();
}, },
error: (e) => { 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); console.error(e);
} }
}); });
@@ -269,17 +272,17 @@ export class LibraryCreatorComponent implements OnInit {
this.router.navigate(['/library', createdLibrary.id, 'books']); this.router.navigate(['/library', createdLibrary.id, 'books']);
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Library Created', summary: this.t.translate('libraryCreator.creator.toast.createdSummary'),
detail: count >= 500 detail: count >= 500
? `Library created with ${count} files. Loading in progress...` ? this.t.translate('libraryCreator.creator.toast.createdLargeDetail', {count})
: 'The library was created successfully.' : this.t.translate('libraryCreator.creator.toast.createdDetail')
}); });
this.dynamicDialogRef.close(); this.dynamicDialogRef.close();
} }
}, },
error: (e) => { error: (e) => {
this.libraryService.setLargeLibraryLoading(false, 0); 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); console.error(e);
} }
}); });
@@ -1,50 +1,52 @@
<div class="fullscreen-loader"> <ng-container *transloco="let t; prefix: 'libraryCreator.loading'">
<div class="library-loader-content"> <div class="fullscreen-loader">
<div class="library-loader-header"> <div class="library-loader-content">
<i class="pi pi-book"></i> <div class="library-loader-header">
<h2>Loading Library</h2> <i class="pi pi-book"></i>
</div> <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) { @if (!isComplete) {
<ng-container> <div class="loader-animation">
Processing: <strong>{{ truncatedTitle }}</strong> <div class="dot"></div>
</ng-container> <div class="dot"></div>
} <div class="dot"></div>
@if (isComplete) { </div>
<strong class="complete-message">
<i class="pi pi-check-circle"></i>
Library Loading Complete!
</strong>
} }
</div> </div>
<div class="progress-info"> @if (isComplete) {
<span>{{ current }} / {{ total }}</span> <div class="library-loader-footer">
<span>{{ percentage }}%</span> <button class="reload-button" (click)="onReload()">
</div> <i class="pi pi-bookmark"></i>
{{ t('openLibrary') }}
<div class="progress-bar-container"> </button>
<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>
</div> </div>
} }
</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>
</div> </ng-container>
@@ -1,10 +1,11 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-library-loading', selector: 'app-library-loading',
standalone: true, standalone: true,
imports: [CommonModule], imports: [CommonModule, TranslocoDirective],
templateUrl: './library-loading.component.html', templateUrl: './library-loading.component.html',
styleUrl: './library-loading.component.scss' 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) { @if (config) {
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi pi-book header-icon"></i> <i class="pi pi-book header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Book Details</h2> <h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">View and edit book metadata</p> <p class="panel-description">{{ t('description') }}</p>
</div> </div>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -23,24 +23,24 @@
<p-tablist> <p-tablist>
<p-tab value="view"> <p-tab value="view">
<i [class]="'pi pi-book'"></i> <i [class]="'pi pi-book'"></i>
Book Details {{ t('tabView') }}
</p-tab> </p-tab>
@if (admin || canEditMetadata) { @if (admin || canEditMetadata) {
<p-tab value="edit"> <p-tab value="edit">
<i [class]="'pi pi-pencil'"></i> <i [class]="'pi pi-pencil'"></i>
Edit Metadata {{ t('tabEdit') }}
</p-tab> </p-tab>
} }
@if (admin || canEditMetadata) { @if (admin || canEditMetadata) {
<p-tab value="match"> <p-tab value="match">
<i [class]="'pi pi-search'"></i> <i [class]="'pi pi-search'"></i>
Search Metadata {{ t('tabSearch') }}
</p-tab> </p-tab>
} }
@if (admin || canEditMetadata) { @if (admin || canEditMetadata) {
<p-tab value="sidecar"> <p-tab value="sidecar">
<i [class]="'pi pi-file'"></i> <i [class]="'pi pi-file'"></i>
Sidecar {{ t('tabSidecar') }}
</p-tab> </p-tab>
} }
</p-tablist> </p-tablist>
@@ -10,6 +10,7 @@ import {Tab, TabList, TabPanel, TabPanels, Tabs,} from 'primeng/tabs';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog'; import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service'; import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service';
import {TranslocoDirective} from '@jsverse/transloco';
import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component'; import {MetadataViewerComponent} from './metadata-viewer/metadata-viewer.component';
import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component'; import {MetadataEditorComponent} from './metadata-editor/metadata-editor.component';
import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component'; import {MetadataSearcherComponent} from './metadata-searcher/metadata-searcher.component';
@@ -29,7 +30,8 @@ import {SidecarViewerComponent} from './sidecar-viewer/sidecar-viewer.component'
MetadataEditorComponent, MetadataEditorComponent,
MetadataSearcherComponent, MetadataSearcherComponent,
SidecarViewerComponent, SidecarViewerComponent,
Button Button,
TranslocoDirective
], ],
styleUrls: ['./book-metadata-center.component.scss'], 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) { @if (loading && sessions.length === 0) {
<div class="loading-state"> <div class="loading-state">
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s"></p-progressSpinner> <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> </div>
} @else if (sessions.length === 0) { } @else if (sessions.length === 0) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-clock" style="font-size: 3rem; color: var(--text-color-secondary);"></i> <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> </div>
} @else { } @else {
<p-table <p-table
@@ -20,16 +20,16 @@
[first]="first" [first]="first"
(onLazyLoad)="onPageChange($event)" (onLazyLoad)="onPageChange($event)"
[showCurrentPageReport]="true" [showCurrentPageReport]="true"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} sessions" [currentPageReportTemplate]="t('pageReport')"
class="p-datatable-sm"> class="p-datatable-sm">
<ng-template #header> <ng-template #header>
<tr> <tr>
<th>Session</th> <th>{{ t('headerSession') }}</th>
<th>Type</th> <th>{{ t('headerType') }}</th>
<th>Duration</th> <th>{{ t('headerDuration') }}</th>
<th>Progress</th> <th>{{ t('headerProgress') }}</th>
<th>Progress Delta</th> <th>{{ t('headerProgressDelta') }}</th>
<th>Location</th> <th>{{ t('headerLocation') }}</th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template #body let-session> <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 {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
import {TableModule} from 'primeng/table'; import {TableModule} from 'primeng/table';
import {ProgressSpinnerModule} from 'primeng/progressspinner'; import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-book-reading-sessions', selector: 'app-book-reading-sessions',
standalone: true, standalone: true,
imports: [CommonModule, TableModule, ProgressSpinnerModule], imports: [CommonModule, TableModule, ProgressSpinnerModule, TranslocoDirective],
templateUrl: './book-reading-sessions.component.html', templateUrl: './book-reading-sessions.component.html',
styleUrls: ['./book-reading-sessions.component.scss'] styleUrls: ['./book-reading-sessions.component.scss']
}) })
@@ -14,6 +15,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
@Input() bookId!: number; @Input() bookId!: number;
private readonly readingSessionService = inject(ReadingSessionApiService); private readonly readingSessionService = inject(ReadingSessionApiService);
private readonly t = inject(TranslocoService);
sessions: ReadingSessionResponse[] = []; sessions: ReadingSessionResponse[] = [];
totalRecords = 0; totalRecords = 0;
@@ -121,7 +123,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
} }
formatBookType(bookType: string): string { formatBookType(bookType: string): string {
if (bookType === 'AUDIOBOOK') return 'Audio'; if (bookType === 'AUDIOBOOK') return this.t.translate('metadata.readingSessions.audio');
return bookType; return bookType;
} }
@@ -159,7 +161,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
} }
if (this.isPageNumber(start)) { if (this.isPageNumber(start)) {
return `Page ${start} → ${end}`; return `${this.t.translate('metadata.readingSessions.page')} ${start} → ${end}`;
} }
return '-'; return '-';
@@ -1,5 +1,5 @@
@if (book$ | async; as book) { @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) { @if (isLoading) {
<div class="loading-overlay"></div> <div class="loading-overlay"></div>
} }
@@ -14,7 +14,7 @@
<div class="cover-section"> <div class="cover-section">
@if (supportsDualCovers(book)) { @if (supportsDualCovers(book)) {
<div class="cover-type-label ebook"> <div class="cover-type-label ebook">
<i class="pi pi-book"></i> Ebook Cover <i class="pi pi-book"></i> {{ t('ebookCover') }}
</div> </div>
} }
<p-image <p-image
@@ -33,7 +33,7 @@
<p-button <p-button
icon="pi pi-refresh" icon="pi pi-refresh"
(onClick)="regenerateCover(book.id)" (onClick)="regenerateCover(book.id)"
pTooltip="Regenerate cover (From File)" [pTooltip]="t('regenerateCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[outlined]="true" [outlined]="true"
severity="warn" severity="warn"
@@ -44,7 +44,7 @@
<p-button <p-button
icon="pi pi-palette" icon="pi pi-palette"
(onClick)="generateCustomCover(book.id)" (onClick)="generateCustomCover(book.id)"
pTooltip="Generate Custom Cover" [pTooltip]="t('generateCustomCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[outlined]="true" [outlined]="true"
severity="help" severity="help"
@@ -58,13 +58,13 @@
size="small" size="small"
icon="pi pi-search" icon="pi pi-search"
(onClick)="openCoverSearch()" (onClick)="openCoverSearch()"
pTooltip="Search for cover" [pTooltip]="t('searchCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
severity="info"> severity="info">
</p-button> </p-button>
<p-fileupload <p-fileupload
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'" [chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
pTooltip="Upload cover" [pTooltip]="t('uploadCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[disabled]="book.metadata!['coverLocked']" [disabled]="book.metadata!['coverLocked']"
name="file" name="file"
@@ -79,10 +79,10 @@
(onBeforeUpload)="onBeforeSend()"> (onBeforeUpload)="onBeforeSend()">
</p-fileupload> </p-fileupload>
@if (!book.metadata!['coverLocked']) { @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']) { @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>
</div> </div>
@@ -92,7 +92,7 @@
@if (hasAudiobookFormat(book)) { @if (hasAudiobookFormat(book)) {
<div class="cover-section audiobook-cover-section"> <div class="cover-section audiobook-cover-section">
<div class="cover-type-label audiobook"> <div class="cover-type-label audiobook">
<i class="pi pi-headphones"></i> Audiobook Cover <i class="pi pi-headphones"></i> {{ t('audiobookCover') }}
</div> </div>
<p-image <p-image
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)" [src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
@@ -110,7 +110,7 @@
<p-button <p-button
icon="pi pi-refresh" icon="pi pi-refresh"
(onClick)="regenerateAudiobookCover(book.id)" (onClick)="regenerateAudiobookCover(book.id)"
pTooltip="Regenerate cover (From File)" [pTooltip]="t('regenerateAudiobookCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[outlined]="true" [outlined]="true"
severity="warn" severity="warn"
@@ -120,7 +120,7 @@
<p-button <p-button
icon="pi pi-palette" icon="pi pi-palette"
(onClick)="generateCustomAudiobookCover(book.id)" (onClick)="generateCustomAudiobookCover(book.id)"
pTooltip="Generate Custom Cover" [pTooltip]="t('generateCustomAudiobookCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[outlined]="true" [outlined]="true"
severity="help" severity="help"
@@ -134,13 +134,13 @@
size="small" size="small"
icon="pi pi-search" icon="pi pi-search"
(onClick)="openAudiobookCoverSearch()" (onClick)="openAudiobookCoverSearch()"
pTooltip="Search for audiobook cover" [pTooltip]="t('searchAudiobookCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
severity="info"> severity="info">
</p-button> </p-button>
<p-fileupload <p-fileupload
[chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'" [chooseStyleClass]="'p-button-sm p-button-outlined p-button-danger'"
pTooltip="Upload audiobook cover" [pTooltip]="t('uploadAudiobookCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
[disabled]="book.metadata!['audiobookCoverLocked']" [disabled]="book.metadata!['audiobookCoverLocked']"
name="file" name="file"
@@ -155,10 +155,10 @@
(onBeforeUpload)="onBeforeSend()"> (onBeforeUpload)="onBeforeSend()">
</p-fileupload> </p-fileupload>
@if (!book.metadata!['audiobookCoverLocked']) { @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']) { @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> </div>
` `
@@ -169,7 +169,7 @@
<div class="field-row"> <div class="field-row">
<div class="field-group title-field"> <div class="field-group title-field">
<label for="title">Title</label> <label for="title">{{ t('title') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="title" formControlName="title"/> <input pInputText id="title" formControlName="title"/>
@if (!book.metadata!['titleLocked']) { @if (!book.metadata!['titleLocked']) {
@@ -182,7 +182,7 @@
</div> </div>
<div class="field-group subtitle-field"> <div class="field-group subtitle-field">
<label for="subtitle">Subtitle</label> <label for="subtitle">{{ t('subtitle') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="subtitle" formControlName="subtitle"/> <input pInputText id="subtitle" formControlName="subtitle"/>
@if (!book.metadata!['subtitleLocked']) { @if (!book.metadata!['subtitleLocked']) {
@@ -195,7 +195,7 @@
</div> </div>
<div class="field-group language-field"> <div class="field-group language-field">
<label for="language">Language</label> <label for="language">{{ t('language') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="language" formControlName="language"/> <input pInputText id="language" formControlName="language"/>
@if (!book.metadata!['languageLocked']) { @if (!book.metadata!['languageLocked']) {
@@ -210,7 +210,7 @@
<div class="field-row"> <div class="field-row">
<div class="field-group authors-field"> <div class="field-group authors-field">
<label for="authors">Authors</label> <label for="authors">{{ t('authors') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-autoComplete <p-autoComplete
formControlName="authors" formControlName="authors"
@@ -233,7 +233,7 @@
</div> </div>
</div> </div>
<div class="field-group publisher-field"> <div class="field-group publisher-field">
<label for="publisher">Publisher</label> <label for="publisher">{{ t('publisher') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-autoComplete <p-autoComplete
[fluid]="true" [fluid]="true"
@@ -255,7 +255,7 @@
</div> </div>
</div> </div>
<div class="field-group date-field"> <div class="field-group date-field">
<label for="publishedDate">Publish Date</label> <label for="publishedDate">{{ t('publishDate') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-datepicker <p-datepicker
formControlName="publishedDate" formControlName="publishedDate"
@@ -280,7 +280,7 @@
<div class="field-row"> <div class="field-row">
<div class="field-group full-width"> <div class="field-group full-width">
<label for="categories">Genres</label> <label for="categories">{{ t('genres') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<div class="autocomplete-wrapper"> <div class="autocomplete-wrapper">
<p-autoComplete <p-autoComplete
@@ -307,7 +307,7 @@
<div class="field-row"> <div class="field-row">
<div class="field-group half-width"> <div class="field-group half-width">
<label for="moods">Moods</label> <label for="moods">{{ t('moods') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<div class="autocomplete-wrapper"> <div class="autocomplete-wrapper">
<p-autoComplete <p-autoComplete
@@ -331,7 +331,7 @@
</div> </div>
</div> </div>
<div class="field-group half-width"> <div class="field-group half-width">
<label for="tags">Tags</label> <label for="tags">{{ t('tags') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<div class="autocomplete-wrapper"> <div class="autocomplete-wrapper">
<p-autoComplete <p-autoComplete
@@ -358,7 +358,7 @@
<div class="field-row"> <div class="field-row">
<div class="field-group series-name-field"> <div class="field-group series-name-field">
<label for="seriesName">Series Name</label> <label for="seriesName">{{ t('seriesName') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-autoComplete <p-autoComplete
[fluid]="true" [fluid]="true"
@@ -381,7 +381,7 @@
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="seriesNumber">Series #</label> <label for="seriesNumber">{{ t('seriesNumber') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="seriesNumber" formControlName="seriesNumber"/> <input pInputText id="seriesNumber" formControlName="seriesNumber"/>
@if (!book.metadata!['seriesNumberLocked']) { @if (!book.metadata!['seriesNumberLocked']) {
@@ -394,7 +394,7 @@
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="seriesTotal">Series Total</label> <label for="seriesTotal">{{ t('seriesTotal') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="seriesTotal" formControlName="seriesTotal"/> <input pInputText id="seriesTotal" formControlName="seriesTotal"/>
@if (!book.metadata!['seriesTotalLocked']) { @if (!book.metadata!['seriesTotalLocked']) {
@@ -406,9 +406,9 @@
</div> </div>
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label>Public Reviews</label> <label>{{ t('publicReviews') }}</label>
<div class="field-with-lock"> <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']) { @if (!book.metadata!['reviewsLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviews')" severity="success"></p-button> <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-row">
<div class="field-group small-field"> <div class="field-group small-field">
<label for="isbn10">ISBN 10</label> <label for="isbn10">{{ t('isbn10') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="isbn10" formControlName="isbn10"/> <input pInputText id="isbn10" formControlName="isbn10"/>
@if (!book.metadata!['isbn10Locked']) { @if (!book.metadata!['isbn10Locked']) {
@@ -433,7 +433,7 @@
</div> </div>
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="isbn13">ISBN 13</label> <label for="isbn13">{{ t('isbn13') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="isbn13" formControlName="isbn13"/> <input pInputText id="isbn13" formControlName="isbn13"/>
@if (!book.metadata!['isbn13Locked']) { @if (!book.metadata!['isbn13Locked']) {
@@ -445,7 +445,7 @@
</div> </div>
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="ageRating">Age Rating</label> <label for="ageRating">{{ t('ageRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-select <p-select
id="ageRating" id="ageRating"
@@ -466,7 +466,7 @@
</div> </div>
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="contentRating">Content Rating</label> <label for="contentRating">{{ t('contentRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<p-select <p-select
id="contentRating" id="contentRating"
@@ -487,7 +487,7 @@
</div> </div>
</div> </div>
<div class="field-group small-field"> <div class="field-group small-field">
<label for="pageCount">Pages</label> <label for="pageCount">{{ t('pages') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pInputText id="pageCount" formControlName="pageCount"/> <input pInputText id="pageCount" formControlName="pageCount"/>
@if (!book.metadata!['pageCountLocked']) { @if (!book.metadata!['pageCountLocked']) {
@@ -508,7 +508,7 @@
<div class="collapsible-section" [class.expanded]="audiobookSectionExpanded"> <div class="collapsible-section" [class.expanded]="audiobookSectionExpanded">
<div class="collapsible-header" (click)="audiobookSectionExpanded = !audiobookSectionExpanded"> <div class="collapsible-header" (click)="audiobookSectionExpanded = !audiobookSectionExpanded">
<i class="pi pi-headphones"></i> <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> <i [class]="audiobookSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div> </div>
@if (audiobookSectionExpanded) { @if (audiobookSectionExpanded) {
@@ -543,7 +543,7 @@
<div class="collapsible-section" [class.expanded]="comicSectionExpanded"> <div class="collapsible-section" [class.expanded]="comicSectionExpanded">
<div class="collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded"> <div class="collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i> <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> <i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div> </div>
@if (comicSectionExpanded) { @if (comicSectionExpanded) {
@@ -625,7 +625,7 @@
<div class="collapsible-section" [class.expanded]="providerSectionExpanded"> <div class="collapsible-section" [class.expanded]="providerSectionExpanded">
<div class="collapsible-header" (click)="providerSectionExpanded = !providerSectionExpanded"> <div class="collapsible-header" (click)="providerSectionExpanded = !providerSectionExpanded">
<i class="pi pi-database"></i> <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> <i [class]="providerSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div> </div>
@if (providerSectionExpanded) { @if (providerSectionExpanded) {
@@ -633,7 +633,7 @@
<div class="field-row metadata-ids-row"> <div class="field-row metadata-ids-row">
@if (isFieldVisible('asin')) { @if (isFieldVisible('asin')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="asin">Amazon ASIN</label> <label for="asin">{{ t('amazonAsin') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="asin" formControlName="asin"/> <input pSize="small" pInputText id="asin" formControlName="asin"/>
@if (!book.metadata!['asinLocked']) { @if (!book.metadata!['asinLocked']) {
@@ -647,7 +647,7 @@
} }
@if (isFieldVisible('amazonRating')) { @if (isFieldVisible('amazonRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="amazonRating">Amazon ★</label> <label for="amazonRating">{{ t('amazonRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/> <input pSize="small" pInputText id="amazonRating" formControlName="amazonRating"/>
@if (!book.metadata!['amazonRatingLocked']) { @if (!book.metadata!['amazonRatingLocked']) {
@@ -661,7 +661,7 @@
} }
@if (isFieldVisible('amazonReviewCount')) { @if (isFieldVisible('amazonReviewCount')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="amazonRatingCount">Amazon #</label> <label for="amazonRatingCount">{{ t('amazonReviewCount') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/> <input pSize="small" pInputText id="amazonRatingCount" formControlName="amazonReviewCount"/>
@if (!book.metadata!['amazonReviewCountLocked']) { @if (!book.metadata!['amazonReviewCountLocked']) {
@@ -675,7 +675,7 @@
} }
@if (isFieldVisible('googleId')) { @if (isFieldVisible('googleId')) {
<div class="field-group metadata-id-field"> <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"> <div class="field-with-lock">
<input pSize="small" pInputText id="googleId" formControlName="googleId"/> <input pSize="small" pInputText id="googleId" formControlName="googleId"/>
@if (!book.metadata!['googleIdLocked']) { @if (!book.metadata!['googleIdLocked']) {
@@ -689,7 +689,7 @@
} }
@if (isFieldVisible('goodreadsId')) { @if (isFieldVisible('goodreadsId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="goodreadsId">Goodreads ID</label> <label for="goodreadsId">{{ t('goodreadsId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/> <input pSize="small" pInputText id="goodreadsId" formControlName="goodreadsId"/>
@if (!book.metadata!['goodreadsIdLocked']) { @if (!book.metadata!['goodreadsIdLocked']) {
@@ -703,7 +703,7 @@
} }
@if (isFieldVisible('goodreadsRating')) { @if (isFieldVisible('goodreadsRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="goodreadsRating">Goodreads ★</label> <label for="goodreadsRating">{{ t('goodreadsRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/> <input pSize="small" pInputText id="goodreadsRating" formControlName="goodreadsRating"/>
@if (!book.metadata!['goodreadsRatingLocked']) { @if (!book.metadata!['goodreadsRatingLocked']) {
@@ -717,7 +717,7 @@
} }
@if (isFieldVisible('goodreadsReviewCount')) { @if (isFieldVisible('goodreadsReviewCount')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="goodreadsReviewCount">Goodreads #</label> <label for="goodreadsReviewCount">{{ t('goodreadsReviewCount') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/> <input pSize="small" pInputText id="goodreadsReviewCount" formControlName="goodreadsReviewCount"/>
@if (!book.metadata!['goodreadsReviewCountLocked']) { @if (!book.metadata!['goodreadsReviewCountLocked']) {
@@ -731,7 +731,7 @@
} }
@if (isFieldVisible('hardcoverId')) { @if (isFieldVisible('hardcoverId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="hardcoverId">Hardcover ID</label> <label for="hardcoverId">{{ t('hardcoverId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/> <input pSize="small" pInputText id="hardcoverId" formControlName="hardcoverId"/>
@if (!book.metadata!['hardcoverIdLocked']) { @if (!book.metadata!['hardcoverIdLocked']) {
@@ -745,7 +745,7 @@
} }
@if (isFieldVisible('hardcoverBookId')) { @if (isFieldVisible('hardcoverBookId')) {
<div class="field-group metadata-id-field"> <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"> <div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/> <input pSize="small" pInputText id="hardcoverBookId" formControlName="hardcoverBookId"/>
@if (!book.metadata!['hardcoverBookIdLocked']) { @if (!book.metadata!['hardcoverBookIdLocked']) {
@@ -759,7 +759,7 @@
} }
@if (isFieldVisible('hardcoverRating')) { @if (isFieldVisible('hardcoverRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="hardcoverRating">Hardcover ★</label> <label for="hardcoverRating">{{ t('hardcoverRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/> <input pSize="small" pInputText id="hardcoverRating" formControlName="hardcoverRating"/>
@if (!book.metadata!['hardcoverRatingLocked']) { @if (!book.metadata!['hardcoverRatingLocked']) {
@@ -773,7 +773,7 @@
} }
@if (isFieldVisible('hardcoverReviewCount')) { @if (isFieldVisible('hardcoverReviewCount')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="hardcoverReviewCount">Hardcover #</label> <label for="hardcoverReviewCount">{{ t('hardcoverReviewCount') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/> <input pSize="small" pInputText id="hardcoverReviewCount" formControlName="hardcoverReviewCount"/>
@if (!book.metadata!['hardcoverReviewCountLocked']) { @if (!book.metadata!['hardcoverReviewCountLocked']) {
@@ -787,7 +787,7 @@
} }
@if (isFieldVisible('lubimyczytacId')) { @if (isFieldVisible('lubimyczytacId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="lubimyczytacId">Lubimyczytac ID</label> <label for="lubimyczytacId">{{ t('lubimyczytacId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/> <input pSize="small" pInputText id="lubimyczytacId" formControlName="lubimyczytacId"/>
@if (!book.metadata!['lubimyczytacIdLocked']) { @if (!book.metadata!['lubimyczytacIdLocked']) {
@@ -801,7 +801,7 @@
} }
@if (isFieldVisible('lubimyczytacRating')) { @if (isFieldVisible('lubimyczytacRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="lubimyczytacRating">Lubimyczytac ★</label> <label for="lubimyczytacRating">{{ t('lubimyczytacRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/> <input pSize="small" pInputText id="lubimyczytacRating" formControlName="lubimyczytacRating"/>
@if (!book.metadata!['lubimyczytacRatingLocked']) { @if (!book.metadata!['lubimyczytacRatingLocked']) {
@@ -815,7 +815,7 @@
} }
@if (isFieldVisible('comicvineId')) { @if (isFieldVisible('comicvineId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="comicvineId">Comicvine ID</label> <label for="comicvineId">{{ t('comicvineId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/> <input pSize="small" pInputText id="comicvineId" formControlName="comicvineId"/>
@if (!book.metadata!['comicvineIdLocked']) { @if (!book.metadata!['comicvineIdLocked']) {
@@ -829,7 +829,7 @@
} }
@if (isFieldVisible('ranobedbId')) { @if (isFieldVisible('ranobedbId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="ranobedbId">Ranobedb ID</label> <label for="ranobedbId">{{ t('ranobedbId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/> <input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId"/>
@if (!book.metadata!['ranobedbIdLocked']) { @if (!book.metadata!['ranobedbIdLocked']) {
@@ -843,7 +843,7 @@
} }
@if (isFieldVisible('ranobedbRating')) { @if (isFieldVisible('ranobedbRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="ranobedbRating">Ranobedb ★</label> <label for="ranobedbRating">{{ t('ranobedbRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/> <input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating"/>
@if (!book.metadata!['ranobedbRatingLocked']) { @if (!book.metadata!['ranobedbRatingLocked']) {
@@ -857,7 +857,7 @@
} }
@if (isFieldVisible('audibleId')) { @if (isFieldVisible('audibleId')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="audibleId">Audible ID</label> <label for="audibleId">{{ t('audibleId') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="audibleId" formControlName="audibleId"/> <input pSize="small" pInputText id="audibleId" formControlName="audibleId"/>
@if (!book.metadata!['audibleIdLocked']) { @if (!book.metadata!['audibleIdLocked']) {
@@ -871,7 +871,7 @@
} }
@if (isFieldVisible('audibleRating')) { @if (isFieldVisible('audibleRating')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="audibleRating">Audible ★</label> <label for="audibleRating">{{ t('audibleRating') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="audibleRating" formControlName="audibleRating"/> <input pSize="small" pInputText id="audibleRating" formControlName="audibleRating"/>
@if (!book.metadata!['audibleRatingLocked']) { @if (!book.metadata!['audibleRatingLocked']) {
@@ -885,7 +885,7 @@
} }
@if (isFieldVisible('audibleReviewCount')) { @if (isFieldVisible('audibleReviewCount')) {
<div class="field-group metadata-id-field"> <div class="field-group metadata-id-field">
<label for="audibleReviewCount">Audible #</label> <label for="audibleReviewCount">{{ t('audibleReviewCount') }}</label>
<div class="field-with-lock"> <div class="field-with-lock">
<input pSize="small" pInputText id="audibleReviewCount" formControlName="audibleReviewCount"/> <input pSize="small" pInputText id="audibleReviewCount" formControlName="audibleReviewCount"/>
@if (!book.metadata!['audibleReviewCountLocked']) { @if (!book.metadata!['audibleReviewCountLocked']) {
@@ -904,7 +904,7 @@
<div class="description-section"> <div class="description-section">
<div class="field-group description-field"> <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"> <div class="field-with-lock description-with-lock">
<textarea <textarea
id="description" id="description"
@@ -930,10 +930,10 @@
<div class="desktop-actions"> <div class="desktop-actions">
@if (showNavigationButtons) { @if (showNavigationButtons) {
<div class="navigation-left"> <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-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]="t('previousBookBtn')" [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('nextBookBtn')" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
</div> </div>
} }
@@ -946,7 +946,7 @@
rounded rounded
outlined outlined
severity="info" severity="info"
pTooltip="Go to previous book" [pTooltip]="t('previousBookTooltip')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
<span class="navigation-position"> <span class="navigation-position">
@@ -960,7 +960,7 @@
severity="info" severity="info"
rounded rounded
outlined outlined
pTooltip="Go to next book" [pTooltip]="t('nextBookTooltip')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
</div> </div>
@@ -968,20 +968,20 @@
<div class="actions-right"> <div class="actions-right">
<p-button <p-button
[label]="isAutoFetching ? 'Fetching…' : 'Auto Fetch'" [label]="isAutoFetching ? t('fetchingBtn') : t('autoFetchBtn')"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'" [icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true" [outlined]="true"
severity="info" severity="info"
(onClick)="autoFetch(book.id)" (onClick)="autoFetch(book.id)"
[disabled]="isAutoFetching" [disabled]="isAutoFetching"
pTooltip="Automatically fetch metadata using default sources" [pTooltip]="t('autoFetchTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
<p-divider layout="vertical"/> <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]="t('unlockAllBtn')" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" [pTooltip]="t('unlockAllTooltip')" 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('lockAllBtn')" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" [pTooltip]="t('lockAllTooltip')" tooltipPosition="top"></p-button>
<p-divider layout="vertical"/> <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>
</div> </div>
@@ -989,9 +989,9 @@
<div class="mobile-actions"> <div class="mobile-actions">
@if (showNavigationButtons) { @if (showNavigationButtons) {
<div class="mobile-nav-buttons"> <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-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="Previous Book" 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="Next 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]="t('nextBookBtn')" tooltipPosition="top"></p-button>
</div> </div>
} }
@@ -1005,7 +1005,7 @@
rounded rounded
outlined outlined
severity="info" severity="info"
pTooltip="Go to previous book" [pTooltip]="t('previousBookTooltip')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
<span class="navigation-position"> <span class="navigation-position">
@@ -1019,7 +1019,7 @@
severity="info" severity="info"
rounded rounded
outlined outlined
pTooltip="Go to next book" [pTooltip]="t('nextBookTooltip')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
</div> </div>
@@ -1031,7 +1031,7 @@
severity="info" severity="info"
(onClick)="autoFetch(book.id)" (onClick)="autoFetch(book.id)"
[disabled]="isAutoFetching" [disabled]="isAutoFetching"
pTooltip="Auto Fetch" [pTooltip]="t('autoFetchBtn')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
@@ -1040,7 +1040,7 @@
[outlined]="true" [outlined]="true"
severity="success" severity="success"
(onClick)="unlockAll()" (onClick)="unlockAll()"
pTooltip="Unlock All" [pTooltip]="t('unlockAllBtn')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
@@ -1049,14 +1049,14 @@
[outlined]="true" [outlined]="true"
severity="warn" severity="warn"
(onClick)="lockAll()" (onClick)="lockAll()"
pTooltip="Lock All" [pTooltip]="t('lockAllBtn')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
<div class="mobile-save-action"> <div class="mobile-save-action">
<p-button <p-button
label="Save" [label]="t('saveBtn')"
icon="pi pi-check" icon="pi pi-check"
[loading]="isSaving" [loading]="isSaving"
[disabled]="isSaving" [disabled]="isSaving"
@@ -31,6 +31,7 @@ import {Router} from '@angular/router';
import {UserService} from '../../../../settings/user-management/user.service'; import {UserService} from '../../../../settings/user-management/user.service';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service'; import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model'; import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: "app-metadata-editor", selector: "app-metadata-editor",
@@ -53,6 +54,7 @@ import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-se
Image, Image,
LazyLoadImageModule, LazyLoadImageModule,
Select, Select,
TranslocoDirective,
], ],
}) })
export class MetadataEditorComponent implements OnInit { export class MetadataEditorComponent implements OnInit {
@@ -76,6 +78,7 @@ export class MetadataEditorComponent implements OnInit {
private userService = inject(UserService); private userService = inject(UserService);
private destroyRef = inject(DestroyRef); private destroyRef = inject(DestroyRef);
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private readonly t = inject(TranslocoService);
metadataForm: FormGroup; metadataForm: FormGroup;
currentBookId!: number; currentBookId!: number;
@@ -107,11 +110,7 @@ export class MetadataEditorComponent implements OnInit {
contentRatingOptions: {label: string, value: string}[] = []; contentRatingOptions: {label: string, value: string}[] = [];
ageRatingOptions: {label: string, value: number}[] = []; ageRatingOptions: {label: string, value: number}[] = [];
booleanOptions: {label: string, value: boolean | null}[] = [ booleanOptions: {label: string, value: boolean | null}[] = [];
{label: 'Unknown', value: null},
{label: 'Yes', value: true},
{label: 'No', value: false},
];
comicSectionExpanded = true; comicSectionExpanded = true;
audiobookSectionExpanded = true; audiobookSectionExpanded = true;
@@ -272,16 +271,22 @@ export class MetadataEditorComponent implements OnInit {
contentRatingLocked: new FormControl(false), 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 = [ this.contentRatingOptions = [
{label: 'Everyone', value: 'EVERYONE'}, {label: this.t.translate('metadata.editor.contentRatingEveryone'), value: 'EVERYONE'},
{label: 'Teen', value: 'TEEN'}, {label: this.t.translate('metadata.editor.contentRatingTeen'), value: 'TEEN'},
{label: 'Mature', value: 'MATURE'}, {label: this.t.translate('metadata.editor.contentRatingMature'), value: 'MATURE'},
{label: 'Adult', value: 'ADULT'}, {label: this.t.translate('metadata.editor.contentRatingAdult'), value: 'ADULT'},
{label: 'Explicit', value: 'EXPLICIT'} {label: this.t.translate('metadata.editor.contentRatingExplicit'), value: 'EXPLICIT'}
]; ];
this.ageRatingOptions = [ this.ageRatingOptions = [
{label: 'All Ages', value: 0}, {label: this.t.translate('metadata.editor.ageRatingAllAges'), value: 0},
{label: '6+', value: 6}, {label: '6+', value: 6},
{label: '10+', value: 10}, {label: '10+', value: 10},
{label: '13+', value: 13}, {label: '13+', value: 13},
@@ -601,8 +606,8 @@ export class MetadataEditorComponent implements OnInit {
this.isSaving = false; this.isSaving = false;
this.messageService.add({ this.messageService.add({
severity: "info", severity: "info",
summary: "Success", summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: "Book metadata updated", detail: this.t.translate('metadata.editor.toast.metadataUpdated'),
}); });
this.prepareAutoComplete(); this.prepareAutoComplete();
this.metadataForm.markAsPristine(); this.metadataForm.markAsPristine();
@@ -611,8 +616,8 @@ export class MetadataEditorComponent implements OnInit {
this.isSaving = false; this.isSaving = false;
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || "Failed to update book metadata", detail: err?.error?.message || this.t.translate('metadata.editor.toast.metadataUpdateFailed'),
}); });
}, },
}) })
@@ -855,19 +860,19 @@ export class MetadataEditorComponent implements OnInit {
this.messageService.add({ this.messageService.add({
severity: "success", severity: "success",
summary: shouldLockAllFields summary: shouldLockAllFields
? "Metadata Locked" ? this.t.translate('metadata.editor.toast.metadataLocked')
: "Metadata Unlocked", : this.t.translate('metadata.editor.toast.metadataUnlocked'),
detail: shouldLockAllFields detail: shouldLockAllFields
? "All fields have been successfully locked." ? this.t.translate('metadata.editor.toast.allFieldsLocked')
: "All fields have been successfully unlocked.", : this.t.translate('metadata.editor.toast.allFieldsUnlocked'),
}); });
} }
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: "Failed to update lock state", detail: this.t.translate('metadata.editor.toast.lockStateFailed'),
}); });
}, },
}); });
@@ -890,8 +895,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false; this.isUploading = false;
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Upload Failed", summary: this.t.translate('metadata.editor.toast.uploadFailedSummary'),
detail: "An error occurred while uploading the cover", detail: this.t.translate('metadata.editor.toast.uploadFailedDetail'),
life: 3000, life: 3000,
}); });
} }
@@ -901,8 +906,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false; this.isUploading = false;
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Upload Error", summary: this.t.translate('metadata.editor.toast.uploadErrorSummary'),
detail: "An error occurred while uploading the cover", detail: this.t.translate('metadata.editor.toast.uploadErrorDetail'),
life: 3000, life: 3000,
}); });
} }
@@ -915,15 +920,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook); this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({ this.messageService.add({
severity: "success", severity: "success",
summary: "Success", summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: "Book cover regenerated successfully.", detail: this.t.translate('metadata.editor.toast.coverRegenerated'),
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: "warning", severity: "warning",
summary: "Partial Success", summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: "Cover regenerated but failed to refresh display. Please refresh the page.", detail: this.t.translate('metadata.editor.toast.coverRegenPartialDetail'),
}); });
}, },
}); });
@@ -931,8 +936,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || "Failed to regenerate cover", 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.bookService.handleBookUpdate(updatedBook);
this.messageService.add({ this.messageService.add({
severity: "success", severity: "success",
summary: "Success", summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: "Custom cover generated successfully.", detail: this.t.translate('metadata.editor.toast.customCoverGenerated'),
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: "warning", severity: "warning",
summary: "Partial Success", summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: "Cover generated but failed to refresh display. Please refresh the page.", detail: this.t.translate('metadata.editor.toast.customCoverPartialDetail'),
}); });
}, },
}); });
@@ -965,8 +970,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: "Failed to generate custom cover", detail: this.t.translate('metadata.editor.toast.customCoverFailed'),
}); });
} }
}); });
@@ -980,15 +985,15 @@ export class MetadataEditorComponent implements OnInit {
this.bookService.handleBookUpdate(updatedBook); this.bookService.handleBookUpdate(updatedBook);
this.messageService.add({ this.messageService.add({
severity: "success", severity: "success",
summary: "Success", summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: "Audiobook cover regenerated successfully.", detail: this.t.translate('metadata.editor.toast.audiobookCoverRegenerated'),
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: "warning", severity: "warning",
summary: "Partial Success", summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: "Cover regenerated but failed to refresh display. Please refresh the page.", detail: this.t.translate('metadata.editor.toast.audiobookCoverRegenPartialDetail'),
}); });
}, },
}); });
@@ -996,8 +1001,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: err?.error?.message || "Failed to regenerate audiobook cover", 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.bookService.handleBookUpdate(updatedBook);
this.messageService.add({ this.messageService.add({
severity: "success", severity: "success",
summary: "Success", summary: this.t.translate('metadata.editor.toast.successSummary'),
detail: "Custom audiobook cover generated successfully.", detail: this.t.translate('metadata.editor.toast.customAudiobookCoverGenerated'),
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: "warning", severity: "warning",
summary: "Partial Success", summary: this.t.translate('metadata.editor.toast.partialSuccessSummary'),
detail: "Cover generated but failed to refresh display. Please refresh the page.", detail: this.t.translate('metadata.editor.toast.customAudiobookCoverPartialDetail'),
}); });
}, },
}); });
@@ -1030,8 +1035,8 @@ export class MetadataEditorComponent implements OnInit {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: "error", severity: "error",
summary: "Error", summary: this.t.translate('metadata.editor.toast.errorSummary'),
detail: "Failed to generate custom audiobook cover", detail: this.t.translate('metadata.editor.toast.customAudiobookCoverFailed'),
}); });
} }
}); });
@@ -1131,7 +1136,7 @@ export class MetadataEditorComponent implements OnInit {
getNavigationPosition(): string { getNavigationPosition(): string {
const position = this.bookNavigationService.getCurrentPosition(); 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 { isFieldVisible(field: keyof MetadataProviderSpecificFields): boolean {
@@ -1201,8 +1206,8 @@ export class MetadataEditorComponent implements OnInit {
this.isUploading = false; this.isUploading = false;
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Upload Failed', summary: this.t.translate('metadata.editor.toast.uploadFailedSummary'),
detail: 'An error occurred while uploading the audiobook cover', detail: this.t.translate('metadata.editor.toast.audiobookUploadFailed'),
life: 3000, life: 3000,
}); });
} }
@@ -1,10 +1,10 @@
@if (book$ | async; as book) { @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"> <div class="dialog-body">
@if (detailLoading) { @if (detailLoading) {
<div class="detail-loading-banner"> <div class="detail-loading-banner">
<i class="pi pi-spin pi-spinner"></i> <i class="pi pi-spin pi-spinner"></i>
<span>Loading complete metadata...</span> <span>{{ t('loadingMetadata') }}</span>
</div> </div>
} }
@@ -12,7 +12,7 @@
<div class="column-headers desktop-only"> <div class="column-headers desktop-only">
<div class="column-label current"> <div class="column-label current">
<i class="pi pi-file-edit"></i> <i class="pi pi-file-edit"></i>
<span>Current</span> <span>{{ t('columnCurrent') }}</span>
</div> </div>
<div class="column-actions"> <div class="column-actions">
<p-button <p-button
@@ -20,7 +20,7 @@
[rounded]="true" [rounded]="true"
[outlined]="true" [outlined]="true"
severity="secondary" severity="secondary"
pTooltip="Copy missing fields" [pTooltip]="t('copyMissingTooltip')"
tooltipPosition="bottom" tooltipPosition="bottom"
(onClick)="copyMissing()" (onClick)="copyMissing()"
/> />
@@ -29,14 +29,14 @@
[rounded]="true" [rounded]="true"
[outlined]="true" [outlined]="true"
severity="primary" severity="primary"
pTooltip="Copy all fields" [pTooltip]="t('copyAllTooltip')"
tooltipPosition="bottom" tooltipPosition="bottom"
(onClick)="copyAll()" (onClick)="copyAll()"
/> />
</div> </div>
<div class="column-label fetched"> <div class="column-label fetched">
<i class="pi pi-cloud-download"></i> <i class="pi pi-cloud-download"></i>
<span>Fetched</span> <span>{{ t('columnFetched') }}</span>
</div> </div>
</div> </div>
@@ -44,7 +44,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-image"></i> <i class="pi pi-image"></i>
<span>Cover Image</span> <span>{{ t('sectionCoverImage') }}</span>
</div> </div>
<div class="section-content" [class.dual-covers-section]="currentBook && supportsDualCovers(currentBook)"> <div class="section-content" [class.dual-covers-section]="currentBook && supportsDualCovers(currentBook)">
@@ -53,19 +53,19 @@
<div class="field-row cover-field-row"> <div class="field-row cover-field-row">
<label class="field-label"> <label class="field-label">
@if (currentBook && supportsDualCovers(currentBook)) { @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 { } @else {
Cover {{ t('coverLabel') }}
} }
</label> </label>
<div class="field-content"> <div class="field-content">
<div class="field-side current cover-side"> <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"> <div class="cover-wrapper">
<p-image <p-image
class="cover-image" class="cover-image"
[src]="metadataForm.get('thumbnailUrl')?.value" [src]="metadataForm.get('thumbnailUrl')?.value"
alt="Current cover" [alt]="t('currentCoverAlt')"
appendTo="body" appendTo="body"
lazyLoad lazyLoad
[preview]="true" [preview]="true"
@@ -75,7 +75,7 @@
class="lock-badge" class="lock-badge"
[class.locked]="metadataForm.get('coverLocked')?.value" [class.locked]="metadataForm.get('coverLocked')?.value"
(click)="toggleLock('thumbnailUrl')" (click)="toggleLock('thumbnailUrl')"
[pTooltip]="metadataForm.get('coverLocked')?.value ? 'Unlock cover' : 'Lock cover'" [pTooltip]="metadataForm.get('coverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
> >
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i> <i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
@@ -97,12 +97,12 @@
</button> </button>
<div class="field-side fetched cover-side"> <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"> <div class="cover-wrapper">
<p-image <p-image
class="cover-image" class="cover-image"
[src]="fetchedMetadata.thumbnailUrl!" [src]="fetchedMetadata.thumbnailUrl!"
alt="Fetched cover" [alt]="t('fetchedCoverAlt')"
appendTo="body" appendTo="body"
lazyLoad lazyLoad
[preview]="true" [preview]="true"
@@ -117,16 +117,16 @@
@if (currentBook && hasAudiobookFormat(currentBook)) { @if (currentBook && hasAudiobookFormat(currentBook)) {
<div class="field-row cover-field-row audiobook-cover-row"> <div class="field-row cover-field-row audiobook-cover-row">
<label class="field-label"> <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> </label>
<div class="field-content"> <div class="field-content">
<div class="field-side current cover-side"> <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"> <div class="cover-wrapper">
<p-image <p-image
class="cover-image square-cover" class="cover-image square-cover"
[src]="metadataForm.get('audiobookThumbnailUrl')?.value" [src]="metadataForm.get('audiobookThumbnailUrl')?.value"
alt="Current audiobook cover" [alt]="t('currentAudiobookCoverAlt')"
appendTo="body" appendTo="body"
lazyLoad lazyLoad
[preview]="true" [preview]="true"
@@ -136,7 +136,7 @@
class="lock-badge" class="lock-badge"
[class.locked]="metadataForm.get('audiobookCoverLocked')?.value" [class.locked]="metadataForm.get('audiobookCoverLocked')?.value"
(click)="toggleLock('audiobookThumbnailUrl')" (click)="toggleLock('audiobookThumbnailUrl')"
[pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? 'Unlock cover' : 'Lock cover'" [pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
tooltipPosition="top" tooltipPosition="top"
> >
<i [class]="metadataForm.get('audiobookCoverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i> <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"> <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"> <div class="cover-wrapper">
@if (isAudibleProvider()) { @if (isAudibleProvider()) {
<p-image <p-image
class="cover-image square-cover" class="cover-image square-cover"
[src]="fetchedMetadata.thumbnailUrl!" [src]="fetchedMetadata.thumbnailUrl!"
alt="Fetched audiobook cover" [alt]="t('fetchedAudiobookCoverAlt')"
appendTo="body" appendTo="body"
lazyLoad lazyLoad
[preview]="true" [preview]="true"
@@ -176,7 +176,7 @@
} @else { } @else {
<div class="no-cover-placeholder"> <div class="no-cover-placeholder">
<i class="pi pi-image"></i> <i class="pi pi-image"></i>
<span>N/A</span> <span>{{ t('na') }}</span>
</div> </div>
} }
</div> </div>
@@ -191,7 +191,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
<span>Basic Information</span> <span>{{ t('sectionBasicInfo') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -241,7 +241,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-tags"></i> <i class="pi pi-tags"></i>
<span>Tags & Categories</span> <span>{{ t('sectionTagsCategories') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -307,7 +307,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-align-left"></i> <i class="pi pi-align-left"></i>
<span>Description</span> <span>{{ t('sectionDescription') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -353,7 +353,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
<span>Series Information</span> <span>{{ t('sectionSeriesInfo') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -399,7 +399,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-id-card"></i> <i class="pi pi-id-card"></i>
<span>Book Details</span> <span>{{ t('sectionBookDetails') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -446,9 +446,9 @@
<section class="form-section"> <section class="form-section">
<div class="section-header collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded"> <div class="section-header collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
<i class="pi pi-bolt"></i> <i class="pi pi-bolt"></i>
<span>Comic Book Details</span> <span>{{ t('sectionComicDetails') }}</span>
@if (!hasAnyFetchedComicData() && !hasAnyCurrentComicData()) { @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> <i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
</div> </div>
@@ -613,7 +613,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-headphones"></i> <i class="pi pi-headphones"></i>
<span>Audiobook Details</span> <span>{{ t('sectionAudiobookDetails') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -679,7 +679,7 @@
<section class="form-section"> <section class="form-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-cloud"></i> <i class="pi pi-cloud"></i>
<span>Provider Metadata</span> <span>{{ t('sectionProviderMetadata') }}</span>
</div> </div>
<div class="section-content"> <div class="section-content">
@@ -727,7 +727,7 @@
<footer class="dialog-footer"> <footer class="dialog-footer">
<div class="footer-left"> <div class="footer-left">
<p-button <p-button
label="Back to List" [label]="t('backToListBtn')"
icon="pi pi-arrow-left" icon="pi pi-arrow-left"
severity="info" severity="info"
[outlined]="true" [outlined]="true"
@@ -739,7 +739,7 @@
icon="pi pi-lock-open" icon="pi pi-lock-open"
severity="success" severity="success"
[outlined]="true" [outlined]="true"
pTooltip="Unlock all fields" [pTooltip]="t('unlockAllTooltip')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="unlockAll()" (onClick)="unlockAll()"
/> />
@@ -747,13 +747,13 @@
icon="pi pi-lock" icon="pi pi-lock"
severity="warn" severity="warn"
[outlined]="true" [outlined]="true"
pTooltip="Lock all fields" [pTooltip]="t('lockAllTooltip')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="lockAll()" (onClick)="lockAll()"
/> />
<div class="footer-divider"></div> <div class="footer-divider"></div>
<p-button <p-button
label="Save Changes" [label]="t('saveChangesBtn')"
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'" [icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="isSaving" [loading]="isSaving"
[disabled]="isSaving" [disabled]="isSaving"
@@ -19,6 +19,7 @@ import {LazyLoadImageModule} from 'ng-lazyload-image';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service'; import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model'; 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 {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({ @Component({
selector: 'app-metadata-picker', selector: 'app-metadata-picker',
@@ -36,7 +37,8 @@ import {ALL_COMIC_METADATA_FIELDS, ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELD
AutoComplete, AutoComplete,
Image, Image,
LazyLoadImageModule, LazyLoadImageModule,
Checkbox Checkbox,
TranslocoDirective
] ]
}) })
export class MetadataPickerComponent implements OnInit { export class MetadataPickerComponent implements OnInit {
@@ -81,6 +83,7 @@ export class MetadataPickerComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private formBuilder = inject(MetadataFormBuilder); private formBuilder = inject(MetadataFormBuilder);
private metadataUtils = inject(MetadataUtilsService); private metadataUtils = inject(MetadataUtilsService);
private readonly t = inject(TranslocoService);
private enabledProviderFields: MetadataProviderSpecificFields | null = null; private enabledProviderFields: MetadataProviderSpecificFields | null = null;
@@ -303,11 +306,11 @@ export class MetadataPickerComponent implements OnInit {
this.savedFields[field] = true; 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: () => { error: () => {
this.isSaving = false; 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) { if (shouldLockAllFields !== undefined) {
this.messageService.add({ this.messageService.add({
severity: 'success', 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 detail: shouldLockAllFields
? 'All fields have been successfully locked.' ? this.t.translate('metadata.picker.toast.allFieldsLocked')
: 'All fields have been successfully unlocked.', : this.t.translate('metadata.picker.toast.allFieldsUnlocked'),
}); });
} }
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('metadata.picker.toast.errorSummary'),
detail: 'Failed to update lock state', detail: this.t.translate('metadata.picker.toast.lockStateFailed'),
}); });
} }
}); });
@@ -603,8 +606,8 @@ export class MetadataPickerComponent implements OnInit {
if (isLocked) { if (isLocked) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Action Blocked', summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
detail: `${comicConfig.label} is locked and cannot be updated.` detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: comicConfig.label})
}); });
return; return;
} }
@@ -627,8 +630,8 @@ export class MetadataPickerComponent implements OnInit {
if (isLocked) { if (isLocked) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Action Blocked', summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
detail: `${lockField} is locked and cannot be updated.` detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: lockField})
}); });
return; return;
} }
@@ -8,20 +8,20 @@
</app-metadata-picker> </app-metadata-picker>
</div> </div>
} @else { } @else {
<div class="searcher-container"> <div class="searcher-container" *transloco="let t; prefix: 'metadata.searcher'">
<form [formGroup]="form" (ngSubmit)="onSubmit()" class="search-card"> <form [formGroup]="form" (ngSubmit)="onSubmit()" class="search-card">
<div class="search-grid"> <div class="search-grid">
<div class="search-field search-field-provider"> <div class="search-field search-field-provider">
<label> <label>
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
Providers {{ t('providers') }}
</label> </label>
<p-multiselect <p-multiselect
[filter]="false" [filter]="false"
showToggleAll="false" showToggleAll="false"
[options]="providers" [options]="providers"
formControlName="provider" formControlName="provider"
placeholder="Select providers" [placeholder]="t('selectProviders')"
class="'custom-multiselect'"> class="'custom-multiselect'">
</p-multiselect> </p-multiselect>
</div> </div>
@@ -29,10 +29,10 @@
<div class="search-field"> <div class="search-field">
<label> <label>
<i class="pi pi-barcode"></i> <i class="pi pi-barcode"></i>
ISBN {{ t('isbn') }}
<i <i
class="pi pi-info-circle" class="pi pi-info-circle"
pTooltip="ISBN takes priority. Without ISBN, search uses Title and Author." [pTooltip]="t('isbnTooltip')"
tooltipPosition="right" tooltipPosition="right"
style="margin-left: 0.25rem; color: var(--primary-color); cursor: pointer;" style="margin-left: 0.25rem; color: var(--primary-color); cursor: pointer;"
></i> ></i>
@@ -40,37 +40,37 @@
<input <input
pInputText pInputText
formControlName="isbn" formControlName="isbn"
placeholder="ISBN-10 or ISBN-13" [placeholder]="t('isbnPlaceholder')"
class="custom-input"/> class="custom-input"/>
</div> </div>
<div class="search-field"> <div class="search-field">
<label> <label>
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
Title {{ t('title') }}
</label> </label>
<input <input
pInputText pInputText
formControlName="title" formControlName="title"
placeholder="Book title" [placeholder]="t('titlePlaceholder')"
class="custom-input"/> class="custom-input"/>
</div> </div>
<div class="search-field"> <div class="search-field">
<label> <label>
<i class="pi pi-user"></i> <i class="pi pi-user"></i>
Author {{ t('author') }}
</label> </label>
<input <input
pInputText pInputText
formControlName="author" formControlName="author"
placeholder="Author name" [placeholder]="t('authorPlaceholder')"
class="custom-input"/> class="custom-input"/>
</div> </div>
<div class="search-field search-button-field"> <div class="search-field search-button-field">
<p-button <p-button
label="Search" [label]="t('search')"
type="submit" type="submit"
[disabled]="!isSearchEnabled || loading" [disabled]="!isSearchEnabled || loading"
icon="pi pi-search" icon="pi pi-search"
@@ -86,14 +86,14 @@
<div class="results-info"> <div class="results-info">
<h3> <h3>
<i class="pi pi-list"></i> <i class="pi pi-list"></i>
Search Results {{ t('searchResults') }}
</h3> </h3>
<span class="results-count">{{ filteredMetadata.length }} books found</span> <span class="results-count">{{ t('booksFound', { count: filteredMetadata.length }) }}</span>
</div> </div>
@if (loading) { @if (loading) {
<span class="fetching-badge"> <span class="fetching-badge">
<i class="pi pi-spin pi-spinner"></i> <i class="pi pi-spin pi-spinner"></i>
Fetching... {{ t('fetching') }}
</span> </span>
} }
</div> </div>
@@ -127,8 +127,8 @@
<div class="empty-icon"> <div class="empty-icon">
<i class="pi pi-search"></i> <i class="pi pi-search"></i>
</div> </div>
<h3>Ready to Search</h3> <h3>{{ t('readyToSearch') }}</h3>
<p>Enter your search criteria above and click Search to find metadata</p> <p>{{ t('readyToSearchDescription') }}</p>
</div> </div>
} }
@@ -137,8 +137,8 @@
<div class="empty-icon no-results"> <div class="empty-icon no-results">
<i class="pi pi-inbox"></i> <i class="pi pi-inbox"></i>
</div> </div>
<h3>No Results Found</h3> <h3>{{ t('noResultsFound') }}</h3>
<p>Try adjusting your search criteria or selecting different providers</p> <p>{{ t('noResultsDescription') }}</p>
</div> </div>
} }
@@ -154,7 +154,7 @@
loading="lazy"/> loading="lazy"/>
<div class="card-overlay"> <div class="card-overlay">
<i class="pi pi-eye"></i> <i class="pi pi-eye"></i>
<span>Select</span> <span>{{ t('select') }}</span>
</div> </div>
</div> </div>
@@ -16,6 +16,7 @@ import {AsyncPipe} from '@angular/common';
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component'; import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
import {BookMetadataService} from '../../../../book/service/book-metadata.service'; import {BookMetadataService} from '../../../../book/service/book-metadata.service';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-searcher', selector: 'app-metadata-searcher',
@@ -29,7 +30,8 @@ import {Tooltip} from 'primeng/tooltip';
MetadataPickerComponent, MetadataPickerComponent,
MultiSelect, MultiSelect,
AsyncPipe, AsyncPipe,
Tooltip Tooltip,
TranslocoDirective
], ],
standalone: true 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-tabs lazy class="custom-p-tabs" [value]="defaultTabValue" scrollable>
<p-tablist> <p-tablist>
@if (bookInSeries.length > 1) { @if (bookInSeries.length > 1) {
<p-tab value="series"> <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>
} }
<p-tab value="similar"> <p-tab value="similar">
<i class="pi pi-bookmark"></i> Similar Books <i class="pi pi-bookmark"></i> {{ t('similarBooks') }}
</p-tab> </p-tab>
@if (supportsDualCovers()) { @if (supportsDualCovers()) {
<p-tab value="covers"> <p-tab value="covers">
<i class="pi pi-images"></i> Covers <i class="pi pi-images"></i> {{ t('covers') }}
</p-tab> </p-tab>
} }
<p-tab value="files"> <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>
<p-tab value="notes"> <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>
<p-tab value="sessions"> <p-tab value="sessions">
<i class="pi pi-clock"></i> Reading Sessions <i class="pi pi-clock"></i> {{ t('readingSessions') }}
</p-tab> </p-tab>
<p-tab value="reviews"> <p-tab value="reviews">
<i class="pi pi-comments"></i> Reviews <i class="pi pi-comments"></i> {{ t('reviews') }}
</p-tab> </p-tab>
</p-tablist> </p-tablist>
<p-tabpanels> <p-tabpanels>
@@ -65,11 +66,11 @@
<div class="covers-grid"> <div class="covers-grid">
<div class="cover-item"> <div class="cover-item">
<div class="cover-label"> <div class="cover-label">
<i class="pi pi-book"></i> Ebook Cover <i class="pi pi-book"></i> {{ t('ebookCover') }}
</div> </div>
<p-image <p-image
[src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)" [src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
alt="Ebook Cover" [alt]="t('ebookCover')"
width="200" width="200"
appendTo="body" appendTo="body"
[preview]="true"> [preview]="true">
@@ -77,11 +78,11 @@
</div> </div>
<div class="cover-item"> <div class="cover-item">
<div class="cover-label audiobook"> <div class="cover-label audiobook">
<i class="pi pi-headphones"></i> Audiobook Cover <i class="pi pi-headphones"></i> {{ t('audiobookCover') }}
</div> </div>
<p-image <p-image
[src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)" [src]="urlHelper.getAudiobookCoverUrl(book.id, book.metadata?.audiobookCoverUpdatedOn)"
alt="Audiobook Cover" [alt]="t('audiobookCover')"
width="200" width="200"
appendTo="body" appendTo="body"
[preview]="true" [preview]="true"
@@ -113,27 +114,27 @@
@if (isPhysicalBook()) { @if (isPhysicalBook()) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-book empty-state-icon"></i> <i class="pi pi-book empty-state-icon"></i>
<h4 class="empty-state-title">Physical Book</h4> <h4 class="empty-state-title">{{ t('physicalBook') }}</h4>
<p class="empty-state-message">This is a physical book. No digital files are associated with this book.</p> <p class="empty-state-message">{{ t('physicalBookMessage') }}</p>
<p class="empty-state-hint">You can upload a digital version using the "Upload File" option in the menu.</p> <p class="empty-state-hint">{{ t('physicalBookHint') }}</p>
</div> </div>
} @else { } @else {
@if (hasMultipleFiles(book)) { @if (hasMultipleFiles(book)) {
<div class="files-section download-all-section"> <div class="files-section download-all-section">
<p-button <p-button
label="Download All ({{ getTotalFileCount(book) }} files)" [label]="t('downloadAll', { count: getTotalFileCount(book) })"
icon="pi pi-download" icon="pi pi-download"
severity="info" severity="info"
outlined outlined
(onClick)="downloadAll(book)" (onClick)="downloadAll(book)"
pTooltip="Download all files as a ZIP archive" [pTooltip]="t('downloadAllTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
} }
@if (book.primaryFile) { @if (book.primaryFile) {
<div class="files-section"> <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="files-list">
<div class="file-item primary-file"> <div class="file-item primary-file">
<div class="file-info"> <div class="file-info">
@@ -150,7 +151,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Read" [pTooltip]="t('read')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id)"> (onClick)="read(book.id)">
</p-button> </p-button>
@@ -159,7 +160,7 @@
size="small" size="small"
text text
severity="info" severity="info"
pTooltip="Streaming Reader" [pTooltip]="t('streamingReader')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, 'pdf-streaming')"> (onClick)="read(book.id, 'pdf-streaming')">
</p-button> </p-button>
@@ -169,7 +170,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Read" [pTooltip]="t('read')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id)"> (onClick)="read(book.id)">
</p-button> </p-button>
@@ -178,7 +179,7 @@
size="small" size="small"
text text
severity="info" severity="info"
pTooltip="Streaming Reader" [pTooltip]="t('streamingReader')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, 'epub-streaming')"> (onClick)="read(book.id, 'epub-streaming')">
</p-button> </p-button>
@@ -188,7 +189,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Read" [pTooltip]="t('read')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id)"> (onClick)="read(book.id)">
</p-button> </p-button>
@@ -198,7 +199,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Play" [pTooltip]="t('play')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id)"> (onClick)="read(book.id)">
</p-button> </p-button>
@@ -208,7 +209,7 @@
size="small" size="small"
text text
severity="success" severity="success"
pTooltip="Download" [pTooltip]="t('download')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="download(book)"> (onClick)="download(book)">
</p-button> </p-button>
@@ -217,7 +218,7 @@
size="small" size="small"
text text
severity="danger" severity="danger"
pTooltip="Delete" [pTooltip]="t('delete')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="deleteFile(book, book.primaryFile!.id, book.primaryFile!.fileName || 'file', true)"> (onClick)="deleteFile(book, book.primaryFile!.id, book.primaryFile!.fileName || 'file', true)">
</p-button> </p-button>
@@ -228,7 +229,7 @@
} }
@if (book.alternativeFormats && book.alternativeFormats.length > 0) { @if (book.alternativeFormats && book.alternativeFormats.length > 0) {
<div class="files-section"> <div class="files-section">
<h4 class="files-section-title">Alternative Formats</h4> <h4 class="files-section-title">{{ t('alternativeFormats') }}</h4>
<div class="files-list"> <div class="files-list">
@for (format of book.alternativeFormats; track format.id) { @for (format of book.alternativeFormats; track format.id) {
<div class="file-item"> <div class="file-item">
@@ -246,7 +247,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Read" [pTooltip]="t('read')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)"> (onClick)="read(book.id, undefined, format.bookType)">
</p-button> </p-button>
@@ -255,7 +256,7 @@
size="small" size="small"
text text
severity="info" severity="info"
pTooltip="Streaming Reader" [pTooltip]="t('streamingReader')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, format.bookType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', format.bookType)"> (onClick)="read(book.id, format.bookType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', format.bookType)">
</p-button> </p-button>
@@ -265,7 +266,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Read" [pTooltip]="t('read')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)"> (onClick)="read(book.id, undefined, format.bookType)">
</p-button> </p-button>
@@ -275,7 +276,7 @@
size="small" size="small"
text text
severity="primary" severity="primary"
pTooltip="Play" [pTooltip]="t('play')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="read(book.id, undefined, format.bookType)"> (onClick)="read(book.id, undefined, format.bookType)">
</p-button> </p-button>
@@ -285,7 +286,7 @@
size="small" size="small"
text text
severity="success" severity="success"
pTooltip="Download" [pTooltip]="t('download')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, format.id)"> (onClick)="downloadAdditionalFile(book, format.id)">
</p-button> </p-button>
@@ -294,7 +295,7 @@
size="small" size="small"
text text
severity="danger" severity="danger"
pTooltip="Delete" [pTooltip]="t('delete')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="deleteFile(book, format.id, format.fileName || 'file', false)"> (onClick)="deleteFile(book, format.id, format.fileName || 'file', false)">
</p-button> </p-button>
@@ -306,7 +307,7 @@
} }
@if (book.supplementaryFiles && book.supplementaryFiles.length > 0) { @if (book.supplementaryFiles && book.supplementaryFiles.length > 0) {
<div class="files-section"> <div class="files-section">
<h4 class="files-section-title">Supplementary Files</h4> <h4 class="files-section-title">{{ t('supplementaryFiles') }}</h4>
<div class="files-list"> <div class="files-list">
@for (file of book.supplementaryFiles; track file.id) { @for (file of book.supplementaryFiles; track file.id) {
<div class="file-item"> <div class="file-item">
@@ -321,7 +322,7 @@
size="small" size="small"
text text
severity="success" severity="success"
pTooltip="Download" [pTooltip]="t('download')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="downloadAdditionalFile(book, file.id)"> (onClick)="downloadAdditionalFile(book, file.id)">
</p-button> </p-button>
@@ -330,7 +331,7 @@
size="small" size="small"
text text
severity="danger" severity="danger"
pTooltip="Delete" [pTooltip]="t('delete')"
tooltipPosition="top" tooltipPosition="top"
(onClick)="deleteSupplementary(book.id, file.id, file.fileName || 'file')"> (onClick)="deleteSupplementary(book.id, file.id, file.fileName || 'file')">
</p-button> </p-button>
@@ -346,3 +347,4 @@
</p-tabpanel> </p-tabpanel>
</p-tabpanels> </p-tabpanels>
</p-tabs> </p-tabs>
</ng-container>
@@ -12,6 +12,7 @@ import {Tooltip} from 'primeng/tooltip';
import {Image} from 'primeng/image'; import {Image} from 'primeng/image';
import {UrlHelperService} from '../../../../../../shared/service/url-helper.service'; import {UrlHelperService} from '../../../../../../shared/service/url-helper.service';
import {BookService} from '../../../../../book/service/book.service'; import {BookService} from '../../../../../book/service/book.service';
import {TranslocoDirective} from '@jsverse/transloco';
export interface ReadEvent { export interface ReadEvent {
bookId: number; bookId: number;
@@ -63,7 +64,8 @@ export interface DeleteSupplementaryFileEvent {
Button, Button,
Tooltip, Tooltip,
UpperCasePipe, UpperCasePipe,
Image Image,
TranslocoDirective
], ],
templateUrl: './metadata-tabs.component.html', templateUrl: './metadata-tabs.component.html',
styleUrl: './metadata-tabs.component.scss' styleUrl: './metadata-tabs.component.scss'
@@ -1,5 +1,5 @@
@if (book$ | async; as book) { @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="metadata-header">
<div class="cover-section"> <div class="cover-section">
@@ -70,7 +70,7 @@
rounded rounded
outlined outlined
severity="info" severity="info"
pTooltip="Go to previous book" [pTooltip]="t('goToPreviousBook')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
<span class="navigation-position"> <span class="navigation-position">
@@ -84,7 +84,7 @@
severity="info" severity="info"
rounded rounded
outlined outlined
pTooltip="Go to next book" [pTooltip]="t('goToNextBook')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
</div> </div>
@@ -114,7 +114,7 @@
<i <i
class="pi lock-icon" class="pi lock-icon"
[ngClass]="isMetadataFullyLocked(book?.metadata!) ? 'pi-lock locked' : 'pi-lock-open unlocked'" [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" tooltipPosition="top"
></i> ></i>
</div> </div>
@@ -134,7 +134,7 @@
<div class="personal-rating"> <div class="personal-rating">
<div class="rating-group"> <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 <p-rating
[ngModel]="book?.personalRating" [ngModel]="book?.personalRating"
(onRate)="onPersonalRatingChange(book, $event)" (onRate)="onPersonalRatingChange(book, $event)"
@@ -148,7 +148,7 @@
icon="pi pi-undo" icon="pi pi-undo"
severity="warn" severity="warn"
(onClick)="resetPersonalRating(book)" (onClick)="resetPersonalRating(book)"
pTooltip="Reset Rating" [pTooltip]="t('resetRating')"
tooltipPosition="top" tooltipPosition="top"
class="reset-button"> class="reset-button">
</p-button> </p-button>
@@ -270,7 +270,7 @@
<div class="tags-section"> <div class="tags-section">
@if (book?.metadata?.categories?.length) { @if (book?.metadata?.categories?.length) {
<div class="tag-row"> <div class="tag-row">
<span class="tag-label">Genres:</span> <span class="tag-label">{{ t('genres') }}</span>
<div class="tag-scroll"> <div class="tag-scroll">
<div class="tag-container"> <div class="tag-container">
@for (category of book.metadata!.categories; track category) { @for (category of book.metadata!.categories; track category) {
@@ -285,7 +285,7 @@
@if (book?.metadata?.moods?.length) { @if (book?.metadata?.moods?.length) {
<div class="tag-row"> <div class="tag-row">
<span class="tag-label">Moods:</span> <span class="tag-label">{{ t('moods') }}</span>
<div class="tag-scroll"> <div class="tag-scroll">
<div class="tag-container"> <div class="tag-container">
@for (mood of book.metadata!.moods; track mood) { @for (mood of book.metadata!.moods; track mood) {
@@ -300,7 +300,7 @@
@if (book?.metadata?.tags?.length) { @if (book?.metadata?.tags?.length) {
<div class="tag-row"> <div class="tag-row">
<span class="tag-label">Tags:</span> <span class="tag-label">{{ t('tags') }}</span>
<div class="tag-scroll"> <div class="tag-scroll">
<div class="tag-container"> <div class="tag-container">
@for (tag of book.metadata!.tags; track tag) { @for (tag of book.metadata!.tags; track tag) {
@@ -316,7 +316,7 @@
<div class="metadata-grid"> <div class="metadata-grid">
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Library:</span> <span class="metadata-key">{{ t('library') }}</span>
@if (book?.libraryName) { @if (book?.libraryName) {
<span class="metadata-value metadata-link" (click)="goToLibrary(book.libraryId!)"> <span class="metadata-value metadata-link" (click)="goToLibrary(book.libraryId!)">
{{ book?.libraryName }} {{ book?.libraryName }}
@@ -327,7 +327,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Publisher:</span> <span class="metadata-key">{{ t('publisher') }}</span>
@if (book?.metadata?.publisher) { @if (book?.metadata?.publisher) {
<span class="metadata-value metadata-link" (click)="goToPublisher(book?.metadata?.publisher!)"> <span class="metadata-value metadata-link" (click)="goToPublisher(book?.metadata?.publisher!)">
{{ book?.metadata?.publisher }} {{ book?.metadata?.publisher }}
@@ -338,7 +338,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Published:</span> <span class="metadata-key">{{ t('published') }}</span>
@if (book?.metadata!.publishedDate) { @if (book?.metadata!.publishedDate) {
<span class="metadata-value metadata-link" (click)="goToPublishedYear(book?.metadata!.publishedDate!)"> <span class="metadata-value metadata-link" (click)="goToPublishedYear(book?.metadata!.publishedDate!)">
{{ book?.metadata!.publishedDate }} {{ book?.metadata!.publishedDate }}
@@ -349,7 +349,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Language:</span> <span class="metadata-key">{{ t('language') }}</span>
@if (book?.metadata!.language) { @if (book?.metadata!.language) {
<span class="metadata-value metadata-link" (click)="goToLanguage(book?.metadata!.language!)"> <span class="metadata-value metadata-link" (click)="goToLanguage(book?.metadata!.language!)">
{{ book?.metadata!.language }} {{ book?.metadata!.language }}
@@ -360,14 +360,14 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Formats:</span> <span class="metadata-key">{{ t('formats') }}</span>
<span class="metadata-value-group format-tags"> <span class="metadata-value-group format-tags">
@if (getDisplayFormat(book?.primaryFile); as displayFormat) { @if (getDisplayFormat(book?.primaryFile); as displayFormat) {
<span class="format-tag-wrapper primary-format" (click)="goToFileType(book?.primaryFile?.filePath)" [pTooltip]="book?.primaryFile?.fileName ?? ''" tooltipPosition="top"> <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"> <app-tag size="3xs" variant="pill" [customBgColor]="getFileTypeBgColor(displayFormat)" customTextColor="#fff">
{{ displayFormat }} {{ displayFormat }}
</app-tag> </app-tag>
<span class="format-badge">PRIMARY</span> <span class="format-badge">{{ t('primary') }}</span>
</span> </span>
} }
@for (formatExt of getUniqueAlternativeFormats(book); track formatExt) { @for (formatExt of getUniqueAlternativeFormats(book); track formatExt) {
@@ -378,20 +378,20 @@
</span> </span>
} }
@if (!book?.primaryFile?.filePath && !book?.alternativeFormats?.length) { @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> </span>
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">BookLore Progress:</span> <span class="metadata-key">{{ t('bookloreProgress') }}</span>
<span class="metadata-value-group"> <span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getProgressColor(getProgressPercent(book))"> <app-tag size="3xs" variant="pill" [color]="getProgressColor(getProgressPercent(book))">
{{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }} {{ getProgressPercent(book) !== null ? getProgressPercent(book) + '%' : 'N/A' }}
</app-tag> </app-tag>
@if (getProgressPercent(book) !== null) { @if (getProgressPercent(book) !== null) {
<p-button <p-button
pTooltip="Reset progress" [pTooltip]="t('resetProgress')"
tooltipPosition="bottom" tooltipPosition="bottom"
icon="pi pi-refresh" icon="pi pi-refresh"
size="small" size="small"
@@ -405,7 +405,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Metadata Match:</span> <span class="metadata-key">{{ t('metadataMatch') }}</span>
@if (book?.metadataMatchScore != null) { @if (book?.metadataMatchScore != null) {
<span (click)="goToMatchScoreRange(book?.metadataMatchScore!)" style="cursor: pointer;"> <span (click)="goToMatchScoreRange(book?.metadataMatchScore!)" style="cursor: pointer;">
<app-tag size="3xs" variant="pill" [color]="getMatchScoreColor(book?.metadataMatchScore!)"> <app-tag size="3xs" variant="pill" [color]="getMatchScoreColor(book?.metadataMatchScore!)">
@@ -418,7 +418,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">ISBN:</span> <span class="metadata-key">{{ t('isbnLabel') }}</span>
@if (book?.metadata?.isbn13 || book?.metadata?.isbn10) { @if (book?.metadata?.isbn13 || book?.metadata?.isbn10) {
<span class="metadata-value"> <span class="metadata-value">
{{ book.metadata!.isbn13 }} {{ book.metadata!.isbn13 }}
@@ -433,7 +433,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Read Status:</span> <span class="metadata-key">{{ t('readStatus') }}</span>
<span class="metadata-value-group"> <span class="metadata-value-group">
<span (click)="goToReadStatus(selectedReadStatus)" style="cursor: pointer;"> <span (click)="goToReadStatus(selectedReadStatus)" style="cursor: pointer;">
<app-tag size="3xs" variant="pill" [color]="getStatusColor(selectedReadStatus)"> <app-tag size="3xs" variant="pill" [color]="getStatusColor(selectedReadStatus)">
@@ -447,13 +447,13 @@
@if (book?.koreaderProgress && book.koreaderProgress?.percentage != null) { @if (book?.koreaderProgress && book.koreaderProgress?.percentage != null) {
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">KOReader Progress:</span> <span class="metadata-key">{{ t('koreaderProgress') }}</span>
<span class="metadata-value-group"> <span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(getKOReaderPercentage(book))"> <app-tag size="3xs" variant="pill" [color]="getKoProgressColor(getKOReaderPercentage(book))">
{{ getKOReaderPercentage(book) + '%' }} {{ getKOReaderPercentage(book) + '%' }}
</app-tag> </app-tag>
<p-button <p-button
pTooltip="Reset progress" [pTooltip]="t('resetProgress')"
tooltipPosition="bottom" tooltipPosition="bottom"
icon="pi pi-refresh" icon="pi pi-refresh"
size="small" size="small"
@@ -468,13 +468,13 @@
@if (book?.koboProgress && book.koboProgress?.percentage != null) { @if (book?.koboProgress && book.koboProgress?.percentage != null) {
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Kobo Progress:</span> <span class="metadata-key">{{ t('koboProgress') }}</span>
<span class="metadata-value-group"> <span class="metadata-value-group">
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(book.koboProgress?.percentage)"> <app-tag size="3xs" variant="pill" [color]="getKoProgressColor(book.koboProgress?.percentage)">
{{ book.koboProgress?.percentage | number:'1.0-1' }}% {{ book.koboProgress?.percentage | number:'1.0-1' }}%
</app-tag> </app-tag>
<p-button <p-button
pTooltip="Reset progress" [pTooltip]="t('resetProgress')"
tooltipPosition="bottom" tooltipPosition="bottom"
icon="pi pi-refresh" icon="pi pi-refresh"
size="small" size="small"
@@ -490,7 +490,7 @@
@if (selectedReadStatus === ReadStatus.READ) { @if (selectedReadStatus === ReadStatus.READ) {
<div class="metadata-item"> <div class="metadata-item">
@if (book?.dateFinished) { @if (book?.dateFinished) {
<span class="metadata-key">Finished On:</span> <span class="metadata-key">{{ t('finishedOn') }}</span>
@if (!isEditingDateFinished) { @if (!isEditingDateFinished) {
<span class="metadata-value-group"> <span class="metadata-value-group">
<span class="metadata-value">{{ formatDate(book.dateFinished) }}</span> <span class="metadata-value">{{ formatDate(book.dateFinished) }}</span>
@@ -506,8 +506,8 @@
iconDisplay="input" iconDisplay="input"
[style]="{ 'width': '125px', 'font-size': '12px' }"> [style]="{ 'width': '125px', 'font-size': '12px' }">
</p-datepicker> </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-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="Cancel"></p-button> <p-button rounded icon="pi pi-times" size="small" severity="danger" text (onClick)="cancelDateFinishedEdit()" [pTooltip]="'common.cancel' | transloco"></p-button>
</span> </span>
} }
} }
@@ -515,7 +515,7 @@
} }
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Page Count:</span> <span class="metadata-key">{{ t('pageCount') }}</span>
@if (book?.metadata!.pageCount) { @if (book?.metadata!.pageCount) {
<span class="metadata-value metadata-link" (click)="goToPageCountRange(book?.metadata!.pageCount!)"> <span class="metadata-value metadata-link" (click)="goToPageCountRange(book?.metadata!.pageCount!)">
{{ book?.metadata!.pageCount }} {{ book?.metadata!.pageCount }}
@@ -526,7 +526,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Age Rating:</span> <span class="metadata-key">{{ t('ageRating') }}</span>
@if (book?.metadata?.ageRating != null) { @if (book?.metadata?.ageRating != null) {
<span class="metadata-value metadata-link" (click)="goToAgeRating(book?.metadata?.ageRating!)"> <span class="metadata-value metadata-link" (click)="goToAgeRating(book?.metadata?.ageRating!)">
{{ getAgeRatingLabel(book?.metadata?.ageRating) }} {{ getAgeRatingLabel(book?.metadata?.ageRating) }}
@@ -537,7 +537,7 @@
</div> </div>
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">Content Rating:</span> <span class="metadata-key">{{ t('contentRating') }}</span>
@if (book?.metadata?.contentRating) { @if (book?.metadata?.contentRating) {
<span class="metadata-value metadata-link" (click)="goToContentRating(book?.metadata?.contentRating!)"> <span class="metadata-value metadata-link" (click)="goToContentRating(book?.metadata?.contentRating!)">
{{ getContentRatingLabel(book?.metadata?.contentRating) }} {{ getContentRatingLabel(book?.metadata?.contentRating) }}
@@ -549,7 +549,7 @@
@if (hasDigitalFile(book)) { @if (hasDigitalFile(book)) {
<div class="metadata-item"> <div class="metadata-item">
<span class="metadata-key">File Size:</span> <span class="metadata-key">{{ t('fileSize') }}</span>
@if (book?.primaryFile?.fileSizeKb) { @if (book?.primaryFile?.fileSizeKb) {
<span class="metadata-value metadata-link" (click)="goToFileSizeRange(book?.primaryFile?.fileSizeKb!)"> <span class="metadata-value metadata-link" (click)="goToFileSizeRange(book?.primaryFile?.fileSizeKb!)">
{{ formatFileSize(book?.primaryFile) }} {{ formatFileSize(book?.primaryFile) }}
@@ -563,7 +563,7 @@
@if (hasDigitalFile(book)) { @if (hasDigitalFile(book)) {
<div class="file-path-section"> <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> <i class="pi eye-icon" [ngClass]="showFilePath ? 'pi-eye-slash' : 'pi-eye'" (click)="showFilePath = !showFilePath"></i>
@if (showFilePath) { @if (showFilePath) {
<code class="file-path-code">{{ book?.primaryFile?.filePath }}</code> <code class="file-path-code">{{ book?.primaryFile?.filePath }}</code>
@@ -584,7 +584,7 @@
rounded rounded
text text
severity="secondary" severity="secondary"
pTooltip="Go to previous book" [pTooltip]="t('goToPreviousBook')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
<span class="navigation-position"> <span class="navigation-position">
@@ -598,7 +598,7 @@
severity="secondary" severity="secondary"
rounded rounded
text text
pTooltip="Go to next book" [pTooltip]="t('goToNextBook')"
tooltipPosition="bottom"> tooltipPosition="bottom">
</p-button> </p-button>
</div> </div>
@@ -628,13 +628,13 @@
} }
@if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) { @if (userState.user!.permissions.canEditMetadata || userState.user!.permissions.admin) {
<p-button <p-button
[label]="isAutoFetching ? 'Fetching...' : 'Fetch Metadata'" [label]="isAutoFetching ? t('fetchingMetadata') : t('fetchMetadata')"
[icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'" [icon]="isAutoFetching ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
[outlined]="true" [outlined]="true"
severity="warn" severity="warn"
(onClick)="quickRefresh(book!.id)" (onClick)="quickRefresh(book!.id)"
[disabled]="isAutoFetching" [disabled]="isAutoFetching"
pTooltip="Automatically fetch metadata using default sources" [pTooltip]="t('fetchMetadataTooltip')"
tooltipPosition="top" tooltipPosition="top"
class="mobile-icon-only"> class="mobile-icon-only">
</p-button> </p-button>
@@ -655,7 +655,7 @@
<div class="description-section"> <div class="description-section">
<div class="section-header"> <div class="section-header">
<i class="pi pi-align-left"></i> <i class="pi pi-align-left"></i>
<span>Synopsis</span> <span>{{ t('synopsis') }}</span>
</div> </div>
<div class="description-body"> <div class="description-body">
<div [ngClass]="{ 'line-clamp-7': !isExpanded }" class="description-content"> <div [ngClass]="{ 'line-clamp-7': !isExpanded }" class="description-content">
@@ -667,7 +667,7 @@
</div> </div>
@if (book.metadata!.description && book.metadata!.description.length > 500) { @if (book.metadata!.description && book.metadata!.description.length > 500) {
<button class="expand-toggle" (click)="toggleExpand()"> <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> <i class="pi" [ngClass]="isExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</button> </button>
} }
@@ -679,7 +679,7 @@
<div class="section-header clickable" (click)="isComicSectionExpanded = !isComicSectionExpanded"> <div class="section-header clickable" (click)="isComicSectionExpanded = !isComicSectionExpanded">
<div class="section-header-left"> <div class="section-header-left">
<i class="pi pi-images"></i> <i class="pi pi-images"></i>
<span>Comic Details</span> <span>{{ t('comicDetails') }}</span>
</div> </div>
<i class="pi section-toggle-icon" [ngClass]="isComicSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i> <i class="pi section-toggle-icon" [ngClass]="isComicSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</div> </div>
@@ -690,13 +690,13 @@
<div class="comic-info-grid"> <div class="comic-info-grid">
@if (comic.issueNumber) { @if (comic.issueNumber) {
<div class="comic-info-item"> <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> <span class="comic-info-value">#{{ comic.issueNumber }}</span>
</div> </div>
} }
@if (comic.volumeName) { @if (comic.volumeName) {
<div class="comic-info-item"> <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"> <span class="comic-info-value">
{{ comic.volumeName }} {{ comic.volumeName }}
@if (comic.volumeNumber) { @if (comic.volumeNumber) {
@@ -707,7 +707,7 @@
} }
@if (comic.storyArc) { @if (comic.storyArc) {
<div class="comic-info-item"> <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"> <span class="comic-info-value">
{{ comic.storyArc }} {{ comic.storyArc }}
@if (comic.storyArcNumber) { @if (comic.storyArcNumber) {
@@ -718,7 +718,7 @@
} }
@if (comic.alternateSeries) { @if (comic.alternateSeries) {
<div class="comic-info-item"> <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"> <span class="comic-info-value">
{{ comic.alternateSeries }} {{ comic.alternateSeries }}
@if (comic.alternateIssue) { @if (comic.alternateIssue) {
@@ -729,13 +729,13 @@
} }
@if (comic.format) { @if (comic.format) {
<div class="comic-info-item"> <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> <span class="comic-info-value">{{ comic.format }}</span>
</div> </div>
} }
@if (comic.imprint) { @if (comic.imprint) {
<div class="comic-info-item"> <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> <span class="comic-info-value">{{ comic.imprint }}</span>
</div> </div>
} }
@@ -745,12 +745,12 @@
<div class="comic-subsection"> <div class="comic-subsection">
<div class="comic-subsection-title"> <div class="comic-subsection-title">
<i class="pi pi-users"></i> <i class="pi pi-users"></i>
<span>Creators</span> <span>{{ t('creators') }}</span>
</div> </div>
<div class="comic-creators-grid"> <div class="comic-creators-grid">
@if (comic.pencillers?.length) { @if (comic.pencillers?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.pencillers; track name) { @for (name of comic.pencillers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'penciller')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'penciller')">{{ name }}</a>
@@ -760,7 +760,7 @@
} }
@if (comic.inkers?.length) { @if (comic.inkers?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.inkers; track name) { @for (name of comic.inkers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'inker')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'inker')">{{ name }}</a>
@@ -770,7 +770,7 @@
} }
@if (comic.colorists?.length) { @if (comic.colorists?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.colorists; track name) { @for (name of comic.colorists; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'colorist')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'colorist')">{{ name }}</a>
@@ -780,7 +780,7 @@
} }
@if (comic.letterers?.length) { @if (comic.letterers?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.letterers; track name) { @for (name of comic.letterers; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'letterer')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'letterer')">{{ name }}</a>
@@ -790,7 +790,7 @@
} }
@if (comic.coverArtists?.length) { @if (comic.coverArtists?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.coverArtists; track name) { @for (name of comic.coverArtists; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'coverArtist')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'coverArtist')">{{ name }}</a>
@@ -800,7 +800,7 @@
} }
@if (comic.editors?.length) { @if (comic.editors?.length) {
<div class="comic-creator-row"> <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"> <div class="comic-creator-names">
@for (name of comic.editors; track name) { @for (name of comic.editors; track name) {
<a class="comic-creator-link" (click)="goToCreator(name, 'editor')">{{ name }}</a> <a class="comic-creator-link" (click)="goToCreator(name, 'editor')">{{ name }}</a>
@@ -816,12 +816,12 @@
<div class="comic-subsection"> <div class="comic-subsection">
<div class="comic-subsection-title"> <div class="comic-subsection-title">
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
<span>Universe</span> <span>{{ t('universe') }}</span>
</div> </div>
<div class="comic-tags-container"> <div class="comic-tags-container">
@if (comic.characters?.length) { @if (comic.characters?.length) {
<div class="comic-tag-row"> <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"> <div class="comic-tag-list">
@for (character of comic.characters; track character) { @for (character of comic.characters; track character) {
<a class="comic-tag-clickable" (click)="goToCharacter(character)"> <a class="comic-tag-clickable" (click)="goToCharacter(character)">
@@ -833,7 +833,7 @@
} }
@if (comic.teams?.length) { @if (comic.teams?.length) {
<div class="comic-tag-row"> <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"> <div class="comic-tag-list">
@for (team of comic.teams; track team) { @for (team of comic.teams; track team) {
<a class="comic-tag-clickable" (click)="goToTeam(team)"> <a class="comic-tag-clickable" (click)="goToTeam(team)">
@@ -845,7 +845,7 @@
} }
@if (comic.locations?.length) { @if (comic.locations?.length) {
<div class="comic-tag-row"> <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"> <div class="comic-tag-list">
@for (location of comic.locations; track location) { @for (location of comic.locations; track location) {
<a class="comic-tag-clickable" (click)="goToLocation(location)"> <a class="comic-tag-clickable" (click)="goToLocation(location)">
@@ -863,17 +863,17 @@
<div class="comic-properties"> <div class="comic-properties">
@if (comic.manga) { @if (comic.manga) {
<span class="comic-property-badge manga"> <span class="comic-property-badge manga">
<i class="pi pi-book"></i> Manga <i class="pi pi-book"></i> {{ t('manga') }}
</span> </span>
} }
@if (comic.blackAndWhite) { @if (comic.blackAndWhite) {
<span class="comic-property-badge bw"> <span class="comic-property-badge bw">
<i class="pi pi-palette"></i> B&W <i class="pi pi-palette"></i> {{ t('bw') }}
</span> </span>
} }
@if (comic.readingDirection === 'rtl') { @if (comic.readingDirection === 'rtl') {
<span class="comic-property-badge 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> </span>
} }
</div> </div>
@@ -892,7 +892,7 @@
<div class="comic-notes"> <div class="comic-notes">
<div class="comic-notes-label"> <div class="comic-notes-label">
<i class="pi pi-file-edit"></i> <i class="pi pi-file-edit"></i>
<span>Notes</span> <span>{{ t('comicNotes') }}</span>
</div> </div>
<p class="comic-notes-content">{{ comic.notes }}</p> <p class="comic-notes-content">{{ comic.notes }}</p>
</div> </div>
@@ -906,7 +906,7 @@
<div class="section-header clickable" (click)="isAudiobookSectionExpanded = !isAudiobookSectionExpanded"> <div class="section-header clickable" (click)="isAudiobookSectionExpanded = !isAudiobookSectionExpanded">
<div class="section-header-left"> <div class="section-header-left">
<i class="pi pi-headphones"></i> <i class="pi pi-headphones"></i>
<span>Audiobook Details</span> <span>{{ t('audiobookDetails') }}</span>
</div> </div>
<i class="pi section-toggle-icon" [ngClass]="isAudiobookSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i> <i class="pi section-toggle-icon" [ngClass]="isAudiobookSectionExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
</div> </div>
@@ -917,13 +917,13 @@
<div class="audiobook-info-grid"> <div class="audiobook-info-grid">
@if (audio.durationSeconds) { @if (audio.durationSeconds) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ formatDuration(audio.durationSeconds) }}</span>
</div> </div>
} }
@if (book.metadata?.narrator) { @if (book.metadata?.narrator) {
<div class="audiobook-info-item"> <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!)"> <a class="audiobook-info-value audiobook-link" (click)="goToNarrator(book.metadata!.narrator!)">
{{ book.metadata?.narrator }} {{ book.metadata?.narrator }}
</a> </a>
@@ -931,31 +931,31 @@
} }
@if (audio.chapterCount) { @if (audio.chapterCount) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ audio.chapterCount }}</span>
</div> </div>
} }
@if (audio.bitrate) { @if (audio.bitrate) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ audio.bitrate }} kbps</span>
</div> </div>
} }
@if (audio.sampleRate) { @if (audio.sampleRate) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ formatSampleRate(audio.sampleRate) }}</span>
</div> </div>
} }
@if (audio.channels) { @if (audio.channels) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ getChannelLabel(audio.channels) }}</span>
</div> </div>
} }
@if (audio.codec) { @if (audio.codec) {
<div class="audiobook-info-item"> <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> <span class="audiobook-info-value">{{ audio.codec.toUpperCase() }}</span>
</div> </div>
} }
@@ -965,7 +965,7 @@
<div class="audiobook-properties"> <div class="audiobook-properties">
<span class="audiobook-property-badge" [ngClass]="book.metadata?.abridged ? 'abridged' : 'unabridged'"> <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> <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> </span>
</div> </div>
} }
@@ -986,8 +986,8 @@
</app-metadata-tabs> </app-metadata-tabs>
</div> </div>
} @else { } @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-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> </div>
} }
@@ -33,6 +33,7 @@ import {BookNavigationService} from '../../../../book/service/book-navigation.se
import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service'; import {BookMetadataHostService} from '../../../../../shared/service/book-metadata-host.service';
import {AppSettingsService} from '../../../../../shared/service/app-settings.service'; import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFileEvent, DownloadAllFilesEvent, DownloadEvent, MetadataTabsComponent, ReadEvent} from './metadata-tabs/metadata-tabs.component'; import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFileEvent, DownloadAllFilesEvent, DownloadEvent, MetadataTabsComponent, ReadEvent} from './metadata-tabs/metadata-tabs.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
@@ -40,7 +41,7 @@ import {DeleteBookFileEvent, DeleteSupplementaryFileEvent, DownloadAdditionalFil
standalone: true, standalone: true,
templateUrl: './metadata-viewer.component.html', templateUrl: './metadata-viewer.component.html',
styleUrl: './metadata-viewer.component.scss', 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 { export class MetadataViewerComponent implements OnInit, OnChanges {
@Input() book$!: Observable<Book | null>; @Input() book$!: Observable<Book | null>;
@@ -48,6 +49,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
@ViewChild(Editor) quillEditor!: Editor; @ViewChild(Editor) quillEditor!: Editor;
private originalRecommendedBooks: BookRecommendation[] = []; private originalRecommendedBooks: BookRecommendation[] = [];
private readonly t = inject(TranslocoService);
private bookDialogHelperService = inject(BookDialogHelperService) private bookDialogHelperService = inject(BookDialogHelperService)
private emailService = inject(EmailService); private emailService = inject(EmailService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
@@ -103,13 +105,13 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const primaryType = book.primaryFile?.bookType; const primaryType = book.primaryFile?.bookType;
if (primaryType === 'PDF') { if (primaryType === 'PDF') {
items.push({ items.push({
label: 'Streaming Reader', label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play', icon: 'pi pi-play',
command: () => this.read(book.id, 'pdf-streaming') command: () => this.read(book.id, 'pdf-streaming')
}); });
} else if (primaryType === 'EPUB') { } else if (primaryType === 'EPUB') {
items.push({ items.push({
label: 'Streaming Reader', label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play', icon: 'pi pi-play',
command: () => this.read(book.id, 'epub-streaming') command: () => this.read(book.id, 'epub-streaming')
}); });
@@ -136,12 +138,12 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
icon: this.getFileIcon(formatType), icon: this.getFileIcon(formatType),
items: [ items: [
{ {
label: 'Standard Reader', label: this.t.translate('metadata.viewer.standardReader'),
icon: 'pi pi-book', icon: 'pi pi-book',
command: () => this.read(book.id, undefined, formatType) command: () => this.read(book.id, undefined, formatType)
}, },
{ {
label: 'Streaming Reader', label: this.t.translate('metadata.viewer.streamingReader'),
icon: 'pi pi-play', icon: 'pi pi-play',
command: () => this.read(book.id, formatType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', formatType) 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[] = []; const items: MenuItem[] = [];
items.push({ items.push({
label: 'Shelf', label: this.t.translate('metadata.viewer.shelf'),
icon: 'pi pi-folder', icon: 'pi pi-folder',
command: () => this.assignShelf(book.id) command: () => this.assignShelf(book.id)
}); });
@@ -223,7 +225,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (userState?.user?.permissions.canUpload || userState?.user?.permissions.admin) { if (userState?.user?.permissions.canUpload || userState?.user?.permissions.admin) {
items.push({ items.push({
label: 'Upload File', label: this.t.translate('metadata.viewer.uploadFile'),
icon: 'pi pi-upload', icon: 'pi pi-upload',
command: () => { command: () => {
this.bookDialogHelperService.openAdditionalFileUploaderDialog(book); 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') { if (hasFiles && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin) && appSettings?.diskType === 'LOCAL') {
items.push({ items.push({
label: 'Organize Files', label: this.t.translate('metadata.viewer.organizeFiles'),
icon: 'pi pi-arrows-h', icon: 'pi pi-arrows-h',
command: () => { command: () => {
this.openFileMoverDialog(book.id); this.openFileMoverDialog(book.id);
@@ -245,16 +247,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (hasFiles && (userState?.user?.permissions.canEmailBook || userState?.user?.permissions.admin)) { if (hasFiles && (userState?.user?.permissions.canEmailBook || userState?.user?.permissions.admin)) {
items.push({ items.push({
label: 'Send Book', label: this.t.translate('metadata.viewer.sendBook'),
icon: 'pi pi-send', icon: 'pi pi-send',
items: [ items: [
{ {
label: 'Quick Send', label: this.t.translate('metadata.viewer.quickSend'),
icon: 'pi pi-bolt', icon: 'pi pi-bolt',
command: () => this.quickSend(book.id) command: () => this.quickSend(book.id)
}, },
{ {
label: 'Custom Send', label: this.t.translate('metadata.viewer.customSend'),
icon: 'pi pi-cog', icon: 'pi pi-cog',
command: () => { command: () => {
this.bookDialogHelperService.openCustomSendDialog(book); this.bookDialogHelperService.openCustomSendDialog(book);
@@ -268,7 +270,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
const isSingleFileBook = hasFiles && !book.alternativeFormats?.length; const isSingleFileBook = hasFiles && !book.alternativeFormats?.length;
if (isSingleFileBook && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin)) { if (isSingleFileBook && (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin)) {
items.push({ items.push({
label: 'Attach to Another Book', label: this.t.translate('metadata.viewer.attachToAnotherBook'),
icon: 'pi pi-link', icon: 'pi pi-link',
command: () => { command: () => {
this.bookDialogHelperService.openBookFileAttacherDialog(book); this.bookDialogHelperService.openBookFileAttacherDialog(book);
@@ -310,7 +312,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
if (deleteFormatItems.length > 0) { if (deleteFormatItems.length > 0) {
items.push({ items.push({
label: 'Delete File Formats', label: this.t.translate('metadata.viewer.deleteFileFormats'),
icon: 'pi pi-file', icon: 'pi pi-file',
items: deleteFormatItems items: deleteFormatItems
}); });
@@ -331,7 +333,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
}); });
items.push({ items.push({
label: 'Delete Supplementary Files', label: this.t.translate('metadata.viewer.deleteSupplementaryFiles'),
icon: 'pi pi-paperclip', icon: 'pi pi-paperclip',
items: deleteSupplementaryItems items: deleteSupplementaryItems
}); });
@@ -354,11 +356,11 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
? `\n\nThe following files will be permanently deleted:\n• ${allFormats.join('\n• ')}` ? `\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 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.` ? this.t.translate('metadata.viewer.confirm.deleteBookMessage', { title: book.metadata?.title })
: `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.`; : this.t.translate('metadata.viewer.confirm.deleteBookAndFilesMessage', { title: book.metadata?.title, fileList: fileListMessage });
const deleteAcceptLabel = isPhysical ? 'Delete' : 'Delete Everything'; const deleteAcceptLabel = isPhysical ? this.t.translate('common.delete') : this.t.translate('metadata.viewer.deleteEverything');
items.push({ items.push({
label: deleteLabel, label: deleteLabel,
@@ -371,7 +373,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
acceptIcon: 'pi pi-trash', acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times', rejectIcon: 'pi pi-times',
acceptLabel: deleteAcceptLabel, acceptLabel: deleteAcceptLabel,
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
acceptButtonStyleClass: 'p-button-danger', acceptButtonStyleClass: 'p-button-danger',
rejectButtonStyleClass: 'p-button-outlined', rejectButtonStyleClass: 'p-button-outlined',
accept: () => { accept: () => {
@@ -478,9 +480,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
getReadButtonLabel(book: Book): string { getReadButtonLabel(book: Book): string {
const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK'; const isAudiobook = book.primaryFile?.bookType === 'AUDIOBOOK';
if (this.isInProgressStatus()) { 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 { getReadButtonIcon(book: Book): string {
@@ -523,8 +525,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
deleteAdditionalFile(bookId: number, fileId: number, fileName: string) { deleteAdditionalFile(bookId: number, fileId: number, fileName: string) {
this.confirmationService.confirm({ 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.`, message: this.t.translate('metadata.viewer.confirm.deleteSupplementaryMessage', { fileName }),
header: 'Delete Supplementary File', header: this.t.translate('metadata.viewer.confirm.deleteSupplementaryHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash', acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times', rejectIcon: 'pi pi-times',
@@ -535,15 +537,15 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('metadata.viewer.toast.deleteSupplementarySuccessSummary'),
detail: `Supplementary file "${fileName}" deleted successfully` detail: this.t.translate('metadata.viewer.toast.deleteSupplementarySuccessDetail', { fileName })
}); });
}, },
error: (error) => { error: (error) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('metadata.viewer.toast.deleteSupplementaryErrorSummary'),
detail: `Failed to delete supplementary file: ${error.message || 'Unknown error'}` 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; let header: string;
if (isOnlyFormat) { if (isOnlyFormat) {
// This is the only book format file - warn user strongly message = this.t.translate('metadata.viewer.confirm.deleteOnlyFormatMessage', { fileName });
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 = this.t.translate('metadata.viewer.confirm.deleteOnlyFormatHeader');
header = 'Delete Only Book Format';
} else if (isPrimary) { } else if (isPrimary) {
// This is the primary format but there are alternatives message = this.t.translate('metadata.viewer.confirm.deletePrimaryFormatMessage', { fileName });
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 = this.t.translate('metadata.viewer.confirm.deletePrimaryFormatHeader');
header = 'Delete Primary Format';
} else { } else {
// This is an alternative format message = this.t.translate('metadata.viewer.confirm.deleteAlternativeFormatMessage', { fileName });
message = `Are you sure you want to delete "${fileName}"?\n\nThis file will be permanently removed from your filesystem.`; header = this.t.translate('metadata.viewer.confirm.deleteAlternativeFormatHeader');
header = 'Delete Book Format';
} }
this.confirmationService.confirm({ this.confirmationService.confirm({
@@ -575,8 +574,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptIcon: 'pi pi-trash', acceptIcon: 'pi pi-trash',
rejectIcon: 'pi pi-times', rejectIcon: 'pi pi-times',
acceptLabel: 'Delete File', acceptLabel: this.t.translate('metadata.viewer.confirm.deleteFile'),
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
rejectButtonStyleClass: 'p-button-secondary', rejectButtonStyleClass: 'p-button-secondary',
acceptButtonStyleClass: 'p-button-danger', acceptButtonStyleClass: 'p-button-danger',
accept: () => { accept: () => {
@@ -584,15 +583,15 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('metadata.viewer.toast.deleteFormatSuccessSummary'),
detail: `Book format "${fileName}" deleted successfully` detail: this.t.translate('metadata.viewer.toast.deleteFormatSuccessDetail', { fileName })
}); });
}, },
error: (error) => { error: (error) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('metadata.viewer.toast.deleteFormatErrorSummary'),
detail: `Failed to delete book format: ${error.message || 'Unknown error'}` 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({ this.emailService.emailBookQuick(bookId).subscribe({
next: () => this.messageService.add({ next: () => this.messageService.add({
severity: 'info', severity: 'info',
summary: 'Success', summary: this.t.translate('metadata.viewer.toast.quickSendSuccessSummary'),
detail: 'The book sending has been scheduled.', detail: this.t.translate('metadata.viewer.toast.quickSendSuccessDetail'),
}), }),
error: (err) => this.messageService.add({ error: (err) => this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('metadata.viewer.toast.quickSendErrorSummary'),
detail: err?.error?.message || 'An error occurred while sending the book.', 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.selectedReadStatus = status;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Read Status Updated', summary: this.t.translate('metadata.viewer.toast.readStatusUpdatedSummary'),
detail: `Marked as "${this.getStatusLabel(status)}"`, detail: this.t.translate('metadata.viewer.toast.readStatusUpdatedDetail', { status: this.getStatusLabel(status) }),
life: 2000 life: 2000
}); });
}, },
@@ -656,8 +655,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
console.error('Failed to update read status:', err); console.error('Failed to update read status:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Update Failed', summary: this.t.translate('metadata.viewer.toast.readStatusFailedSummary'),
detail: 'Could not update read status.', detail: this.t.translate('metadata.viewer.toast.readStatusFailedDetail'),
life: 3000 life: 3000
}); });
} }
@@ -667,27 +666,27 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
resetProgress(book: Book, type: ResetProgressType): void { resetProgress(book: Book, type: ResetProgressType): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: `Reset reading progress for "${book.metadata?.title}"?`, message: this.t.translate('metadata.viewer.confirm.resetProgressMessage', { title: book.metadata?.title }),
header: 'Confirm Reset', header: this.t.translate('metadata.viewer.confirm.resetProgressHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Yes', acceptLabel: this.t.translate('common.yes'),
rejectLabel: 'Cancel', rejectLabel: this.t.translate('common.cancel'),
acceptButtonStyleClass: 'p-button-danger', acceptButtonStyleClass: 'p-button-danger',
accept: () => { accept: () => {
this.bookService.resetProgress(book.id, type).subscribe({ this.bookService.resetProgress(book.id, type).subscribe({
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Progress Reset', summary: this.t.translate('metadata.viewer.toast.progressResetSummary'),
detail: 'Reading progress has been reset.', detail: this.t.translate('metadata.viewer.toast.progressResetDetail'),
life: 1500 life: 1500
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Failed', summary: this.t.translate('metadata.viewer.toast.progressResetFailedSummary'),
detail: 'Could not reset progress.', detail: this.t.translate('metadata.viewer.toast.progressResetFailedDetail'),
life: 1500 life: 1500
}); });
} }
@@ -701,16 +700,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Rating Saved', summary: this.t.translate('metadata.viewer.toast.ratingSavedSummary'),
detail: 'Personal rating updated successfully' detail: this.t.translate('metadata.viewer.toast.ratingSavedDetail')
}); });
}, },
error: err => { error: err => {
console.error('Failed to update personal rating:', err); console.error('Failed to update personal rating:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Update Failed', summary: this.t.translate('metadata.viewer.toast.ratingFailedSummary'),
detail: 'Could not update personal rating' detail: this.t.translate('metadata.viewer.toast.ratingFailedDetail')
}); });
} }
}); });
@@ -721,16 +720,16 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'info', severity: 'info',
summary: 'Rating Reset', summary: this.t.translate('metadata.viewer.toast.ratingResetSummary'),
detail: 'Personal rating has been cleared.' detail: this.t.translate('metadata.viewer.toast.ratingResetDetail')
}); });
}, },
error: err => { error: err => {
console.error('Failed to reset personal rating:', err); console.error('Failed to reset personal rating:', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Reset Failed', summary: this.t.translate('metadata.viewer.toast.ratingResetFailedSummary'),
detail: 'Could not reset personal rating' detail: this.t.translate('metadata.viewer.toast.ratingResetFailedDetail')
}); });
} }
}); });
@@ -1161,8 +1160,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Date Updated', summary: this.t.translate('metadata.viewer.toast.dateUpdatedSummary'),
detail: 'Book finish date has been updated.', detail: this.t.translate('metadata.viewer.toast.dateUpdatedDetail'),
life: 1500 life: 1500
}); });
this.isEditingDateFinished = false; this.isEditingDateFinished = false;
@@ -1171,8 +1170,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Update Failed', summary: this.t.translate('metadata.viewer.toast.dateFailedSummary'),
detail: 'Could not update book finish date.', detail: this.t.translate('metadata.viewer.toast.dateFailedDetail'),
life: 3000 life: 3000
}); });
} }
@@ -1226,7 +1225,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
getNavigationPosition(): string { getNavigationPosition(): string {
const position = this.bookNavigationService.getCurrentPosition(); 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 { hasDigitalFile(book: Book): boolean {
@@ -1,9 +1,10 @@
<ng-container *transloco="let t; prefix: 'metadata.sidecar'">
<div class="sidecar-viewer"> <div class="sidecar-viewer">
<div class="sidecar-header"> <div class="sidecar-header">
<div class="header-info"> <div class="header-info">
<h3>Sidecar Metadata</h3> <h3>{{ t('title') }}</h3>
<p class="header-description"> <p class="header-description">
View and manage the .metadata.json file stored alongside your book file. {{ t('description') }}
</p> </p>
</div> </div>
<div class="header-actions"> <div class="header-actions">
@@ -18,29 +19,29 @@
@if (loading) { @if (loading) {
<div class="loading-state"> <div class="loading-state">
<i class="pi pi-spin pi-spinner"></i> <i class="pi pi-spin pi-spinner"></i>
<span>Loading sidecar data...</span> <span>{{ t('loading') }}</span>
</div> </div>
} @else { } @else {
<div class="sidecar-actions"> <div class="sidecar-actions">
<p-button <p-button
label="Export to Sidecar" [label]="t('exportToSidecar')"
icon="pi pi-upload" icon="pi pi-upload"
[loading]="exporting" [loading]="exporting"
(onClick)="exportToSidecar()" (onClick)="exportToSidecar()"
severity="primary" severity="primary"
size="small" size="small"
pTooltip="Create or update the sidecar JSON file with current database metadata" [pTooltip]="t('exportTooltip')"
tooltipPosition="top" tooltipPosition="top"
/> />
<p-button <p-button
label="Import from Sidecar" [label]="t('importFromSidecar')"
icon="pi pi-download" icon="pi pi-download"
[loading]="importing" [loading]="importing"
[disabled]="syncStatus === 'MISSING'" [disabled]="syncStatus === 'MISSING'"
(onClick)="importFromSidecar()" (onClick)="importFromSidecar()"
severity="secondary" severity="secondary"
size="small" size="small"
pTooltip="Import metadata from the sidecar JSON file into the database" [pTooltip]="t('importTooltip')"
tooltipPosition="top" tooltipPosition="top"
/> />
</div> </div>
@@ -48,10 +49,9 @@
@if (syncStatus === 'MISSING') { @if (syncStatus === 'MISSING') {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-file"></i> <i class="pi pi-file"></i>
<h4>No Sidecar File Found</h4> <h4>{{ t('noSidecarFile') }}</h4>
<p> <p>
No .metadata.json file exists for this book yet. {{ t('noSidecarDescription') }}
Click "Export to Sidecar" to create one with the current metadata.
</p> </p>
</div> </div>
} @else if (sidecarContent) { } @else if (sidecarContent) {
@@ -60,15 +60,15 @@
<div class="content-meta"> <div class="content-meta">
<span class="meta-item"> <span class="meta-item">
<i class="pi pi-clock"></i> <i class="pi pi-clock"></i>
Generated: {{ sidecarContent.generatedAt | date:'medium' }} {{ t('generated') }} {{ sidecarContent.generatedAt | date:'medium' }}
</span> </span>
<span class="meta-item"> <span class="meta-item">
<i class="pi pi-tag"></i> <i class="pi pi-tag"></i>
Version: {{ sidecarContent.version }} {{ t('version') }} {{ sidecarContent.version }}
</span> </span>
<span class="meta-item"> <span class="meta-item">
<i class="pi pi-cog"></i> <i class="pi pi-cog"></i>
By: {{ sidecarContent.generatedBy }} {{ t('generatedBy') }} {{ sidecarContent.generatedBy }}
</span> </span>
</div> </div>
</div> </div>
@@ -80,10 +80,11 @@
@if (sidecarContent.cover) { @if (sidecarContent.cover) {
<div class="cover-info"> <div class="cover-info">
<i class="pi pi-image"></i> <i class="pi pi-image"></i>
<span>Cover file: {{ sidecarContent.cover.path }}</span> <span>{{ t('coverFile') }} {{ sidecarContent.cover.path }}</span>
</div> </div>
} }
</div> </div>
} }
} }
</div> </div>
</ng-container>
@@ -8,19 +8,21 @@ import {Button} from 'primeng/button';
import {Tag} from 'primeng/tag'; import {Tag} from 'primeng/tag';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {DatePipe, JsonPipe} from '@angular/common'; import {DatePipe, JsonPipe} from '@angular/common';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-sidecar-viewer', selector: 'app-sidecar-viewer',
standalone: true, standalone: true,
templateUrl: './sidecar-viewer.component.html', templateUrl: './sidecar-viewer.component.html',
styleUrls: ['./sidecar-viewer.component.scss'], styleUrls: ['./sidecar-viewer.component.scss'],
imports: [Button, Tag, Tooltip, JsonPipe, DatePipe] imports: [Button, Tag, Tooltip, JsonPipe, DatePipe, TranslocoDirective]
}) })
export class SidecarViewerComponent implements OnInit, OnDestroy { export class SidecarViewerComponent implements OnInit, OnDestroy {
@Input() book$!: Observable<Book>; @Input() book$!: Observable<Book>;
private sidecarService = inject(SidecarService); private sidecarService = inject(SidecarService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
sidecarContent: SidecarMetadata | null = null; sidecarContent: SidecarMetadata | null = null;
@@ -95,8 +97,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Export Successful', summary: this.t.translate('metadata.sidecar.toast.exportSuccessSummary'),
detail: 'Sidecar metadata file has been created.' detail: this.t.translate('metadata.sidecar.toast.exportSuccessDetail')
}); });
this.loadSidecarData(this.currentBookId!); this.loadSidecarData(this.currentBookId!);
this.exporting = false; this.exporting = false;
@@ -104,8 +106,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Export Failed', summary: this.t.translate('metadata.sidecar.toast.exportFailedSummary'),
detail: 'Failed to create sidecar metadata file.' detail: this.t.translate('metadata.sidecar.toast.exportFailedDetail')
}); });
this.exporting = false; this.exporting = false;
console.error('Export failed:', err); console.error('Export failed:', err);
@@ -123,8 +125,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Import Successful', summary: this.t.translate('metadata.sidecar.toast.importSuccessSummary'),
detail: 'Metadata has been imported from sidecar file.' detail: this.t.translate('metadata.sidecar.toast.importSuccessDetail')
}); });
this.loadSidecarData(this.currentBookId!); this.loadSidecarData(this.currentBookId!);
this.importing = false; this.importing = false;
@@ -132,8 +134,8 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Import Failed', summary: this.t.translate('metadata.sidecar.toast.importFailedSummary'),
detail: 'Failed to import metadata from sidecar file.' detail: this.t.translate('metadata.sidecar.toast.importFailedDetail')
}); });
this.importing = false; this.importing = false;
console.error('Import failed:', err); console.error('Import failed:', err);
@@ -159,17 +161,17 @@ export class SidecarViewerComponent implements OnInit, OnDestroy {
getSyncStatusLabel(): string { getSyncStatusLabel(): string {
switch (this.syncStatus) { switch (this.syncStatus) {
case 'IN_SYNC': case 'IN_SYNC':
return 'In Sync'; return this.t.translate('metadata.sidecar.syncStatus.inSync');
case 'OUTDATED': case 'OUTDATED':
return 'Outdated'; return this.t.translate('metadata.sidecar.syncStatus.outdated');
case 'CONFLICT': case 'CONFLICT':
return 'Conflict'; return this.t.translate('metadata.sidecar.syncStatus.conflict');
case 'MISSING': case 'MISSING':
return 'Missing'; return this.t.translate('metadata.sidecar.syncStatus.missing');
case 'NOT_APPLICABLE': case 'NOT_APPLICABLE':
return 'N/A'; return this.t.translate('metadata.sidecar.syncStatus.notApplicable');
default: 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="cover-search-container">
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi {{ coverType === 'audiobook' ? 'pi-headphones' : 'pi-image' }} header-icon"></i> <i class="pi {{ coverType === 'audiobook' ? 'pi-headphones' : 'pi-image' }} header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Search {{ coverType === 'audiobook' ? 'Audiobook' : 'Ebook' }} Cover</h2> <h2 class="panel-title">{{ coverType === 'audiobook' ? t('searchAudiobookCover') : t('searchEbookCover') }}</h2>
<p class="panel-description">Find and select a cover for your book</p> <p class="panel-description">{{ t('description') }}</p>
</div> </div>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -25,19 +26,19 @@
<div class="form-field title-field"> <div class="form-field title-field">
<label for="title"> <label for="title">
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
Title {{ t('titleLabel') }}
<span class="required">*</span> <span class="required">*</span>
</label> </label>
<input <input
pInputText pInputText
id="title" id="title"
formControlName="title" formControlName="title"
placeholder="Enter book title" [placeholder]="t('titlePlaceholder')"
/> />
@if (searchForm.get('title')?.invalid && searchForm.get('title')?.touched) { @if (searchForm.get('title')?.invalid && searchForm.get('title')?.touched) {
<small class="error-message"> <small class="error-message">
<i class="pi pi-exclamation-circle"></i> <i class="pi pi-exclamation-circle"></i>
Title is required {{ t('titleRequired') }}
</small> </small>
} }
</div> </div>
@@ -45,20 +46,20 @@
<div class="form-field author-field"> <div class="form-field author-field">
<label for="author"> <label for="author">
<i class="pi pi-user"></i> <i class="pi pi-user"></i>
Author {{ t('authorLabel') }}
</label> </label>
<input <input
pInputText pInputText
id="author" id="author"
formControlName="author" formControlName="author"
placeholder="Enter author name (optional)" [placeholder]="t('authorPlaceholder')"
/> />
</div> </div>
<div class="form-actions"> <div class="form-actions">
<p-button <p-button
type="submit" type="submit"
label="Search" [label]="t('searchBtn')"
icon="pi pi-search" icon="pi pi-search"
[loading]="loading" [loading]="loading"
[disabled]="searchForm.invalid"> [disabled]="searchForm.invalid">
@@ -70,7 +71,7 @@
[rounded]="true" [rounded]="true"
severity="secondary" severity="secondary"
(click)="onClear()" (click)="onClear()"
pTooltip="Reset search" [pTooltip]="t('resetSearchTooltip')"
tooltipPosition="top"> tooltipPosition="top">
</p-button> </p-button>
</div> </div>
@@ -86,14 +87,14 @@
<div class="empty-state-icon"> <div class="empty-state-icon">
<i class="pi pi-images"></i> <i class="pi pi-images"></i>
</div> </div>
<h3>Search for Book Covers</h3> <h3>{{ t('searchForCovers') }}</h3>
<p>Enter a book title above to find cover images from various sources.</p> <p>{{ t('searchForCoversDescription') }}</p>
</div> </div>
} @else if (loading) { } @else if (loading) {
<!-- Loading State --> <!-- Loading State -->
<div class="loading-state"> <div class="loading-state">
<p-progressSpinner strokeWidth="3" animationDuration="1s"></p-progressSpinner> <p-progressSpinner strokeWidth="3" animationDuration="1s"></p-progressSpinner>
<p>Searching for covers...</p> <p>{{ t('searchingForCovers') }}</p>
</div> </div>
} @else if (coverImages.length === 0) { } @else if (coverImages.length === 0) {
<!-- No Results State --> <!-- No Results State -->
@@ -101,19 +102,19 @@
<div class="empty-state-icon warning"> <div class="empty-state-icon warning">
<i class="pi pi-search"></i> <i class="pi pi-search"></i>
</div> </div>
<h3>No Covers Found</h3> <h3>{{ t('noCoversFound') }}</h3>
<p>Try adjusting your search terms or check the spelling.</p> <p>{{ t('noCoversFoundDescription') }}</p>
</div> </div>
} @else { } @else {
<!-- Results Grid --> <!-- Results Grid -->
<div class="results-header"> <div class="results-header">
<span class="results-count"> <span class="results-count">
<i class="pi pi-images"></i> <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>
<span class="results-hint"> <span class="results-hint">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Click on an image to preview, or select to apply {{ t('resultsHint') }}
</span> </span>
</div> </div>
@@ -123,7 +124,7 @@
<div class="cover-image-wrapper"> <div class="cover-image-wrapper">
<p-image <p-image
[src]="cover.url" [src]="cover.url"
[alt]="'Book cover ' + (i + 1)" [alt]="t('bookCoverAlt', { index: i + 1 })"
appendTo="body" appendTo="body"
[preview]="true"> [preview]="true">
</p-image> </p-image>
@@ -135,7 +136,7 @@
<div class="cover-overlay"> <div class="cover-overlay">
<p-button <p-button
(click)="selectAndSave(cover)" (click)="selectAndSave(cover)"
label="Select Cover" [label]="t('selectCover')"
icon="pi pi-check" icon="pi pi-check"
size="small"> size="small">
</p-button> </p-button>
@@ -148,3 +149,4 @@
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -10,6 +10,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {BookService} from '../../../book/service/book.service'; import {BookService} from '../../../book/service/book.service';
import {Image} from 'primeng/image'; import {Image} from 'primeng/image';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-cover-search', selector: 'app-cover-search',
@@ -21,7 +22,8 @@ import {Tooltip} from 'primeng/tooltip';
InputText, InputText,
ProgressSpinner, ProgressSpinner,
Image, Image,
Tooltip Tooltip,
TranslocoDirective
], ],
styleUrls: ['./cover-search.component.scss'] styleUrls: ['./cover-search.component.scss']
}) })
@@ -39,6 +41,7 @@ export class CoverSearchComponent implements OnInit {
protected dynamicDialogRef = inject(DynamicDialogRef); protected dynamicDialogRef = inject(DynamicDialogRef);
protected bookService = inject(BookService); protected bookService = inject(BookService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
constructor() { constructor() {
this.searchForm = this.fb.group({ this.searchForm = this.fb.group({
@@ -111,16 +114,18 @@ export class CoverSearchComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Cover Updated', summary: this.t.translate('metadata.coverSearch.toast.coverUpdatedSummary'),
detail: `${this.coverType === 'audiobook' ? 'Audiobook' : 'Ebook'} cover image updated successfully.` detail: this.coverType === 'audiobook'
? this.t.translate('metadata.coverSearch.toast.audiobookCoverUpdatedDetail')
: this.t.translate('metadata.coverSearch.toast.ebookCoverUpdatedDetail')
}); });
this.dynamicDialogRef.close(true); this.dynamicDialogRef.close(true);
}, },
error: err => { error: err => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Cover Update Failed', summary: this.t.translate('metadata.coverSearch.toast.coverUpdateFailedSummary'),
detail: err?.message || 'Failed to update cover image.' 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="main-container enclosing-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-sitemap"></i> <i class="pi pi-sitemap"></i>
Metadata Manager {{ t('title') }}
<app-external-doc-link docType="metadataManager"></app-external-doc-link> <app-external-doc-link docType="metadataManager"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Organize, merge, split, rename, and standardize authors, genres, moods, and tags across your library. {{ t('description') }}
<i <i
class="pi pi-exclamation-triangle info-icon" 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" tooltipPosition="right"
[escape]="false"></i> [escape]="false"></i>
</p> </p>
@@ -20,7 +21,7 @@
<p-tablist> <p-tablist>
@for (tab of tabConfigs; track tab.type) { @for (tab of tabConfigs; track tab.type) {
<p-tab [value]="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-tab>
} }
</p-tablist> </p-tablist>
@@ -35,11 +36,11 @@
type="text" type="text"
#tableFilter #tableFilter
(input)="filterGlobal($event, dataTable)" (input)="filterGlobal($event, dataTable)"
[placeholder]="tab.placeholder"/> [placeholder]="t(tab.placeholderKey)"/>
</p-iconfield> </p-iconfield>
<div class="actions"> <div class="actions">
<p-button <p-button
label="Clear Selection" [label]="t('clearSelection')"
icon="pi pi-times" icon="pi pi-times"
[disabled]="getSelectedItems(tab.type).length === 0" [disabled]="getSelectedItems(tab.type).length === 0"
(onClick)="clearSelection(tab.type)" (onClick)="clearSelection(tab.type)"
@@ -47,7 +48,7 @@
size="small" size="small"
outlined></p-button> outlined></p-button>
<p-button <p-button
label="Delete Selected" [label]="t('deleteSelected')"
icon="pi pi-trash" icon="pi pi-trash"
[disabled]="getSelectedItems(tab.type).length === 0" [disabled]="getSelectedItems(tab.type).length === 0"
(onClick)="openDeleteDialog(tab.type)" (onClick)="openDeleteDialog(tab.type)"
@@ -55,7 +56,7 @@
size="small" size="small"
outlined></p-button> outlined></p-button>
<p-button <p-button
label="Merge/Split Selected" [label]="t('mergeSplitSelected')"
icon="pi pi-sitemap" icon="pi pi-sitemap"
[disabled]="getSelectedItems(tab.type).length < 2" [disabled]="getSelectedItems(tab.type).length < 2"
(onClick)="openMergeDialog(tab.type)" (onClick)="openMergeDialog(tab.type)"
@@ -89,21 +90,21 @@
<th pSortableColumn="value"> <th pSortableColumn="value">
<div class="header-content"> <div class="header-content">
<i class="pi {{ tab.icon }}"></i> <i class="pi {{ tab.icon }}"></i>
<span>{{ tab.label }}</span> <span>{{ t(tab.labelKey) }}</span>
<p-sortIcon field="value"></p-sortIcon> <p-sortIcon field="value"></p-sortIcon>
</div> </div>
</th> </th>
<th pSortableColumn="count"> <th pSortableColumn="count">
<div class="header-content"> <div class="header-content">
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
<span>Books</span> <span>{{ t('booksColumn') }}</span>
<p-sortIcon field="count"></p-sortIcon> <p-sortIcon field="count"></p-sortIcon>
</div> </div>
</th> </th>
<th class="actions-header"> <th class="actions-header">
<div class="header-content"> <div class="header-content">
<i class="pi pi-cog"></i> <i class="pi pi-cog"></i>
<span>Actions</span> <span>{{ t('actionsColumn') }}</span>
</div> </div>
</th> </th>
</tr> </tr>
@@ -129,7 +130,7 @@
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
pTooltip="Select similar" [pTooltip]="t('selectSimilarTooltip')"
(onClick)="selectSimilar(tab.type, item.value)"></p-button> (onClick)="selectSimilar(tab.type, item.value)"></p-button>
<p-button <p-button
icon="pi pi-pencil" icon="pi pi-pencil"
@@ -137,7 +138,7 @@
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
pTooltip="Rename/Split" [pTooltip]="t('renameSplitTooltip')"
(onClick)="openRenameDialog(tab.type, item)"></p-button> (onClick)="openRenameDialog(tab.type, item)"></p-button>
<p-button <p-button
icon="pi pi-trash" icon="pi pi-trash"
@@ -145,7 +146,7 @@
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
pTooltip="Delete" [pTooltip]="t('deleteTooltip')"
(onClick)="openDeleteDialog(tab.type, item)"></p-button> (onClick)="openDeleteDialog(tab.type, item)"></p-button>
</td> </td>
</tr> </tr>
@@ -159,57 +160,40 @@
</div> </div>
<p-dialog <p-dialog
header="Merge/Split {{ currentMergeType | titlecase }}" [header]="t('mergeSplitDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showMergeDialog" [(visible)]="showMergeDialog"
[modal]="true" [modal]="true"
class="user-dialog" class="user-dialog"
[style]="{width: '50rem'}"> [style]="{width: '50rem'}">
<div class="dialog-form"> <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"> <ul class="selected-items">
@for (item of getSelectedItems(currentMergeType); track item.value) { @for (item of getSelectedItems(currentMergeType); track item.value) {
<li> <li>
• {{ item.value }} <span class="count">({{ item.count }} books)</span> &#8226; {{ item.value }} <span class="count">{{ t('booksCount', { count: item.count }) }}</span>
</li> </li>
} }
</ul> </ul>
<div class="form-field"> <div class="form-field">
<label for="mergeTarget">Target Value{{ isSingleValueField(currentMergeType) ? '' : '(s)' }}:</label> <label for="mergeTarget">{{ isSingleValueField(currentMergeType) ? t('targetValueLabel') : t('targetValuesLabel') }}</label>
<input <input
id="mergeTarget" id="mergeTarget"
type="text" type="text"
pInputText pInputText
[(ngModel)]="mergeTarget" [(ngModel)]="mergeTarget"
class="full-width-input" 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)) { @if (isSingleValueField(currentMergeType)) {
<small class="help-text"> <small class="help-text" [innerHTML]="t('singleMergeHowItWorks', { type: currentMergeType, singular: currentMergeType.slice(0, -1) })"></small>
<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>
} @else { } @else {
<small class="help-text"> <small class="help-text" [innerHTML]="t('multiMergeHowItWorks', { type: currentMergeType })"></small>
<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>
} }
</div> </div>
@if (mergingInProgress) { @if (mergingInProgress) {
<div class="processing-note"> <div class="processing-note">
<i class="pi pi-info-circle"></i> <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>
} }
</div> </div>
@@ -217,14 +201,14 @@
<ng-template pTemplate="footer"> <ng-template pTemplate="footer">
<div class="dialog-actions"> <div class="dialog-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
(onClick)="showMergeDialog = false" (onClick)="showMergeDialog = false"
[disabled]="mergingInProgress" [disabled]="mergingInProgress"
severity="secondary" severity="secondary"
outlined></p-button> outlined></p-button>
<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'" [icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="mergingInProgress" [loading]="mergingInProgress"
[disabled]="mergingInProgress" [disabled]="mergingInProgress"
@@ -235,51 +219,38 @@
</p-dialog> </p-dialog>
<p-dialog <p-dialog
header="Rename/Split {{ currentMergeType | titlecase }}" [header]="t('renameSplitDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showRenameDialog" [(visible)]="showRenameDialog"
[modal]="true" [modal]="true"
class="user-dialog" class="user-dialog"
[style]="{width: '40rem'}"> [style]="{width: '40rem'}">
<div class="dialog-form"> <div class="dialog-form">
<p>You are renaming/splitting:</p> <p>{{ t('renameSplitDescription') }}</p>
<div class="current-value"> <div class="current-value">
<strong>{{ currentRenameItem?.value }}</strong> <strong>{{ currentRenameItem?.value }}</strong>
<span class="count">({{ currentRenameItem?.count }} books)</span> <span class="count">{{ t('booksCount', { count: currentRenameItem?.count }) }}</span>
</div> </div>
<div class="form-field"> <div class="form-field">
<label for="renameTarget">New Name(s):</label> <label for="renameTarget">{{ t('newNamesLabel') }}</label>
<input <input
id="renameTarget" id="renameTarget"
type="text" type="text"
pInputText pInputText
[(ngModel)]="renameTarget" [(ngModel)]="renameTarget"
class="full-width-input" class="full-width-input"
[placeholder]="isSingleValueField(currentMergeType) ? 'e.g., Mystery' : 'e.g., Mystery, Detective'" [placeholder]="isSingleValueField(currentMergeType) ? t('singleRenamePlaceholder') : t('multiRenamePlaceholder')"
(keyup.enter)="confirmRename()"/> (keyup.enter)="confirmRename()"/>
@if (isSingleValueField(currentMergeType)) { @if (isSingleValueField(currentMergeType)) {
<small class="help-text"> <small class="help-text" [innerHTML]="t('singleRenameHowItWorks', { singular: currentMergeType.slice(0, -1) })"></small>
<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>
} @else { } @else {
<small class="help-text"> <small class="help-text" [innerHTML]="t('multiRenameHowItWorks', { singular: currentMergeType.slice(0, -1), type: currentMergeType })"></small>
<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>
} }
</div> </div>
@if (mergingInProgress) { @if (mergingInProgress) {
<div class="processing-note"> <div class="processing-note">
<i class="pi pi-info-circle"></i> <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>
} }
</div> </div>
@@ -287,14 +258,14 @@
<ng-template pTemplate="footer"> <ng-template pTemplate="footer">
<div class="dialog-actions"> <div class="dialog-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
(onClick)="showRenameDialog = false" (onClick)="showRenameDialog = false"
[disabled]="mergingInProgress" [disabled]="mergingInProgress"
severity="secondary" severity="secondary"
outlined></p-button> outlined></p-button>
<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'" [icon]="mergingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
[loading]="mergingInProgress" [loading]="mergingInProgress"
[disabled]="mergingInProgress" [disabled]="mergingInProgress"
@@ -305,7 +276,7 @@
</p-dialog> </p-dialog>
<p-dialog <p-dialog
header="Delete {{ currentMergeType | titlecase }}" [header]="t('deleteDialogTitle', { type: currentMergeType | titlecase })"
[(visible)]="showDeleteDialog" [(visible)]="showDeleteDialog"
[modal]="true" [modal]="true"
class="user-dialog" class="user-dialog"
@@ -313,36 +284,36 @@
<div class="dialog-form"> <div class="dialog-form">
<div class="warning-message"> <div class="warning-message">
<i class="pi pi-exclamation-triangle"></i> <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> </div>
@if (currentDeleteItem) { @if (currentDeleteItem) {
<div class="current-value"> <div class="current-value">
<strong>{{ currentDeleteItem.value }}</strong> <strong>{{ currentDeleteItem.value }}</strong>
<span class="count">({{ currentDeleteItem.count }} books)</span> <span class="count">{{ t('booksCount', { count: currentDeleteItem.count }) }}</span>
</div> </div>
} @else { } @else {
<ul class="selected-items"> <ul class="selected-items">
@for (item of getSelectedItems(currentMergeType); track item.value) { @for (item of getSelectedItems(currentMergeType); track item.value) {
<li> <li>
• {{ item.value }} <span class="count">({{ item.count }} books)</span> &#8226; {{ item.value }} <span class="count">{{ t('booksCount', { count: item.count }) }}</span>
</li> </li>
} }
</ul> </ul>
} }
<div class="delete-info"> <div class="delete-info">
<p><strong>What will happen:</strong></p> <p><strong>{{ t('whatWillHappen') }}</strong></p>
<ul> <ul>
<li>The {{ currentMergeType.slice(0, -1) }} will be removed from all affected books</li> <li>{{ t('deleteItemRemoved', { singular: currentMergeType.slice(0, -1) }) }}</li>
<li>This action cannot be undone</li> <li>{{ t('deleteCannotUndo') }}</li>
<li>Total books affected: <strong>{{ currentDeleteItem ? currentDeleteItem.count : getTotalAffectedBooks(getSelectedItems(currentMergeType)) }}</strong></li> <li>{{ t('totalBooksAffected') }} <strong>{{ currentDeleteItem ? currentDeleteItem.count : getTotalAffectedBooks(getSelectedItems(currentMergeType)) }}</strong></li>
</ul> </ul>
</div> </div>
@if (deletingInProgress) { @if (deletingInProgress) {
<div class="processing-note"> <div class="processing-note">
<i class="pi pi-info-circle"></i> <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>
} }
</div> </div>
@@ -350,14 +321,14 @@
<ng-template pTemplate="footer"> <ng-template pTemplate="footer">
<div class="dialog-actions"> <div class="dialog-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
(onClick)="showDeleteDialog = false" (onClick)="showDeleteDialog = false"
[disabled]="deletingInProgress" [disabled]="deletingInProgress"
severity="secondary" severity="secondary"
outlined></p-button> outlined></p-button>
<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'" [icon]="deletingInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-trash'"
[loading]="deletingInProgress" [loading]="deletingInProgress"
[disabled]="deletingInProgress" [disabled]="deletingInProgress"
@@ -367,3 +338,4 @@
</ng-template> </ng-template>
</p-dialog> </p-dialog>
</div> </div>
</ng-container>
@@ -18,6 +18,7 @@ import {InputIcon} from 'primeng/inputicon';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Subscription} from 'rxjs'; import {Subscription} from 'rxjs';
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface MetadataItem { interface MetadataItem {
value: string; value: string;
@@ -30,8 +31,8 @@ type MetadataType = 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'pu
interface TabConfig { interface TabConfig {
type: MetadataType; type: MetadataType;
label: string; labelKey: string;
placeholder: string; placeholderKey: string;
selectAllKey: 'selectAllAuthors' | 'selectAllCategories' | 'selectAllMoods' | 'selectAllTags' | 'selectAllSeries' | 'selectAllPublishers' | 'selectAllLanguages'; selectAllKey: 'selectAllAuthors' | 'selectAllCategories' | 'selectAllMoods' | 'selectAllTags' | 'selectAllSeries' | 'selectAllPublishers' | 'selectAllLanguages';
icon: string; icon: string;
} }
@@ -56,7 +57,9 @@ interface TabConfig {
Tooltip, Tooltip,
IconField, IconField,
InputIcon, InputIcon,
ExternalDocLinkComponent ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
], ],
providers: [ConfirmationService], providers: [ConfirmationService],
templateUrl: './metadata-manager.component.html', templateUrl: './metadata-manager.component.html',
@@ -68,6 +71,7 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
private router = inject(Router); private router = inject(Router);
private route = inject(ActivatedRoute); private route = inject(ActivatedRoute);
private pageTitle = inject(PageTitleService); private pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
private routeSub!: Subscription; private routeSub!: Subscription;
@@ -119,13 +123,13 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
} }
tabConfigs: TabConfig[] = [ tabConfigs: TabConfig[] = [
{type: 'authors', label: 'Author', placeholder: 'Search authors...', selectAllKey: 'selectAllAuthors', icon: 'pi-user'}, {type: 'authors', labelKey: 'tabs.author', placeholderKey: 'placeholders.searchAuthors', selectAllKey: 'selectAllAuthors', icon: 'pi-user'},
{type: 'categories', label: 'Genre', placeholder: 'Search genres...', selectAllKey: 'selectAllCategories', icon: 'pi-tag'}, {type: 'categories', labelKey: 'tabs.genre', placeholderKey: 'placeholders.searchGenres', selectAllKey: 'selectAllCategories', icon: 'pi-tag'},
{type: 'moods', label: 'Mood', placeholder: 'Search moods...', selectAllKey: 'selectAllMoods', icon: 'pi-heart'}, {type: 'moods', labelKey: 'tabs.mood', placeholderKey: 'placeholders.searchMoods', selectAllKey: 'selectAllMoods', icon: 'pi-heart'},
{type: 'tags', label: 'Tag', placeholder: 'Search tags...', selectAllKey: 'selectAllTags', icon: 'pi-tags'}, {type: 'tags', labelKey: 'tabs.tag', placeholderKey: 'placeholders.searchTags', selectAllKey: 'selectAllTags', icon: 'pi-tags'},
{type: 'series', label: 'Series', placeholder: 'Search series...', selectAllKey: 'selectAllSeries', icon: 'pi-book'}, {type: 'series', labelKey: 'tabs.series', placeholderKey: 'placeholders.searchSeries', selectAllKey: 'selectAllSeries', icon: 'pi-book'},
{type: 'publishers', label: 'Publisher', placeholder: 'Search publishers...', selectAllKey: 'selectAllPublishers', icon: 'pi-building'}, {type: 'publishers', labelKey: 'tabs.publisher', placeholderKey: 'placeholders.searchPublishers', selectAllKey: 'selectAllPublishers', icon: 'pi-building'},
{type: 'languages', label: 'Language', placeholder: 'Search languages...', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'} {type: 'languages', labelKey: 'tabs.language', placeholderKey: 'placeholders.searchLanguages', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'}
]; ];
ngOnInit() { ngOnInit() {
@@ -149,7 +153,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
updatePageTitle() { updatePageTitle() {
const currentTab = this.tabConfigs.find((tab) => tab.type === this._activeTab); 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 { ngOnDestroy(): void {
@@ -232,8 +237,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (selected.length < 2) { if (selected.length < 2) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Selection', summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: 'Please select at least 2 items to merge.' detail: this.t.translate('metadata.manager.toast.mergeMinDetail')
}); });
return; return;
} }
@@ -260,8 +265,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (selected.length === 0) { if (selected.length === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Selection', summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: 'Please select at least 1 item to delete.' detail: this.t.translate('metadata.manager.toast.deleteMinDetail')
}); });
return; return;
} }
@@ -275,8 +280,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (!this.currentRenameItem || !this.renameTarget.trim()) { if (!this.currentRenameItem || !this.renameTarget.trim()) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: 'Please enter a valid name.' detail: this.t.translate('metadata.manager.toast.enterValidName')
}); });
return; return;
} }
@@ -286,8 +291,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (targetValues.length === 0) { if (targetValues.length === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: 'Please enter at least one valid target value.' detail: this.t.translate('metadata.manager.toast.enterValidTarget')
}); });
return; return;
} }
@@ -295,8 +300,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) { if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one value.` detail: this.t.translate('metadata.manager.toast.singleValueOnly', {singular: this.currentMergeType.slice(0, -1)})
}); });
return; return;
} }
@@ -325,8 +330,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Successful`, summary: action === 'renamed'
detail: `Successfully ${action} "${oldValue}" ${action === 'renamed' ? 'to' : 'into'} ${resultText}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`, ? 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 life: 5000
}); });
this.showRenameDialog = false; this.showRenameDialog = false;
@@ -339,8 +348,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => { error: (error) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: `${action === 'renamed' ? 'Rename' : 'Split'} Failed`, summary: action === 'renamed'
detail: error?.error?.message || `An error occurred during ${action === 'renamed' ? 'rename' : 'split'}.` ? 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.loading = false;
this.mergingInProgress = false; this.mergingInProgress = false;
@@ -353,8 +366,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (!this.mergeTarget.trim()) { if (!this.mergeTarget.trim()) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: 'Please enter a target value for merging.' detail: this.t.translate('metadata.manager.toast.enterMergeTarget')
}); });
return; return;
} }
@@ -364,8 +377,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (targetValues.length === 0) { if (targetValues.length === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: 'Please enter at least one valid target value.' detail: this.t.translate('metadata.manager.toast.enterValidTarget')
}); });
return; return;
} }
@@ -373,8 +386,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) { if (this.isSingleValueField(this.currentMergeType) && targetValues.length > 1) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Target', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'),
detail: `Each book can only have one ${this.currentMergeType.slice(0, -1)}. Please enter only one target value to standardize to.` detail: this.t.translate('metadata.manager.toast.singleMergeValueOnly', {singular: this.currentMergeType.slice(0, -1)})
}); });
return; return;
} }
@@ -387,7 +400,6 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
const valuesToMerge = selected.map(s => s.value); const valuesToMerge = selected.map(s => s.value);
const affectedBooks = this.getTotalAffectedBooks(selected); const affectedBooks = this.getTotalAffectedBooks(selected);
const operation = targetValues.length === 1 ? 'merge' : 'merge/split'; const operation = targetValues.length === 1 ? 'merge' : 'merge/split';
const operationPast = targetValues.length === 1 ? 'merged' : 'merged/split';
this.loading = true; this.loading = true;
this.mergingInProgress = true; this.mergingInProgress = true;
@@ -395,8 +407,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Successful`, summary: operation === 'merge'
detail: `Successfully ${operationPast} ${selected.length} ${this.currentMergeType} into ${targetValues.length} value(s). ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`, ? 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 life: 5000
}); });
this.showMergeDialog = false; this.showMergeDialog = false;
@@ -409,8 +425,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => { error: (error) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: `${operation === 'merge' ? 'Merge' : 'Merge/Split'} Failed`, summary: operation === 'merge'
detail: error?.error?.message || `An error occurred during ${operation}.` ? 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.loading = false;
this.mergingInProgress = false; this.mergingInProgress = false;
@@ -426,8 +446,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
if (itemsToDelete.length === 0) { if (itemsToDelete.length === 0) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Invalid Selection', summary: this.t.translate('metadata.manager.toast.invalidSelectionSummary'),
detail: 'Please select at least one item to delete.' detail: this.t.translate('metadata.manager.toast.deleteSelectMinDetail')
}); });
return; return;
} }
@@ -447,8 +467,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Delete Successful', summary: this.t.translate('metadata.manager.toast.deleteSuccessfulSummary'),
detail: `Successfully deleted ${itemCount} ${this.currentMergeType.slice(0, -1)}${itemCount > 1 ? 's' : ''}. ${affectedBooks} book${affectedBooks > 1 ? 's' : ''} updated.`, detail: this.t.translate('metadata.manager.toast.deleteSuccessfulDetail', {count: itemCount, type: this.currentMergeType.slice(0, -1) + (itemCount > 1 ? 's' : ''), bookCount: affectedBooks}),
life: 5000 life: 5000
}); });
this.showDeleteDialog = false; this.showDeleteDialog = false;
@@ -461,8 +481,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
error: (error) => { error: (error) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Delete Failed', summary: this.t.translate('metadata.manager.toast.deleteFailedSummary'),
detail: error?.error?.message || 'An error occurred during deletion.' detail: error?.error?.message || this.t.translate('metadata.manager.toast.deleteFailedDetail')
}); });
this.loading = false; this.loading = false;
this.deletingInProgress = false; this.deletingInProgress = false;
@@ -1,62 +1,63 @@
<ng-container *transloco="let t; prefix: 'metadata.advancedFetchOptions'">
<div class="options-container"> <div class="options-container">
<table class="custom-table"> <table class="custom-table">
<thead> <thead>
<tr> <tr>
<th class="table-header" style="max-width: 70px; width: 70px;">Enabled</th> <th class="table-header" style="max-width: 70px; width: 70px;">{{ t('enabledHeader') }}</th>
<th class="table-header" style="max-width: 127px; width: 127px;">Field</th> <th class="table-header" style="max-width: 127px; width: 127px;">{{ t('fieldHeader') }}</th>
<th class="table-header"> <th class="table-header">
1st Priority {{ t('firstPriority') }}
<i class="pi pi-question-circle help-icon" <i class="pi pi-question-circle help-icon"
pTooltip="First choice - always tried first for this field" [pTooltip]="t('firstPriorityTooltip')"
tooltipPosition="top"></i> tooltipPosition="top"></i>
</th> </th>
<th class="table-header"> <th class="table-header">
2nd Priority {{ t('secondPriority') }}
<i class="pi pi-question-circle help-icon" <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> tooltipPosition="top"></i>
</th> </th>
<th class="table-header"> <th class="table-header">
3rd Priority {{ t('thirdPriority') }}
<i class="pi pi-question-circle help-icon" <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> tooltipPosition="top"></i>
</th> </th>
<th class="table-header"> <th class="table-header">
4th Priority {{ t('fourthPriority') }}
<i class="pi pi-question-circle help-icon" <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> tooltipPosition="top"></i>
</th> </th>
</tr> </tr>
<tr> <tr>
<td class="table-cell" style="max-width: 70px; width: 70px;"></td> <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"> <td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP1" <p-select [options]="providersWithClear" [(ngModel)]="bulkP1"
(ngModelChange)="setBulkProvider('p1', $event)" (ngModelChange)="setBulkProvider('p1', $event)"
placeholder="Set all P1" appendTo="body" [placeholder]="t('setAllP1')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell"> <td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP2" <p-select [options]="providersWithClear" [(ngModel)]="bulkP2"
(ngModelChange)="setBulkProvider('p2', $event)" (ngModelChange)="setBulkProvider('p2', $event)"
placeholder="Set all P2" appendTo="body" [placeholder]="t('setAllP2')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell"> <td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP3" <p-select [options]="providersWithClear" [(ngModel)]="bulkP3"
(ngModelChange)="setBulkProvider('p3', $event)" (ngModelChange)="setBulkProvider('p3', $event)"
placeholder="Set all P3" appendTo="body" [placeholder]="t('setAllP3')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell"> <td class="table-cell">
<p-select [options]="providersWithClear" [(ngModel)]="bulkP4" <p-select [options]="providersWithClear" [(ngModel)]="bulkP4"
(ngModelChange)="setBulkProvider('p4', $event)" (ngModelChange)="setBulkProvider('p4', $event)"
placeholder="Set all P4" appendTo="body" [placeholder]="t('setAllP4')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
@@ -67,35 +68,35 @@
<tr [hidden]="field === 'cover' && !refreshCovers" [class.row-disabled]="!enabledFields[field]"> <tr [hidden]="field === 'cover' && !refreshCovers" [class.row-disabled]="!enabledFields[field]">
<td class="table-cell-sm" style="max-width: 70px; width: 70px;"> <td class="table-cell-sm" style="max-width: 70px; width: 70px;">
<p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true" <p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true"
pTooltip="Enable this field during metadata fetch" [pTooltip]="t('enableFieldTooltip')"
tooltipPosition="top"></p-checkbox> tooltipPosition="top"></p-checkbox>
</td> </td>
<td class="table-cell-sm field-label" style="max-width: 127px; width: 127px;">{{ formatLabel(field) }}</td> <td class="table-cell-sm field-label" style="max-width: 127px; width: 127px;">{{ formatLabel(field) }}</td>
<td class="table-cell-sm"> <td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
[disabled]="!enabledFields[field]" [disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body" [placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell-sm"> <td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
[disabled]="!enabledFields[field]" [disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body" [placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell-sm"> <td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
[disabled]="!enabledFields[field]" [disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body" [placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
<td class="table-cell-sm"> <td class="table-cell-sm">
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4" <p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
[disabled]="!enabledFields[field]" [disabled]="!enabledFields[field]"
placeholder="Unset" appendTo="body" [placeholder]="t('unset')" appendTo="body"
class="select-full-width" size="small"> class="select-full-width" size="small">
</p-select> </p-select>
</td> </td>
@@ -105,13 +106,13 @@
</table> </table>
<div class="provider-specific-section"> <div class="provider-specific-section">
<h3 class="section-title">Provider-Specific Fields</h3> <h3 class="section-title">{{ t('providerSpecificFields') }}</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> <p class="section-description">{{ t('providerSpecificDescription') }}</p>
<div class="fields-grid"> <div class="fields-grid">
@for (field of providerSpecificFields; track field) { @for (field of providerSpecificFields; track field) {
<div class="field-card"> <div class="field-card">
<p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true" <p-checkbox [(ngModel)]="enabledFields[field]" [binary]="true"
pTooltip="Enable this field during metadata fetch" [pTooltip]="t('enableFieldTooltip')"
tooltipPosition="top"></p-checkbox> tooltipPosition="top"></p-checkbox>
<span class="field-card-label">{{ formatLabel(field) }}</span> <span class="field-card-label">{{ formatLabel(field) }}</span>
</div> </div>
@@ -123,29 +124,30 @@
<div class="options-group"> <div class="options-group">
<div class="option-item"> <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" <p-select [options]="replaceModeOptions" [(ngModel)]="replaceMode" optionLabel="label" optionValue="value"
appendTo="body" size="small" class="select-mode"> appendTo="body" size="small" class="select-mode">
</p-select> </p-select>
</div> </div>
<div class="option-item"> <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> <p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
</div> </div>
<div class="option-item"> <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> <p-checkbox [(ngModel)]="mergeCategories" [binary]="true"></p-checkbox>
</div> </div>
<div class="option-item"> <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> <p-checkbox [(ngModel)]="reviewBeforeApply" [binary]="true"></p-checkbox>
</div> </div>
</div> </div>
<div class="action-buttons"> <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> <p-button [label]="submitButtonLabel" severity="success" icon="pi pi-save" outlined="true" (onClick)="submit()"></p-button>
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -11,11 +11,12 @@ import {
MetadataReplaceMode MetadataReplaceMode
} from '../../../model/request/metadata-refresh-options.model'; } from '../../../model/request/metadata-refresh-options.model';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-advanced-fetch-options', selector: 'app-metadata-advanced-fetch-options',
templateUrl: './metadata-advanced-fetch-options.component.html', 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', styleUrl: './metadata-advanced-fetch-options.component.scss',
standalone: true standalone: true
}) })
@@ -64,11 +65,13 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
reviewBeforeApply: boolean = false; reviewBeforeApply: boolean = false;
replaceMode: MetadataReplaceMode = 'REPLACE_MISSING'; replaceMode: MetadataReplaceMode = 'REPLACE_MISSING';
replaceModeOptions: { label: string; value: MetadataReplaceMode }[] = [ get replaceModeOptions(): { label: string; value: MetadataReplaceMode }[] {
{ label: 'Replace Missing Only', value: 'REPLACE_MISSING' }, return [
{ label: 'Replace All Fields', value: 'REPLACE_ALL' }, { label: this.t.translate('metadata.advancedFetchOptions.replaceMissingOnly'), value: 'REPLACE_MISSING' },
{ label: 'Replace When Provided', value: 'REPLACE_WHEN_PROVIDED' } { 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(); fieldOptions: FieldOptions = this.initializeFieldOptions();
enabledFields: Record<keyof FieldOptions, boolean> = this.initializeEnabledFields(); enabledFields: Record<keyof FieldOptions, boolean> = this.initializeEnabledFields();
@@ -79,6 +82,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
bulkP4: string | null = null; bulkP4: string | null = null;
private messageService = inject(MessageService); private messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private justSubmitted = false; private justSubmitted = false;
@@ -191,8 +195,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
} else { } else {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('metadata.advancedFetchOptions.toast.providerRequiredSummary'),
detail: 'At least one provider (P1–P4) must be selected for each enabled book field.', detail: this.t.translate('metadata.advancedFetchOptions.toast.providerRequiredDetail'),
life: 5000 life: 5000
}); });
} }
@@ -1,9 +1,11 @@
<ng-container *transloco="let t; prefix: 'metadata.fetchOptions'">
<div class="metadata-fetch-options-container"> <div class="metadata-fetch-options-container">
<div class="dialog-content"> <div class="dialog-content">
<app-metadata-advanced-fetch-options <app-metadata-advanced-fetch-options
(metadataOptionsSubmitted)="onMetadataSubmit($event)" (metadataOptionsSubmitted)="onMetadataSubmit($event)"
[currentMetadataOptions]="currentMetadataOptions" [currentMetadataOptions]="currentMetadataOptions"
[submitButtonLabel]="'Start Refresh'"> [submitButtonLabel]="t('startRefresh')">
</app-metadata-advanced-fetch-options> </app-metadata-advanced-fetch-options>
</div> </div>
</div> </div>
</ng-container>
@@ -7,13 +7,15 @@ import {AppSettingsService} from '../../../../../shared/service/app-settings.ser
import {filter, take} from 'rxjs/operators'; import {filter, take} from 'rxjs/operators';
import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component'; import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
import {TaskHelperService} from '../../../../settings/task-management/task-helper.service'; import {TaskHelperService} from '../../../../settings/task-management/task-helper.service';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-fetch-options', selector: 'app-metadata-fetch-options',
standalone: true, standalone: true,
templateUrl: './metadata-fetch-options.component.html', templateUrl: './metadata-fetch-options.component.html',
imports: [ imports: [
MetadataAdvancedFetchOptionsComponent MetadataAdvancedFetchOptionsComponent,
TranslocoDirective
], ],
styleUrl: './metadata-fetch-options.component.scss' styleUrl: './metadata-fetch-options.component.scss'
}) })
@@ -1,36 +1,38 @@
<div class="settings-card"> <ng-container *transloco="let t; prefix: 'settingsMeta.fieldSelector'">
<div class="section-header"> <div class="settings-card">
<h3 class="section-title"> <div class="section-header">
<i class="pi pi-list"></i> <h3 class="section-title">
Enabled Fields in Metadata Editor & Picker <i class="pi pi-list"></i>
</h3> {{ t('sectionTitle') }}
<p class="section-description"> </h3>
Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface. <p class="section-description">
</p> {{ t('sectionDesc') }}
</div> </p>
</div>
<div class="section-body"> <div class="section-body">
<div class="provider-groups-container"> <div class="provider-groups-container">
@for (group of providerGroups; track group.label) { @for (group of providerGroups; track group.label) {
<div class="provider-group"> <div class="provider-group">
<div class="group-header"> <div class="group-header">
<span class="group-icon pi pi-database"></span> <span class="group-icon pi pi-database"></span>
<h4 class="group-label">{{ group.label }}</h4> <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>
<div class="field-list"> }
@for (field of group.fields; track field) { </div>
<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>
</div> </ng-container>
@@ -4,11 +4,12 @@ import {FormsModule} from '@angular/forms';
import {AppSettingsService} from '../../../../shared/service/app-settings.service'; import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model'; import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model';
import {filter, take} from 'rxjs/operators'; import {filter, take} from 'rxjs/operators';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-provider-field-selector', selector: 'app-metadata-provider-field-selector',
standalone: true, standalone: true,
imports: [ToggleSwitchModule, FormsModule], imports: [ToggleSwitchModule, FormsModule, TranslocoDirective],
templateUrl: './metadata-provider-field-selector.component.html', templateUrl: './metadata-provider-field-selector.component.html',
styleUrl: './metadata-provider-field-selector.component.scss' styleUrl: './metadata-provider-field-selector.component.scss'
}) })
@@ -1,111 +1,113 @@
<div> <ng-container *transloco="let t; prefix: 'settingsReader.fonts'">
<div class="settings-content" style="position: relative;"> <div>
<div class="float-top-right"> <div class="settings-content" style="position: relative;">
<p-button <div class="float-top-right">
icon="pi pi-upload" <p-button
rounded icon="pi pi-upload"
size="large" rounded
(click)="openUploadDialog()" size="large"
[disabled]="customFonts.length >= maxFonts" (click)="openUploadDialog()"
></p-button> [disabled]="customFonts.length >= maxFonts"
</div> ></p-button>
@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>
</div> </div>
} @else { @if (customFonts.length === 0 && !isLoading) {
<div class="preferences-section"> <div class="preferences-section">
<div class="section-header"> <div class="empty-state">
<div> <div class="empty-icon-wrapper">
<h3 class="section-title"> <i class="pi pi-palette empty-icon"></i>
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>
</div> </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> } @else {
} <div class="preferences-section">
</div> <div class="section-header">
</div> <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 {CommonModule} from '@angular/common';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api'; 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 {FontUploadDialogComponent} from './font-upload-dialog/font-upload-dialog.component';
import {Skeleton} from 'primeng/skeleton'; import {Skeleton} from 'primeng/skeleton';
import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service'; import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-custom-fonts', selector: 'app-custom-fonts',
standalone: true, standalone: true,
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton], imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton, TranslocoDirective],
templateUrl: './custom-fonts.component.html', templateUrl: './custom-fonts.component.html',
styleUrls: ['./custom-fonts.component.scss'], styleUrls: ['./custom-fonts.component.scss'],
providers: [ConfirmationService, DialogService] providers: [ConfirmationService, DialogService]
@@ -28,6 +29,8 @@ export class CustomFontsComponent implements OnInit {
readonly maxFonts = 10; readonly maxFonts = 10;
private t = inject(TranslocoService);
constructor( constructor(
private customFontService: CustomFontService, private customFontService: CustomFontService,
private messageService: MessageService, private messageService: MessageService,
@@ -60,8 +63,8 @@ export class CustomFontsComponent implements OnInit {
console.error('Failed to load fonts:', error); console.error('Failed to load fonts:', error);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to load custom fonts' detail: this.t.translate('settingsReader.fonts.loadError')
}); });
this.isLoading = false; this.isLoading = false;
this.fontsLoadedInBrowser = true; this.fontsLoadedInBrowser = true;
@@ -72,8 +75,8 @@ export class CustomFontsComponent implements OnInit {
if (this.customFonts.length >= this.maxFonts) { if (this.customFonts.length >= this.maxFonts) {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Quota Exceeded', summary: this.t.translate('settingsReader.fonts.quotaExceeded'),
detail: `Maximum ${this.maxFonts} fonts allowed per user` detail: this.t.translate('settingsReader.fonts.quotaExceededDetail', {max: this.maxFonts})
}); });
return; return;
} }
@@ -98,8 +101,8 @@ export class CustomFontsComponent implements OnInit {
deleteFont(font: CustomFont): void { deleteFont(font: CustomFont): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: `Are you sure you want to delete the font "${font.fontName}"?`, message: this.t.translate('settingsReader.fonts.deleteFontConfirm', {name: font.fontName}),
header: 'Delete Font', header: this.t.translate('settingsReader.fonts.deleteFontHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
accept: () => { accept: () => {
this.customFontService.deleteFont(font.id).subscribe({ this.customFontService.deleteFont(font.id).subscribe({
@@ -108,15 +111,15 @@ export class CustomFontsComponent implements OnInit {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: 'Success',
detail: `Font "${font.fontName}" deleted successfully` detail: this.t.translate('settingsReader.fonts.deleteSuccess', {name: font.fontName})
}); });
}, },
error: (error) => { error: (error) => {
console.error('Failed to delete font:', error); console.error('Failed to delete font:', error);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Delete Failed', summary: this.t.translate('settingsReader.fonts.deleteFailed'),
detail: 'Failed to delete font' 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="font-upload-dialog">
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi pi-upload header-icon"></i> <i class="pi pi-upload header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Add New Font</h2> <h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description"> <p class="panel-description">
Upload a custom font for your EPUB reader {{ t('description') }}
</p> </p>
</div> </div>
<p-button <p-button
@@ -24,7 +25,7 @@
<div class="section-header"> <div class="section-header">
<span class="section-title"> <span class="section-title">
<i class="pi pi-file"></i> <i class="pi pi-file"></i>
Select Font File {{ t('selectFile') }}
</span> </span>
</div> </div>
@@ -47,12 +48,9 @@
<div class="empty-icon-wrapper"> <div class="empty-icon-wrapper">
<i class="pi pi-cloud-upload empty-icon"></i> <i class="pi pi-cloud-upload empty-icon"></i>
</div> </div>
<h3 class="empty-title">Drag and Drop Font File</h3> <h3 class="empty-title">{{ t('dragDrop') }}</h3>
<p class="empty-description"> <p class="empty-description" [innerHTML]="t('supportedFormats')"></p>
Supported formats: <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong> <p class="empty-description">{{ t('maxSize') }}</p>
<br/>
Maximum file size: 5 MB
</p>
</div> </div>
</div> </div>
} @else { } @else {
@@ -69,7 +67,7 @@
<div class="preview-section"> <div class="preview-section">
<label class="preview-label"> <label class="preview-label">
<i class="pi pi-eye"></i> <i class="pi pi-eye"></i>
Font Preview {{ t('fontPreview') }}
</label> </label>
<div class="font-preview" [style.font-family]="previewFontFamily"> <div class="font-preview" [style.font-family]="previewFontFamily">
<p class="preview-paragraph"> <p class="preview-paragraph">
@@ -91,9 +89,9 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <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"> <p class="setting-description">
This name will appear in the font selector when reading EPUB books. {{ t('displayNameDesc') }}
</p> </p>
</div> </div>
<div class="setting-control"> <div class="setting-control">
@@ -101,7 +99,7 @@
pInputText pInputText
id="fontName" id="fontName"
[(ngModel)]="uploadedFontName" [(ngModel)]="uploadedFontName"
placeholder="e.g., Bookerly, Open Sans, Merriweather" [placeholder]="t('displayNamePlaceholder')"
[disabled]="isUploading" [disabled]="isUploading"
class="font-name-input" class="font-name-input"
/> />
@@ -110,10 +108,11 @@
</div> </div>
} }
</div> </div>
</div>
<div class="dialog-footer"> <div class="dialog-footer">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
icon="pi pi-times" icon="pi pi-times"
severity="secondary" severity="secondary"
[outlined]="true" [outlined]="true"
@@ -121,7 +120,7 @@
[disabled]="isUploading" [disabled]="isUploading"
></p-button> ></p-button>
<p-button <p-button
label="Upload Font" [label]="t('uploadBtn')"
icon="pi pi-upload" icon="pi pi-upload"
(click)="uploadFont()" (click)="uploadFont()"
[disabled]="isUploading || !selectedFile || !uploadedFontName.trim()" [disabled]="isUploading || !selectedFile || !uploadedFontName.trim()"
@@ -129,3 +128,4 @@
></p-button> ></p-button>
</div> </div>
</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 {CommonModule} from '@angular/common';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
@@ -7,16 +7,18 @@ import {formatFileSize} from '../../../../shared/model/custom-font.model';
import {InputText} from 'primeng/inputtext'; import {InputText} from 'primeng/inputtext';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog'; import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-font-upload-dialog', selector: 'app-font-upload-dialog',
standalone: true, standalone: true,
imports: [CommonModule, Button, InputText, FormsModule], imports: [CommonModule, Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
templateUrl: './font-upload-dialog.component.html', templateUrl: './font-upload-dialog.component.html',
styleUrls: ['./font-upload-dialog.component.scss'] styleUrls: ['./font-upload-dialog.component.scss']
}) })
export class FontUploadDialogComponent implements OnDestroy { export class FontUploadDialogComponent implements OnDestroy {
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>; @ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
private readonly t = inject(TranslocoService);
isUploading = false; isUploading = false;
uploadedFontName = ''; uploadedFontName = '';
@@ -96,8 +98,8 @@ export class FontUploadDialogComponent implements OnDestroy {
this.previewFontFamily = null; this.previewFontFamily = null;
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Preview Failed', summary: this.t.translate('settingsReader.fonts.upload.previewFailed'),
detail: 'Unable to preview font, but you can still upload it' detail: this.t.translate('settingsReader.fonts.upload.previewFailedDetail')
}); });
} }
} finally { } finally {
@@ -111,8 +113,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!this.selectedFile) { if (!this.selectedFile) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'No File Selected', summary: this.t.translate('settingsReader.fonts.upload.noFileSelected'),
detail: 'Please select a font file to upload' detail: this.t.translate('settingsReader.fonts.upload.noFileSelectedDetail')
}); });
return; return;
} }
@@ -122,21 +124,20 @@ export class FontUploadDialogComponent implements OnDestroy {
next: (font) => { next: (font) => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('settingsReader.fonts.upload.success'),
detail: `Font "${font.fontName}" uploaded successfully` detail: this.t.translate('settingsReader.fonts.upload.successDetail', {name: font.fontName})
}); });
this.isUploading = false; this.isUploading = false;
this.dialogRef.close(font); // Return the uploaded font this.dialogRef.close(font); // Return the uploaded font
}, },
error: (error) => { error: (error) => {
console.error('Failed to upload font:', error); console.error('Failed to upload font:', error);
let errorMessage = 'Failed to upload font'; const errorMessage = error.status === 400
if (error.status === 400) { ? this.t.translate('settingsReader.fonts.upload.uploadFailedInvalid')
errorMessage = 'Invalid file format or quota exceeded'; : this.t.translate('settingsReader.fonts.upload.uploadFailedDefault');
}
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Upload Failed', summary: this.t.translate('settingsReader.fonts.upload.uploadFailed'),
detail: errorMessage detail: errorMessage
}); });
@@ -193,8 +194,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!isValidFormat) { if (!isValidFormat) {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Invalid File Type', summary: this.t.translate('settingsReader.fonts.upload.invalidFileType'),
detail: 'Please upload a TTF, OTF, WOFF, or WOFF2 font file' detail: this.t.translate('settingsReader.fonts.upload.invalidFileTypeDetail')
}); });
return false; return false;
} }
@@ -202,8 +203,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (file.size > this.maxFileSize) { if (file.size > this.maxFileSize) {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'File Too Large', summary: this.t.translate('settingsReader.fonts.upload.fileTooLarge'),
detail: `File size must not exceed ${this.formatFileSize(this.maxFileSize)}` detail: this.t.translate('settingsReader.fonts.upload.fileTooLargeDetail', {size: this.formatFileSize(this.maxFileSize)})
}); });
return false; return false;
} }
@@ -1,14 +1,15 @@
<ng-container *transloco="let t; prefix: 'settingsDevice'">
<p-toast position="top-right"></p-toast> <p-toast position="top-right"></p-toast>
<div class="main-container"> <div class="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
Hardcover Integration {{ t('hardcover.title') }}
<app-external-doc-link docType="hardcover"></app-external-doc-link> <app-external-doc-link docType="hardcover"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Sync your reading progress from Booklore to your Hardcover account. {{ t('hardcover.description') }}
</p> </p>
</div> </div>
@@ -18,10 +19,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-sync"></i> <i class="pi pi-sync"></i>
Sync Configuration {{ t('hardcover.syncConfig') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Enable and configure synchronization between Booklore and Hardcover. {{ t('hardcover.syncConfigDesc') }}
</p> </p>
</div> </div>
@@ -30,7 +31,7 @@
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label"> <label class="setting-label">
Sync KOReader Reading Progress to Hardcover</label> {{ t('hardcover.syncLabel') }}</label>
<p-toggle-switch <p-toggle-switch
id="hardcoverSyncEnabled" id="hardcoverSyncEnabled"
name="hardcoverSyncEnabled" name="hardcoverSyncEnabled"
@@ -39,7 +40,7 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description">
When enabled, your KOReader reading progress will be automatically synced to your Hardcover account. {{ t('hardcover.syncDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -48,7 +49,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="token-input-group">
<input <input
pInputText pInputText
@@ -57,7 +58,7 @@
[type]="showHardcoverApiKey ? 'text' : 'password'" [type]="showHardcoverApiKey ? 'text' : 'password'"
name="hardcoverApiKey" name="hardcoverApiKey"
class="token-input" class="token-input"
placeholder="Enter your Hardcover API key" [placeholder]="t('hardcover.apiKeyPlaceholder')"
(blur)="onHardcoverApiKeyChange()" (blur)="onHardcoverApiKeyChange()"
/> />
<p-button <p-button
@@ -77,10 +78,7 @@
</p-button> </p-button>
</div> </div>
</div> </div>
<p class="setting-description"> <p class="setting-description" [innerHTML]="t('hardcover.apiKeyDesc')">
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> </p>
</div> </div>
</div> </div>
@@ -93,14 +91,15 @@
<div class="access-denied-card"> <div class="access-denied-card">
<i class="pi pi-lock"></i> <i class="pi pi-lock"></i>
<div class="access-denied-content"> <div class="access-denied-content">
<h3>Access Restricted</h3> <h3>{{ t('accessRestricted') }}</h3>
<p> <p>
Access to Hardcover sync is restricted. {{ t('hardcover.accessDenied') }}
<br> <br>
Please contact your administrator to request permission. {{ t('contactAdmin') }}
</p> </p>
</div> </div>
</div> </div>
</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 {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {UserService} from '../../../user-management/user.service'; import {UserService} from '../../../user-management/user.service';
import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service'; import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
standalone: true, standalone: true,
@@ -20,7 +21,8 @@ import {HardcoverSyncSettingsService} from './hardcover-sync-settings.service';
ToggleSwitch, ToggleSwitch,
Button, Button,
ToastModule, ToastModule,
ExternalDocLinkComponent ExternalDocLinkComponent,
TranslocoDirective
], ],
providers: [MessageService], providers: [MessageService],
templateUrl: './hardcover-settings-component.html', templateUrl: './hardcover-settings-component.html',
@@ -30,6 +32,7 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
private readonly messageService = inject(MessageService); private readonly messageService = inject(MessageService);
private readonly hardcoverSyncSettingsService = inject(HardcoverSyncSettingsService); private readonly hardcoverSyncSettingsService = inject(HardcoverSyncSettingsService);
private readonly userService = inject(UserService); private readonly userService = inject(UserService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>(); private readonly destroy$ = new Subject<void>();
hasPermission = false; hasPermission = false;
@@ -63,8 +66,8 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Load Error', summary: this.t.translate('common.error'),
detail: 'Unable to retrieve Hardcover sync settings. Please try again.' detail: this.t.translate('settingsDevice.hardcover.loadError')
}); });
} }
}); });
@@ -76,13 +79,13 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
onHardcoverSyncToggle() { onHardcoverSyncToggle() {
const message = this.hardcoverSyncEnabled const message = this.hardcoverSyncEnabled
? 'Hardcover sync enabled' ? this.t.translate('settingsDevice.hardcover.syncEnabledMsg')
: 'Hardcover sync disabled'; : this.t.translate('settingsDevice.hardcover.syncDisabledMsg');
this.updateHardcoverSettings(message); this.updateHardcoverSettings(message);
} }
onHardcoverApiKeyChange() { onHardcoverApiKeyChange() {
this.updateHardcoverSettings('Hardcover API key updated'); this.updateHardcoverSettings(this.t.translate('settingsDevice.hardcover.apiKeyUpdated'));
} }
private updateHardcoverSettings(successMessage: string) { private updateHardcoverSettings(successMessage: string) {
@@ -93,13 +96,13 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
next: settings => { next: settings => {
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false; this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
this.hardcoverApiKey = settings.hardcoverApiKey ?? ''; 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: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Update Failed', summary: this.t.translate('settingsDevice.hardcover.updateFailed'),
detail: 'Unable to update Hardcover sync settings. Please try again.' detail: this.t.translate('settingsDevice.hardcover.updateError')
}); });
} }
}); });
@@ -112,15 +115,15 @@ export class HardcoverSettingsComponent implements OnInit, OnDestroy {
navigator.clipboard.writeText(text).then(() => { navigator.clipboard.writeText(text).then(() => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Copied', summary: this.t.translate('settingsDevice.copied'),
detail: `${label} copied to clipboard` detail: this.t.translate('settingsDevice.copiedDetail', {label})
}); });
}).catch(err => { }).catch(err => {
console.error('Copy failed', err); console.error('Copy failed', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Copy Failed', summary: this.t.translate('settingsDevice.copyFailed'),
detail: `Unable to copy ${label.toLowerCase()} to clipboard` 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-toast position="top-right"></p-toast>
<p-confirmDialog></p-confirmDialog> <p-confirmDialog></p-confirmDialog>
@@ -5,11 +6,11 @@
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-tablet"></i> <i class="pi pi-tablet"></i>
Kobo Integration Configuration {{ t('kobo.title') }}
<app-external-doc-link docType="kobo"></app-external-doc-link> <app-external-doc-link docType="kobo"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <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> </p>
</div> </div>
@@ -19,10 +20,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-sync"></i> <i class="pi pi-sync"></i>
Sync Configuration {{ t('kobo.syncConfig') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Enable and configure synchronization between your Booklore library and Kobo device. {{ t('kobo.syncConfigDesc') }}
</p> </p>
</div> </div>
@@ -30,7 +31,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Enable Kobo Sync</label> <label class="setting-label">{{ t('kobo.enableSync') }}</label>
<p-toggle-switch <p-toggle-switch
id="syncEnabled" id="syncEnabled"
name="syncEnabled" name="syncEnabled"
@@ -39,7 +40,7 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Turn on synchronization to automatically sync your library books to your Kobo device. {{ t('kobo.enableSyncDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -48,7 +49,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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 <p-toggle-switch
id="autoAddToShelf" id="autoAddToShelf"
name="autoAddToShelf" name="autoAddToShelf"
@@ -57,8 +58,7 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description">
When enabled, newly added books will be automatically added to your Kobo shelf for syncing. {{ t('kobo.autoAddDesc') }}
This eliminates the need to manually add each book to the shelf.
</p> </p>
</div> </div>
</div> </div>
@@ -68,7 +68,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="token-input-group">
<input <input
pInputText pInputText
@@ -98,7 +98,7 @@
</div> </div>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Your unique sync token for authenticating with your Kobo device. Keep this secure. {{ t('kobo.tokenDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -106,19 +106,19 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Token Management</label> <label class="setting-label">{{ t('kobo.tokenManagement') }}</label>
<p-button <p-button
icon="pi pi-refresh" icon="pi pi-refresh"
outlined="true" outlined="true"
severity="warn" severity="warn"
size="small" size="small"
label="Regenerate Token" [label]="t('kobo.regenerateToken')"
(onClick)="confirmRegenerateToken()" (onClick)="confirmRegenerateToken()"
[disabled]="!credentialsSaved"> [disabled]="!credentialsSaved">
</p-button> </p-button>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Regenerate your sync token if needed. This will invalidate the current token. {{ t('kobo.tokenManagementDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -126,7 +126,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
id="markAsReadingThreshold" id="markAsReadingThreshold"
@@ -140,9 +140,9 @@
</div> </div>
</div> </div>
<p class="setting-description"> <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> <br>
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two. <strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.markAsReadingRec') }}
</p> </p>
</div> </div>
</div> </div>
@@ -150,7 +150,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
id="markAsFinishedThreshold" id="markAsFinishedThreshold"
@@ -164,9 +164,9 @@
</div> </div>
</div> </div>
<p class="setting-description"> <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> <br>
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete. <strong>{{ t('kobo.recommended') }}</strong> {{ t('kobo.markAsFinishedRec') }}
</p> </p>
</div> </div>
</div> </div>
@@ -179,10 +179,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-cog"></i> <i class="pi pi-cog"></i>
Administrator Settings {{ t('kobo.adminSettings') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Configure advanced Kobo sync settings that affect all users on this server. {{ t('kobo.adminSettingsDesc') }}
</p> </p>
</div> </div>
@@ -190,7 +190,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Convert to KEPUB</label> <label class="setting-label">{{ t('kobo.convertKepub') }}</label>
<p-toggle-switch <p-toggle-switch
id="convertToKepub" id="convertToKepub"
[(ngModel)]="koboSettings.convertToKepub" [(ngModel)]="koboSettings.convertToKepub"
@@ -198,10 +198,9 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <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> <br>
<strong>Cons:</strong> Conversion takes extra processing time and may occasionally fail for complex layouts. <strong>{{ t('kobo.cons') }}</strong> {{ t('kobo.convertKepubCons') }}
Books over the size limit below will skip conversion automatically.
</p> </p>
</div> </div>
</div> </div>
@@ -209,7 +208,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
id="conversionLimit" id="conversionLimit"
@@ -222,9 +221,9 @@
</div> </div>
</div> </div>
<p class="setting-description"> <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> <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> </p>
</div> </div>
</div> </div>
@@ -232,16 +231,14 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Force Enable Hyphenation</label> <label class="setting-label">{{ t('kobo.forceHyphenation') }}</label>
<p-toggle-switch <p-toggle-switch
id="forceEnableHyphenation" id="forceEnableHyphenation"
[(ngModel)]="koboSettings.forceEnableHyphenation" [(ngModel)]="koboSettings.forceEnableHyphenation"
(ngModelChange)="onToggleChange()"> (ngModelChange)="onToggleChange()">
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description" [innerHTML]="t('kobo.forceHyphenationDesc')">
Force enable hyphenation. Otherwise, hyphenation is only enabled when text alignment on the Kobo
device is explicitly set to <i>justified</i>.
</p> </p>
</div> </div>
</div> </div>
@@ -251,7 +248,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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 <p-toggle-switch
id="convertCbxToEpub" id="convertCbxToEpub"
[(ngModel)]="koboSettings.convertCbxToEpub" [(ngModel)]="koboSettings.convertCbxToEpub"
@@ -259,14 +256,14 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <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> </p>
</div> </div>
</div> </div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
id="conversionLimit" id="conversionLimit"
@@ -279,14 +276,14 @@
</div> </div>
</div> </div>
<p class="setting-description"> <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> </p>
</div> </div>
</div> </div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
id="conversionLimitForCbx" id="conversionLimitForCbx"
@@ -299,9 +296,9 @@
</div> </div>
</div> </div>
<p class="setting-description"> <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> <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> </p>
</div> </div>
</div> </div>
@@ -314,14 +311,15 @@
<div class="access-denied-card"> <div class="access-denied-card">
<i class="pi pi-lock"></i> <i class="pi pi-lock"></i>
<div class="access-denied-content"> <div class="access-denied-content">
<h3>Access Restricted</h3> <h3>{{ t('accessRestricted') }}</h3>
<p> <p>
Access to Kobo sync is restricted. {{ t('kobo.accessDenied') }}
<br> <br>
Please contact your administrator to request permission. {{ t('contactAdmin') }}
</p> </p>
</div> </div>
</div> </div>
</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 {ShelfService} from '../../../../book/service/shelf.service';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {ToastModule} from 'primeng/toast'; import {ToastModule} from 'primeng/toast';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-kobo-sync-setting-component', selector: 'app-kobo-sync-setting-component',
standalone: true, standalone: true,
templateUrl: './kobo-sync-settings-component.html', templateUrl: './kobo-sync-settings-component.html',
styleUrl: './kobo-sync-settings-component.scss', 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] providers: [MessageService, ConfirmationService]
}) })
export class KoboSyncSettingsComponent implements OnInit, OnDestroy { export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
@@ -34,6 +35,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
protected appSettingsService = inject(AppSettingsService); protected appSettingsService = inject(AppSettingsService);
protected settingsHelperService = inject(SettingsHelperService); protected settingsHelperService = inject(SettingsHelperService);
private shelfService = inject(ShelfService); private shelfService = inject(ShelfService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>(); private readonly destroy$ = new Subject<void>();
private readonly sliderChange$ = new Subject<void>(); private readonly sliderChange$ = new Subject<void>();
@@ -78,7 +80,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
debounceTime(500), debounceTime(500),
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe(() => { ).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; this.credentialsSaved = !!settings.token;
}, },
error: () => { 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(() => { navigator.clipboard.writeText(text).then(() => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Copied', summary: this.t.translate('settingsDevice.copied'),
detail: `${label} copied to clipboard` detail: this.t.translate('settingsDevice.copiedDetail', {label})
}); });
}).catch(err => { }).catch(err => {
console.error('Copy failed', err); console.error('Copy failed', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Copy Failed', summary: this.t.translate('settingsDevice.copyFailed'),
detail: `Unable to copy ${label.toLowerCase()} to clipboard` detail: this.t.translate('settingsDevice.copyFailedDetail', {label})
}); });
}); });
} }
@@ -170,8 +172,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
confirmRegenerateToken() { confirmRegenerateToken() {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'This will generate a new token and invalidate the previous one. Continue?', message: this.t.translate('settingsDevice.kobo.confirmRegenerate'),
header: 'Confirm Regeneration', header: this.t.translate('settingsDevice.kobo.confirmRegenerateHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
accept: () => this.regenerateToken() accept: () => this.regenerateToken()
}); });
@@ -182,10 +184,10 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: (settings) => { next: (settings) => {
this.koboSyncSettings.token = settings.token; this.koboSyncSettings.token = settings.token;
this.credentialsSaved = true; 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: () => { 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() { onSyncToggle() {
if (!this.koboSyncSettings.syncEnabled) { if (!this.koboSyncSettings.syncEnabled) {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: 'Disabling Kobo sync will delete your Kobo shelf. Are you sure you want to proceed?', message: this.t.translate('settingsDevice.kobo.confirmDisable'),
header: 'Confirm Disable', header: this.t.translate('settingsDevice.kobo.confirmDisableHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
accept: () => this.updateKoboSettings('Kobo sync disabled'), accept: () => this.updateKoboSettings(this.t.translate('settingsDevice.kobo.syncDisabled')),
reject: () => { reject: () => {
this.koboSyncSettings.syncEnabled = true; this.koboSyncSettings.syncEnabled = true;
} }
}); });
} else { } 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() { onAutoAddToggle() {
const message = this.koboSyncSettings.autoAddToShelf const message = this.koboSyncSettings.autoAddToShelf
? 'New books will be automatically added to Kobo shelf' ? this.t.translate('settingsDevice.kobo.autoAddEnabled')
: 'Auto-add to Kobo shelf disabled'; : this.t.translate('settingsDevice.kobo.autoAddDisabled');
this.updateKoboSettings(message); this.updateKoboSettings(message);
} }
@@ -230,7 +232,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Settings Updated', summary: this.t.translate('settingsDevice.kobo.settingsUpdated'),
detail: successMessage detail: successMessage
}); });
if (!this.koboSyncSettings.syncEnabled) { if (!this.koboSyncSettings.syncEnabled) {
@@ -240,8 +242,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to update Kobo settings' detail: this.t.translate('settingsDevice.kobo.settingsUpdateError')
}); });
} }
}); });
@@ -253,15 +255,15 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Settings Saved', summary: this.t.translate('settingsDevice.kobo.settingsSaved'),
detail: 'Kobo settings updated successfully' detail: this.t.translate('settingsDevice.kobo.settingsSuccess')
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Save Failed', summary: this.t.translate('settingsDevice.kobo.saveFailed'),
detail: 'Failed to save Kobo settings' 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> <p-toast position="top-right"></p-toast>
<div class="main-container"> <div class="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-mobile"></i> <i class="pi pi-mobile"></i>
KOReader Sync Configuration {{ t('koreader.title') }}
<app-external-doc-link docType="koReader"></app-external-doc-link> <app-external-doc-link docType="koReader"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Configure KOReader integration to sync your reading progress between your device and Booklore library. {{ t('koreader.description') }}
</p> </p>
</div> </div>
@@ -18,10 +19,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-sync"></i> <i class="pi pi-sync"></i>
Sync Configuration {{ t('koreader.syncConfig') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Enable and configure synchronization between your Booklore library and KOReader device. {{ t('koreader.syncConfigDesc') }}
</p> </p>
</div> </div>
@@ -30,7 +31,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Enable KOReader Sync</label> <label class="setting-label">{{ t('koreader.enableSync') }}</label>
<p-toggle-switch <p-toggle-switch
name="syncEnabled" name="syncEnabled"
[(ngModel)]="koReaderSyncEnabled" [(ngModel)]="koReaderSyncEnabled"
@@ -40,7 +41,7 @@
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Turn on synchronization to automatically sync your reading progress. {{ t('koreader.enableSyncDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -48,7 +49,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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 <p-toggle-switch
name="syncWithBookloreReader" name="syncWithBookloreReader"
[(ngModel)]="syncWithBookloreReader" [(ngModel)]="syncWithBookloreReader"
@@ -57,8 +58,7 @@
[disabled]="!credentialsSaved || !koReaderSyncEnabled"> [disabled]="!credentialsSaved || !koReaderSyncEnabled">
</p-toggle-switch> </p-toggle-switch>
</div> </div>
<p class="setting-description"> <p class="setting-description" [innerHTML]="t('koreader.syncWithBookloreDesc')">
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> </p>
</div> </div>
</div> </div>
@@ -66,7 +66,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="token-input-group">
<input <input
pInputText pInputText
@@ -85,7 +85,7 @@
</div> </div>
</div> </div>
<p class="setting-description"> <p class="setting-description">
The API endpoint path for your KOReader sync service. {{ t('koreader.apiPathDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -93,7 +93,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="token-input-group">
<input <input
pInputText pInputText
@@ -116,11 +116,11 @@
</div> </div>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Your username for authenticating with the KOReader sync service. {{ t('koreader.usernameDesc') }}
</p> </p>
@if (editMode && usernameModel.invalid && usernameModel.touched) { @if (editMode && usernameModel.invalid && usernameModel.touched) {
<small class="error-message"> <small class="error-message">
Username is required. {{ t('koreader.usernameRequired') }}
</small> </small>
} }
</div> </div>
@@ -129,7 +129,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="token-input-group">
<input <input
pInputText pInputText
@@ -162,11 +162,11 @@
</div> </div>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Your password for authenticating with the KOReader sync service. {{ t('koreader.passwordDesc') }}
</p> </p>
@if (editMode && passwordModel.invalid && passwordModel.touched) { @if (editMode && passwordModel.invalid && passwordModel.touched) {
<small class="error-message"> <small class="error-message">
Password must be at least 6 characters. {{ t('koreader.passwordMinLength') }}
</small> </small>
} }
</div> </div>
@@ -175,19 +175,19 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Settings Management</label> <label class="setting-label">{{ t('koreader.settingsManagement') }}</label>
<p-button <p-button
[icon]="!editMode ? 'pi pi-save' : 'pi pi-pencil'" [icon]="!editMode ? 'pi pi-save' : 'pi pi-pencil'"
outlined="true" outlined="true"
[severity]="!editMode ? 'success' : 'warn'" [severity]="!editMode ? 'success' : 'warn'"
[label]="!editMode ? 'Save' : 'Edit'" [label]="!editMode ? ('common.save' | transloco) : ('common.edit' | transloco)"
size="small" size="small"
(onClick)="onEditSave()" (onClick)="onEditSave()"
[disabled]="!editMode && !canSave"> [disabled]="!editMode && !canSave">
</p-button> </p-button>
</div> </div>
<p class="setting-description"> <p class="setting-description">
Save your credentials or edit existing settings. {{ t('koreader.settingsManagementDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -201,14 +201,15 @@
<div class="access-denied-card"> <div class="access-denied-card">
<i class="pi pi-lock"></i> <i class="pi pi-lock"></i>
<div class="access-denied-content"> <div class="access-denied-content">
<h3>Access Restricted</h3> <h3>{{ t('accessRestricted') }}</h3>
<p> <p>
Access to KOReader sync is restricted. {{ t('koreader.accessDenied') }}
<br> <br>
Please contact your administrator to request permission. {{ t('contactAdmin') }}
</p> </p>
</div> </div>
</div> </div>
</div> </div>
} }
</div> </div>
</ng-container>
@@ -11,6 +11,7 @@ import {UserService} from '../../../user-management/user.service';
import {filter, takeUntil} from 'rxjs/operators'; import {filter, takeUntil} from 'rxjs/operators';
import {Subject} from 'rxjs'; import {Subject} from 'rxjs';
import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
standalone: true, standalone: true,
@@ -21,8 +22,10 @@ import {ExternalDocLinkComponent} from '../../../../../shared/components/externa
ToggleSwitch, ToggleSwitch,
Button, Button,
ToastModule, ToastModule,
ExternalDocLinkComponent ExternalDocLinkComponent,
], TranslocoDirective,
TranslocoPipe
],
providers: [MessageService], providers: [MessageService],
templateUrl: './koreader-settings-component.html', templateUrl: './koreader-settings-component.html',
styleUrls: ['./koreader-settings-component.scss'] styleUrls: ['./koreader-settings-component.scss']
@@ -40,6 +43,7 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
private readonly messageService = inject(MessageService); private readonly messageService = inject(MessageService);
private readonly koreaderService = inject(KoreaderService); private readonly koreaderService = inject(KoreaderService);
private readonly userService = inject(UserService); private readonly userService = inject(UserService);
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>(); private readonly destroy$ = new Subject<void>();
hasPermission = false; hasPermission = false;
@@ -72,8 +76,8 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
if (err.status !== 404) { if (err.status !== 404) {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Load Error', summary: this.t.translate('common.error'),
detail: 'Unable to retrieve KOReader account. Please try again.' detail: this.t.translate('settingsDevice.koreader.loadError')
}); });
} }
} }
@@ -98,10 +102,10 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
this.koreaderService.toggleSync(enabled).subscribe({ this.koreaderService.toggleSync(enabled).subscribe({
next: () => { next: () => {
this.koReaderSyncEnabled = enabled; 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: () => { 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.syncWithBookloreReader = enabled;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Sync Updated', summary: this.t.translate('settingsDevice.koreader.syncUpdated'),
detail: `Booklore eBook Reader sync has been ${enabled ? 'enabled' : 'disabled'}.` detail: enabled ? this.t.translate('settingsDevice.koreader.bookloreReaderEnabled') : this.t.translate('settingsDevice.koreader.bookloreReaderDisabled')
}); });
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Update Failed', summary: this.t.translate('settingsDevice.koreader.syncUpdateFailed'),
detail: 'Unable to update Booklore eBook Reader sync setting. Please try again.' detail: this.t.translate('settingsDevice.koreader.bookloreReaderError')
}); });
} }
}); });
@@ -136,10 +140,10 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
.subscribe({ .subscribe({
next: () => { next: () => {
this.credentialsSaved = true; 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: () => 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(() => { navigator.clipboard.writeText(text).then(() => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Copied', summary: this.t.translate('settingsDevice.copied'),
detail: `${label} copied to clipboard` detail: this.t.translate('settingsDevice.copiedDetail', {label})
}); });
}).catch(err => { }).catch(err => {
console.error('Copy failed', err); console.error('Copy failed', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Copy Failed', summary: this.t.translate('settingsDevice.copyFailed'),
detail: `Unable to copy ${label.toLowerCase()} to clipboard` 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="email-provider-creator">
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi pi-envelope header-icon"></i> <i class="pi pi-envelope header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Create Email Provider</h2> <h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">Configure a new email provider for sending notifications</p> <p class="panel-description">{{ t('description') }}</p>
</div> </div>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -14,8 +15,7 @@
[text]="true" [text]="true"
[rounded]="true" [rounded]="true"
class="close-button" class="close-button"
pTooltip="Close" />
tooltipPosition="left"/>
</div> </div>
<form [formGroup]="emailProviderForm" (ngSubmit)="createEmailProvider()"> <form [formGroup]="emailProviderForm" (ngSubmit)="createEmailProvider()">
@@ -23,7 +23,7 @@
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="providerName" class="form-label"> <label for="providerName" class="form-label">
<i class="pi pi-tag label-icon"></i> <i class="pi pi-tag label-icon"></i>
Provider Name {{ t('providerName') }}
<span class="required-indicator">*</span> <span class="required-indicator">*</span>
</label> </label>
<div class="input-wrapper"> <div class="input-wrapper">
@@ -33,16 +33,16 @@
pInputText pInputText
formControlName="name" formControlName="name"
class="input-full" class="input-full"
placeholder="e.g., Gmail SMTP, SendGrid" [placeholder]="t('providerNamePlaceholder')"
[class.filled]="emailProviderForm.get('name')?.value" [class.filled]="emailProviderForm.get('name')?.value"
/> />
@if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) { @if (emailProviderForm.get('name')?.value && emailProviderForm.get('name')?.valid) {
<i class="pi pi-check-circle input-icon success"></i> <i class="pi pi-check-circle input-icon success"></i>
} }
</div> </div>
@if (emailProviderForm.get('name')?.invalid && (emailProviderForm.get('name')?.dirty || emailProviderForm.get('name')?.touched)) { @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> </div>
@@ -51,7 +51,7 @@
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="host" class="form-label"> <label for="host" class="form-label">
<i class="pi pi-server label-icon"></i> <i class="pi pi-server label-icon"></i>
Host {{ t('host') }}
<span class="required-indicator">*</span> <span class="required-indicator">*</span>
</label> </label>
<div class="input-wrapper"> <div class="input-wrapper">
@@ -61,7 +61,7 @@
pInputText pInputText
formControlName="host" formControlName="host"
class="input-full" class="input-full"
placeholder="e.g., smtp.gmail.com" [placeholder]="t('hostPlaceholder')"
[class.filled]="emailProviderForm.get('host')?.value" [class.filled]="emailProviderForm.get('host')?.value"
/> />
@if (emailProviderForm.get('host')?.value && emailProviderForm.get('host')?.valid) { @if (emailProviderForm.get('host')?.value && emailProviderForm.get('host')?.valid) {
@@ -69,14 +69,14 @@
} }
</div> </div>
@if (emailProviderForm.get('host')?.invalid && (emailProviderForm.get('host')?.dirty || emailProviderForm.get('host')?.touched)) { @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>
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="port" class="form-label"> <label for="port" class="form-label">
<i class="pi pi-hashtag label-icon"></i> <i class="pi pi-hashtag label-icon"></i>
Port {{ t('port') }}
<span class="required-indicator">*</span> <span class="required-indicator">*</span>
</label> </label>
<div class="input-wrapper"> <div class="input-wrapper">
@@ -86,7 +86,7 @@
pInputText pInputText
formControlName="port" formControlName="port"
class="input-full" class="input-full"
placeholder="e.g., 587, 465" [placeholder]="t('portPlaceholder')"
[class.filled]="emailProviderForm.get('port')?.value" [class.filled]="emailProviderForm.get('port')?.value"
/> />
@if (emailProviderForm.get('port')?.value && emailProviderForm.get('port')?.valid) { @if (emailProviderForm.get('port')?.value && emailProviderForm.get('port')?.valid) {
@@ -94,7 +94,7 @@
} }
</div> </div>
@if (emailProviderForm.get('port')?.invalid && (emailProviderForm.get('port')?.dirty || emailProviderForm.get('port')?.touched)) { @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> </div>
@@ -103,7 +103,7 @@
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="username" class="form-label"> <label for="username" class="form-label">
<i class="pi pi-user label-icon"></i> <i class="pi pi-user label-icon"></i>
Username {{ t('username') }}
</label> </label>
<input <input
id="username" id="username"
@@ -111,14 +111,14 @@
pInputText pInputText
formControlName="username" formControlName="username"
class="input-full" class="input-full"
placeholder="Enter username" [placeholder]="t('usernamePlaceholder')"
/> />
</div> </div>
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="password" class="form-label"> <label for="password" class="form-label">
<i class="pi pi-lock label-icon"></i> <i class="pi pi-lock label-icon"></i>
Password {{ t('password') }}
</label> </label>
<input <input
id="password" id="password"
@@ -126,14 +126,14 @@
pInputText pInputText
formControlName="password" formControlName="password"
class="input-full" class="input-full"
placeholder="Enter password" [placeholder]="t('passwordPlaceholder')"
/> />
</div> </div>
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="fromAddress" class="form-label"> <label for="fromAddress" class="form-label">
<i class="pi pi-at label-icon"></i> <i class="pi pi-at label-icon"></i>
From Address {{ t('fromAddress') }}
</label> </label>
<input <input
id="fromAddress" id="fromAddress"
@@ -141,7 +141,7 @@
pInputText pInputText
formControlName="fromAddress" formControlName="fromAddress"
class="input-full" class="input-full"
placeholder="e.g., noreply@example.com" [placeholder]="t('fromAddressPlaceholder')"
/> />
</div> </div>
@@ -151,8 +151,8 @@
<div class="checkbox-row"> <div class="checkbox-row">
<p-checkbox formControlName="auth" [binary]="true" inputId="auth"></p-checkbox> <p-checkbox formControlName="auth" [binary]="true" inputId="auth"></p-checkbox>
<label for="auth" class="checkbox-label"> <label for="auth" class="checkbox-label">
<span class="checkbox-title">Enable Authentication</span> <span class="checkbox-title">{{ t('enableAuth') }}</span>
<span class="checkbox-description">Require username and password for SMTP</span> <span class="checkbox-description">{{ t('enableAuthDesc') }}</span>
</label> </label>
</div> </div>
</div> </div>
@@ -161,8 +161,8 @@
<div class="checkbox-row"> <div class="checkbox-row">
<p-checkbox formControlName="startTls" [binary]="true" inputId="startTls"></p-checkbox> <p-checkbox formControlName="startTls" [binary]="true" inputId="startTls"></p-checkbox>
<label for="startTls" class="checkbox-label"> <label for="startTls" class="checkbox-label">
<span class="checkbox-title">Enable StartTLS</span> <span class="checkbox-title">{{ t('enableStartTls') }}</span>
<span class="checkbox-description">Use TLS encryption for secure connection</span> <span class="checkbox-description">{{ t('enableStartTlsDesc') }}</span>
</label> </label>
</div> </div>
</div> </div>
@@ -173,25 +173,25 @@
@if (emailProviderForm.invalid) { @if (emailProviderForm.invalid) {
<div class="validation-message error"> <div class="validation-message error">
<i class="pi pi-exclamation-circle"></i> <i class="pi pi-exclamation-circle"></i>
<span>Please fill in all required fields</span> <span>{{ t('requiredFieldsError') }}</span>
</div> </div>
} @else { } @else {
<div class="validation-message success"> <div class="validation-message success">
<i class="pi pi-check-circle"></i> <i class="pi pi-check-circle"></i>
<span>Ready to create provider</span> <span>{{ t('readyToCreate') }}</span>
</div> </div>
} }
</div> </div>
<div class="footer-actions"> <div class="footer-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
severity="secondary" severity="secondary"
[outlined]="true" [outlined]="true"
(onClick)="closeDialog()" (onClick)="closeDialog()"
type="button" type="button"
/> />
<p-button <p-button
label="Create Provider" [label]="t('createBtn')"
icon="pi pi-plus" icon="pi pi-plus"
severity="success" severity="success"
type="submit" type="submit"
@@ -201,3 +201,4 @@
</div> </div>
</form> </form>
</div> </div>
</ng-container>
@@ -7,6 +7,7 @@ import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
import {DynamicDialogRef} from 'primeng/dynamicdialog'; import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.service'; import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-create-email-provider-dialog', selector: 'app-create-email-provider-dialog',
@@ -14,7 +15,9 @@ import {EmailV2ProviderService} from '../email-v2-provider/email-v2-provider.ser
Button, Button,
Checkbox, Checkbox,
InputText, InputText,
ReactiveFormsModule ReactiveFormsModule,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './create-email-provider-dialog.component.html', templateUrl: './create-email-provider-dialog.component.html',
styleUrl: './create-email-provider-dialog.component.scss' styleUrl: './create-email-provider-dialog.component.scss'
@@ -26,6 +29,7 @@ export class CreateEmailProviderDialogComponent implements OnInit {
private emailProviderService = inject(EmailV2ProviderService); private emailProviderService = inject(EmailV2ProviderService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private ref = inject(DynamicDialogRef); private ref = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
ngOnInit() { ngOnInit() {
this.emailProviderForm = this.fb.group({ this.emailProviderForm = this.fb.group({
@@ -44,8 +48,8 @@ export class CreateEmailProviderDialogComponent implements OnInit {
if (this.emailProviderForm.invalid) { if (this.emailProviderForm.invalid) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Validation Error', summary: this.t.translate('settingsEmail.provider.create.validationError'),
detail: 'Please correct errors before submitting.' detail: this.t.translate('settingsEmail.provider.create.validationErrorDetail')
}); });
return; return;
} }
@@ -56,18 +60,18 @@ export class CreateEmailProviderDialogComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Email Provider Created', summary: this.t.translate('settingsEmail.provider.create.success'),
detail: 'The email provider has been successfully created.' detail: this.t.translate('settingsEmail.provider.create.successDetail')
}); });
this.ref.close(true); this.ref.close(true);
}, },
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Email Provider Creation Failed', summary: this.t.translate('settingsEmail.provider.create.failed'),
detail: err?.error?.message detail: err?.error?.message
? `Unable to create email provider: ${err.error.message}` ? this.t.translate('settingsEmail.provider.create.failedDetail', {message: err.error.message})
: 'An unexpected error occurred while creating the email provider. Please try again later.' : 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="email-recipient-creator">
<div class="panel-header"> <div class="panel-header">
<div class="header-icon-wrapper"> <div class="header-icon-wrapper">
<i class="pi pi-user header-icon"></i> <i class="pi pi-user header-icon"></i>
</div> </div>
<div class="header-text"> <div class="header-text">
<h2 class="panel-title">Create Email Recipient</h2> <h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">Add a new recipient for email notifications</p> <p class="panel-description">{{ t('description') }}</p>
</div> </div>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -14,7 +15,7 @@
[text]="true" [text]="true"
[rounded]="true" [rounded]="true"
class="close-button" class="close-button"
pTooltip="Close" [pTooltip]="'common.close' | transloco"
tooltipPosition="left"/> tooltipPosition="left"/>
</div> </div>
@@ -23,7 +24,7 @@
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="recipientName" class="form-label"> <label for="recipientName" class="form-label">
<i class="pi pi-user label-icon"></i> <i class="pi pi-user label-icon"></i>
Recipient Name {{ t('recipientName') }}
<span class="required-indicator">*</span> <span class="required-indicator">*</span>
</label> </label>
<div class="input-wrapper"> <div class="input-wrapper">
@@ -33,16 +34,16 @@
pInputText pInputText
formControlName="name" formControlName="name"
class="input-full" class="input-full"
placeholder="Enter recipient name..." [placeholder]="t('recipientNamePlaceholder')"
[class.filled]="emailRecipientForm.get('name')?.value" [class.filled]="emailRecipientForm.get('name')?.value"
/> />
@if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) { @if (emailRecipientForm.get('name')?.value && emailRecipientForm.get('name')?.valid) {
<i class="pi pi-check-circle input-icon success"></i> <i class="pi pi-check-circle input-icon success"></i>
} }
</div> </div>
@if (emailRecipientForm.get('name')?.invalid && (emailRecipientForm.get('name')?.dirty || emailRecipientForm.get('name')?.touched)) { @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> </div>
@@ -51,7 +52,7 @@
<div class="form-group highlight-group"> <div class="form-group highlight-group">
<label for="email" class="form-label"> <label for="email" class="form-label">
<i class="pi pi-at label-icon"></i> <i class="pi pi-at label-icon"></i>
Email Address {{ t('emailAddress') }}
<span class="required-indicator">*</span> <span class="required-indicator">*</span>
</label> </label>
<div class="input-wrapper"> <div class="input-wrapper">
@@ -61,7 +62,7 @@
pInputText pInputText
formControlName="email" formControlName="email"
class="input-full" class="input-full"
placeholder="Enter email address..." [placeholder]="t('emailAddressPlaceholder')"
[class.filled]="emailRecipientForm.get('email')?.value" [class.filled]="emailRecipientForm.get('email')?.value"
/> />
@if (emailRecipientForm.get('email')?.value && emailRecipientForm.get('email')?.valid) { @if (emailRecipientForm.get('email')?.value && emailRecipientForm.get('email')?.valid) {
@@ -69,7 +70,7 @@
} }
</div> </div>
@if (emailRecipientForm.get('email')?.invalid && (emailRecipientForm.get('email')?.dirty || emailRecipientForm.get('email')?.touched)) { @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> </div>
@@ -79,8 +80,8 @@
<div class="checkbox-row"> <div class="checkbox-row">
<p-checkbox formControlName="defaultRecipient" [binary]="true" inputId="defaultRecipient"></p-checkbox> <p-checkbox formControlName="defaultRecipient" [binary]="true" inputId="defaultRecipient"></p-checkbox>
<label for="defaultRecipient" class="checkbox-label"> <label for="defaultRecipient" class="checkbox-label">
<span class="checkbox-title">Default Recipient</span> <span class="checkbox-title">{{ t('defaultRecipient') }}</span>
<span class="checkbox-description">Set as default recipient for all notifications</span> <span class="checkbox-description">{{ t('defaultRecipientDesc') }}</span>
</label> </label>
</div> </div>
</div> </div>
@@ -91,25 +92,25 @@
@if (emailRecipientForm.invalid) { @if (emailRecipientForm.invalid) {
<div class="validation-message error"> <div class="validation-message error">
<i class="pi pi-exclamation-circle"></i> <i class="pi pi-exclamation-circle"></i>
<span>Please fill in all required fields</span> <span>{{ t('requiredFieldsError') }}</span>
</div> </div>
} @else { } @else {
<div class="validation-message success"> <div class="validation-message success">
<i class="pi pi-check-circle"></i> <i class="pi pi-check-circle"></i>
<span>Ready to add recipient</span> <span>{{ t('readyToAdd') }}</span>
</div> </div>
} }
</div> </div>
<div class="footer-actions"> <div class="footer-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
severity="secondary" severity="secondary"
[outlined]="true" [outlined]="true"
(onClick)="closeDialog()" (onClick)="closeDialog()"
type="button" type="button"
/> />
<p-button <p-button
label="Add Recipient" [label]="t('addBtn')"
icon="pi pi-plus" icon="pi pi-plus"
severity="success" severity="success"
type="submit" type="submit"
@@ -119,3 +120,4 @@
</div> </div>
</form> </form>
</div> </div>
</ng-container>
@@ -7,6 +7,7 @@ import {Button} from 'primeng/button';
import {InputText} from 'primeng/inputtext'; import {InputText} from 'primeng/inputtext';
import {EmailV2RecipientService} from '../email-v2-recipient/email-v2-recipient.service'; import {EmailV2RecipientService} from '../email-v2-recipient/email-v2-recipient.service';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-create-email-recipient-dialog', selector: 'app-create-email-recipient-dialog',
@@ -15,7 +16,9 @@ import {Tooltip} from 'primeng/tooltip';
ReactiveFormsModule, ReactiveFormsModule,
Button, Button,
InputText, InputText,
Tooltip Tooltip,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './create-email-recipient-dialog.component.html', templateUrl: './create-email-recipient-dialog.component.html',
styleUrls: ['./create-email-recipient-dialog.component.scss'] styleUrls: ['./create-email-recipient-dialog.component.scss']
@@ -26,6 +29,7 @@ export class CreateEmailRecipientDialogComponent {
private emailRecipientService = inject(EmailV2RecipientService); private emailRecipientService = inject(EmailV2RecipientService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private ref = inject(DynamicDialogRef); private ref = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
constructor() { constructor() {
this.emailRecipientForm = this.fb.group({ this.emailRecipientForm = this.fb.group({
@@ -43,8 +47,8 @@ export class CreateEmailRecipientDialogComponent {
if (this.emailRecipientForm.invalid) { if (this.emailRecipientForm.invalid) {
this.messageService.add({ this.messageService.add({
severity: 'warn', severity: 'warn',
summary: 'Validation Error', summary: this.t.translate('settingsEmail.recipient.create.validationError'),
detail: 'Please correct errors before submitting.' detail: this.t.translate('settingsEmail.recipient.create.validationErrorDetail')
}); });
return; return;
} }
@@ -55,18 +59,18 @@ export class CreateEmailRecipientDialogComponent {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Recipient Added', summary: this.t.translate('settingsEmail.recipient.create.success'),
detail: `${emailRecipientData.name} has been successfully added.` detail: this.t.translate('settingsEmail.recipient.create.successDetail', {name: emailRecipientData.name})
}); });
this.ref.close(true); this.ref.close(true);
}, },
error: (err) => { error: (err) => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Recipient Creation Failed', summary: this.t.translate('settingsEmail.recipient.create.failed'),
detail: err?.error?.message detail: err?.error?.message
? `Unable to create recipient: ${err.error.message}` ? this.t.translate('settingsEmail.recipient.create.failedDetail', {message: err.error.message})
: 'An unexpected error occurred while adding the recipient. Please try again later.' : this.t.translate('settingsEmail.recipient.create.failedDefault')
}); });
} }
}); });
@@ -1,209 +1,211 @@
<div class="settings-card"> <ng-container *transloco="let t; prefix: 'settingsEmail.provider'">
<div class="section-header"> <div class="settings-card">
<div class="section-header-row"> <div class="section-header">
<div class="section-header-text"> <div class="section-header-row">
<h3 class="section-title"> <div class="section-header-text">
<i class="pi pi-server"></i> <h3 class="section-title">
Email Providers <i class="pi pi-server"></i>
</h3> {{ t('title') }}
<p class="section-description"> </h3>
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 class="section-description">
</p> {{ t('description') }}
</p>
</div>
<p-button
icon="pi pi-plus"
[label]="t('addProvider')"
severity="success"
size="small"
[outlined]="true"
(onClick)="openCreateProviderDialog()">
</p-button>
</div> </div>
<p-button
icon="pi pi-plus"
label="Add Provider"
severity="success"
size="small"
[outlined]="true"
(onClick)="openCreateProviderDialog()">
</p-button>
</div> </div>
</div>
<div class="section-body"> <div class="section-body">
@if (emailProviders.length === 0) { @if (emailProviders.length === 0) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-envelope"></i> <i class="pi pi-envelope"></i>
<p class="empty-title">No email providers configured</p> <p class="empty-title">{{ t('emptyTitle') }}</p>
<p class="empty-subtitle">Create your first email provider to start sending books</p> <p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
</div> </div>
} @else { } @else {
<div class="providers-list"> <div class="providers-list">
@for (provider of emailProviders; track provider.id) { @for (provider of emailProviders; track provider.id) {
<div class="provider-item" [class.is-default]="provider.id === defaultProviderId"> <div class="provider-item" [class.is-default]="provider.id === defaultProviderId">
<div class="provider-header"> <div class="provider-header">
<div class="provider-info"> <div class="provider-info">
<div class="provider-name-row"> <div class="provider-name-row">
<p-radioButton <p-radioButton
name="defaultProvider" name="defaultProvider"
[value]="provider.id" [value]="provider.id"
[(ngModel)]="defaultProviderId" [(ngModel)]="defaultProviderId"
(onClick)="setDefaultProvider(provider)"> (onClick)="setDefaultProvider(provider)">
</p-radioButton> </p-radioButton>
@if (provider.isEditing) { @if (provider.isEditing) {
<input type="text" pInputText [(ngModel)]="provider.name" placeholder="Provider name" class="name-input"/> <input type="text" pInputText [(ngModel)]="provider.name" [placeholder]="t('providerNamePlaceholder')" class="name-input"/>
} @else { } @else {
<span class="provider-name">{{ provider.name }}</span> <span class="provider-name">{{ provider.name }}</span>
@if (provider.shared) { @if (provider.shared) {
<span class="shared-badge" pTooltip="Shared with all users"> <span class="shared-badge" [pTooltip]="t('sharedTooltip')">
<i class="pi pi-share-alt"></i> <i class="pi pi-share-alt"></i>
</span> </span>
}
@if (provider.id === defaultProviderId) {
<span class="default-badge">{{ t('default') }}</span>
}
} }
@if (provider.id === defaultProviderId) { </div>
<span class="default-badge">Default</span> </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>
<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 class="provider-details"> <div class="detail-item">
<div class="detail-grid"> <label class="detail-label">
<div class="detail-item"> <i class="pi pi-link"></i>
<label class="detail-label"> {{ t('port') }}
<i class="pi pi-server"></i> </label>
Host @if (provider.isEditing) {
</label> <input type="number" pInputText [(ngModel)]="provider.port" [placeholder]="t('portPlaceholder')"/>
@if (provider.isEditing) { } @else {
<input type="text" pInputText [(ngModel)]="provider.host" placeholder="smtp.example.com"/> <span class="detail-value">{{ provider.port }}</span>
} @else { }
<span class="detail-value">{{ provider.host }}</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>
<div class="detail-item"> <div class="toggle-options">
<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-item"> <div class="toggle-item">
<p-checkbox <p-checkbox
[(ngModel)]="provider.shared" [(ngModel)]="provider.auth"
[binary]="true" [binary]="true"
(onChange)="toggleShared(provider)" [disabled]="!provider.isEditing"
inputId="shared-{{provider.id}}" inputId="auth-{{provider.id}}">
pTooltip="Share this provider with all users">
</p-checkbox> </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>
}
<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>
</div> </div>
</div> </ng-container>
@@ -11,6 +11,7 @@ import {EmailV2ProviderService} from './email-v2-provider.service';
import {EmailProvider} from '../email-provider.model'; import {EmailProvider} from '../email-provider.model';
import {UserService} from '../../user-management/user.service'; import {UserService} from '../../user-management/user.service';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service'; import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-email-v2-provider', selector: 'app-email-v2-provider',
@@ -21,7 +22,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
ReactiveFormsModule, ReactiveFormsModule,
TableModule, TableModule,
Tooltip, Tooltip,
FormsModule FormsModule,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './email-v2-provider.component.html', templateUrl: './email-v2-provider.component.html',
styleUrl: './email-v2-provider.component.scss' styleUrl: './email-v2-provider.component.scss'
@@ -34,6 +37,7 @@ export class EmailV2ProviderComponent implements OnInit {
private emailProvidersService = inject(EmailV2ProviderService); private emailProvidersService = inject(EmailV2ProviderService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private userService = inject(UserService); private userService = inject(UserService);
private t = inject(TranslocoService);
defaultProviderId: unknown; defaultProviderId: unknown;
currentUserId: number | null = null; currentUserId: number | null = null;
isAdmin: boolean = false; isAdmin: boolean = false;
@@ -62,8 +66,8 @@ export class EmailV2ProviderComponent implements OnInit {
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to load Email Providers', detail: this.t.translate('settingsEmail.provider.loadError'),
}); });
}, },
}); });
@@ -84,37 +88,37 @@ export class EmailV2ProviderComponent implements OnInit {
provider.isEditing = false; provider.isEditing = false;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('common.success'),
detail: 'Provider updated successfully', detail: this.t.translate('settingsEmail.provider.updateSuccess'),
}); });
this.loadEmailProviders(); this.loadEmailProviders();
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to update provider', detail: this.t.translate('settingsEmail.provider.updateError'),
}); });
}, },
}); });
} }
deleteProvider(provider: EmailProvider): void { 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({ this.emailProvidersService.deleteProvider(provider.id).subscribe({
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('common.success'),
detail: `Provider "${provider.name}" deleted successfully`, detail: this.t.translate('settingsEmail.provider.deleteSuccess', {name: provider.name}),
}); });
this.loadEmailProviders(); this.loadEmailProviders();
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to delete provider', detail: this.t.translate('settingsEmail.provider.deleteError'),
}); });
}, },
}); });
@@ -136,16 +140,16 @@ export class EmailV2ProviderComponent implements OnInit {
this.defaultProviderId = provider.id; this.defaultProviderId = provider.id;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Default Provider Set', summary: this.t.translate('settingsEmail.provider.defaultSetSummary'),
detail: `${provider.name} is now the default email provider.` detail: this.t.translate('settingsEmail.provider.defaultSetDetail', {name: provider.name}),
}); });
}, },
error: (err) => { error: (err) => {
console.error('Failed to set default provider', err); console.error('Failed to set default provider', err);
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: `Failed to set ${provider.name} as the default provider. Please try again.` detail: this.t.translate('settingsEmail.provider.defaultSetError', {name: provider.name}),
}); });
} }
}); });
@@ -158,18 +162,19 @@ export class EmailV2ProviderComponent implements OnInit {
toggleShared(provider: EmailProvider): void { toggleShared(provider: EmailProvider): void {
this.emailProvidersService.updateProvider(provider).subscribe({ this.emailProvidersService.updateProvider(provider).subscribe({
next: () => { next: () => {
const status = this.t.translate(provider.shared ? 'settingsEmail.provider.sharedStatusOn' : 'settingsEmail.provider.sharedStatusOff');
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('common.success'),
detail: `Provider "${provider.name}" is now ${provider.shared ? 'shared' : 'not shared'}`, detail: this.t.translate('settingsEmail.provider.sharedSuccess', {name: provider.name, status}),
}); });
}, },
error: () => { error: () => {
provider.shared = !provider.shared; provider.shared = !provider.shared;
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to update shared status', detail: this.t.translate('settingsEmail.provider.sharedError'),
}); });
}, },
}); });
@@ -1,129 +1,131 @@
<div class="settings-card"> <ng-container *transloco="let t; prefix: 'settingsEmail.recipient'">
<div class="section-header"> <div class="settings-card">
<div class="section-header-row"> <div class="section-header">
<div class="section-header-text"> <div class="section-header-row">
<h3 class="section-title"> <div class="section-header-text">
<i class="pi pi-users"></i> <h3 class="section-title">
Recipient Emails <i class="pi pi-users"></i>
</h3> {{ t('title') }}
<p class="section-description"> </h3>
Manage recipient email addresses for sending books. The default recipient is used for 'Quick Book Send' in the Book Card menu. <p class="section-description">
</p> {{ t('description') }}
</p>
</div>
<p-button
icon="pi pi-plus"
[label]="t('addRecipient')"
severity="success"
size="small"
[outlined]="true"
(onClick)="openAddRecipientDialog()">
</p-button>
</div> </div>
<p-button
icon="pi pi-plus"
label="Add Recipient"
severity="success"
size="small"
[outlined]="true"
(onClick)="openAddRecipientDialog()">
</p-button>
</div> </div>
</div>
<div class="section-body"> <div class="section-body">
@if (recipientEmails.length === 0) { @if (recipientEmails.length === 0) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-users"></i> <i class="pi pi-users"></i>
<p class="empty-title">No recipients configured</p> <p class="empty-title">{{ t('emptyTitle') }}</p>
<p class="empty-subtitle">Add your first email recipient to start sending books</p> <p class="empty-subtitle">{{ t('emptySubtitle') }}</p>
</div> </div>
} @else { } @else {
<div class="recipients-list"> <div class="recipients-list">
@for (recipient of recipientEmails; track recipient.id) { @for (recipient of recipientEmails; track recipient.id) {
<div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId"> <div class="recipient-item" [class.is-default]="recipient.id === defaultRecipientId">
<div class="recipient-content"> <div class="recipient-content">
<div class="recipient-select"> <div class="recipient-select">
<p-radioButton <p-radioButton
name="defaultRecipient" name="defaultRecipient"
[value]="recipient.id" [value]="recipient.id"
[(ngModel)]="defaultRecipientId" [(ngModel)]="defaultRecipientId"
(onClick)="setDefaultRecipient(recipient)"> (onClick)="setDefaultRecipient(recipient)">
</p-radioButton> </p-radioButton>
</div> </div>
<div class="recipient-info"> <div class="recipient-info">
@if (recipient.isEditing) { @if (recipient.isEditing) {
<div class="edit-form"> <div class="edit-form">
<div class="form-field"> <div class="form-field">
<label class="field-label"> <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> <i class="pi pi-envelope"></i>
Email <span>{{ recipient.email }}</span>
</label> @if (recipient.id === defaultRecipientId) {
<input type="email" pInputText [(ngModel)]="recipient.email" placeholder="recipient@example.com"/> <span class="default-badge">{{ t('default') }}</span>
</div> }
<div class="form-field"> </div>
<label class="field-label"> @if (recipient.name) {
<i class="pi pi-user"></i> <div class="recipient-name">
Name <i class="pi pi-user"></i>
</label> <span>{{ recipient.name }}</span>
<input type="text" pInputText [(ngModel)]="recipient.name" placeholder="Recipient name"/> </div>
</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>
} }
</div> </div>
@if (recipient.name) { }
<div class="recipient-name"> </div>
<i class="pi pi-user"></i>
<span>{{ recipient.name }}</span>
</div>
}
</div>
}
</div>
<div class="recipient-actions"> <div class="recipient-actions">
@if (!recipient.isEditing) { @if (!recipient.isEditing) {
<p-button <p-button
icon="pi pi-pencil" icon="pi pi-pencil"
severity="info" severity="info"
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="toggleEditRecipient(recipient)" (onClick)="toggleEditRecipient(recipient)"
pTooltip="Edit recipient"> [pTooltip]="t('editRecipient')">
</p-button> </p-button>
<p-button <p-button
icon="pi pi-trash" icon="pi pi-trash"
severity="danger" severity="danger"
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="deleteRecipient(recipient)" (onClick)="deleteRecipient(recipient)"
pTooltip="Delete recipient"> [pTooltip]="t('deleteRecipient')">
</p-button> </p-button>
} @else { } @else {
<p-button <p-button
icon="pi pi-check" icon="pi pi-check"
severity="success" severity="success"
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="saveRecipient(recipient)" (onClick)="saveRecipient(recipient)"
pTooltip="Save changes"> [pTooltip]="t('saveChanges')">
</p-button> </p-button>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
severity="secondary" severity="secondary"
size="small" size="small"
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="toggleEditRecipient(recipient)" (onClick)="toggleEditRecipient(recipient)"
pTooltip="Cancel"> [pTooltip]="'common.cancel' | transloco">
</p-button> </p-button>
} }
</div>
</div> </div>
</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 {EmailV2RecipientService} from './email-v2-recipient.service';
import {EmailRecipient} from '../email-recipient.model'; import {EmailRecipient} from '../email-recipient.model';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service'; import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-email-v2-recipient', selector: 'app-email-v2-recipient',
@@ -18,7 +19,9 @@ import {DialogLauncherService} from '../../../../shared/services/dialog-launcher
ReactiveFormsModule, ReactiveFormsModule,
TableModule, TableModule,
Tooltip, Tooltip,
FormsModule FormsModule,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './email-v2-recipient.component.html', templateUrl: './email-v2-recipient.component.html',
styleUrl: './email-v2-recipient.component.scss' styleUrl: './email-v2-recipient.component.scss'
@@ -30,6 +33,7 @@ export class EmailV2RecipientComponent implements OnInit {
private dialogLauncherService = inject(DialogLauncherService); private dialogLauncherService = inject(DialogLauncherService);
private emailRecipientService = inject(EmailV2RecipientService); private emailRecipientService = inject(EmailV2RecipientService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private t = inject(TranslocoService);
defaultRecipientId: unknown; defaultRecipientId: unknown;
ngOnInit(): void { ngOnInit(): void {
@@ -49,8 +53,8 @@ export class EmailV2RecipientComponent implements OnInit {
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to load recipient emails', detail: this.t.translate('settingsEmail.recipient.loadError'),
}); });
}, },
}); });
@@ -71,37 +75,37 @@ export class EmailV2RecipientComponent implements OnInit {
recipient.isEditing = false; recipient.isEditing = false;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('common.success'),
detail: 'Recipient updated successfully', detail: this.t.translate('settingsEmail.recipient.updateSuccess'),
}); });
this.loadRecipientEmails(); this.loadRecipientEmails();
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to update recipient', detail: this.t.translate('settingsEmail.recipient.updateError'),
}); });
}, },
}); });
} }
deleteRecipient(recipient: EmailRecipient): void { 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({ this.emailRecipientService.deleteRecipient(recipient.id).subscribe({
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Success', summary: this.t.translate('common.success'),
detail: `Recipient "${recipient.email}" deleted successfully`, detail: this.t.translate('settingsEmail.recipient.deleteSuccess', {email: recipient.email}),
}); });
this.loadRecipientEmails(); this.loadRecipientEmails();
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to delete recipient', detail: this.t.translate('settingsEmail.recipient.deleteError'),
}); });
}, },
}); });
@@ -122,8 +126,8 @@ export class EmailV2RecipientComponent implements OnInit {
this.defaultRecipientId = recipient.id; this.defaultRecipientId = recipient.id;
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Default Recipient Set', summary: this.t.translate('settingsEmail.recipient.defaultSetSummary'),
detail: `${recipient.email} is now the default recipient.` detail: this.t.translate('settingsEmail.recipient.defaultSetDetail', {email: recipient.email}),
}); });
}); });
} }
@@ -1,30 +1,32 @@
<div class="email-settings-container"> <ng-container *transloco="let t; prefix: 'settingsEmail'">
<div class="settings-header"> <div class="email-settings-container">
<h2 class="settings-title"> <div class="settings-header">
<i class="pi pi-envelope"></i> <h2 class="settings-title">
Email Configuration <i class="pi pi-envelope"></i>
<app-external-doc-link docType="email"></app-external-doc-link> {{ t('title') }}
</h2> <app-external-doc-link docType="email"></app-external-doc-link>
<p class="settings-description"> </h2>
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 class="settings-description">
</p> {{ t('description') }}
</div> </p>
@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>
</div> </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 {UserService} from '../user-management/user.service';
import {Subject} from 'rxjs'; import {Subject} from 'rxjs';
import {filter, takeUntil, tap} from 'rxjs/operators'; import {filter, takeUntil, tap} from 'rxjs/operators';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({ @Component({
@@ -16,7 +17,8 @@ import {filter, takeUntil, tap} from 'rxjs/operators';
TableModule, TableModule,
EmailV2ProviderComponent, EmailV2ProviderComponent,
EmailV2RecipientComponent, EmailV2RecipientComponent,
ExternalDocLinkComponent ExternalDocLinkComponent,
TranslocoDirective
], ],
templateUrl: './email-v2.component.html', templateUrl: './email-v2.component.html',
styleUrls: ['./email-v2.component.scss'], styleUrls: ['./email-v2.component.scss'],
@@ -1,20 +1,20 @@
<ng-container *transloco="let t; prefix: 'settingsNaming'">
<div class="file-naming-container"> <div class="file-naming-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-file"></i> <i class="pi pi-file"></i>
File Naming Patterns {{ t('title') }}
<app-external-doc-link docType="fileNamePatterns"></app-external-doc-link> <app-external-doc-link docType="fileNamePatterns"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <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> </p>
</div> </div>
<div class="warning-notice"> <div class="warning-notice">
<i class="pi pi-exclamation-triangle"></i> <i class="pi pi-exclamation-triangle"></i>
<div> <div>
<strong>Metadata Quality Notice:</strong> File naming relies entirely on metadata stored in Booklore. <strong>{{ t('warning.title') }}</strong> {{ t('warning.text') }}
This feature is recommended only for high-quality, curated libraries with complete metadata.
</div> </div>
</div> </div>
@@ -22,9 +22,9 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-bolt"></i> <i class="pi pi-bolt"></i>
Default Pattern {{ t('defaultPattern.sectionTitle') }}
</h3> </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>
<div class="section-body"> <div class="section-body">
@@ -35,11 +35,11 @@
pInputText pInputText
id="defaultPattern" id="defaultPattern"
[(ngModel)]="defaultPattern" [(ngModel)]="defaultPattern"
placeholder="e.g., {title} - {authors}" [placeholder]="t('defaultPattern.placeholder')"
(input)="onDefaultPatternChange(defaultPattern)" (input)="onDefaultPatternChange(defaultPattern)"
class="pattern-input"/> class="pattern-input"/>
<p-button <p-button
label="Save" [label]="'common.save' | transloco"
icon="pi pi-save" icon="pi pi-save"
(onClick)="savePatterns()" (onClick)="savePatterns()"
severity="success" severity="success"
@@ -53,7 +53,7 @@
<div class="preview-row"> <div class="preview-row">
<span class="preview-label"> <span class="preview-label">
<i class="pi pi-eye"></i> <i class="pi pi-eye"></i>
Preview: {{ t('defaultPattern.preview') }}
</span> </span>
<code class="preview-value">{{ generateDefaultPreview() }}</code> <code class="preview-value">{{ generateDefaultPreview() }}</code>
</div> </div>
@@ -66,10 +66,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-folder"></i> <i class="pi pi-folder"></i>
Library Overrides {{ t('libraryOverrides.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Define custom patterns for specific libraries. Leave empty to use the default pattern. {{ t('libraryOverrides.sectionDesc') }}
</p> </p>
</div> </div>
@@ -77,8 +77,8 @@
@if (libraries.length === 0) { @if (libraries.length === 0) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-folder-open"></i> <i class="pi pi-folder-open"></i>
<p class="empty-title">No libraries found</p> <p class="empty-title">{{ t('libraryOverrides.emptyTitle') }}</p>
<p class="empty-subtitle">Create a library to configure custom naming patterns</p> <p class="empty-subtitle">{{ t('libraryOverrides.emptySubtitle') }}</p>
</div> </div>
} @else { } @else {
<div class="libraries-list"> <div class="libraries-list">
@@ -91,9 +91,9 @@
</div> </div>
<span class="library-name">{{ library.name }}</span> <span class="library-name">{{ library.name }}</span>
@if (library.fileNamingPattern) { @if (library.fileNamingPattern) {
<span class="custom-badge">Custom</span> <span class="custom-badge">{{ t('libraryOverrides.custom') }}</span>
} @else { } @else {
<span class="default-badge">Using Default</span> <span class="default-badge">{{ t('libraryOverrides.usingDefault') }}</span>
} }
</div> </div>
<p-button <p-button
@@ -104,7 +104,7 @@
[rounded]="true" [rounded]="true"
(onClick)="clearLibraryPattern(library)" (onClick)="clearLibraryPattern(library)"
[disabled]="!library.fileNamingPattern" [disabled]="!library.fileNamingPattern"
pTooltip="Clear pattern"> [pTooltip]="t('libraryOverrides.clearPattern')">
</p-button> </p-button>
</div> </div>
<div class="library-body"> <div class="library-body">
@@ -112,13 +112,13 @@
<input <input
pInputText pInputText
[(ngModel)]="library.fileNamingPattern" [(ngModel)]="library.fileNamingPattern"
placeholder="Leave empty to use default pattern" [placeholder]="t('libraryOverrides.placeholder')"
(input)="onLibraryPatternChange(library)" (input)="onLibraryPatternChange(library)"
class="pattern-input"/> class="pattern-input"/>
<div class="preview-row"> <div class="preview-row">
<span class="preview-label"> <span class="preview-label">
<i class="pi pi-eye"></i> <i class="pi pi-eye"></i>
Preview: {{ t('libraryOverrides.preview') }}
</span> </span>
<code class="preview-value">{{ generateLibraryPreview(library) }}</code> <code class="preview-value">{{ generateLibraryPreview(library) }}</code>
</div> </div>
@@ -130,7 +130,7 @@
<div class="actions-row"> <div class="actions-row">
<p-button <p-button
label="Save All" [label]="t('libraryOverrides.saveAll')"
(onClick)="saveLibraryPatterns()" (onClick)="saveLibraryPatterns()"
severity="success" severity="success"
icon="pi pi-save" icon="pi pi-save"
@@ -145,10 +145,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Placeholders Reference {{ t('placeholders.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Use placeholders to dynamically insert metadata into file names and folder paths. {{ t('placeholders.sectionDesc') }}
</p> </p>
</div> </div>
@@ -157,43 +157,41 @@
<div class="placeholder-group"> <div class="placeholder-group">
<h4 class="group-title"> <h4 class="group-title">
<i class="pi pi-hashtag"></i> <i class="pi pi-hashtag"></i>
Available Placeholders {{ t('placeholders.available') }}
</h4> </h4>
<div class="placeholder-list"> <div class="placeholder-list">
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>Book title</span></div> <div class="placeholder-item"><code>{{ '{title}' }}</code><span>{{ t('placeholders.title') }}</span></div>
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>Book subtitle</span></div> <div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>{{ t('placeholders.subtitle') }}</span></div>
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>Author(s)</span></div> <div class="placeholder-item"><code>{{ '{authors}' }}</code><span>{{ t('placeholders.authors') }}</span></div>
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>Publication year</span></div> <div class="placeholder-item"><code>{{ '{year}' }}</code><span>{{ t('placeholders.year') }}</span></div>
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>Series name</span></div> <div class="placeholder-item"><code>{{ '{series}' }}</code><span>{{ t('placeholders.series') }}</span></div>
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>Series index</span></div> <div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>{{ t('placeholders.seriesIndex') }}</span></div>
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>Language code</span></div> <div class="placeholder-item"><code>{{ '{language}' }}</code><span>{{ t('placeholders.language') }}</span></div>
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>Publisher</span></div> <div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>{{ t('placeholders.publisher') }}</span></div>
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>ISBN number</span></div> <div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>{{ t('placeholders.isbn') }}</span></div>
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>Original filename</span></div> <div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>{{ t('placeholders.currentFilename') }}</span></div>
</div> </div>
</div> </div>
<div class="placeholder-group"> <div class="placeholder-group">
<h4 class="group-title"> <h4 class="group-title">
<i class="pi pi-code"></i> <i class="pi pi-code"></i>
Optional Blocks {{ t('placeholders.optionalBlocks') }}
</h4> </h4>
<p class="group-description"> <p class="group-description" [innerHTML]="t('placeholders.optionalDesc', { syntax: '{<...>}' })">
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> </p>
<div class="example-block"> <div class="example-block">
<div class="example-pattern"> <div class="example-pattern">
<span class="pattern-prefix">Pattern:</span> <span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
<code>{{ '{<{seriesIndex} - >{title}' }}</code> <code>{{ '{<{seriesIndex} - >{title}' }}</code>
</div> </div>
<div class="example-results"> <div class="example-results">
<div class="result-item"> <div class="result-item">
<span class="result-prefix">With index:</span> <span class="result-prefix">{{ t('placeholders.withIndex') }}</span>
<code>01 - Dune</code> <code>01 - Dune</code>
</div> </div>
<div class="result-item"> <div class="result-item">
<span class="result-prefix">Without:</span> <span class="result-prefix">{{ t('placeholders.without') }}</span>
<code>Dune</code> <code>Dune</code>
</div> </div>
</div> </div>
@@ -207,10 +205,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-eye"></i> <i class="pi pi-eye"></i>
Pattern Examples {{ t('examples.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Sample patterns with example metadata to help you understand how patterns work. {{ t('examples.sectionDesc') }}
</p> </p>
</div> </div>
@@ -220,7 +218,7 @@
<div class="category-header"> <div class="category-header">
<h4 class="category-title"> <h4 class="category-title">
<i class="pi pi-check-circle"></i> <i class="pi pi-check-circle"></i>
With Full Metadata {{ t('examples.withFull') }}
</h4> </h4>
<div class="sample-metadata"> <div class="sample-metadata">
<div class="metadata-items"> <div class="metadata-items">
@@ -236,32 +234,32 @@
<div class="example-grid"> <div class="example-grid">
<div class="example-row"> <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="pattern-col"><code>{{ '{authors} - {title}' }}</code></span>
<span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span> <span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '{title}: {series}' }}</code></span>
<span class="result-col"><code>The Name of the Wind: The Kingkiller Chronicle.epub</code></span> <span class="result-col"><code>The Name of the Wind: The Kingkiller Chronicle.epub</code></span>
</div> </div>
<div class="example-row"> <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="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> <span class="result-col"><code>Patrick Rothfuss/The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '{title}/' }}</code></span>
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span> <span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '/{authors}/{title}' }}</code></span>
<span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span> <span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span> <span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
</div> </div>
@@ -274,48 +272,48 @@
<div class="category-header"> <div class="category-header">
<h4 class="category-title"> <h4 class="category-title">
<i class="pi pi-question-circle"></i> <i class="pi pi-question-circle"></i>
With Missing Optional Fields {{ t('examples.withMissing') }}
</h4> </h4>
<div class="sample-metadata"> <div class="sample-metadata">
<div class="metadata-items"> <div class="metadata-items">
<span><strong>title:</strong> <code>Project Hail Mary</code></span> <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>authors:</strong> <code>Andy Weir</code></span>
<span><strong>year:</strong> <code>2021</code></span> <span><strong>year:</strong> <code>2021</code></span>
<span><strong>series:</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">not set</em></span> <span><strong>seriesIndex:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
</div> </div>
</div> </div>
</div> </div>
<div class="example-grid"> <div class="example-grid">
<div class="example-row"> <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="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
<span class="result-col"><code>Andy Weir/Project Hail Mary (2021).epub</code></span> <span class="result-col"><code>Andy Weir/Project Hail Mary (2021).epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '<{seriesIndex}. >{title}< - {authors}>' }}</code></span>
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span> <span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '<[{series}] >{title} - {authors}' }}</code></span>
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span> <span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '<{series}: >{title} by {authors}' }}</code></span>
<span class="result-col"><code>Project Hail Mary by Andy Weir.epub</code></span> <span class="result-col"><code>Project Hail Mary by Andy Weir.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '{authors}/{year}__{currentFilename}' }}</code></span>
<span class="result-col"><code>Andy Weir/2021__project_hail_mary_final.epub</code></span> <span class="result-col"><code>Andy Weir/2021__project_hail_mary_final.epub</code></span>
</div> </div>
<div class="example-row"> <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="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
<span class="result-col"><code>Project Hail Mary.epub</code></span> <span class="result-col"><code>Project Hail Mary.epub</code></span>
</div> </div>
@@ -325,3 +323,4 @@
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -9,13 +9,15 @@ import {catchError, filter, take} from 'rxjs/operators';
import {Library} from '../../book/model/library.model'; import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service'; import {LibraryService} from '../../book/service/library.service';
import {InputText} from 'primeng/inputtext'; import {InputText} from 'primeng/inputtext';
import {Tooltip} from 'primeng/tooltip';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-file-naming-pattern', selector: 'app-file-naming-pattern',
templateUrl: './file-naming-pattern.component.html', templateUrl: './file-naming-pattern.component.html',
standalone: true, standalone: true,
imports: [FormsModule, Button, InputText, ExternalDocLinkComponent], imports: [FormsModule, Button, InputText, Tooltip, ExternalDocLinkComponent, TranslocoDirective, TranslocoPipe],
styleUrls: ['./file-naming-pattern.component.scss'], styleUrls: ['./file-naming-pattern.component.scss'],
}) })
export class FileNamingPatternComponent implements OnInit { export class FileNamingPatternComponent implements OnInit {
@@ -38,6 +40,7 @@ export class FileNamingPatternComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private libraryService = inject(LibraryService); private libraryService = inject(LibraryService);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -100,7 +103,7 @@ export class FileNamingPatternComponent implements OnInit {
onDefaultPatternChange(pattern: string): void { onDefaultPatternChange(pattern: string): void {
this.defaultPattern = pattern; 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 { onLibraryPatternChange(library: Library): void {
@@ -113,7 +116,7 @@ export class FileNamingPatternComponent implements OnInit {
savePatterns(): void { savePatterns(): void {
if (this.defaultErrorMessage) { 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; return;
} }
this.appSettingsService this.appSettingsService
@@ -121,8 +124,8 @@ export class FileNamingPatternComponent implements OnInit {
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern}, {key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
]) ])
.subscribe({ .subscribe({
next: () => this.showMessage('success', 'Settings Saved', 'The default pattern was successfully saved!'), next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
error: () => this.showMessage('error', 'Error', 'There was an error saving the settings.'), 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 => { forkJoin(patchRequests).subscribe(results => {
const failures = results.filter(result => result === null); const failures = results.filter(result => result === null);
if (failures.length === 0) { 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 { } 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="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-cog"></i> <i class="pi pi-cog"></i>
Global Preferences {{ t('title') }}
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Configure global settings for your Booklore instance, including cover image handling, search preferences, and file upload limits. {{ t('description') }}
</p> </p>
</div> </div>
@@ -14,7 +15,7 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-image"></i> <i class="pi pi-image"></i>
Book Cover Image {{ t('covers.sectionTitle') }}
</h3> </h3>
</div> </div>
@@ -22,9 +23,9 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Regenerate Covers</label> <label class="setting-label">{{ t('covers.regenerate') }}</label>
<p-button <p-button
label="Regenerate" [label]="t('covers.regenerateBtn')"
icon="pi pi-refresh" icon="pi pi-refresh"
outlined="true" outlined="true"
size="small" size="small"
@@ -34,7 +35,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Regenerates cover images for all books from the embedded covers in the file. {{ t('covers.regenerateDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -42,7 +43,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Vertical Cover Cropping</label> <label class="setting-label">{{ t('covers.verticalCropping') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="coverCroppingSettings.verticalCroppingEnabled" [(ngModel)]="coverCroppingSettings.verticalCroppingEnabled"
(onChange)="onCoverCroppingChange()"> (onChange)="onCoverCroppingChange()">
@@ -50,7 +51,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <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> </p>
</div> </div>
</div> </div>
@@ -58,7 +59,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Horizontal Cover Cropping</label> <label class="setting-label">{{ t('covers.horizontalCropping') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="coverCroppingSettings.horizontalCroppingEnabled" [(ngModel)]="coverCroppingSettings.horizontalCroppingEnabled"
(onChange)="onCoverCroppingChange()"> (onChange)="onCoverCroppingChange()">
@@ -66,7 +67,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Automatically crop extremely wide images from the left to create usable cover thumbnails. {{ t('covers.horizontalCroppingDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -74,7 +75,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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"> <div class="slider-container">
<p-slider <p-slider
[(ngModel)]="coverCroppingSettings.aspectRatioThreshold" [(ngModel)]="coverCroppingSettings.aspectRatioThreshold"
@@ -87,7 +88,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <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> </p>
</div> </div>
</div> </div>
@@ -95,7 +96,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Smart Cropping</label> <label class="setting-label">{{ t('covers.smartCropping') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="coverCroppingSettings.smartCroppingEnabled" [(ngModel)]="coverCroppingSettings.smartCroppingEnabled"
(onChange)="onCoverCroppingChange()"> (onChange)="onCoverCroppingChange()">
@@ -103,7 +104,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <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> </p>
</div> </div>
</div> </div>
@@ -114,7 +115,7 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-search"></i> <i class="pi pi-search"></i>
Search & Recommendations {{ t('search.sectionTitle') }}
</h3> </h3>
</div> </div>
@@ -122,7 +123,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Auto Book Search</label> <label class="setting-label">{{ t('search.autoBookSearch') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="toggles.autoBookSearch" [(ngModel)]="toggles.autoBookSearch"
(onChange)="onToggleChange('autoBookSearch', $event.checked)"> (onChange)="onToggleChange('autoBookSearch', $event.checked)">
@@ -130,7 +131,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Automatically attempts metadata matching when the book information panel is opened. {{ t('search.autoBookSearchDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -138,7 +139,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Similar Book Recommendation</label> <label class="setting-label">{{ t('search.similarBook') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="toggles.similarBookRecommendation" [(ngModel)]="toggles.similarBookRecommendation"
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)"> (onChange)="onToggleChange('similarBookRecommendation', $event.checked)">
@@ -146,7 +147,7 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
Enables or disables similar book recommendations based on your library. {{ t('search.similarBookDesc') }}
</p> </p>
</div> </div>
</div> </div>
@@ -157,7 +158,7 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-upload"></i> <i class="pi pi-upload"></i>
File Management {{ t('fileManagement.sectionTitle') }}
</h3> </h3>
</div> </div>
@@ -165,26 +166,26 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <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-group">
<div class="input-with-unit"> <div class="input-with-unit">
<input <input
type="text" type="text"
pInputText pInputText
[(ngModel)]="maxFileUploadSizeInMb" [(ngModel)]="maxFileUploadSizeInMb"
placeholder="Max size"/> [placeholder]="t('fileManagement.maxUploadPlaceholder')"/>
<span class="unit">MB</span> <span class="unit">MB</span>
</div> </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>
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <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> </p>
<div class="warning-message"> <div class="warning-message">
<i class="pi pi-exclamation-triangle"></i> <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> </div>
</div> </div>
@@ -196,7 +197,7 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-chart-bar"></i> <i class="pi pi-chart-bar"></i>
Telemetry {{ t('telemetry.sectionTitle') }}
<app-external-doc-link docType="telemetry"></app-external-doc-link> <app-external-doc-link docType="telemetry"></app-external-doc-link>
</h3> </h3>
</div> </div>
@@ -204,7 +205,7 @@
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Enable Telemetry</label> <label class="setting-label">{{ t('telemetry.enableTelemetry') }}</label>
<p-toggleswitch <p-toggleswitch
[(ngModel)]="toggles.enableTelemetry" [(ngModel)]="toggles.enableTelemetry"
(onChange)="onToggleChange('enableTelemetry', $event.checked)"> (onChange)="onToggleChange('enableTelemetry', $event.checked)">
@@ -212,11 +213,12 @@
</div> </div>
<p class="setting-description"> <p class="setting-description">
<i class="pi pi-info-circle"></i> <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 {{ t('telemetry.telemetryDesc') }}
is sent to the Booklore server automatically once every 24 hours. It’s completely safe and very helpful to the developers. </p> </p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -12,6 +12,7 @@ import {filter, take} from 'rxjs/operators';
import {InputText} from 'primeng/inputtext'; import {InputText} from 'primeng/inputtext';
import {Slider} from 'primeng/slider'; import {Slider} from 'primeng/slider';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-global-preferences', selector: 'app-global-preferences',
@@ -22,7 +23,9 @@ import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-
FormsModule, FormsModule,
InputText, InputText,
Slider, Slider,
ExternalDocLinkComponent ExternalDocLinkComponent,
TranslocoDirective,
TranslocoPipe
], ],
templateUrl: './global-preferences.component.html', templateUrl: './global-preferences.component.html',
styleUrl: './global-preferences.component.scss' styleUrl: './global-preferences.component.scss'
@@ -45,6 +48,7 @@ export class GlobalPreferencesComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private bookService = inject(BookService); private bookService = inject(BookService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
maxFileUploadSizeInMb?: number; maxFileUploadSizeInMb?: number;
@@ -87,7 +91,7 @@ export class GlobalPreferencesComponent implements OnInit {
saveFileSize() { saveFileSize() {
if (!this.maxFileUploadSizeInMb || this.maxFileUploadSizeInMb <= 0) { 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; return;
} }
this.saveSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, this.maxFileUploadSizeInMb); this.saveSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, this.maxFileUploadSizeInMb);
@@ -96,18 +100,18 @@ export class GlobalPreferencesComponent implements OnInit {
regenerateCovers(): void { regenerateCovers(): void {
this.bookService.regenerateCovers().subscribe({ this.bookService.regenerateCovers().subscribe({
next: () => 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: () => 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 { private saveSetting(key: string, value: unknown): void {
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({ this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () => 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: () => 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"> <ng-container *transloco="let t; prefix: 'settingsMeta.matchWeights'">
<div class="section-header"> <div class="settings-card">
<h3 class="section-title"> <div class="section-header">
<i class="pi pi-sliders-h"></i> <h3 class="section-title">
Metadata Match Weights <i class="pi pi-sliders-h"></i>
</h3> {{ t('sectionTitle') }}
<p class="section-description"> </h3>
Configure how important each metadata field is when computing match scores. Higher weights make fields more influential in determining the overall match quality. <p class="section-description">
</p> {{ t('sectionDesc') }}
</div> </p>
<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>
</div> </div>
<div class="setting-item weights-item"> <div class="section-body">
<div class="weights-header"> <div class="setting-item action-item">
<span class="weights-icon pi pi-sliders-v"></span> <div class="action-row">
<h4 class="weights-label">Field Weights</h4> <div class="action-info">
</div> <span class="action-label">{{ t('recalculateLabel') }}</span>
<span class="action-description">{{ t('recalculateDesc') }}</span>
<form [formGroup]="form" class="weights-form"> </div>
<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 <p-button
type="button" type="button"
severity="success" icon="pi pi-refresh"
label="Save Weights" [label]="t('recalculateBtn')"
icon="pi pi-save" [disabled]="isRecalculating"
outlined (click)="recalculate()"
[disabled]="isSaving" outlined>
(click)="save()">
</p-button> </p-button>
</div> </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> </div>
</div> </ng-container>
@@ -8,14 +8,15 @@ import {Observable} from 'rxjs';
import {AppSettingKey, AppSettings} from '../../../../shared/model/app-settings.model'; import {AppSettingKey, AppSettings} from '../../../../shared/model/app-settings.model';
import {AppSettingsService} from '../../../../shared/service/app-settings.service'; import {AppSettingsService} from '../../../../shared/service/app-settings.service';
import {InputNumber} from 'primeng/inputnumber'; import {InputNumber} from 'primeng/inputnumber';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-match-weights-component', selector: 'app-metadata-match-weights-component',
imports: [ imports: [
ReactiveFormsModule, ReactiveFormsModule,
Button, Button,
InputNumber InputNumber,
TranslocoDirective
], ],
templateUrl: './metadata-match-weights-component.html', templateUrl: './metadata-match-weights-component.html',
styleUrl: './metadata-match-weights-component.scss' styleUrl: './metadata-match-weights-component.scss'
@@ -56,6 +57,7 @@ export class MetadataMatchWeightsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private fb = inject(FormBuilder); private fb = inject(FormBuilder);
private t = inject(TranslocoService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -114,16 +116,16 @@ export class MetadataMatchWeightsComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Saved', summary: this.t.translate('common.success'),
detail: 'Weights saved successfully' detail: this.t.translate('settingsMeta.matchWeights.saveSuccess')
}); });
this.isSaving = false; this.isSaving = false;
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to save weights' detail: this.t.translate('settingsMeta.matchWeights.saveError')
}); });
this.isSaving = false; this.isSaving = false;
} }
@@ -136,16 +138,16 @@ export class MetadataMatchWeightsComponent implements OnInit {
next: () => { next: () => {
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Recalculated', summary: this.t.translate('common.success'),
detail: 'All book match scores were recalculated successfully.' detail: this.t.translate('settingsMeta.matchWeights.recalcSuccess')
}); });
this.isRecalculating = false; this.isRecalculating = false;
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to recalculate match scores.' detail: this.t.translate('settingsMeta.matchWeights.recalcError')
}); });
this.isRecalculating = false; this.isRecalculating = false;
} }
@@ -1,189 +1,191 @@
<div class="metadata-settings"> <ng-container *transloco="let t; prefix: 'settingsMeta.providers'">
<div class="settings-card"> <div class="metadata-settings">
<div class="section-header"> <div class="settings-card">
<h3 class="section-title"> <div class="section-header">
<i class="pi pi-cloud"></i> <h3 class="section-title">
Metadata Providers <i class="pi pi-cloud"></i>
</h3> {{ t('sectionTitle') }}
<p class="section-description"> </h3>
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 class="section-description">
</p> {{ t('sectionDesc') }}
</div> </p>
</div>
<div class="section-body"> <div class="section-body">
<div class="configurable-providers-section"> <div class="configurable-providers-section">
<h4 class="provider-group-title">Providers with Configuration</h4> <h4 class="provider-group-title">{{ t('configurableTitle') }}</h4>
<div class="configurable-providers-list"> <div class="configurable-providers-list">
<div class="setting-item"> <div class="setting-item">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch [(ngModel)]="amazonEnabled"></p-toggleswitch> <p-toggleswitch [(ngModel)]="amazonEnabled"></p-toggleswitch>
<label class="setting-label">Amazon</label> <label class="setting-label">Amazon</label>
</div> </div>
@if (amazonEnabled) { @if (amazonEnabled) {
<div class="setting-options"> <div class="setting-options">
<div class="config-field"> <div class="config-field">
<label class="config-label">Region</label> <label class="config-label">{{ t('region') }}</label>
<p-select <p-select
[options]="amazonDomains" [options]="amazonDomains"
[(ngModel)]="selectedAmazonDomain" [(ngModel)]="selectedAmazonDomain"
placeholder="Select Domain" [placeholder]="t('selectDomain')"
class="config-select"> class="config-select">
</p-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>
<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-field">
<div class="config-label-row"> <div class="config-label-row">
<label class="config-label">Cookie (Optional, but highly recommended)</label> <label class="config-label">{{ t('apiToken') }}</label>
<app-external-doc-link docType="amazonCookie"></app-external-doc-link> <app-external-doc-link docType="hardcover"></app-external-doc-link>
</div> </div>
<p class="config-description">Providing your Amazon session cookie allows the app to access richer book metadata and bypass rate limits.</p>
<input <input
type="text" type="text"
pInputText pInputText
placeholder="Paste your Amazon cookie" [placeholder]="t('hardcoverPlaceholder')"
[(ngModel)]="amazonCookie" [(ngModel)]="hardcoverToken"
(ngModelChange)="onTokenChange($event)"
class="config-input"/> class="config-input"/>
</div> </div>
</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> </div>
@if (googleEnabled) {
<div class="setting-options"> <div class="setting-item">
<div class="config-field"> <div class="setting-header">
<label class="config-label">Language Restriction</label> <p-toggleswitch [(ngModel)]="comicvineEnabled"></p-toggleswitch>
<p-select <label class="setting-label">Comic Vine</label>
[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> </div>
} @if (comicvineEnabled) {
</div> <div class="setting-options">
<div class="config-field">
<div class="setting-item"> <label class="config-label">{{ t('apiToken') }}</label>
<div class="setting-header"> <input
<p-toggleswitch type="text"
[(ngModel)]="hardcoverEnabled" pInputText
[disabled]="!hardcoverToken"> [placeholder]="t('comicvinePlaceholder')"
</p-toggleswitch> [(ngModel)]="comicvineToken"
<label class="setting-label">Hardcover</label> (ngModelChange)="onComicTokenChange($event)"
</div> class="config-input"/>
<div class="setting-options"> </div>
<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>
</div> </div>
<input }
type="text"
pInputText
placeholder="Enter Hardcover API token"
[(ngModel)]="hardcoverToken"
(ngModelChange)="onTokenChange($event)"
class="config-input"/>
</div>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch [(ngModel)]="comicvineEnabled"></p-toggleswitch> <p-toggleswitch [(ngModel)]="audibleEnabled"></p-toggleswitch>
<label class="setting-label">Comic Vine</label> <label class="setting-label">Audible</label>
</div> </div>
@if (comicvineEnabled) { @if (audibleEnabled) {
<div class="setting-options"> <div class="setting-options">
<div class="config-field"> <div class="config-field">
<label class="config-label">API Token</label> <label class="config-label">{{ t('region') }}</label>
<input <p-select
type="text" [options]="audibleDomains"
pInputText [(ngModel)]="selectedAudibleDomain"
placeholder="Enter Comic Vine API token" [placeholder]="t('selectDomain')"
[(ngModel)]="comicvineToken" class="config-select">
(ngModelChange)="onComicTokenChange($event)" </p-select>
class="config-input"/> </div>
</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> </div>
</div>
<div class="setting-actions"> <div class="simple-providers-section">
<p-button label="Save Configurations" icon="pi pi-save" severity="success" [outlined]="true" (click)="saveSettings()"></p-button> <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>
</div> </div>
</div> </ng-container>
@@ -11,6 +11,7 @@ import {AppSettingKey} from '../../../../shared/model/app-settings.model';
import {Select} from 'primeng/select'; import {Select} from 'primeng/select';
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
import { ToggleSwitchModule } from 'primeng/toggleswitch'; import { ToggleSwitchModule } from 'primeng/toggleswitch';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-provider-settings', selector: 'app-metadata-provider-settings',
@@ -22,7 +23,8 @@ import { ToggleSwitchModule } from 'primeng/toggleswitch';
FormsModule, FormsModule,
Select, Select,
ExternalDocLinkComponent, ExternalDocLinkComponent,
ToggleSwitchModule ToggleSwitchModule,
TranslocoDirective
], ],
templateUrl: './metadata-provider-settings.component.html', templateUrl: './metadata-provider-settings.component.html',
styleUrl: './metadata-provider-settings.component.scss' styleUrl: './metadata-provider-settings.component.scss'
@@ -100,6 +102,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private destroyRef = inject(DestroyRef); private destroyRef = inject(DestroyRef);
private t = inject(TranslocoService);
private appSettings$ = this.appSettingsService.appSettings$; private appSettings$ = this.appSettingsService.appSettings$;
@@ -180,14 +183,14 @@ export class MetadataProviderSettingsComponent implements OnInit {
next: () => next: () =>
this.messageService.add({ this.messageService.add({
severity: 'success', severity: 'success',
summary: 'Saved', summary: this.t.translate('common.success'),
detail: 'Metadata provider settings saved.' detail: this.t.translate('settingsMeta.providers.saveSuccess')
}), }),
error: () => error: () =>
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Error', summary: this.t.translate('common.error'),
detail: 'Failed to save metadata provider settings.' detail: this.t.translate('settingsMeta.providers.saveError')
}) })
}); });
} }
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsLibMeta'">
<div class="main-container"> <div class="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-database"></i> <i class="pi pi-database"></i>
Library Metadata Configuration {{ t('title') }}
<app-external-doc-link docType="fetchConfig"></app-external-doc-link> <app-external-doc-link docType="fetchConfig"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <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> </p>
</div> </div>
@@ -15,22 +16,17 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
Default Metadata Settings {{ t('defaultSettings.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Set global default provider priorities for book metadata fields. These settings apply to all libraries unless overridden below. {{ t('defaultSettings.sectionDesc') }}
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.
</p> </p>
</div> </div>
<div class="settings-card"> <div class="settings-card">
<app-metadata-advanced-fetch-options <app-metadata-advanced-fetch-options
[currentMetadataOptions]="defaultMetadataOptions" [currentMetadataOptions]="defaultMetadataOptions"
[submitButtonLabel]="'Save Default Settings'" [submitButtonLabel]="t('defaultSettings.saveButton')"
(metadataOptionsSubmitted)="onDefaultMetadataOptionsSubmitted($event)"> (metadataOptionsSubmitted)="onDefaultMetadataOptionsSubmitted($event)">
</app-metadata-advanced-fetch-options> </app-metadata-advanced-fetch-options>
</div> </div>
@@ -40,11 +36,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-book"></i> <i class="pi pi-book"></i>
Library-Specific Overrides {{ t('libraryOverrides.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <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. {{ t('libraryOverrides.sectionDesc') }}
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.
</p> </p>
</div> </div>
@@ -62,36 +57,36 @@
@if (hasLibraryOverride(library.id!)) { @if (hasLibraryOverride(library.id!)) {
<span class="override-indicator custom"> <span class="override-indicator custom">
<i class="pi pi-check-circle"></i> <i class="pi pi-check-circle"></i>
Custom Settings {{ t('libraryOverrides.customSettings') }}
</span> </span>
} @else { } @else {
<span class="default-indicator default"> <span class="default-indicator default">
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
Default Settings {{ t('libraryOverrides.defaultSettings') }}
</span> </span>
} }
</div> </div>
<div class="sidecar-actions"> <div class="sidecar-actions">
<p-button <p-button
icon="pi pi-upload" icon="pi pi-upload"
label="Export Sidecar" [label]="t('libraryOverrides.exportSidecar')"
size="small" size="small"
severity="secondary" severity="secondary"
[outlined]="true" [outlined]="true"
[loading]="isSidecarExporting(library.id!)" [loading]="isSidecarExporting(library.id!)"
(onClick)="exportSidecarForLibrary(library.id!, $event)" (onClick)="exportSidecarForLibrary(library.id!, $event)"
pTooltip="Generate .metadata.json files for all books in this library" [pTooltip]="t('libraryOverrides.exportTooltip')"
tooltipPosition="top" tooltipPosition="top"
/> />
<p-button <p-button
icon="pi pi-download" icon="pi pi-download"
label="Import Sidecar" [label]="t('libraryOverrides.importSidecar')"
size="small" size="small"
severity="secondary" severity="secondary"
[outlined]="true" [outlined]="true"
[loading]="isSidecarImporting(library.id!)" [loading]="isSidecarImporting(library.id!)"
(onClick)="importSidecarForLibrary(library.id!, $event)" (onClick)="importSidecarForLibrary(library.id!, $event)"
pTooltip="Import metadata from existing .metadata.json files in this library" [pTooltip]="t('libraryOverrides.importTooltip')"
tooltipPosition="top" tooltipPosition="top"
/> />
</div> </div>
@@ -102,7 +97,7 @@
@if (activePanel === i) { @if (activePanel === i) {
<app-metadata-advanced-fetch-options <app-metadata-advanced-fetch-options
[currentMetadataOptions]="getLibraryOptions(library.id!)" [currentMetadataOptions]="getLibraryOptions(library.id!)"
[submitButtonLabel]="'Save ' + library.name + ' Settings'" [submitButtonLabel]="t('libraryOverrides.saveLibraryButton', {name: library.name})"
(metadataOptionsSubmitted)="onLibraryMetadataOptionsSubmitted(library.id!, $event)"> (metadataOptionsSubmitted)="onLibraryMetadataOptionsSubmitted(library.id!, $event)">
</app-metadata-advanced-fetch-options> </app-metadata-advanced-fetch-options>
} }
@@ -116,3 +111,4 @@
</div> </div>
</div> </div>
</div> </div>
</ng-container>
@@ -7,6 +7,7 @@ import {AccordionModule} from 'primeng/accordion';
import {MessageService} from 'primeng/api'; import {MessageService} from 'primeng/api';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {Library} from '../../book/model/library.model'; import {Library} from '../../book/model/library.model';
import {LibraryService} from '../../book/service/library.service'; import {LibraryService} from '../../book/service/library.service';
@@ -20,7 +21,7 @@ import {SidecarService} from '../../metadata/service/sidecar.service';
@Component({ @Component({
selector: 'app-library-metadata-settings-component', selector: 'app-library-metadata-settings-component',
standalone: true, 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', templateUrl: './library-metadata-settings.component.html',
styleUrls: ['./library-metadata-settings.component.scss'] styleUrls: ['./library-metadata-settings.component.scss']
}) })
@@ -29,6 +30,7 @@ export class LibraryMetadataSettingsComponent implements OnInit {
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private messageService = inject(MessageService); private messageService = inject(MessageService);
private sidecarService = inject(SidecarService); private sidecarService = inject(SidecarService);
private t = inject(TranslocoService);
libraries$: Observable<Library[]> = this.libraryService.libraryState$.pipe( libraries$: Observable<Library[]> = this.libraryService.libraryState$.pipe(
map(state => state.libraries || []) map(state => state.libraries || [])
@@ -105,12 +107,12 @@ export class LibraryMetadataSettingsComponent implements OnInit {
this.appSettingsService.saveSettings(settingsToSave).subscribe({ this.appSettingsService.saveSettings(settingsToSave).subscribe({
next: () => { 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(); this.updateLibrariesUsingDefaults();
}, },
error: (error) => { error: (error) => {
console.error('Error saving default metadata options:', 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({ this.appSettingsService.saveSettings(settingsToSave).subscribe({
next: () => { 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) => { error: (error) => {
console.error('Error saving library metadata options:', 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({ this.sidecarService.bulkExport(libraryId).subscribe({
next: (response) => { next: (response) => {
this.sidecarExporting[libraryId] = false; 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) => { error: (error) => {
this.sidecarExporting[libraryId] = false; this.sidecarExporting[libraryId] = false;
console.error('Bulk sidecar export failed:', error); 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({ this.sidecarService.bulkImport(libraryId).subscribe({
next: (response) => { next: (response) => {
this.sidecarImporting[libraryId] = false; 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) => { error: (error) => {
this.sidecarImporting[libraryId] = false; this.sidecarImporting[libraryId] = false;
console.error('Bulk sidecar import failed:', error); 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"> <ng-container *transloco="let t; prefix: 'settingsMeta.persistence'">
<div class="section-header"> <div class="settings-card">
<h3 class="section-title"> <div class="section-header">
<i class="pi pi-save"></i> <h3 class="section-title">
Metadata Persistence <i class="pi pi-save"></i>
</h3> {{ t('sectionTitle') }}
<p class="section-description"> </h3>
Configure how metadata is written to original files and how files are moved or renamed when metadata changes. <p class="section-description">
</p> {{ t('sectionDesc') }}
</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>
</p> </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>
<div class="setting-item"> <div class="section-notice">
<div class="setting-header"> <div class="warning-notice">
<p-toggleswitch <i class="pi pi-exclamation-triangle"></i>
[ngModel]="metadataPersistence.saveToOriginalFile.audiobook.enabled" <div>
(onChange)="onSaveToOriginalFileToggle('audiobook')"> <strong>{{ t('networkWarningTitle') }}</strong> {{ t('networkWarning') }}
</p-toggleswitch> </div>
<label class="setting-label">Write Metadata to Audiobooks</label>
</div> </div>
<p class="setting-description"> <div class="info-notice unsupported-formats-note">
Write metadata directly into audiobook files (M4B, M4A, MP3, etc.) when editing book information. <i class="pi pi-info-circle"></i>
<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> <div>
</p> <strong>Note:</strong> <span [innerHTML]="t('unsupportedNote')"></span>
@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> </div>
} </div>
</div> </div>
@if ((appSettings$ | async)?.diskType === 'LOCAL') { <div class="section-body">
<div class="setting-item"> <div class="setting-item">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch <p-toggleswitch
[ngModel]="metadataPersistence.moveFilesToLibraryPattern" [ngModel]="metadataPersistence.saveToOriginalFile.epub.enabled"
(onChange)="onPersistenceToggle('moveFilesToLibraryPattern')"> (onChange)="onSaveToOriginalFileToggle('epub')">
</p-toggleswitch> </p-toggleswitch>
<label class="setting-label">Auto-Move Files on Metadata Update</label> <label class="setting-label">{{ t('writeEpub') }}</label>
</div> </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>
<div class="section-header sidecar-section-header"> <div class="setting-item">
<h3 class="section-title"> <div class="setting-header">
<i class="pi pi-file"></i> <p-toggleswitch
Sidecar JSON Files [ngModel]="metadataPersistence.saveToOriginalFile.cbx.enabled"
</h3> (onChange)="onSaveToOriginalFileToggle('cbx')">
<p class="section-description"> </p-toggleswitch>
Create external .metadata.json files alongside your books for portable metadata storage and backup. <label class="setting-label">{{ t('writeCbx') }}</label>
</p> </div>
</div> <p class="setting-description">{{ t('writeCbxDesc') }}</p>
@if (metadataPersistence.saveToOriginalFile.cbx.enabled) {
<div class="section-body"> <div class="setting-options">
<div class="setting-item"> <div class="filesize-input">
<div class="setting-header"> <label>{{ t('maxFileSize') }}</label>
<p-toggleswitch <input
[ngModel]="metadataPersistence.sidecarSettings?.enabled" type="number"
(onChange)="onSidecarToggle('enabled')"> [(ngModel)]="metadataPersistence.saveToOriginalFile.cbx.maxFileSizeInMb"
</p-toggleswitch> (change)="onFilesizeChange('cbx')"
<label class="setting-label">Enable Sidecar JSON</label> 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>
<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> </div>
@if (metadataPersistence.sidecarSettings?.enabled) { <div class="section-header sidecar-section-header">
<div class="setting-item nested-setting"> <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"> <div class="setting-header">
<p-toggleswitch <p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.writeOnUpdate" [ngModel]="metadataPersistence.sidecarSettings?.enabled"
(onChange)="onSidecarToggle('writeOnUpdate')"> (onChange)="onSidecarToggle('enabled')">
</p-toggleswitch> </p-toggleswitch>
<label class="setting-label">Write on Metadata Update</label> <label class="setting-label">{{ t('enableSidecar') }}</label>
</div> </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>
<div class="setting-item nested-setting"> @if (metadataPersistence.sidecarSettings?.enabled) {
<div class="setting-header"> <div class="setting-item nested-setting">
<p-toggleswitch <div class="setting-header">
[ngModel]="metadataPersistence.sidecarSettings?.writeOnScan" <p-toggleswitch
(onChange)="onSidecarToggle('writeOnScan')"> [ngModel]="metadataPersistence.sidecarSettings?.writeOnUpdate"
</p-toggleswitch> (onChange)="onSidecarToggle('writeOnUpdate')">
<label class="setting-label">Write on Initial Scan</label> </p-toggleswitch>
<label class="setting-label">{{ t('writeOnUpdate') }}</label>
</div>
<p class="setting-description">{{ t('writeOnUpdateDesc') }}</p>
</div> </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-item nested-setting">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch <p-toggleswitch
[ngModel]="metadataPersistence.sidecarSettings?.includeCoverFile" [ngModel]="metadataPersistence.sidecarSettings?.writeOnScan"
(onChange)="onSidecarToggle('includeCoverFile')"> (onChange)="onSidecarToggle('writeOnScan')">
</p-toggleswitch> </p-toggleswitch>
<label class="setting-label">Include Cover Image File</label> <label class="setting-label">{{ t('writeOnScan') }}</label>
</div>
<p class="setting-description">{{ t('writeOnScanDesc') }}</p>
</div> </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>
</div> </ng-container>
@@ -8,6 +8,7 @@ import {Observable} from 'rxjs';
import {filter, take} from 'rxjs/operators'; import {filter, take} from 'rxjs/operators';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
import {AsyncPipe} from '@angular/common'; import {AsyncPipe} from '@angular/common';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-persistence-settings-component', selector: 'app-metadata-persistence-settings-component',
@@ -15,7 +16,8 @@ import {AsyncPipe} from '@angular/common';
ToggleSwitch, ToggleSwitch,
FormsModule, FormsModule,
Tooltip, Tooltip,
AsyncPipe AsyncPipe,
TranslocoDirective
], ],
templateUrl: './metadata-persistence-settings-component.html', templateUrl: './metadata-persistence-settings-component.html',
styleUrl: './metadata-persistence-settings-component.scss' styleUrl: './metadata-persistence-settings-component.scss'
@@ -53,6 +55,7 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService); private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService); private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -92,7 +95,7 @@ export class MetadataPersistenceSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings), next: (settings) => this.initializeSettings(settings),
error: (error) => { error: (error) => {
console.error('Failed to load settings:', 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"> <ng-container *transloco="let t; prefix: 'settingsMeta'">
<div class="settings-header"> <div class="metadata-settings-container">
<h2 class="settings-title"> <div class="settings-header">
<i class="pi pi-tags"></i> <h2 class="settings-title">
Metadata Settings <i class="pi pi-tags"></i>
</h2> {{ t('title') }}
<p class="settings-description"> </h2>
Configure how metadata is retrieved, stored, and matched for your books, including provider settings and field preferences. <p class="settings-description">
</p> {{ t('description') }}
</div> </p>
</div>
<app-metadata-persistence-settings-component></app-metadata-persistence-settings-component> <app-metadata-persistence-settings-component></app-metadata-persistence-settings-component>
<div class="section-divider"><hr></div> <div class="section-divider"><hr></div>
<div class="preferences-section"> <div class="preferences-section">
<div class="settings-card"> <div class="settings-card">
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-download"></i> <i class="pi pi-download"></i>
Automatic Metadata Download {{ t('autoDownload.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
<i class="pi pi-exclamation-triangle"></i> <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> <span>{{ t('autoDownload.warning') }}</span>
</p> </p>
</div> </div>
<div class="section-body"> <div class="section-body">
<div class="setting-item"> <div class="setting-item">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch <p-toggleswitch
[(ngModel)]="metadataDownloadOnBookdrop" [(ngModel)]="metadataDownloadOnBookdrop"
(onChange)="onMetadataDownloadOnBookdropToggle($event.checked)"> (onChange)="onMetadataDownloadOnBookdropToggle($event.checked)">
</p-toggleswitch> </p-toggleswitch>
<label class="setting-label">Enable automatic metadata download for Bookdrop imports</label> <label class="setting-label">{{ t('autoDownload.enableLabel') }}</label>
</div>
</div> </div>
</div> </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> </div>
<app-metadata-provider-settings></app-metadata-provider-settings> </ng-container>
<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>
@@ -12,6 +12,7 @@ import {MetadataMatchWeightsComponent} from '../global-preferences/metadata-matc
import {MetadataPersistenceSettingsComponent} from './metadata-persistence-settings/metadata-persistence-settings-component'; import {MetadataPersistenceSettingsComponent} from './metadata-persistence-settings/metadata-persistence-settings-component';
import {PublicReviewsSettingsComponent} from './public-reviews-settings/public-reviews-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 {MetadataProviderFieldSelectorComponent} from '../../metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-metadata-settings-component', selector: 'app-metadata-settings-component',
@@ -24,7 +25,8 @@ import {MetadataProviderFieldSelectorComponent} from '../../metadata/component/m
ToggleSwitch, ToggleSwitch,
MetadataPersistenceSettingsComponent, MetadataPersistenceSettingsComponent,
PublicReviewsSettingsComponent, PublicReviewsSettingsComponent,
MetadataProviderFieldSelectorComponent MetadataProviderFieldSelectorComponent,
TranslocoDirective
], ],
templateUrl: './metadata-settings-component.html', templateUrl: './metadata-settings-component.html',
styleUrl: './metadata-settings-component.scss' styleUrl: './metadata-settings-component.scss'
@@ -36,6 +38,7 @@ export class MetadataSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService); private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService); private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -61,7 +64,7 @@ export class MetadataSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings), next: (settings) => this.initializeSettings(settings),
error: (error) => { error: (error) => {
console.error('Failed to load settings:', 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"> <ng-container *transloco="let t; prefix: 'settingsMeta.publicReviews'">
<div class="section-header"> <div class="settings-card">
<h3 class="section-title"> <div class="section-header">
<i class="pi pi-star"></i> <h3 class="section-title">
Public Reviews <i class="pi pi-star"></i>
</h3> {{ t('sectionTitle') }}
<p class="section-description"> </h3>
Configure automatic downloading of user reviews from external platforms. Reviews can be fetched from Amazon, Goodreads, and Hardcover for offline access. <p class="section-description">
</p> {{ t('sectionDesc') }}
</div> </p>
<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>
</div> </div>
@if (publicReviewSettings.downloadEnabled) { <div class="section-body">
<div class="setting-item"> <div class="setting-item">
<div class="setting-header"> <div class="setting-header">
<p-toggleswitch <p-toggleswitch
[(ngModel)]="publicReviewSettings.autoDownloadEnabled" [(ngModel)]="publicReviewSettings.downloadEnabled"
(onChange)="onAutoDownloadToggle($event.checked)"> (onChange)="onPublicReviewsToggle($event.checked)">
</p-toggleswitch> </p-toggleswitch>
<label class="setting-label">Auto Download on Book Open</label> <label class="setting-label">{{ t('downloadLabel') }}</label>
</div> </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>
<div class="setting-item"> @if (publicReviewSettings.downloadEnabled) {
<div class="setting-header-standalone"> <div class="setting-item">
<label class="setting-label">Review Sources</label> <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> </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-item">
<div class="setting-options"> <div class="setting-header-standalone">
<div class="providers-grid"> <label class="setting-label">{{ t('reviewSources') }}</label>
@for (provider of publicReviewSettings.providers; track provider.provider) { </div>
<div class="provider-item"> <p class="setting-description">{{ t('reviewSourcesDesc') }}</p>
<div class="provider-row"> @if (publicReviewSettings.providers.length > 0) {
<p-toggleswitch <div class="setting-options">
[(ngModel)]="provider.enabled" <div class="providers-grid">
(onChange)="onProviderToggle(provider.provider, $event.checked)"> @for (provider of publicReviewSettings.providers; track provider.provider) {
</p-toggleswitch> <div class="provider-item">
<label class="provider-label">{{ provider.provider }}</label> <div class="provider-row">
</div> <p-toggleswitch
@if (provider.enabled) { [(ngModel)]="provider.enabled"
<div class="max-reviews-control"> (onChange)="onProviderToggle(provider.provider, $event.checked)">
<label class="max-reviews-label">Max:</label> </p-toggleswitch>
<input <label class="provider-label">{{ provider.provider }}</label>
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> </div>
} @if (provider.enabled) {
</div> <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>
</div> } @else {
} @else { <div class="no-providers-message">
<div class="no-providers-message"> <i class="pi pi-exclamation-triangle"></i>
<i class="pi pi-exclamation-triangle"></i> <span>{{ t('noProviders') }}</span>
<span>No review sources available. Please ensure metadata providers are configured in the Provider Settings section above.</span> </div>
</div> }
} </div>
</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 {SettingsHelperService} from '../../../../shared/service/settings-helper.service';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {filter, take} from 'rxjs/operators'; import {filter, take} from 'rxjs/operators';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
const DEFAULT_PROVIDERS: readonly ReviewProviderConfig[] = [ const DEFAULT_PROVIDERS: readonly ReviewProviderConfig[] = [
{provider: 'Amazon', enabled: true, maxReviews: 5}, {provider: 'Amazon', enabled: true, maxReviews: 5},
@@ -17,7 +18,7 @@ const REQUIRED_PROVIDERS = ['Amazon', 'GoodReads', 'Douban'] as const;
@Component({ @Component({
selector: 'app-public-reviews-settings-component', selector: 'app-public-reviews-settings-component',
imports: [FormsModule, ToggleSwitch], imports: [FormsModule, ToggleSwitch, TranslocoDirective],
templateUrl: './public-reviews-settings-component.html', templateUrl: './public-reviews-settings-component.html',
styleUrl: './public-reviews-settings-component.scss' styleUrl: './public-reviews-settings-component.scss'
}) })
@@ -31,6 +32,7 @@ export class PublicReviewsSettingsComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService); private readonly appSettingsService = inject(AppSettingsService);
private readonly settingsHelper = inject(SettingsHelperService); private readonly settingsHelper = inject(SettingsHelperService);
private t = inject(TranslocoService);
readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$; readonly appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
@@ -64,7 +66,7 @@ export class PublicReviewsSettingsComponent implements OnInit {
next: (settings) => this.initializeSettings(settings), next: (settings) => this.initializeSettings(settings),
error: (error) => { error: (error) => {
console.error('Failed to load settings:', 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="main-container">
<div class="settings-header"> <div class="settings-header">
<h2 class="settings-title"> <h2 class="settings-title">
<i class="pi pi-server"></i> <i class="pi pi-server"></i>
OPDS Configuration {{ t('title') }}
<app-external-doc-link docType="opds"></app-external-doc-link> <app-external-doc-link docType="opds"></app-external-doc-link>
</h2> </h2>
<p class="settings-description"> <p class="settings-description">
Manage your OPDS credentials and control how your book collection is shared with reading apps. {{ t('description') }}
By default, all libraries you have access to will be included in the OPDS feed.
</p> </p>
</div> </div>
@@ -16,10 +16,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-sliders-h"></i> <i class="pi pi-sliders-h"></i>
Server Settings {{ t('server.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Enable or disable OPDS and Komga API services to control access to your book collection. {{ t('server.sectionDesc') }}
</p> </p>
</div> </div>
@@ -32,14 +32,14 @@
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
</div> </div>
<div class="toggle-info"> <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"> <span class="toggle-status" [class.active]="opdsEnabled">
{{ opdsEnabled ? 'Enabled' : 'Disabled' }} {{ opdsEnabled ? t('server.enabled') : t('server.disabled') }}
</span> </span>
</div> </div>
</div> </div>
<p class="toggle-description"> <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> </p>
</div> </div>
<p-toggleswitch <p-toggleswitch
@@ -55,14 +55,14 @@
<i class="pi pi-box"></i> <i class="pi pi-box"></i>
</div> </div>
<div class="toggle-info"> <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"> <span class="toggle-status" [class.active]="komgaApiEnabled">
{{ komgaApiEnabled ? 'Enabled' : 'Disabled' }} {{ komgaApiEnabled ? t('server.enabled') : t('server.disabled') }}
</span> </span>
</div> </div>
</div> </div>
<p class="toggle-description"> <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> </p>
</div> </div>
<p-toggleswitch <p-toggleswitch
@@ -79,14 +79,14 @@
<i class="pi pi-folder"></i> <i class="pi pi-folder"></i>
</div> </div>
<div class="toggle-info"> <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"> <span class="toggle-status" [class.active]="komgaGroupUnknown">
{{ komgaGroupUnknown ? 'Grouped' : 'Individual' }} {{ komgaGroupUnknown ? t('server.grouped') : t('server.individual') }}
</span> </span>
</div> </div>
</div> </div>
<p class="toggle-description"> <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> </p>
</div> </div>
<p-toggleswitch <p-toggleswitch
@@ -104,10 +104,10 @@
<div class="section-header"> <div class="section-header">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-link"></i> <i class="pi pi-link"></i>
API Endpoints {{ t('endpoints.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Use these URLs to connect your reading apps to Booklore. {{ t('endpoints.sectionDesc') }}
</p> </p>
</div> </div>
@@ -120,8 +120,8 @@
<i class="pi pi-globe"></i> <i class="pi pi-globe"></i>
</div> </div>
<div class="endpoint-info"> <div class="endpoint-info">
<span class="endpoint-label">OPDS Catalog URL</span> <span class="endpoint-label">{{ t('endpoints.opdsCatalog') }}</span>
<span class="endpoint-hint">For OPDS-compatible apps</span> <span class="endpoint-hint">{{ t('endpoints.opdsHint') }}</span>
</div> </div>
</div> </div>
<div class="endpoint-url-row"> <div class="endpoint-url-row">
@@ -138,7 +138,7 @@
[outlined]="true" [outlined]="true"
size="small" size="small"
(onClick)="copyEndpoint()" (onClick)="copyEndpoint()"
pTooltip="Copy URL"> [pTooltip]="t('endpoints.copyUrl')">
</p-button> </p-button>
</div> </div>
</div> </div>
@@ -151,8 +151,8 @@
<i class="pi pi-box"></i> <i class="pi pi-box"></i>
</div> </div>
<div class="endpoint-info"> <div class="endpoint-info">
<span class="endpoint-label">Komga Base URL</span> <span class="endpoint-label">{{ t('endpoints.komgaBase') }}</span>
<span class="endpoint-hint">For Tachiyomi, Komelia, etc.</span> <span class="endpoint-hint">{{ t('endpoints.komgaHint') }}</span>
</div> </div>
</div> </div>
<div class="endpoint-url-row"> <div class="endpoint-url-row">
@@ -169,7 +169,7 @@
[outlined]="true" [outlined]="true"
size="small" size="small"
(onClick)="copyKomgaEndpoint()" (onClick)="copyKomgaEndpoint()"
pTooltip="Copy URL"> [pTooltip]="t('endpoints.copyUrl')">
</p-button> </p-button>
</div> </div>
</div> </div>
@@ -186,15 +186,15 @@
<div class="section-header-text"> <div class="section-header-text">
<h3 class="section-title"> <h3 class="section-title">
<i class="pi pi-users"></i> <i class="pi pi-users"></i>
OPDS Users {{ t('users.sectionTitle') }}
</h3> </h3>
<p class="section-description"> <p class="section-description">
Manage user accounts for OPDS and Komga API access. These are separate from Booklore user accounts. {{ t('users.sectionDesc') }}
</p> </p>
</div> </div>
<p-button <p-button
icon="pi pi-plus" icon="pi pi-plus"
label="Add User" [label]="t('users.addUser')"
severity="success" severity="success"
size="small" size="small"
[outlined]="true" [outlined]="true"
@@ -207,8 +207,8 @@
@if (users.length === 0) { @if (users.length === 0) {
<div class="empty-state"> <div class="empty-state">
<i class="pi pi-users"></i> <i class="pi pi-users"></i>
<p class="empty-title">No users found</p> <p class="empty-title">{{ t('users.emptyTitle') }}</p>
<p class="empty-subtitle">Create your first OPDS user to get started</p> <p class="empty-subtitle">{{ t('users.emptySubtitle') }}</p>
</div> </div>
} @else { } @else {
<div class="users-list"> <div class="users-list">
@@ -231,6 +231,12 @@
[style]="{width: '160px'}" [style]="{width: '160px'}"
size="small" size="small"
[appendTo]="'body'"> [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> </p-select>
} @else { } @else {
<span class="sort-order-badge">{{ getSortOrderLabel(user.sortOrder) }}</span> <span class="sort-order-badge">{{ getSortOrderLabel(user.sortOrder) }}</span>
@@ -247,7 +253,7 @@
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="saveSortOrder(user)" (onClick)="saveSortOrder(user)"
pTooltip="Save"> [pTooltip]="'common.save' | transloco">
</p-button> </p-button>
<p-button <p-button
icon="pi pi-times" icon="pi pi-times"
@@ -256,7 +262,7 @@
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="cancelEdit()" (onClick)="cancelEdit()"
pTooltip="Cancel"> [pTooltip]="'common.cancel' | transloco">
</p-button> </p-button>
} @else { } @else {
<p-button <p-button
@@ -266,7 +272,7 @@
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="startEdit(user)" (onClick)="startEdit(user)"
pTooltip="Edit sort order"> [pTooltip]="t('users.editSortOrder')">
</p-button> </p-button>
<p-button <p-button
icon="pi pi-trash" icon="pi pi-trash"
@@ -275,7 +281,7 @@
[outlined]="true" [outlined]="true"
[rounded]="true" [rounded]="true"
(onClick)="confirmDelete(user)" (onClick)="confirmDelete(user)"
pTooltip="Delete user"> [pTooltip]="t('users.deleteUser')">
</p-button> </p-button>
} }
</div> </div>
@@ -288,32 +294,32 @@
} }
<p-dialog <p-dialog
header="Create OPDS User" [header]="t('createDialog.title')"
[(visible)]="showCreateUserDialog" [(visible)]="showCreateUserDialog"
[modal]="true" [modal]="true"
class="user-dialog" class="user-dialog"
[style]="{width: '400px'}"> [style]="{width: '400px'}">
<div class="dialog-form"> <div class="dialog-form">
<div class="form-field"> <div class="form-field">
<label for="username">Username</label> <label for="username">{{ t('createDialog.username') }}</label>
<input <input
id="username" id="username"
type="text" type="text"
pInputText pInputText
[(ngModel)]="newUser.username" [(ngModel)]="newUser.username"
placeholder="Enter username"/> [placeholder]="t('createDialog.enterUsername')"/>
</div> </div>
<div class="form-field"> <div class="form-field">
<label for="password">Password</label> <label for="password">{{ t('createDialog.password') }}</label>
<input <input
id="password" id="password"
type="password" type="password"
pInputText pInputText
[(ngModel)]="newUser.password" [(ngModel)]="newUser.password"
placeholder="Enter password"/> [placeholder]="t('createDialog.enterPassword')"/>
</div> </div>
<div class="form-field"> <div class="form-field">
<label for="sortOrder">Default Sort Order</label> <label for="sortOrder">{{ t('createDialog.sortOrder') }}</label>
<p-select <p-select
id="sortOrder" id="sortOrder"
[options]="sortOrderOptions" [options]="sortOrderOptions"
@@ -321,25 +327,31 @@
optionLabel="label" optionLabel="label"
optionValue="value" optionValue="value"
[style]="{width: '100%'}" [style]="{width: '100%'}"
placeholder="Select sort order" [placeholder]="t('createDialog.selectSortOrder')"
[appendTo]="'body'"> [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> </p-select>
<small class="form-hint"> <small class="form-hint">
<i class="pi pi-info-circle"></i> <i class="pi pi-info-circle"></i>
This will determine how books appear in the OPDS feed for this user {{ t('createDialog.sortHint') }}
</small> </small>
</div> </div>
</div> </div>
<ng-template pTemplate="footer"> <ng-template pTemplate="footer">
<div class="dialog-actions"> <div class="dialog-actions">
<p-button <p-button
label="Cancel" [label]="'common.cancel' | transloco"
severity="secondary" severity="secondary"
outlined="true" outlined="true"
(onClick)="cancelCreateUser()"> (onClick)="cancelCreateUser()">
</p-button> </p-button>
<p-button <p-button
label="Create" [label]="t('createDialog.create')"
severity="success" severity="success"
[disabled]="!newUser.username || !newUser.password" [disabled]="!newUser.username || !newUser.password"
(onClick)="createUser()"> (onClick)="createUser()">
@@ -353,13 +365,14 @@
<div class="access-denied-card"> <div class="access-denied-card">
<i class="pi pi-lock"></i> <i class="pi pi-lock"></i>
<div class="access-denied-content"> <div class="access-denied-content">
<h3>Access Restricted</h3> <h3>{{ t('accessRestricted') }}</h3>
<p> <p>
Access to OPDS is restricted. {{ t('accessDenied') }}
<br> <br>
Please contact your administrator to request permission. {{ t('contactAdmin') }}
</p> </p>
</div> </div>
</div> </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 {AppSettingKey} from '../../../shared/model/app-settings.model';
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component'; import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
import {Select} from 'primeng/select'; import {Select} from 'primeng/select';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({ @Component({
selector: 'app-opds-settings', selector: 'app-opds-settings',
@@ -31,7 +32,9 @@ import {Select} from 'primeng/select';
TableModule, TableModule,
ToggleSwitch, ToggleSwitch,
ExternalDocLinkComponent, ExternalDocLinkComponent,
Select Select,
TranslocoDirective,
TranslocoPipe
], ],
providers: [ConfirmationService], providers: [ConfirmationService],
templateUrl: './opds-settings.html', templateUrl: './opds-settings.html',
@@ -50,6 +53,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
private messageService = inject(MessageService); private messageService = inject(MessageService);
private userService = inject(UserService); private userService = inject(UserService);
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
private t = inject(TranslocoService);
users: OpdsUserV2[] = []; users: OpdsUserV2[] = [];
loading = false; loading = false;
@@ -65,15 +69,15 @@ export class OpdsSettings implements OnInit, OnDestroy {
dummyPassword: string = "***********************"; dummyPassword: string = "***********************";
sortOrderOptions = [ sortOrderOptions = [
{label: 'Recently Added', value: 'RECENT' as OpdsSortOrder}, {label: 'Recently Added', value: 'RECENT' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.recent'},
{label: 'Title (A-Z)', value: 'TITLE_ASC' as OpdsSortOrder}, {label: 'Title (A-Z)', value: 'TITLE_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleAsc'},
{label: 'Title (Z-A)', value: 'TITLE_DESC' as OpdsSortOrder}, {label: 'Title (Z-A)', value: 'TITLE_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.titleDesc'},
{label: 'Author (A-Z)', value: 'AUTHOR_ASC' as OpdsSortOrder}, {label: 'Author (A-Z)', value: 'AUTHOR_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorAsc'},
{label: 'Author (Z-A)', value: 'AUTHOR_DESC' as OpdsSortOrder}, {label: 'Author (Z-A)', value: 'AUTHOR_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.authorDesc'},
{label: 'Series (A-Z)', value: 'SERIES_ASC' as OpdsSortOrder}, {label: 'Series (A-Z)', value: 'SERIES_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesAsc'},
{label: 'Series (Z-A)', value: 'SERIES_DESC' as OpdsSortOrder}, {label: 'Series (Z-A)', value: 'SERIES_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.seriesDesc'},
{label: 'Rating (Low to High)', value: 'RATING_ASC' as OpdsSortOrder}, {label: 'Rating (Low to High)', value: 'RATING_ASC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingAsc'},
{label: 'Rating (High to Low)', value: 'RATING_DESC' as OpdsSortOrder} {label: 'Rating (High to Low)', value: 'RATING_DESC' as OpdsSortOrder, translationKey: 'settingsOpds.sortOrders.ratingDesc'}
]; ];
ngOnInit(): void { ngOnInit(): void {
@@ -118,7 +122,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$), takeUntil(this.destroy$),
catchError(err => { catchError(err => {
console.error('Error loading users:', 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([]); return of([]);
}) })
).subscribe(users => { ).subscribe(users => {
@@ -137,20 +141,20 @@ export class OpdsSettings implements OnInit, OnDestroy {
next: user => { next: user => {
this.users.push(user); this.users.push(user);
this.resetCreateUserDialog(); this.resetCreateUserDialog();
this.showMessage('success', 'Success', 'User created successfully'); this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsOpds.createSuccess'));
}, },
error: err => { error: err => {
console.error('Error creating user:', err); console.error('Error creating user:', err);
const message = err?.error?.message || 'Failed to create user'; const message = err?.error?.message || this.t.translate('settingsOpds.createError');
this.showMessage('error', 'Error', message); this.showMessage('error', this.t.translate('common.error'), message);
} }
}); });
} }
confirmDelete(user: OpdsUserV2): void { confirmDelete(user: OpdsUserV2): void {
this.confirmationService.confirm({ this.confirmationService.confirm({
message: `Are you sure you want to delete user "${user.username}"?`, message: this.t.translate('settingsOpds.deleteConfirm', {username: user.username}),
header: 'Delete Confirmation', header: this.t.translate('settingsOpds.deleteHeader'),
icon: 'pi pi-exclamation-triangle', icon: 'pi pi-exclamation-triangle',
acceptButtonStyleClass: 'p-button-danger', acceptButtonStyleClass: 'p-button-danger',
accept: () => this.deleteUser(user) accept: () => this.deleteUser(user)
@@ -164,12 +168,12 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$), takeUntil(this.destroy$),
catchError(err => { catchError(err => {
console.error('Error deleting user:', 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); return of(null);
}) })
).subscribe(() => { ).subscribe(() => {
this.users = this.users.filter(u => u.id !== user.id); 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 { copyEndpoint(): void {
navigator.clipboard.writeText(this.opdsEndpoint).then(() => { 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 { copyKomgaEndpoint(): void {
navigator.clipboard.writeText(this.komgaEndpoint).then(() => { 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({ this.appSettingsService.saveSettings([{key: AppSettingKey.KOMGA_GROUP_UNKNOWN, newValue: this.komgaGroupUnknown}]).subscribe({
next: () => { next: () => {
const successMessage = (this.komgaGroupUnknown === true) const successMessage = (this.komgaGroupUnknown === true)
? 'Books without series will be grouped under "Unknown Series".' ? this.t.translate('settingsOpds.groupEnabled')
: 'Books without series will appear as individual series.'; : this.t.translate('settingsOpds.groupDisabled');
this.showMessage('success', 'Settings Saved', successMessage); this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
}, },
error: () => { 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({ this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () => { next: () => {
const successMessage = (value === true) const successMessage = (value === true)
? 'OPDS Server Enabled.' ? this.t.translate('settingsOpds.opdsEnabled')
: 'OPDS Server Disabled.'; : this.t.translate('settingsOpds.opdsDisabled');
this.showMessage('success', 'Settings Saved', successMessage); this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
}, },
error: () => { 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({ this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
next: () => { next: () => {
const successMessage = (value === true) const successMessage = (value === true)
? 'Komga API Enabled.' ? this.t.translate('settingsOpds.komgaEnabled')
: 'Komga API Disabled.'; : this.t.translate('settingsOpds.komgaDisabled');
this.showMessage('success', 'Settings Saved', successMessage); this.showMessage('success', this.t.translate('settingsOpds.settingsSaved'), successMessage);
}, },
error: () => { 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 { 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); 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 { startEdit(user: OpdsUserV2): void {
@@ -281,7 +285,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
takeUntil(this.destroy$), takeUntil(this.destroy$),
catchError(err => { catchError(err => {
console.error('Error updating sort order:', 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); return of(null);
}) })
).subscribe(updatedUser => { ).subscribe(updatedUser => {
@@ -290,7 +294,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
if (index !== -1) { if (index !== -1) {
this.users[index] = updatedUser; 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(); this.cancelEdit();
}); });
@@ -1,123 +1,125 @@
<div class="cbx-preferences-container"> <ng-container *transloco="let t; prefix: 'settingsReader.cbx'">
<div class="setting-item"> <div class="cbx-preferences-container">
<div class="setting-info"> <div class="setting-item">
<div class="setting-label-row"> <div class="setting-info">
<label class="setting-label">Page Spread</label> <div class="setting-label-row">
<div class="button-group"> <label class="setting-label">{{ t('pageSpread') }}</label>
@for (spread of cbxSpreads; track spread) { <div class="button-group">
<button @for (spread of cbxSpreads; track spread) {
type="button" <button
class="option-button" type="button"
[class.selected]="selectedCbxSpread === spread.key" class="option-button"
(click)="selectedCbxSpread = spread.key"> [class.selected]="selectedCbxSpread === spread.key"
<i [class]="spread.icon"></i> (click)="selectedCbxSpread = spread.key">
<span class="option-text">{{ spread.name }}</span> <i [class]="spread.icon"></i>
</button> <span class="option-text">{{ t(spread.translationKey) }}</span>
} </button>
}
</div>
</div> </div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div> </div>
<p class="setting-description">
Configure how comic book pages are displayed - single page or double page spread.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Page Layout</label> <label class="setting-label">{{ t('pageLayout') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of cbxViewModes; track mode) { @for (mode of cbxViewModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedCbxViewMode === mode.key" [class.selected]="selectedCbxViewMode === mode.key"
(click)="selectedCbxViewMode = mode.key"> (click)="selectedCbxViewMode = mode.key">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('pageLayoutDesc') }}
</p>
</div> </div>
<p class="setting-description">
Choose how comic pages are displayed while reading.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Fit Mode</label> <label class="setting-label">{{ t('fitMode') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of cbxFitModes; track mode) { @for (mode of cbxFitModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedCbxFitMode === mode.key" [class.selected]="selectedCbxFitMode === mode.key"
(click)="selectedCbxFitMode = mode.key" (click)="selectedCbxFitMode = mode.key"
[pTooltip]="mode.name" [pTooltip]="t(mode.translationKey)"
tooltipPosition="bottom"> tooltipPosition="bottom">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('fitModeDesc') }}
</p>
</div> </div>
<p class="setting-description">
Select how images should be scaled to fit the reader window.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Scroll Mode</label> <label class="setting-label">{{ t('scrollMode') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of cbxScrollModes; track mode) { @for (mode of cbxScrollModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedCbxScrollMode === mode.key" [class.selected]="selectedCbxScrollMode === mode.key"
(click)="selectedCbxScrollMode = mode.key"> (click)="selectedCbxScrollMode = mode.key">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('scrollModeDesc') }}
</p>
</div> </div>
<p class="setting-description">
Choose between paginated or infinite scroll reading experience.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Background Color</label> <label class="setting-label">{{ t('backgroundColor') }}</label>
<div class="theme-selector"> <div class="theme-selector">
@for (color of cbxBackgroundColors; track color) { @for (color of cbxBackgroundColors; track color) {
<button <button
type="button" type="button"
class="theme-option" class="theme-option"
[class.selected]="selectedCbxBackgroundColor === color.key" [class.selected]="selectedCbxBackgroundColor === color.key"
[style.background-color]="color.color" [style.background-color]="color.color"
(click)="selectedCbxBackgroundColor = color.key" (click)="selectedCbxBackgroundColor = color.key"
[attr.aria-label]="color.name" [attr.aria-label]="t(color.translationKey)"
[pTooltip]="color.name" [pTooltip]="t(color.translationKey)"
tooltipPosition="bottom"> tooltipPosition="bottom">
@if (selectedCbxBackgroundColor === color.key) { @if (selectedCbxBackgroundColor === color.key) {
<i class="pi pi-check"></i> <i class="pi pi-check"></i>
} }
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('backgroundColorDesc') }}
</p>
</div> </div>
<p class="setting-description">
Set the background color for the comic reader.
</p>
</div> </div>
</div> </div>
</div> </ng-container>
@@ -1,5 +1,6 @@
import {Component, inject, Input} from '@angular/core'; import {Component, inject, Input} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service'; import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
import {ReaderPreferencesService} from '../reader-preferences.service'; import {ReaderPreferencesService} from '../reader-preferences.service';
import {TooltipModule} from 'primeng/tooltip'; import {TooltipModule} from 'primeng/tooltip';
@@ -8,6 +9,7 @@ import {TooltipModule} from 'primeng/tooltip';
selector: 'app-cbx-reader-preferences-component', selector: 'app-cbx-reader-preferences-component',
imports: [ imports: [
FormsModule, FormsModule,
TranslocoDirective,
TooltipModule TooltipModule
], ],
templateUrl: './cbx-reader-preferences-component.html', templateUrl: './cbx-reader-preferences-component.html',
@@ -27,32 +29,32 @@ export class CbxReaderPreferencesComponent {
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor'; private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
readonly cbxSpreads = [ readonly cbxSpreads = [
{name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left'}, {name: 'Even', key: CbxPageSpread.EVEN, icon: 'pi pi-align-left', translationKey: 'even'},
{name: 'Odd', key: CbxPageSpread.ODD, icon: 'pi pi-align-right'} {name: 'Odd', key: CbxPageSpread.ODD, icon: 'pi pi-align-right', translationKey: 'odd'}
]; ];
readonly cbxViewModes = [ readonly cbxViewModes = [
{name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE, icon: 'pi pi-book'}, {name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE, icon: 'pi pi-book', translationKey: 'singlePage'},
{name: 'Two Page', key: CbxPageViewMode.TWO_PAGE, icon: 'pi pi-copy'}, {name: 'Two Page', key: CbxPageViewMode.TWO_PAGE, icon: 'pi pi-copy', translationKey: 'twoPage'},
]; ];
readonly cbxFitModes = [ readonly cbxFitModes = [
{name: 'Fit Page', key: CbxFitMode.FIT_PAGE, icon: 'pi pi-window-maximize'}, {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'}, {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'}, {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'}, {name: 'Actual Size', key: CbxFitMode.ACTUAL_SIZE, icon: 'pi pi-expand', translationKey: 'actualSize'},
{name: 'Automatic', key: CbxFitMode.AUTO, icon: 'pi pi-sparkles'} {name: 'Automatic', key: CbxFitMode.AUTO, icon: 'pi pi-sparkles', translationKey: 'automatic'}
]; ];
readonly cbxScrollModes = [ readonly cbxScrollModes = [
{name: 'Paginated', key: CbxScrollMode.PAGINATED, icon: 'pi pi-book'}, {name: 'Paginated', key: CbxScrollMode.PAGINATED, icon: 'pi pi-book', translationKey: 'paginated'},
{name: 'Infinite', key: CbxScrollMode.INFINITE, icon: 'pi pi-sort-alt'} {name: 'Infinite', key: CbxScrollMode.INFINITE, icon: 'pi pi-sort-alt', translationKey: 'infinite'}
]; ];
readonly cbxBackgroundColors = [ readonly cbxBackgroundColors = [
{name: 'Gray', key: CbxBackgroundColor.GRAY, color: '#808080'}, {name: 'Gray', key: CbxBackgroundColor.GRAY, color: '#808080', translationKey: 'gray'},
{name: 'Black', key: CbxBackgroundColor.BLACK, color: '#000000'}, {name: 'Black', key: CbxBackgroundColor.BLACK, color: '#000000', translationKey: 'black'},
{name: 'White', key: CbxBackgroundColor.WHITE, color: '#FFFFFF'} {name: 'White', key: CbxBackgroundColor.WHITE, color: '#FFFFFF', translationKey: 'white'}
]; ];
get selectedCbxSpread(): CbxPageSpread { 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"> <div class="settings-group">
<h3 class="group-title">Appearance</h3> <h3 class="group-title">{{ t('appearance') }}</h3>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Theme</label> <label class="setting-label">{{ t('theme') }}</label>
<div class="theme-selector"> <div class="theme-selector">
@for (theme of themes; track theme) { @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 <button
type="button" type="button"
class="theme-option" class="option-button"
[class.selected]="selectedTheme === theme.name" [class.selected]="!isDark"
(click)="selectedTheme = theme.name" (click)="isDark = false">
[attr.aria-label]="theme.label" <i class="pi pi-sun"></i>
[pTooltip]="theme.label" <span class="option-text">{{ t('light') }}</span>
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> </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 <button
type="button" type="button"
class="option-button font-button" class="option-button"
[class.selected]="selectedFont === font.key" [class.selected]="isDark"
[class.separator]="font.key === 'separator'" (click)="isDark = true">
[attr.data-font]="font.key" <i class="pi pi-moon"></i>
[disabled]="font.key === 'separator'" <span class="option-text">{{ t('dark') }}</span>
(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> </button>
} </div>
@if (!customFontsReady) {
<p-skeleton width="3.5rem" height="2.5rem" borderRadius="6px"></p-skeleton>
}
</div> </div>
<p class="setting-description">
{{ t('darkModeDesc') }}
</p>
</div> </div>
<p class="setting-description">
Choose a typeface that best suits your reading preference.
</p>
</div> </div>
</div> </div>
<div class="setting-item"> <div class="settings-group">
<div class="setting-info"> <h3 class="group-title">{{ t('typography') }}</h3>
<div class="setting-label-row"> <div class="setting-item">
<label class="setting-label">Font Size</label> <div class="setting-info">
<div class="font-size-controls"> <div class="setting-label-row">
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseFontSize()"></p-button> <label class="setting-label">{{ t('fontFamily') }}</label>
<span class="font-size-value">{{ fontSize }}pt</span> <div class="button-group">
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseFontSize()"></p-button> @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> </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> </div>
<p class="setting-description">
Increase or decrease text size in points for optimal readability.
</p>
</div> </div>
</div> </div>
<div class="setting-item"> <div class="settings-group">
<div class="setting-info"> <h3 class="group-title">{{ t('layout') }}</h3>
<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="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Text Justification</label> <label class="setting-label">{{ t('flow') }}</label>
<div class="button-group"> <div class="button-group">
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="!justify" [class.selected]="flow === 'paginated'"
(click)="justify = false"> (click)="flow = 'paginated'">
<i class="pi pi-align-left"></i> <i class="pi pi-clone"></i>
<span class="option-text">Left</span> <span class="option-text">{{ t('paginated') }}</span>
</button> </button>
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="justify" [class.selected]="flow === 'scrolled'"
(click)="justify = true"> (click)="flow = 'scrolled'">
<i class="pi pi-align-justify"></i> <i class="pi pi-arrows-v"></i>
<span class="option-text">Justified</span> <span class="option-text">{{ t('scrolled') }}</span>
</button> </button>
</div>
</div> </div>
<p class="setting-description">
{{ t('flowDesc') }}
</p>
</div> </div>
<p class="setting-description">
Align text to the left or justify it for a clean edge on both sides.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Hyphenation</label> <label class="setting-label">{{ t('maxColumns') }}</label>
<div class="button-group"> <div class="font-size-controls">
<button <p-button icon="pi pi-minus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount > 1 ? maxColumnCount - 1 : 1"></p-button>
type="button" <span class="font-size-value">{{ maxColumnCount }}</span>
class="option-button" <p-button icon="pi pi-plus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount < 4 ? maxColumnCount + 1 : 4"></p-button>
[class.selected]="!hyphenate" </div>
(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> </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> </div>
<p class="setting-description">
Enable to break long words at line ends for a smoother text flow.
</p>
</div> </div>
</div> </div>
</div> </div>
</ng-container>
<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>
@@ -1,6 +1,7 @@
import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core'; import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core';
import {Button} from 'primeng/button'; import {Button} from 'primeng/button';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {TranslocoDirective} from '@jsverse/transloco';
import {ReaderPreferencesService} from '../reader-preferences.service'; import {ReaderPreferencesService} from '../reader-preferences.service';
import {UserSettings} from '../../user-management/user.service'; import {UserSettings} from '../../user-management/user.service';
import {Tooltip} from 'primeng/tooltip'; import {Tooltip} from 'primeng/tooltip';
@@ -16,6 +17,7 @@ import {themes} from '../../../readers/ebook-reader/state/themes.constant';
imports: [ imports: [
Button, Button,
FormsModule, FormsModule,
TranslocoDirective,
Tooltip, Tooltip,
Skeleton Skeleton
], ],
@@ -1,123 +1,125 @@
<div class="pdf-preferences-container"> <ng-container *transloco="let t; prefix: 'settingsReader.streamingPdf'">
<div class="setting-item"> <div class="pdf-preferences-container">
<div class="setting-info"> <div class="setting-item">
<div class="setting-label-row"> <div class="setting-info">
<label class="setting-label">Page Spread</label> <div class="setting-label-row">
<div class="button-group"> <label class="setting-label">{{ t('pageSpread') }}</label>
@for (spread of pdfSpreads; track spread) { <div class="button-group">
<button @for (spread of pdfSpreads; track spread) {
type="button" <button
class="option-button" type="button"
[class.selected]="selectedPdfSpread === spread.key" class="option-button"
(click)="selectedPdfSpread = spread.key"> [class.selected]="selectedPdfSpread === spread.key"
<i [class]="spread.icon"></i> (click)="selectedPdfSpread = spread.key">
<span class="option-text">{{ spread.name }}</span> <i [class]="spread.icon"></i>
</button> <span class="option-text">{{ t(spread.translationKey) }}</span>
} </button>
}
</div>
</div> </div>
<p class="setting-description">
{{ t('pageSpreadDesc') }}
</p>
</div> </div>
<p class="setting-description">
Configure how PDF pages are displayed - single page or double page spread.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Page Layout</label> <label class="setting-label">{{ t('pageLayout') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of pdfViewModes; track mode) { @for (mode of pdfViewModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedPdfViewMode === mode.key" [class.selected]="selectedPdfViewMode === mode.key"
(click)="selectedPdfViewMode = mode.key"> (click)="selectedPdfViewMode = mode.key">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('pageLayoutDesc') }}
</p>
</div> </div>
<p class="setting-description">
Choose how PDF pages are displayed while reading.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Fit Mode</label> <label class="setting-label">{{ t('fitMode') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of pdfFitModes; track mode) { @for (mode of pdfFitModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedPdfFitMode === mode.key" [class.selected]="selectedPdfFitMode === mode.key"
(click)="selectedPdfFitMode = mode.key" (click)="selectedPdfFitMode = mode.key"
[pTooltip]="mode.name" [pTooltip]="t(mode.translationKey)"
tooltipPosition="bottom"> tooltipPosition="bottom">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('fitModeDesc') }}
</p>
</div> </div>
<p class="setting-description">
Select how pages should be scaled to fit the reader window.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Scroll Mode</label> <label class="setting-label">{{ t('scrollMode') }}</label>
<div class="button-group"> <div class="button-group">
@for (mode of pdfScrollModes; track mode) { @for (mode of pdfScrollModes; track mode) {
<button <button
type="button" type="button"
class="option-button" class="option-button"
[class.selected]="selectedPdfScrollMode === mode.key" [class.selected]="selectedPdfScrollMode === mode.key"
(click)="selectedPdfScrollMode = mode.key"> (click)="selectedPdfScrollMode = mode.key">
<i [class]="mode.icon"></i> <i [class]="mode.icon"></i>
<span class="option-text">{{ mode.name }}</span> <span class="option-text">{{ t(mode.translationKey) }}</span>
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('scrollModeDesc') }}
</p>
</div> </div>
<p class="setting-description">
Choose between paginated or infinite scroll reading experience.
</p>
</div> </div>
</div>
<div class="setting-item"> <div class="setting-item">
<div class="setting-info"> <div class="setting-info">
<div class="setting-label-row"> <div class="setting-label-row">
<label class="setting-label">Background Color</label> <label class="setting-label">{{ t('backgroundColor') }}</label>
<div class="theme-selector"> <div class="theme-selector">
@for (color of pdfBackgroundColors; track color) { @for (color of pdfBackgroundColors; track color) {
<button <button
type="button" type="button"
class="theme-option" class="theme-option"
[class.selected]="selectedPdfBackgroundColor === color.key" [class.selected]="selectedPdfBackgroundColor === color.key"
[style.background-color]="color.color" [style.background-color]="color.color"
(click)="selectedPdfBackgroundColor = color.key" (click)="selectedPdfBackgroundColor = color.key"
[attr.aria-label]="color.name" [attr.aria-label]="t(color.translationKey)"
[pTooltip]="color.name" [pTooltip]="t(color.translationKey)"
tooltipPosition="bottom"> tooltipPosition="bottom">
@if (selectedPdfBackgroundColor === color.key) { @if (selectedPdfBackgroundColor === color.key) {
<i class="pi pi-check"></i> <i class="pi pi-check"></i>
} }
</button> </button>
} }
</div>
</div> </div>
<p class="setting-description">
{{ t('backgroundColorDesc') }}
</p>
</div> </div>
<p class="setting-description">
Set the background color for the PDF reader.
</p>
</div> </div>
</div> </div>
</div> </ng-container>

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