refactor(types): replace most usages of 'any' with 'unknown' and improve type safety across services and components (#2050)
* refactor(types): replace most usages of 'any' with 'unknown' and improve type safety across services and components - Update method signatures, variables, and interfaces to use 'unknown' instead of 'any' - Refine event and observable typings for better type inference - Add or adjust explicit types for function parameters and return values - Update Chart.js tooltip and context typings for chart services - Improve type safety in Book, BookState, and related models - Adjust template bindings and method calls to match stricter typings - Add SecureSrcDirective for secure image loading with fallback and error handling Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * chore(angular): remove proxy configuration from development build settings Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(book-browser): streamline entity and book state management with reactive streams - Refactor entity type and entity fetching logic to use observables and combine route params - Simplify book state handling by consolidating filtering and fetching into a single reactive pipeline - Remove redundant applySortOption logic and related subscriptions - Fix book card index binding in template for improved rendering performance - Ensure proper cleanup of epub rendition in epub-reader component Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(book-browser, book-uploader): improve permission checks and enhance file upload handling - Use optional chaining for user permission checks in book-browser.component.html to prevent runtime errors when user data is undefined - Refactor book-uploader.component.ts to pass destination and IDs explicitly to uploadBatch, reconstruct files for strict type handling, and ensure proper upload flow and UI feedback Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(charts, services): improve type safety for book state validation and update form field checks - Refactor isValidBookState methods across chart components and services to use type predicates and stricter type checks for BookState - Update metadata-picker.component to simplify array field checks for authors, categories, moods, and tags - Adjust magic-shelf-utils to remove unnecessary fallback in object spread - Update notification-event.service to use correct timeout type for highlightTimeout Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(theme): ensure safe merging of theme properties and improve type definition for themesMap Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(epub-reader): streamline book and rendition initialization logic Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
@@ -14,6 +14,8 @@ module.exports = tseslint.config(
|
||||
],
|
||||
processor: angular.processInlineTemplates,
|
||||
rules: {
|
||||
"*": "off",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
|
||||
Generated
-268
@@ -2299,19 +2299,6 @@
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/source-map": {
|
||||
"version": "0.3.11",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
|
||||
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/gen-mapping": "^0.3.5",
|
||||
"@jridgewell/trace-mapping": "^0.3.25"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
@@ -5730,21 +5717,6 @@
|
||||
"node": ">=6.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/copy-anything": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz",
|
||||
"integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"is-what": "^3.14.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/mesqueeb"
|
||||
}
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "3.47.0",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.47.0.tgz",
|
||||
@@ -6286,21 +6258,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/errno": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
|
||||
"integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"prr": "~1.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"errno": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
@@ -7556,21 +7513,6 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/image-size": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
|
||||
"integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"image-size": "bin/image-size.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/immediate": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
|
||||
@@ -7784,15 +7726,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/is-what": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz",
|
||||
"integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
@@ -7907,17 +7840,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jiti": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz",
|
||||
"integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"jiti": "lib/jiti-cli.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/jose": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/jose/-/jose-6.1.3.tgz",
|
||||
@@ -8602,102 +8524,6 @@
|
||||
"json-buffer": "3.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/less": {
|
||||
"version": "4.4.2",
|
||||
"resolved": "https://registry.npmjs.org/less/-/less-4.4.2.tgz",
|
||||
"integrity": "sha512-j1n1IuTX1VQjIy3tT7cyGbX7nvQOsFLoIqobZv4ttI5axP923gA44zUj6miiA6R5Aoms4sEGVIIcucXUbRI14g==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"copy-anything": "^2.0.1",
|
||||
"parse-node-version": "^1.0.1",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"lessc": "bin/lessc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"errno": "^0.1.1",
|
||||
"graceful-fs": "^4.1.2",
|
||||
"image-size": "~0.5.0",
|
||||
"make-dir": "^2.1.0",
|
||||
"mime": "^1.4.1",
|
||||
"needle": "^3.1.0",
|
||||
"source-map": "~0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/make-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
|
||||
"integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pify": "^4.0.1",
|
||||
"semver": "^5.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/pify": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
|
||||
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/semver": {
|
||||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
|
||||
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"semver": "bin/semver"
|
||||
}
|
||||
},
|
||||
"node_modules/less/node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/levn": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
||||
@@ -9471,40 +9297,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/needle": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/needle/-/needle-3.3.1.tgz",
|
||||
"integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"iconv-lite": "^0.6.3",
|
||||
"sax": "^1.2.4"
|
||||
},
|
||||
"bin": {
|
||||
"needle": "bin/needle"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/needle/node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
||||
@@ -10093,18 +9885,6 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-node-version": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
|
||||
"integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz",
|
||||
@@ -10578,15 +10358,6 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/prr": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
|
||||
"integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
||||
@@ -11040,15 +10811,6 @@
|
||||
"@parcel/watcher": "^2.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.4.3.tgz",
|
||||
"integrity": "sha512-yqYn1JhPczigF94DMS+shiDMjDowYO6y9+wB/4WgO0Y19jWYk0lQ4tuG5KI7kj4FTp1wxPj5IFfcrz/s1c3jjQ==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||
@@ -11900,36 +11662,6 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/terser": {
|
||||
"version": "5.44.0",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.0.tgz",
|
||||
"integrity": "sha512-nIVck8DK+GM/0Frwd+nIhZ84pR/BX7rmXMfYwyg+Sri5oGVE99/E3KvXqpC2xHFxyqXyGHTKBSioxxplrO4I4w==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/source-map": "^0.3.3",
|
||||
"acorn": "^8.15.0",
|
||||
"commander": "^2.20.0",
|
||||
"source-map-support": "~0.5.20"
|
||||
},
|
||||
"bin": {
|
||||
"terser": "bin/terser"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/terser/node_modules/commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/thenify": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
|
||||
|
||||
@@ -19,7 +19,6 @@ import {StatsComponent} from './features/stats/component/stats-component';
|
||||
import {EpubReaderComponent} from './features/readers/epub-reader/component/epub-reader.component';
|
||||
import {PdfReaderComponent} from './features/readers/pdf-reader/pdf-reader.component';
|
||||
import {BookdropFileReviewComponent} from './features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component';
|
||||
import {ManageLibraryGuard} from './core/security/guards/manage-library.guard';
|
||||
import {LoginGuard} from './shared/components/setup/login.guard';
|
||||
import {UserStatsComponent} from './features/stats/component/user-stats/user-stats.component';
|
||||
import {BookdropGuard} from './core/security/guards/bookdrop.guard';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {HttpErrorResponse, HttpHandlerFn, HttpInterceptorFn, HttpRequest} from '@angular/common/http';
|
||||
import {HttpErrorResponse, HttpEvent, HttpHandlerFn, HttpInterceptorFn, HttpRequest} from '@angular/common/http';
|
||||
import {inject} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {catchError, filter, switchMap, take} from 'rxjs/operators';
|
||||
@@ -31,7 +31,7 @@ export const AuthInterceptorService: HttpInterceptorFn = (req, next: HttpHandler
|
||||
let isRefreshing = false;
|
||||
const refreshTokenSubject = new BehaviorSubject<string | null>(null);
|
||||
|
||||
function handle401Error(authService: AuthService, request: HttpRequest<any>, next: HttpHandlerFn, router: Router, isInternal: boolean): Observable<any> {
|
||||
function handle401Error(authService: AuthService, request: HttpRequest<unknown>, next: HttpHandlerFn, router: Router, isInternal: boolean): Observable<HttpEvent<unknown>> {
|
||||
if (!isRefreshing && isInternal) {
|
||||
isRefreshing = true;
|
||||
refreshTokenSubject.next(null);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Directive, ElementRef, Input, OnChanges, OnDestroy, inject, SimpleChanges } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Directive({
|
||||
selector: '[appSecureSrc]',
|
||||
standalone: true
|
||||
})
|
||||
export class SecureSrcDirective implements OnChanges, OnDestroy {
|
||||
@Input('appSecureSrc') src!: string;
|
||||
|
||||
private currentUrl: string | null = null;
|
||||
private subscription: Subscription | null = null;
|
||||
|
||||
private el = inject(ElementRef);
|
||||
private http = inject(HttpClient);
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['src']) {
|
||||
this.loadImage();
|
||||
}
|
||||
}
|
||||
|
||||
private loadImage(): void {
|
||||
this.cleanup();
|
||||
|
||||
if (!this.src) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.subscription = this.http.get(this.src, { responseType: 'blob' }).subscribe({
|
||||
next: (blob) => {
|
||||
this.currentUrl = URL.createObjectURL(blob);
|
||||
this.el.nativeElement.src = this.currentUrl;
|
||||
},
|
||||
error: (err) => {
|
||||
// Only log non-CORS errors to avoid console spam
|
||||
// CORS errors are expected in development and will be resolved by backend CORS config
|
||||
if (err.status !== 0 && err.status !== 403) {
|
||||
console.error('Error loading secure image:', err);
|
||||
}
|
||||
// Set a fallback placeholder image if available
|
||||
const fallbackSrc = this.el.nativeElement.getAttribute('data-fallback-src') || 'assets/images/missing-cover.jpg';
|
||||
this.el.nativeElement.src = fallbackSrc;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private cleanup(): void {
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
this.subscription = null;
|
||||
}
|
||||
if (this.currentUrl) {
|
||||
URL.revokeObjectURL(this.currentUrl);
|
||||
this.currentUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.cleanup();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -90,7 +90,7 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
return this.files.length > 0;
|
||||
}
|
||||
|
||||
choose(_event: any, chooseCallback: () => void): void {
|
||||
choose(_event: unknown, chooseCallback: () => void): void {
|
||||
chooseCallback();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
onRemoveTemplatingFile(_event: any, _file: File, removeFileCallback: (event: any, index: number) => void, index: number): void {
|
||||
onRemoveTemplatingFile(_event: unknown, _file: File, removeFileCallback: (event: unknown, index: number) => void, index: number): void {
|
||||
removeFileCallback(_event, index);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ export class BookDialogHelperService {
|
||||
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
|
||||
private openDialog(component: any, options: {}): DynamicDialogRef | null {
|
||||
private openDialog(component: unknown, options: {}): DynamicDialogRef | null {
|
||||
return this.dialogLauncherService.openDialog(component, options);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -35,10 +35,10 @@
|
||||
<div
|
||||
class="filter-row"
|
||||
[ngClass]="{
|
||||
'active': activeFilters[filterType]?.includes(filter.value?.id || filter.value)
|
||||
'active': activeFilters[filterType]?.includes(getFilterValueId(filter))
|
||||
}"
|
||||
(click)="handleFilterClick(filterType, filter.value?.id || filter.value)">
|
||||
{{ filter.value.name || filter.value }}
|
||||
(click)="handleFilterClick(filterType, getFilterValueId(filter))">
|
||||
{{ getFilterValueDisplay(filter) }}
|
||||
<p-badge class="filter-value-badge" [value]="filter.bookCount"></p-badge>
|
||||
</div>
|
||||
}
|
||||
|
||||
+85
-30
@@ -16,7 +16,36 @@ import {MagicShelf} from '../../../../magic-shelf/service/magic-shelf.service';
|
||||
import {BookRuleEvaluatorService} from '../../../../magic-shelf/service/book-rule-evaluator.service';
|
||||
import {GroupRule} from '../../../../magic-shelf/component/magic-shelf-component';
|
||||
|
||||
type Filter<T> = { value: T; bookCount: number };
|
||||
export interface FilterValue {
|
||||
id?: string | number;
|
||||
name?: string;
|
||||
sortIndex?: number;
|
||||
}
|
||||
|
||||
export interface Filter<T extends FilterValue = FilterValue> {
|
||||
value: T;
|
||||
bookCount: number;
|
||||
}
|
||||
|
||||
export type FilterType =
|
||||
| 'author'
|
||||
| 'category'
|
||||
| 'series'
|
||||
| 'publisher'
|
||||
| 'readStatus'
|
||||
| 'personalRating'
|
||||
| 'publishedDate'
|
||||
| 'matchScore'
|
||||
| 'mood'
|
||||
| 'tag'
|
||||
| 'language'
|
||||
| 'bookType'
|
||||
| 'shelfStatus'
|
||||
| 'fileSize'
|
||||
| 'pageCount'
|
||||
| 'amazonRating'
|
||||
| 'goodreadsRating'
|
||||
| 'hardcoverRating';
|
||||
|
||||
export const ratingRanges = [
|
||||
{id: '0to1', label: '0 to 1', min: 0, max: 1, sortIndex: 0},
|
||||
@@ -153,9 +182,9 @@ function getReadStatusName(status?: ReadStatus | null): string {
|
||||
]
|
||||
})
|
||||
export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
private filterChangeSubject = new Subject<Record<string, any> | null>();
|
||||
private filterChangeSubject = new Subject<Record<string, unknown> | null>();
|
||||
|
||||
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
|
||||
@Output() filterSelected = new EventEmitter<Record<string, unknown> | null>();
|
||||
@Output() filterModeChanged = new EventEmitter<BookFilterMode>();
|
||||
|
||||
@Input() entity$!: Observable<Library | Shelf | MagicShelf | null> | undefined;
|
||||
@@ -163,10 +192,10 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
@Input() resetFilter$!: Subject<void>;
|
||||
@Input() showFilter: boolean = false;
|
||||
|
||||
activeFilters: Record<string, any> = {};
|
||||
filterStreams: Record<string, Observable<Filter<any>[]>> = {};
|
||||
activeFilters: Record<string, unknown[]> = {};
|
||||
filterStreams: Record<FilterType, Observable<Filter[]>> = {} as Record<FilterType, Observable<Filter[]>>;
|
||||
truncatedFilters: Record<string, boolean> = {};
|
||||
filterTypes: string[] = [];
|
||||
filterTypes: FilterType[] = [];
|
||||
filterModeOptions = [
|
||||
{label: 'AND', value: 'and'},
|
||||
{label: 'OR', value: 'or'},
|
||||
@@ -174,7 +203,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
];
|
||||
private _selectedFilterMode: BookFilterMode = 'and';
|
||||
expandedPanels: number[] = [0];
|
||||
readonly filterLabels: Record<string, string> = {
|
||||
readonly filterLabels: Record<FilterType, string> = {
|
||||
author: 'Author',
|
||||
category: 'Genre',
|
||||
series: 'Series',
|
||||
@@ -183,6 +212,8 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
personalRating: 'Personal Rating',
|
||||
publishedDate: 'Published Year',
|
||||
matchScore: 'Metadata Match Score',
|
||||
mood: 'Mood',
|
||||
tag: 'Tag',
|
||||
language: 'Language',
|
||||
bookType: 'Book Type',
|
||||
shelfStatus: 'Shelf Status',
|
||||
@@ -260,7 +291,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', 'sortIndex'),
|
||||
};
|
||||
|
||||
this.filterTypes = Object.keys(this.filterStreams);
|
||||
this.filterTypes = Object.keys(this.filterStreams) as FilterType[];
|
||||
this.setExpandedPanels();
|
||||
});
|
||||
|
||||
@@ -273,12 +304,12 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private getFilterStream<T>(
|
||||
private getFilterStream<T extends FilterValue>(
|
||||
extractor: (book: Book) => T[] | undefined,
|
||||
idKey: keyof T,
|
||||
nameKey: keyof T,
|
||||
sortMode: FilterSortingMode | 'sortIndex' = this.filterSortingMode
|
||||
): Observable<Filter<T[keyof T]>[]> {
|
||||
): Observable<Filter<T>[]> {
|
||||
return combineLatest([
|
||||
this.bookService.bookState$,
|
||||
this.entity$ ?? of(null),
|
||||
@@ -286,7 +317,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
]).pipe(
|
||||
map(([state, entity, entityType]) => {
|
||||
const filteredBooks = this.filterBooksByEntityType(state.books || [], entity, entityType);
|
||||
const filterMap = new Map<any, Filter<any>>();
|
||||
const filterMap = new Map<unknown, Filter<T>>();
|
||||
|
||||
filteredBooks.forEach((book) => {
|
||||
(extractor(book) || []).forEach((item) => {
|
||||
@@ -302,11 +333,17 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
|
||||
const sorted = result.sort((a, b) => {
|
||||
if (sortMode === 'sortIndex') {
|
||||
return (a.value.sortIndex ?? 999) - (b.value.sortIndex ?? 999);
|
||||
const aValue = a.value as { sortIndex?: number };
|
||||
const bValue = b.value as { sortIndex?: number };
|
||||
return (aValue.sortIndex ?? 999) - (bValue.sortIndex ?? 999);
|
||||
} else if (sortMode === 'count' && b.bookCount !== a.bookCount) {
|
||||
return b.bookCount - a.bookCount;
|
||||
}
|
||||
return a.value[nameKey].toString().localeCompare(b.value[nameKey].toString());
|
||||
const aValue = a.value as Record<string, unknown>;
|
||||
const bValue = b.value as Record<string, unknown>;
|
||||
const aKey = String(aValue[String(nameKey)] ?? '');
|
||||
const bKey = String(bValue[String(nameKey)] ?? '');
|
||||
return aKey.localeCompare(bKey);
|
||||
});
|
||||
|
||||
const isTruncated = sorted.length > 500;
|
||||
@@ -317,13 +354,13 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
map(({items, isTruncated}) => {
|
||||
setTimeout(() => {
|
||||
const filterType = Object.keys(this.filterStreams).find(key =>
|
||||
this.filterStreams[key] === this.getFilterStream(extractor, idKey, nameKey)
|
||||
this.filterStreams[key as FilterType] === this.getFilterStream(extractor, idKey, nameKey)
|
||||
);
|
||||
if (filterType) {
|
||||
this.truncatedFilters[filterType] = isTruncated;
|
||||
}
|
||||
});
|
||||
return items;
|
||||
return items as Filter<T>[];
|
||||
}),
|
||||
shareReplay({bufferSize: 1, refCount: true})
|
||||
);
|
||||
@@ -343,18 +380,21 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private filterBooksByEntityType(books: Book[], entity: any, entityType: EntityType): Book[] {
|
||||
if (entityType === EntityType.LIBRARY && entity && 'id' in entity) {
|
||||
return books.filter((book) => book.libraryId === entity.id);
|
||||
private filterBooksByEntityType(books: Book[], entity: unknown, entityType: EntityType): Book[] {
|
||||
if (entityType === EntityType.LIBRARY && entity !== null && typeof entity === 'object' && 'id' in entity) {
|
||||
const libraryEntity = entity as { id: number };
|
||||
return books.filter((book) => book.libraryId === libraryEntity.id);
|
||||
}
|
||||
|
||||
if (entityType === EntityType.SHELF && entity && 'id' in entity) {
|
||||
return books.filter((book) => book.shelves?.some((shelf) => shelf.id === entity.id));
|
||||
if (entityType === EntityType.SHELF && entity !== null && typeof entity === 'object' && 'id' in entity) {
|
||||
const shelfEntity = entity as { id: number };
|
||||
return books.filter((book) => book.shelves?.some((shelf) => shelf.id === shelfEntity.id));
|
||||
}
|
||||
|
||||
if (entityType === EntityType.MAGIC_SHELF && entity && 'filterJson' in entity) {
|
||||
if (entityType === EntityType.MAGIC_SHELF && entity !== null && typeof entity === 'object' && 'filterJson' in entity) {
|
||||
try {
|
||||
const groupRule = JSON.parse(entity.filterJson) as GroupRule;
|
||||
const magicShelfEntity = entity as { filterJson: string };
|
||||
const groupRule = JSON.parse(magicShelfEntity.filterJson) as GroupRule;
|
||||
return books.filter((book) => this.bookRuleEvaluatorService.evaluateGroup(book, groupRule));
|
||||
} catch (e) {
|
||||
console.warn('Invalid filterJson for MagicShelf:', e);
|
||||
@@ -365,18 +405,19 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
return books;
|
||||
}
|
||||
|
||||
handleFilterClick(filterType: string, value: any): void {
|
||||
handleFilterClick(filterType: string, value: unknown): void {
|
||||
if (!this.activeFilters[filterType]) {
|
||||
this.activeFilters[filterType] = [];
|
||||
}
|
||||
|
||||
const index = this.activeFilters[filterType].indexOf(value);
|
||||
const filterArray = this.activeFilters[filterType];
|
||||
const index = filterArray.indexOf(value);
|
||||
if (index > -1) {
|
||||
if (this._selectedFilterMode == 'single') {
|
||||
this.activeFilters = {};
|
||||
} else {
|
||||
this.activeFilters[filterType].splice(index, 1);
|
||||
if (this.activeFilters[filterType].length === 0) {
|
||||
filterArray.splice(index, 1);
|
||||
if (filterArray.length === 0) {
|
||||
delete this.activeFilters[filterType];
|
||||
}
|
||||
}
|
||||
@@ -389,7 +430,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
this.filterChangeSubject.next(Object.keys(this.activeFilters).length ? {...this.activeFilters} : null);
|
||||
}
|
||||
|
||||
setFilters(filters: Record<string, any>) {
|
||||
setFilters(filters: Record<string, unknown>) {
|
||||
this.activeFilters = {};
|
||||
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
@@ -422,12 +463,26 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
this.setExpandedPanels();
|
||||
}
|
||||
|
||||
trackByFilterType(_: number, type: string): string {
|
||||
trackByFilterType(_: number, type: FilterType): string {
|
||||
return type;
|
||||
}
|
||||
|
||||
trackByFilter(_: number, filter: Filter<any>): any {
|
||||
return filter.value.id ?? filter.value;
|
||||
trackByFilter(_: number, filter: Filter<FilterValue>): unknown {
|
||||
const value = filter.value as { id?: unknown } | unknown;
|
||||
return (typeof value === 'object' && value !== null && 'id' in value) ? (value as any).id : filter.value;
|
||||
}
|
||||
|
||||
getFilterValueId(filter: Filter<FilterValue>): unknown {
|
||||
const value = filter.value as { id?: unknown } | unknown;
|
||||
return (typeof value === 'object' && value !== null && 'id' in value) ? (value as any).id : filter.value;
|
||||
}
|
||||
|
||||
getFilterValueDisplay(filter: Filter<FilterValue>): string {
|
||||
const value = filter.value as { name?: string } | string | unknown;
|
||||
if (typeof value === 'object' && value !== null && 'name' in value) {
|
||||
return String((value as any).name ?? '');
|
||||
}
|
||||
return String(value ?? '');
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
+13
-9
@@ -39,7 +39,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Output() selectedBooksChange = new EventEmitter<Set<number>>();
|
||||
@Input() books: Book[] = [];
|
||||
@Input() sortOption: SortOption | null = null;
|
||||
@Input() visibleColumns: any[] = [];
|
||||
@Input() visibleColumns: { field: string; header: string }[] = [];
|
||||
@Input() preselectedBookIds = new Set<number>();
|
||||
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
@@ -120,17 +120,21 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
}
|
||||
|
||||
onRowSelect(event: any): void {
|
||||
this.selectedBookIds.add(event.data.id);
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
onRowSelect(event: { data?: Book | Book[] }): void {
|
||||
if (event.data && !Array.isArray(event.data)) {
|
||||
this.selectedBookIds.add(event.data.id);
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
}
|
||||
}
|
||||
|
||||
onRowUnselect(event: any): void {
|
||||
this.selectedBookIds.delete(event.data.id);
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
onRowUnselect(event: { data?: Book | Book[] }): void {
|
||||
if (event.data && !Array.isArray(event.data)) {
|
||||
this.selectedBookIds.delete(event.data.id);
|
||||
this.selectedBooksChange.emit(this.selectedBookIds);
|
||||
}
|
||||
}
|
||||
|
||||
onHeaderCheckboxToggle(event: any): void {
|
||||
onHeaderCheckboxToggle(event: { checked: boolean }): void {
|
||||
if (event.checked) {
|
||||
this.selectedBooks = [...this.books];
|
||||
this.selectedBookIds = new Set(this.books.map(book => book.id));
|
||||
@@ -204,7 +208,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
'isbn': 'isbn'
|
||||
} as const;
|
||||
|
||||
let data: string[] = [metadata[field]];
|
||||
let data: string[] = [metadata[field] as string];
|
||||
|
||||
switch (field) {
|
||||
case 'title':
|
||||
|
||||
@@ -5,7 +5,7 @@ import {map, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators
|
||||
|
||||
export class HeaderFilter implements BookFilter {
|
||||
|
||||
constructor(private searchTerm$: Observable<any>) {
|
||||
constructor(private searchTerm$: Observable<string>) {
|
||||
}
|
||||
|
||||
filter(bookState: BookState): Observable<BookState> {
|
||||
@@ -25,7 +25,7 @@ export class HeaderFilter implements BookFilter {
|
||||
|
||||
return this.searchTerm$.pipe(
|
||||
distinctUntilChanged(),
|
||||
switchMap(term => {
|
||||
switchMap((term: string) => {
|
||||
const normalizedTerm = normalize(term || '').trim();
|
||||
if (normalizedTerm.length < 2) {
|
||||
return of(bookState);
|
||||
|
||||
@@ -47,7 +47,7 @@ export function doesBookMatchReadStatus(book: Book, selected: string[]): boolean
|
||||
|
||||
export class SideBarFilter implements BookFilter {
|
||||
|
||||
constructor(private selectedFilter$: Observable<any>, private selectedFilterMode$: Observable<BookFilterMode>) {
|
||||
constructor(private selectedFilter$: Observable<unknown>, private selectedFilterMode$: Observable<BookFilterMode>) {
|
||||
}
|
||||
|
||||
filter(bookState: BookState): Observable<BookState> {
|
||||
|
||||
@@ -33,8 +33,8 @@ export class BookSenderComponent implements OnInit {
|
||||
|
||||
emailProviders: { label: string, value: EmailProvider }[] = [];
|
||||
emailRecipients: { label: string, value: EmailRecipient }[] = [];
|
||||
selectedProvider?: any;
|
||||
selectedRecipient?: any;
|
||||
selectedProvider?: { label: string; value: EmailProvider };
|
||||
selectedRecipient?: { label: string; value: EmailRecipient };
|
||||
|
||||
ngOnInit(): void {
|
||||
this.emailProviderService.getEmailProviders().subscribe({
|
||||
|
||||
@@ -48,6 +48,7 @@ export interface Book extends FileInfo {
|
||||
libraryPath?: { id: number };
|
||||
alternativeFormats?: AdditionalFile[];
|
||||
supplementaryFiles?: AdditionalFile[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface EpubProgress {
|
||||
@@ -145,7 +146,7 @@ export interface BookMetadata {
|
||||
tagsLocked?: boolean;
|
||||
coverLocked?: boolean;
|
||||
reviewsLocked?: boolean;
|
||||
[key: string]: any;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface MetadataClearFlags {
|
||||
@@ -215,7 +216,7 @@ export interface BookSetting {
|
||||
epubSettings?: EpubViewerSetting;
|
||||
cbxSettings?: CbxViewerSetting;
|
||||
newPdfSettings?: NewPdfReaderSetting;
|
||||
[key: string]: any;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface BookRecommendation {
|
||||
|
||||
@@ -484,7 +484,7 @@ export class BookService {
|
||||
for (const [field, action] of Object.entries(fieldActions)) {
|
||||
const lockField = field.endsWith('Locked') ? field : `${field}Locked`;
|
||||
if (lockField in updatedMetadata) {
|
||||
(updatedMetadata as any)[lockField] = action === 'LOCK';
|
||||
(updatedMetadata as Record<string, unknown>)[lockField] = action === 'LOCK';
|
||||
}
|
||||
}
|
||||
return {
|
||||
@@ -508,7 +508,7 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
consolidateMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', targetValues: string[], valuesToMerge: string[]): Observable<any> {
|
||||
consolidateMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', targetValues: string[], valuesToMerge: string[]): Observable<unknown> {
|
||||
const payload = {metadataType, targetValues, valuesToMerge};
|
||||
return this.http.post(`${this.url}/metadata/manage/consolidate`, payload).pipe(
|
||||
tap(() => {
|
||||
@@ -517,7 +517,7 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
deleteMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', valuesToDelete: string[]): Observable<any> {
|
||||
deleteMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', valuesToDelete: string[]): Observable<unknown> {
|
||||
const payload = {metadataType, valuesToDelete};
|
||||
return this.http.post(`${this.url}/metadata/manage/delete`, payload).pipe(
|
||||
tap(() => {
|
||||
|
||||
@@ -135,7 +135,7 @@ export class LibraryShelfMenuService {
|
||||
];
|
||||
}
|
||||
|
||||
initializeShelfMenuItems(entity: any): MenuItem[] {
|
||||
initializeShelfMenuItems(entity: Shelf | null): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: 'Options',
|
||||
@@ -183,7 +183,7 @@ export class LibraryShelfMenuService {
|
||||
];
|
||||
}
|
||||
|
||||
initializeMagicShelfMenuItems(entity: any): MenuItem[] {
|
||||
initializeMagicShelfMenuItems(entity: MagicShelf | null): MenuItem[] {
|
||||
const isAdmin = this.userService.getCurrentUser()?.permissions.admin ?? false;
|
||||
const isPublicShelf = entity?.isPublic ?? false;
|
||||
const disableOptions = isPublicShelf && !isAdmin;
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@
|
||||
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
|
||||
<input
|
||||
pInputText
|
||||
[formControl]="$any(bulkEditForm.get(field.controlName))"
|
||||
[formControl]="getControl(field.controlName)"
|
||||
[attr.id]="field.controlName"
|
||||
[attr.aria-label]="field.label"
|
||||
class="field-input"/>
|
||||
@@ -46,7 +46,7 @@
|
||||
<input
|
||||
pInputText
|
||||
type="number"
|
||||
[formControl]="$any(bulkEditForm.get(field.controlName))"
|
||||
[formControl]="getControl(field.controlName)"
|
||||
[attr.id]="field.controlName"
|
||||
[attr.aria-label]="field.label"
|
||||
class="field-input field-input-small"/>
|
||||
@@ -83,7 +83,7 @@
|
||||
</p-checkbox>
|
||||
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
|
||||
<p-autoComplete
|
||||
[formControl]="$any(bulkEditForm.get(field.controlName))"
|
||||
[formControl]="getControl(field.controlName)"
|
||||
[multiple]="true"
|
||||
[suggestions]="[]"
|
||||
[forceSelection]="false"
|
||||
|
||||
+4
@@ -136,6 +136,10 @@ export class BookdropBulkEditDialogComponent implements OnInit {
|
||||
return this.enabledFields.has(fieldName);
|
||||
}
|
||||
|
||||
getControl(controlName: string): FormControl {
|
||||
return this.bulkEditForm.get(controlName) as FormControl;
|
||||
}
|
||||
|
||||
get hasEnabledFields(): boolean {
|
||||
return this.enabledFields.size > 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<input
|
||||
#patternInput
|
||||
pInputText
|
||||
[formControl]="$any(patternForm.get('pattern'))"
|
||||
[formControl]="patternControl"
|
||||
[placeholder]="patternPlaceholderText"
|
||||
id="pattern-input"
|
||||
aria-label="Filename pattern for metadata extraction"
|
||||
|
||||
+4
@@ -244,6 +244,10 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
|
||||
return placeholderRegex.test(pattern);
|
||||
}
|
||||
|
||||
get patternControl(): FormControl {
|
||||
return this.patternForm.get('pattern') as FormControl;
|
||||
}
|
||||
|
||||
getPlaceholderLabel(name: string): string {
|
||||
return name === '*' ? '*' : `{${name}}`;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import {MultiSelect} from 'primeng/multiselect';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../service/magic-shelf-utils';
|
||||
import {IconPickerService, IconSelection} from '../../../shared/service/icon-picker.service';
|
||||
import {CheckboxModule} from "primeng/checkbox";
|
||||
import {CheckboxChangeEvent, CheckboxModule} from "primeng/checkbox";
|
||||
import {UserService} from "../../settings/user-management/user.service";
|
||||
import {IconDisplayComponent} from '../../../shared/components/icon-display/icon-display.component';
|
||||
|
||||
@@ -79,9 +79,9 @@ type FieldType = 'number' | 'decimal' | 'date' | undefined;
|
||||
export interface Rule {
|
||||
field: RuleField;
|
||||
operator: RuleOperator;
|
||||
value: any;
|
||||
valueStart?: any;
|
||||
valueEnd?: any;
|
||||
value: unknown;
|
||||
valueStart?: unknown;
|
||||
valueEnd?: unknown;
|
||||
}
|
||||
|
||||
export interface FieldConfig {
|
||||
@@ -214,7 +214,7 @@ export class MagicShelfComponent implements OnInit {
|
||||
|
||||
selectedIcon: IconSelection | null = null;
|
||||
|
||||
trackByFn(ruleCtrl: AbstractControl, index: number): any {
|
||||
trackByFn(ruleCtrl: AbstractControl, index: number): unknown {
|
||||
return ruleCtrl;
|
||||
}
|
||||
|
||||
@@ -446,8 +446,9 @@ export class MagicShelfComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onAutoCompleteBlur(formControl: any, event: any) {
|
||||
const inputValue = event.target.value?.trim();
|
||||
onAutoCompleteBlur(formControl: { value: unknown; setValue: (value: unknown[]) => void }, event: Event) {
|
||||
const target = event.target as HTMLInputElement | null;
|
||||
const inputValue = target?.value?.trim();
|
||||
if (inputValue) {
|
||||
const currentValue = formControl.value || [];
|
||||
const values = Array.isArray(currentValue) ? currentValue :
|
||||
@@ -457,12 +458,15 @@ export class MagicShelfComponent implements OnInit {
|
||||
values.push(inputValue);
|
||||
formControl.setValue(values);
|
||||
}
|
||||
event.target.value = '';
|
||||
if (target) {
|
||||
target.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onIsPublicChange(event: any) {
|
||||
this.form.get('isPublic')?.setValue(event.checked);
|
||||
onIsPublicChange(event: CheckboxChangeEvent): void {
|
||||
const checked = event.checked ?? false;
|
||||
this.form.get('isPublic')?.setValue(checked);
|
||||
}
|
||||
|
||||
submit() {
|
||||
|
||||
@@ -19,7 +19,7 @@ export class BookRuleEvaluatorService {
|
||||
private evaluateRule(book: Book, rule: Rule): boolean {
|
||||
const rawValue = this.extractBookValue(book, rule.field);
|
||||
|
||||
const normalize = (val: any): any => {
|
||||
const normalize = (val: unknown): unknown => {
|
||||
if (val === null || val === undefined) return val;
|
||||
if (val instanceof Date) return val;
|
||||
if (typeof val === 'string') {
|
||||
@@ -188,7 +188,7 @@ export class BookRuleEvaluatorService {
|
||||
}
|
||||
}
|
||||
|
||||
private extractBookValue(book: Book, field: RuleField): any {
|
||||
private extractBookValue(book: Book, field: RuleField): unknown {
|
||||
switch (field) {
|
||||
case 'library':
|
||||
return book.libraryId;
|
||||
@@ -245,7 +245,7 @@ export class BookRuleEvaluatorService {
|
||||
case 'hardcoverReviewCount':
|
||||
return book.metadata?.hardcoverReviewCount;
|
||||
default:
|
||||
return (book as any)[field];
|
||||
return (book as Record<string, unknown>)[field];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,49 +11,51 @@ export const EMPTY_CHECK_OPERATORS: RuleOperator[] = [
|
||||
'is_not_empty'
|
||||
];
|
||||
|
||||
export function parseValue(val: any, type: 'string' | 'number' | 'decimal' | 'date' | undefined): any {
|
||||
export function parseValue(val: unknown, type: 'string' | 'number' | 'decimal' | 'date' | undefined): unknown {
|
||||
if (val == null) return null;
|
||||
if (type === 'number' || type === 'decimal') {
|
||||
const num = Number(val);
|
||||
return isNaN(num) ? null : num;
|
||||
}
|
||||
if (type === 'date') {
|
||||
const d = new Date(val);
|
||||
const d = new Date(val as string | number | Date);
|
||||
return isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
export function removeNulls(obj: any): any {
|
||||
export function removeNulls(obj: unknown): unknown {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(removeNulls);
|
||||
} else if (typeof obj === 'object' && obj !== null) {
|
||||
return Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
return Object.entries(obj).reduce((acc: Record<string, unknown>, [key, value]) => {
|
||||
const cleanedValue = removeNulls(value);
|
||||
if (cleanedValue !== null && cleanedValue !== undefined) {
|
||||
acc[key] = cleanedValue;
|
||||
}
|
||||
return acc;
|
||||
}, {} as any);
|
||||
}, {});
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function serializeDateRules(ruleOrGroup: any): any {
|
||||
if ('rules' in ruleOrGroup) {
|
||||
export function serializeDateRules(ruleOrGroup: unknown): unknown {
|
||||
if (ruleOrGroup !== null && typeof ruleOrGroup === 'object' && 'rules' in ruleOrGroup) {
|
||||
const group = ruleOrGroup as { rules: unknown[] };
|
||||
return {
|
||||
...ruleOrGroup,
|
||||
rules: ruleOrGroup.rules.map(serializeDateRules)
|
||||
...(ruleOrGroup as Record<string, unknown>),
|
||||
rules: group.rules.map(serializeDateRules)
|
||||
};
|
||||
}
|
||||
|
||||
const isDateField = ruleOrGroup.field === 'publishedDate' || ruleOrGroup.field === 'dateFinished';
|
||||
const serialize = (val: any) => (val instanceof Date ? val.toISOString().split('T')[0] : val);
|
||||
const rule = ruleOrGroup as { field?: string; value?: unknown; valueStart?: unknown; valueEnd?: unknown; [key: string]: unknown };
|
||||
const isDateField = rule.field === 'publishedDate' || rule.field === 'dateFinished';
|
||||
const serialize = (val: unknown) => (val instanceof Date ? val.toISOString().split('T')[0] : val);
|
||||
|
||||
return {
|
||||
...ruleOrGroup,
|
||||
value: isDateField ? serialize(ruleOrGroup.value) : ruleOrGroup.value,
|
||||
valueStart: isDateField ? serialize(ruleOrGroup.valueStart) : ruleOrGroup.valueStart,
|
||||
valueEnd: isDateField ? serialize(ruleOrGroup.valueEnd) : ruleOrGroup.valueEnd
|
||||
...(ruleOrGroup as Record<string, unknown>),
|
||||
value: isDateField ? serialize(rule.value) : rule.value,
|
||||
valueStart: isDateField ? serialize(rule.valueStart) : rule.valueStart,
|
||||
valueEnd: isDateField ? serialize(rule.valueEnd) : rule.valueEnd
|
||||
};
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ export class MagicShelfService {
|
||||
);
|
||||
}
|
||||
|
||||
saveShelf(data: { id?: number; name: string | null; icon: string | null; iconType?: 'PRIME_NG' | 'CUSTOM_SVG'; group: any, isPublic?: boolean | null }): Observable<MagicShelf> {
|
||||
saveShelf(data: { id?: number; name: string | null; icon: string | null; iconType?: 'PRIME_NG' | 'CUSTOM_SVG'; group: unknown, isPublic?: boolean | null }): Observable<MagicShelf> {
|
||||
const payload: MagicShelf = {
|
||||
id: data.id,
|
||||
name: data.name ?? '',
|
||||
|
||||
+2
-1
@@ -49,7 +49,8 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
onPageChange(event: any) {
|
||||
onPageChange(event: { first?: number; rows?: number | null }): void {
|
||||
if (event.first === undefined || event.rows === undefined || event.rows === null) return;
|
||||
this.first = event.first;
|
||||
const page = Math.floor(event.first / event.rows);
|
||||
this.loadSessions(page);
|
||||
|
||||
+10
-9
@@ -17,6 +17,7 @@ import {filter, take, finalize} from "rxjs/operators";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {MetadataRefreshType} from "../../../model/request/metadata-refresh-type.enum";
|
||||
import {AutoComplete} from "primeng/autocomplete";
|
||||
import {AutoCompleteSelectEvent} from "primeng/autocomplete";
|
||||
import {DatePicker} from "primeng/datepicker";
|
||||
import {Textarea} from "primeng/textarea";
|
||||
import {Image} from "primeng/image";
|
||||
@@ -383,10 +384,10 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onAutoCompleteSelect(fieldName: string, event: any) {
|
||||
const values = this.metadataForm.get(fieldName)?.value || [];
|
||||
if (!values.includes(event.value)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value]);
|
||||
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
|
||||
const values = (this.metadataForm.get(fieldName)?.value as string[]) || [];
|
||||
if (!values.includes(event.value as string)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value as string]);
|
||||
}
|
||||
(event.originalEvent.target as HTMLInputElement).value = "";
|
||||
}
|
||||
@@ -550,10 +551,10 @@ export class MetadataEditorComponent implements OnInit {
|
||||
const original = this.originalMetadata;
|
||||
|
||||
const wasCleared = (key: keyof BookMetadata): boolean => {
|
||||
const current = (metadata[key] as any) ?? null;
|
||||
const prev = (original[key] as any) ?? null;
|
||||
const current = (metadata[key] as unknown) ?? null;
|
||||
const prev = (original[key] as unknown) ?? null;
|
||||
|
||||
const isEmpty = (val: any): boolean =>
|
||||
const isEmpty = (val: unknown): boolean =>
|
||||
val === null || val === "" || (Array.isArray(val) && val.length === 0);
|
||||
|
||||
return isEmpty(current) && !isEmpty(prev);
|
||||
@@ -630,8 +631,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
onUpload(event: FileUploadEvent): void {
|
||||
const response: HttpResponse<any> =
|
||||
event.originalEvent as HttpResponse<any>;
|
||||
const response: HttpResponse<unknown> =
|
||||
event.originalEvent as HttpResponse<unknown>;
|
||||
if (response && response.status === 200) {
|
||||
const bookMetadata: BookMetadata = response.body as BookMetadata;
|
||||
this.bookService.handleBookMetadataUpdate(
|
||||
|
||||
+11
-10
@@ -14,6 +14,7 @@ import {Textarea} from 'primeng/textarea';
|
||||
import {filter, map, take} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {AutoCompleteSelectEvent} from 'primeng/autocomplete';
|
||||
import {Image} from 'primeng/image';
|
||||
import {LazyLoadImageModule} from 'ng-lazyload-image';
|
||||
|
||||
@@ -349,10 +350,10 @@ export class MetadataPickerComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onAutoCompleteSelect(fieldName: string, event: any) {
|
||||
const values = this.metadataForm.get(fieldName)?.value || [];
|
||||
if (!values.includes(event.value)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value]);
|
||||
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
|
||||
const values = (this.metadataForm.get(fieldName)?.value as string[]) || [];
|
||||
if (!values.includes(event.value as string)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value as string]);
|
||||
}
|
||||
(event.originalEvent.target as HTMLInputElement).value = '';
|
||||
}
|
||||
@@ -604,7 +605,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||
this.copiedFields[field] = true;
|
||||
return this.fetchedMetadata[field] || null;
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as number | null) || null;
|
||||
}
|
||||
return Number(formValue);
|
||||
}
|
||||
@@ -613,7 +614,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
const formValue = this.metadataForm.get('pageCount')?.value;
|
||||
if (formValue === '' || formValue === null || isNaN(formValue)) {
|
||||
this.copiedFields['pageCount'] = true;
|
||||
return this.fetchedMetadata.pageCount || null;
|
||||
return (this.fetchedMetadata.pageCount as number | null) || null;
|
||||
}
|
||||
return Number(formValue);
|
||||
}
|
||||
@@ -622,20 +623,20 @@ export class MetadataPickerComponent implements OnInit {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (!formValue || formValue === '') {
|
||||
this.copiedFields[field] = true;
|
||||
return this.fetchedMetadata[field] || '';
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as string) || '';
|
||||
}
|
||||
return formValue;
|
||||
}
|
||||
|
||||
getArrayFromFormField(field: string, fallbackValue: any): any[] {
|
||||
getArrayFromFormField(field: string, fallbackValue: unknown): string[] {
|
||||
const fieldValue = this.metadataForm.get(field)?.value;
|
||||
if (!fieldValue) {
|
||||
return fallbackValue ? (Array.isArray(fallbackValue) ? fallbackValue : [fallbackValue]) : [];
|
||||
return fallbackValue ? (Array.isArray(fallbackValue) ? fallbackValue as string[] : [fallbackValue as string]) : [];
|
||||
}
|
||||
if (typeof fieldValue === 'string') {
|
||||
return fieldValue.split(',').map(item => item.trim());
|
||||
}
|
||||
return Array.isArray(fieldValue) ? fieldValue : [];
|
||||
return Array.isArray(fieldValue) ? fieldValue as string[] : [];
|
||||
}
|
||||
|
||||
lockAll(): void {
|
||||
|
||||
+5
-4
@@ -11,6 +11,7 @@ import {BookService} from '../../../book/service/book.service';
|
||||
import {Book, BulkMetadataUpdateRequest} from '../../../book/model/book.model';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {AutoCompleteSelectEvent} from 'primeng/autocomplete';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {filter, take} from "rxjs/operators";
|
||||
|
||||
@@ -181,10 +182,10 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onAutoCompleteSelect(fieldName: string, event: any) {
|
||||
const values = this.metadataForm.get(fieldName)?.value || [];
|
||||
if (!values.includes(event.value)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value]);
|
||||
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
|
||||
const values = (this.metadataForm.get(fieldName)?.value as string[]) || [];
|
||||
if (!values.includes(event.value as string)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value as string]);
|
||||
}
|
||||
(event.originalEvent.target as HTMLInputElement).value = "";
|
||||
}
|
||||
|
||||
+5
-2
@@ -556,8 +556,11 @@ export class MetadataManagerComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
filterGlobal(event: any, dt: any) {
|
||||
dt.filterGlobal(event.target.value, 'contains');
|
||||
filterGlobal(event: Event, dt: { filterGlobal: (value: string, matchMode: string) => void }): void {
|
||||
const target = event.target as HTMLInputElement;
|
||||
if (target) {
|
||||
dt.filterGlobal(target.value, 'contains');
|
||||
}
|
||||
}
|
||||
|
||||
onMetadataClick(type: MetadataType, value: string): void {
|
||||
|
||||
+1
-5
@@ -1,11 +1,9 @@
|
||||
<div #epubContainer class="epub-viewer-container">
|
||||
<div class="epub-viewer-container">
|
||||
@if (isLoading) {
|
||||
<div class="spinner-wrapper">
|
||||
<p-progressSpinner></p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
@if (!isLoading) {
|
||||
<div>
|
||||
@if (isDrawerVisible) {
|
||||
<div class="drawer-backdrop" (click)="isDrawerVisible = false; startHeaderAutoHide()"></div>
|
||||
}
|
||||
@@ -302,8 +300,6 @@
|
||||
@if (selectedFlow !== 'scrolled') {
|
||||
<button class="epub-controls-right" [class.visible]="showControls" [class.dark-theme]="selectedTheme === 'black' || selectedTheme === 'grey'" (click)="nextPage(); onBookTouch()">→</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<app-bookmark-edit-dialog
|
||||
[(visible)]="showEditBookmarkDialog"
|
||||
|
||||
+90
-75
@@ -73,6 +73,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
showEditBookmarkDialog = false;
|
||||
|
||||
private book: any;
|
||||
private epubArrayBuffer: ArrayBuffer | null = null;
|
||||
private rendition: any;
|
||||
private keyListener: (e: KeyboardEvent) => void = () => {
|
||||
};
|
||||
@@ -146,11 +147,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
this.pageTitle.setBookPageTitle(epub);
|
||||
|
||||
fileReader.onload = () => {
|
||||
this.book = ePub(fileReader.result as ArrayBuffer);
|
||||
|
||||
this.book.loaded.navigation.then((nav: any) => {
|
||||
this.chapters = this.extractChapters(nav.toc, 0);
|
||||
});
|
||||
this.epubArrayBuffer = fileReader.result as ArrayBuffer;
|
||||
|
||||
const settingScope = myself.userSettings.perBookSetting.epub;
|
||||
const globalSettings = myself.userSettings.epubReaderSetting;
|
||||
@@ -171,48 +168,8 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
if (resolvedFlow != null) this.selectedFlow = resolvedFlow;
|
||||
if (resolvedSpread != null) this.selectedSpread = resolvedSpread;
|
||||
|
||||
this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
|
||||
flow: this.selectedFlow ?? 'paginated',
|
||||
manager: this.selectedFlow === 'scrolled' ? 'continuous' : 'default',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
spread: this.selectedFlow === 'paginated' && !this.isMobileDevice() ? (this.selectedSpread === 'single' ? 'none' : this.selectedSpread) : 'none',
|
||||
allowScriptedContent: true,
|
||||
});
|
||||
|
||||
const baseTheme = EpubThemeUtil.themesMap.get(this.selectedTheme ?? 'black') || {};
|
||||
const combinedTheme = {
|
||||
...baseTheme,
|
||||
body: {
|
||||
...baseTheme.body,
|
||||
...(this.selectedFontType ? {'font-family': this.selectedFontType} : {}),
|
||||
...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}),
|
||||
...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}),
|
||||
},
|
||||
'*': {
|
||||
...baseTheme['*'],
|
||||
...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}),
|
||||
...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}),
|
||||
},
|
||||
};
|
||||
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.rendition.themes.register('custom', combinedTheme);
|
||||
this.rendition.themes.select('custom');
|
||||
|
||||
const displayPromise = this.epub?.epubProgress?.cfi
|
||||
? this.rendition.display(this.epub.epubProgress.cfi)
|
||||
: this.rendition.display();
|
||||
|
||||
displayPromise.then(() => {
|
||||
this.updateCurrentChapter(this.rendition.currentLocation());
|
||||
this.setupKeyListener();
|
||||
this.trackProgress();
|
||||
this.setupTouchListener();
|
||||
this.isLoading = false;
|
||||
this.startHeaderAutoHide();
|
||||
});
|
||||
|
||||
this.initBook();
|
||||
this.initRendition();
|
||||
};
|
||||
|
||||
fileReader.readAsArrayBuffer(epubData);
|
||||
@@ -269,21 +226,10 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
if (!this.rendition || !this.book) return;
|
||||
|
||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||
this.rendition.destroy();
|
||||
const locations = this.book.locations.save();
|
||||
|
||||
this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
|
||||
flow: this.selectedFlow,
|
||||
manager: this.selectedFlow === 'scrolled' ? 'continuous' : 'default',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
spread: this.selectedFlow === 'paginated' && !this.isMobileDevice() ? (this.selectedSpread === 'single' ? 'none' : this.selectedSpread) : 'none',
|
||||
allowScriptedContent: true,
|
||||
});
|
||||
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.applyCombinedTheme();
|
||||
this.setupKeyListener();
|
||||
this.rendition.display(cfi || undefined);
|
||||
this.initBook(locations);
|
||||
this.initRendition(cfi);
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
@@ -291,21 +237,10 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
if (!this.rendition || !this.book || this.selectedFlow === 'scrolled' || this.isMobileDevice()) return;
|
||||
|
||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||
this.rendition.destroy();
|
||||
const locations = this.book.locations.save();
|
||||
|
||||
this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
|
||||
flow: this.selectedFlow,
|
||||
manager: 'default',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
spread: this.selectedSpread === 'single' ? 'none' : this.selectedSpread,
|
||||
allowScriptedContent: true,
|
||||
});
|
||||
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.applyCombinedTheme();
|
||||
this.setupKeyListener();
|
||||
this.rendition.display(cfi || undefined);
|
||||
this.initBook(locations);
|
||||
this.initRendition(cfi);
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
@@ -645,6 +580,9 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
|
||||
this.book.ready.then(() => {
|
||||
if (this.locationsReady && this.book.locations.total > 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this.book.locations.generate(1600);
|
||||
}).then(() => {
|
||||
this.locationsReady = true;
|
||||
@@ -665,6 +603,83 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private initBook(restoreLocations?: string): void {
|
||||
if (!this.epubArrayBuffer) return;
|
||||
|
||||
if (this.book) {
|
||||
this.book.destroy();
|
||||
}
|
||||
|
||||
this.book = ePub(this.epubArrayBuffer);
|
||||
|
||||
this.book.loaded.navigation.then((nav: any) => {
|
||||
this.chapters = this.extractChapters(nav.toc, 0);
|
||||
});
|
||||
|
||||
if (restoreLocations) {
|
||||
this.book.ready.then(() => {
|
||||
this.book.locations.load(restoreLocations);
|
||||
this.locationsReady = true;
|
||||
});
|
||||
} else {
|
||||
this.locationsReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
private initRendition(targetCfi?: string): void {
|
||||
if (!this.book) return;
|
||||
|
||||
if (this.rendition) {
|
||||
try {
|
||||
this.rendition.destroy();
|
||||
} catch (e) {
|
||||
console.warn('Error destroying rendition', e);
|
||||
}
|
||||
}
|
||||
|
||||
this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
|
||||
flow: this.selectedFlow ?? 'paginated',
|
||||
manager: this.selectedFlow === 'scrolled' ? 'continuous' : 'default',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
spread: this.selectedFlow === 'paginated' && !this.isMobileDevice() ? (this.selectedSpread === 'single' ? 'none' : this.selectedSpread) : 'none',
|
||||
allowScriptedContent: true,
|
||||
});
|
||||
|
||||
const baseTheme = EpubThemeUtil.themesMap.get(this.selectedTheme ?? 'black') || {};
|
||||
const combinedTheme = {
|
||||
...baseTheme,
|
||||
body: {
|
||||
...(baseTheme.body || {}),
|
||||
...(this.selectedFontType ? {'font-family': this.selectedFontType} : {}),
|
||||
...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}),
|
||||
...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}),
|
||||
},
|
||||
'*': {
|
||||
...(baseTheme['*'] || {}),
|
||||
...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}),
|
||||
...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}),
|
||||
},
|
||||
};
|
||||
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.rendition.themes.register('custom', combinedTheme);
|
||||
this.rendition.themes.select('custom');
|
||||
|
||||
const displayPromise = targetCfi
|
||||
? this.rendition.display(targetCfi)
|
||||
: (this.epub?.epubProgress?.cfi ? this.rendition.display(this.epub.epubProgress.cfi) : this.rendition.display());
|
||||
|
||||
displayPromise.then(() => {
|
||||
this.updateCurrentChapter(this.rendition.currentLocation());
|
||||
this.setupKeyListener();
|
||||
this.trackProgress();
|
||||
this.setupTouchListener();
|
||||
this.isLoading = false;
|
||||
this.startHeaderAutoHide();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.readingSessionService.isSessionActive()) {
|
||||
this.readingSessionService.endSession(
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import {EpubCFI} from 'epubjs';
|
||||
import { Book, EpubCFI, Location, TocItem } from 'epubjs';
|
||||
|
||||
export const FALLBACK_EPUB_SETTINGS = {
|
||||
maxFontSize: 300,
|
||||
minFontSize: 50
|
||||
};
|
||||
|
||||
export function flatten(chapters: any) {
|
||||
return [].concat.apply([], chapters.map((chapter: any) => [].concat.apply([chapter], flatten(chapter.subitems))));
|
||||
export function flatten(chapters: TocItem[]): TocItem[] {
|
||||
if (!chapters || !Array.isArray(chapters)) return [];
|
||||
return chapters.flatMap((chapter: TocItem) => [chapter, ...flatten(chapter.subitems || [])]);
|
||||
}
|
||||
|
||||
export function getCfiFromHref(book: any, href: string): string | null {
|
||||
export function getCfiFromHref(book: Book, href: string): string | null {
|
||||
const [_, id] = href.split('#');
|
||||
const section = book.spine.get(href);
|
||||
|
||||
@@ -27,18 +28,20 @@ export function getCfiFromHref(book: any, href: string): string | null {
|
||||
return section.cfiFromElement(el);
|
||||
}
|
||||
|
||||
export function getChapter(book: any, location: any) {
|
||||
export function getChapter(book: Book, location: Location): TocItem | null {
|
||||
const locationHref = location.start.href;
|
||||
return flatten(book.navigation.toc)
|
||||
.filter((chapter: any) => {
|
||||
return book.canonical(chapter.href).includes(book.canonical(locationHref));
|
||||
return flatten(book.navigation.toc || [])
|
||||
.filter((chapter: TocItem) => {
|
||||
return chapter.href && book.canonical && typeof book.canonical === 'function' &&
|
||||
book.canonical(chapter.href).includes(book.canonical(locationHref));
|
||||
})
|
||||
.reduce((result: any | null, chapter: any) => {
|
||||
.reduce((result: TocItem | null, chapter: TocItem) => {
|
||||
if (!chapter.href) return result;
|
||||
const chapterCfi = getCfiFromHref(book, chapter.href);
|
||||
if (!chapterCfi) {
|
||||
return result;
|
||||
}
|
||||
const locationAfterChapter = EpubCFI.prototype.compare(location.start.cfi, chapterCfi) > 0;
|
||||
const locationAfterChapter = (EpubCFI.prototype as any).compare(location.start.cfi, chapterCfi) > 0;
|
||||
return locationAfterChapter ? chapter : result;
|
||||
}, null);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
interface EpubThemeObject {
|
||||
body?: Record<string, string>;
|
||||
p?: Record<string, string>;
|
||||
'h1, h2, h3, h4, h5, h6'?: Record<string, string>;
|
||||
a?: Record<string, string>;
|
||||
img?: Record<string, string>;
|
||||
code?: Record<string, string>;
|
||||
'*'?: Record<string, string>;
|
||||
[key: string]: Record<string, string> | undefined;
|
||||
}
|
||||
|
||||
interface EpubRenditionThemes {
|
||||
register(name: string, theme: EpubThemeObject): void;
|
||||
select(name: string): void;
|
||||
}
|
||||
|
||||
interface EpubRenditionMinimal {
|
||||
themes: {
|
||||
register(name: string, theme: Record<string, Record<string, string>>): void;
|
||||
select(name: string): void;
|
||||
};
|
||||
}
|
||||
|
||||
export enum EpubTheme {
|
||||
WHITE = 'white',
|
||||
BLACK = 'black',
|
||||
@@ -17,7 +40,7 @@ export enum EpubTheme {
|
||||
}
|
||||
|
||||
export class EpubThemeUtil {
|
||||
static readonly themesMap = new Map<string, any>([
|
||||
static readonly themesMap = new Map<string, EpubThemeObject>([
|
||||
[EpubTheme.BLACK, {
|
||||
"body": {"background-color": "#000000", "color": "#f9f9f9"},
|
||||
"p": {"color": "#f9f9f9"},
|
||||
@@ -177,27 +200,27 @@ export class EpubThemeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static applyTheme(rendition: any, themeKey: string, fontFamily?: string, fontSize?: number, lineHeight?: number, letterSpacing?: number): void {
|
||||
static applyTheme(rendition: EpubRenditionMinimal, themeKey: string, fontFamily?: string, fontSize?: number, lineHeight?: number, letterSpacing?: number): void {
|
||||
if (!rendition) return;
|
||||
|
||||
const baseTheme = this.themesMap.get(themeKey ?? 'black') ?? {};
|
||||
const combined = {
|
||||
const baseTheme = this.themesMap.get(themeKey ?? 'black') as EpubThemeObject ?? {};
|
||||
const combined: EpubThemeObject = {
|
||||
...baseTheme,
|
||||
body: {
|
||||
...baseTheme.body,
|
||||
'font-family': fontFamily,
|
||||
...(baseTheme.body || {}),
|
||||
...(fontFamily && { 'font-family': fontFamily }),
|
||||
'font-size': `${fontSize ?? 100}%`,
|
||||
'line-height': lineHeight,
|
||||
'letter-spacing': `${letterSpacing}em`
|
||||
...(lineHeight && { 'line-height': lineHeight.toString() }),
|
||||
'letter-spacing': `${letterSpacing ?? 0}em`
|
||||
},
|
||||
'*': {
|
||||
...baseTheme['*'],
|
||||
'line-height': lineHeight,
|
||||
'letter-spacing': `${letterSpacing}em`
|
||||
...(baseTheme['*'] || {}),
|
||||
...(lineHeight && { 'line-height': lineHeight.toString() }),
|
||||
'letter-spacing': `${letterSpacing ?? 0}em`
|
||||
}
|
||||
};
|
||||
|
||||
rendition.themes.register('custom', combined);
|
||||
rendition.themes.register('custom', combined as Record<string, Record<string, string>>);
|
||||
rendition.themes.select('custom');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy {
|
||||
this.bookService.savePdfProgress(this.bookId, this.page, percentage).subscribe();
|
||||
}
|
||||
|
||||
onPdfPagesLoaded(event: any): void {
|
||||
onPdfPagesLoaded(event: { pagesCount: number }): void {
|
||||
this.totalPages = event.pagesCount;
|
||||
const percentage = this.totalPages > 0 ? Math.round((this.page / this.totalPages) * 1000) / 10 : 0;
|
||||
this.readingSessionService.startSession(this.bookId, "PDF", this.page.toString(), percentage);
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ export class KoreaderService {
|
||||
private http = inject(HttpClient);
|
||||
|
||||
createUser(username: string, password: string): Observable<KoreaderUser> {
|
||||
const payload: any = {username, password};
|
||||
const payload: unknown = {username, password};
|
||||
return this.http.put<KoreaderUser>(`${this.url}/me`, payload);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
private emailProvidersService = inject(EmailV2ProviderService);
|
||||
private messageService = inject(MessageService);
|
||||
private userService = inject(UserService);
|
||||
defaultProviderId: any;
|
||||
defaultProviderId: unknown;
|
||||
currentUserId: number | null = null;
|
||||
isAdmin: boolean = false;
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
private emailRecipientService = inject(EmailV2RecipientService);
|
||||
private messageService = inject(MessageService);
|
||||
defaultRecipientId: any;
|
||||
defaultRecipientId: unknown;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadRecipientEmails();
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ export class ReaderPreferencesService implements OnDestroy {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
updatePreference(path: string[], value: any): void {
|
||||
updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
|
||||
let target: any = this.currentUser.userSettings;
|
||||
|
||||
+3
-3
@@ -76,8 +76,8 @@
|
||||
<i class="pi pi-clock"></i>
|
||||
<span class="cron-label">Scheduled:</span>
|
||||
@if (!isEditingCron(taskInfo.taskType)) {
|
||||
@if (getCronConfig(taskInfo.taskType).cronExpression) {
|
||||
<span class="cron-expression">{{ getCronConfig(taskInfo.taskType).cronExpression }}</span>
|
||||
@if (getCronConfig(taskInfo.taskType)?.cronExpression) {
|
||||
<span class="cron-expression">{{ getCronConfig(taskInfo.taskType)!.cronExpression }}</span>
|
||||
} @else {
|
||||
<span class="cron-expression empty">Not configured</span>
|
||||
}
|
||||
@@ -131,7 +131,7 @@
|
||||
</div>
|
||||
}
|
||||
<p-toggleswitch
|
||||
[ngModel]="getCronConfig(taskInfo.taskType).enabled"
|
||||
[ngModel]="getCronConfig(taskInfo.taskType)?.enabled ?? false"
|
||||
[disabled]="isEditingCron(taskInfo.taskType) || cronUpdating"
|
||||
(ngModelChange)="toggleCronEnabled(taskInfo.taskType)">
|
||||
</p-toggleswitch>
|
||||
|
||||
@@ -5,7 +5,8 @@ import {ProgressBar} from 'primeng/progressbar';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TaskInfo, MetadataReplaceMode, TaskHistory, TASK_TYPE_CONFIG, TaskCreateRequest, TaskCronConfigRequest, TaskProgressPayload, TaskService, TaskStatus, TaskType} from './task.service';
|
||||
import {TaskInfo, MetadataReplaceMode, TaskHistory, TASK_TYPE_CONFIG, TaskCreateRequest, TaskCronConfigRequest, TaskProgressPayload, TaskService, TaskStatus, TaskType, LibraryRescanOptions} from './task.service';
|
||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {finalize, forkJoin, Subscription} from 'rxjs';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
@@ -174,7 +175,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
||||
this.runTaskWithOptions(type, options);
|
||||
}
|
||||
|
||||
private runTaskWithOptions(type: string, options: any): void {
|
||||
private runTaskWithOptions(type: string, options: LibraryRescanOptions | MetadataRefreshRequest | null): void {
|
||||
const request: TaskCreateRequest = {
|
||||
taskType: type as TaskType,
|
||||
options: options
|
||||
@@ -273,9 +274,15 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
||||
return taskInfo?.cronSupported || false;
|
||||
}
|
||||
|
||||
getCronConfig(taskType: string): any {
|
||||
getCronConfig(taskType: string): { enabled?: boolean; cronExpression?: string } | null | undefined {
|
||||
const taskInfo = this.taskInfos.find(t => t.taskType === taskType);
|
||||
return taskInfo?.cronConfig;
|
||||
if (!taskInfo?.cronConfig) return null;
|
||||
|
||||
const cronConfig = taskInfo.cronConfig;
|
||||
return {
|
||||
enabled: cronConfig.enabled,
|
||||
cronExpression: cronConfig.cronExpression ?? undefined
|
||||
};
|
||||
}
|
||||
|
||||
toggleCronEnabled(taskType: string): void {
|
||||
@@ -283,7 +290,7 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
|
||||
if (!cronConfig) return;
|
||||
|
||||
const request: TaskCronConfigRequest = {
|
||||
enabled: !cronConfig.enabled
|
||||
enabled: !(cronConfig.enabled ?? false)
|
||||
};
|
||||
|
||||
this.updateCronConfig(taskType, request);
|
||||
|
||||
@@ -66,7 +66,7 @@ export interface CronConfig {
|
||||
taskType: string;
|
||||
cronExpression: string | null;
|
||||
enabled: boolean;
|
||||
options: Record<string, any> | null;
|
||||
options: Record<string, unknown> | null;
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {LowerCasePipe, TitleCasePipe} from '@angular/common';
|
||||
import {User, UserService} from './user.service';
|
||||
|
||||
interface UserWithEditing extends User {
|
||||
isEditing?: boolean;
|
||||
selectedLibraryIds?: number[];
|
||||
libraryNames?: string;
|
||||
}
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
@@ -43,7 +49,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
private messageService = inject(MessageService);
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
users: User[] = [];
|
||||
users: UserWithEditing[] = [];
|
||||
currentUser: User | null = null;
|
||||
editingLibraryIds: number[] = [];
|
||||
allLibraries: Library[] = [];
|
||||
@@ -91,7 +97,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
this.users = data.map((user) => ({
|
||||
...user,
|
||||
isEditing: false,
|
||||
selectedLibraryIds: user.assignedLibraries?.map((lib) => lib.id) || [],
|
||||
selectedLibraryIds: user.assignedLibraries?.map((lib) => lib.id!).filter(id => id !== undefined) as number[] || [],
|
||||
libraryNames:
|
||||
user.assignedLibraries?.map((lib) => lib.name).join(', ') || '',
|
||||
}));
|
||||
@@ -115,10 +121,10 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
toggleEdit(user: any) {
|
||||
toggleEdit(user: UserWithEditing) {
|
||||
user.isEditing = !user.isEditing;
|
||||
if (user.isEditing) {
|
||||
this.editingLibraryIds = [...user.selectedLibraryIds];
|
||||
this.editingLibraryIds = [...(user.selectedLibraryIds || [])];
|
||||
} else {
|
||||
user.libraryNames =
|
||||
user.assignedLibraries
|
||||
@@ -127,14 +133,14 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
saveUser(user: any) {
|
||||
saveUser(user: UserWithEditing) {
|
||||
user.selectedLibraryIds = [...this.editingLibraryIds];
|
||||
this.userService
|
||||
.updateUser(user.id, {
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
permissions: user.permissions,
|
||||
assignedLibraries: user.selectedLibraryIds,
|
||||
assignedLibraries: this.allLibraries.filter(lib => lib.id && user.selectedLibraryIds?.includes(lib.id)),
|
||||
})
|
||||
.subscribe({
|
||||
next: () => {
|
||||
@@ -291,7 +297,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
return this.expandedRows[user.id];
|
||||
}
|
||||
|
||||
onAdminCheckboxChange(user: any) {
|
||||
onAdminCheckboxChange(user: User) {
|
||||
if (user.permissions.admin) {
|
||||
user.permissions.canUpload = true;
|
||||
user.permissions.canDownload = true;
|
||||
@@ -322,7 +328,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
isPermissionDisabled(user: any): boolean {
|
||||
isPermissionDisabled(user: UserWithEditing): boolean {
|
||||
return !user.isEditing || user.permissions.admin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ export class UserStatsService {
|
||||
}
|
||||
|
||||
getFavoriteDays(year?: number, month?: number): Observable<FavoriteDaysResponse[]> {
|
||||
let params: any = {};
|
||||
let params: Record<string, string> = {};
|
||||
if (year !== undefined && year !== null) {
|
||||
params.year = year.toString();
|
||||
params['year'] = year.toString();
|
||||
}
|
||||
if (month !== undefined && month !== null) {
|
||||
params.month = month.toString();
|
||||
params['month'] = month.toString();
|
||||
}
|
||||
|
||||
return this.http.get<FavoriteDaysResponse[]>(
|
||||
@@ -99,12 +99,12 @@ export class UserStatsService {
|
||||
}
|
||||
|
||||
getPeakHours(year?: number, month?: number): Observable<PeakHoursResponse[]> {
|
||||
let params: any = {};
|
||||
let params: Record<string, string> = {};
|
||||
if (year !== undefined && year !== null) {
|
||||
params.year = year.toString();
|
||||
params['year'] = year.toString();
|
||||
}
|
||||
if (month !== undefined && month !== null) {
|
||||
params.month = month.toString();
|
||||
params['month'] = month.toString();
|
||||
}
|
||||
|
||||
return this.http.get<PeakHoursResponse[]>(
|
||||
|
||||
@@ -311,7 +311,7 @@ export class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
updateUserSetting(userId: number, key: string, value: any): void {
|
||||
updateUserSetting(userId: number, key: string, value: unknown): void {
|
||||
const payload = {
|
||||
key,
|
||||
value
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ export class FilterPreferencesComponent implements OnInit, OnDestroy {
|
||||
this.selectedFilterSortingMode = settings.filterSortingMode ?? 'alphabetical';
|
||||
}
|
||||
|
||||
private updatePreference(path: string[], value: any): void {
|
||||
private updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
|
||||
let target: any = this.currentUser.userSettings;
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
this.selectedMagicShelfSorting = settings.sidebarMagicShelfSorting;
|
||||
}
|
||||
|
||||
private updatePreference(path: string[], value: any): void {
|
||||
private updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
let target: any = this.currentUser.userSettings;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
|
||||
interface RatingStats {
|
||||
ratingRange: string;
|
||||
@@ -212,8 +213,16 @@ export class PersonalRatingChartComponent implements OnInit, OnDestroy {
|
||||
return this.processPersonalRatingStats(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private processPersonalRatingStats(books: Book[]): RatingStats[] {
|
||||
|
||||
+17
-8
@@ -3,9 +3,10 @@ import {CommonModule} from '@angular/common';
|
||||
import {BaseChartDirective} from 'ng2-charts';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, Chart, TooltipItem} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../../book/model/book.model';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
|
||||
interface ReadingStatusStats {
|
||||
status: string;
|
||||
@@ -154,8 +155,16 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
return this.processReadingStatusStats(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private processReadingStatusStats(books: Book[]): ReadingStatusStats[] {
|
||||
@@ -209,7 +218,7 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
return STATUS_MAPPING[status] ?? 'No Status';
|
||||
}
|
||||
|
||||
private generateLegendLabels(chart: any) {
|
||||
private generateLegendLabels(chart: Chart) {
|
||||
const data = chart.data;
|
||||
if (!data.labels?.length || !data.datasets?.[0]?.data?.length) {
|
||||
return [];
|
||||
@@ -218,13 +227,13 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
const dataset = data.datasets[0];
|
||||
const dataValues = dataset.data as number[];
|
||||
|
||||
return data.labels.map((label: string, index: number) => {
|
||||
return data.labels.map((label: unknown, index: number) => {
|
||||
const isVisible = typeof chart.getDataVisibility === 'function'
|
||||
? chart.getDataVisibility(index)
|
||||
: !((chart.getDatasetMeta && chart.getDatasetMeta(0)?.data?.[index]?.hidden) || false);
|
||||
: !((chart.getDatasetMeta && (chart.getDatasetMeta(0)?.data?.[index] as any)?.hidden) || false);
|
||||
|
||||
return {
|
||||
text: `${label} (${dataValues[index]})`,
|
||||
text: `${String(label)} (${dataValues[index]})`,
|
||||
fillStyle: (dataset.backgroundColor as string[])[index],
|
||||
strokeStyle: '#ffffff',
|
||||
lineWidth: 1,
|
||||
@@ -235,7 +244,7 @@ export class ReadStatusChartComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const dataset = context.dataset;
|
||||
const value = dataset.data[dataIndex] as number;
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../../book/model/book.model';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
|
||||
interface ReadingDNAProfile {
|
||||
adventurous: number;
|
||||
@@ -238,8 +239,16 @@ export class ReadingDNAChartComponent implements OnInit, OnDestroy {
|
||||
return this.analyzeReadingDNA(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private analyzeReadingDNA(books: Book[]): ReadingDNAProfile {
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../../book/model/book.model';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
|
||||
interface ReadingHabitsProfile {
|
||||
consistency: number;
|
||||
@@ -238,8 +239,16 @@ export class ReadingHabitsChartComponent implements OnInit, OnDestroy {
|
||||
return this.analyzeReadingHabits(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private analyzeReadingHabits(books: Book[]): ReadingHabitsProfile {
|
||||
|
||||
+11
-2
@@ -6,6 +6,7 @@ import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
|
||||
interface MatrixDataPoint {
|
||||
x: number; // month (0-11)
|
||||
@@ -204,8 +205,16 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
|
||||
return this.processHeatmapData(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private processHeatmapData(books: Book[]): YearMonthData[] {
|
||||
|
||||
+11
-2
@@ -5,6 +5,7 @@ import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {catchError, filter, first, takeUntil} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
|
||||
interface ReadingProgressStats {
|
||||
@@ -195,8 +196,16 @@ export class ReadingProgressChartComponent implements OnInit, OnDestroy {
|
||||
return this.processReadingProgressStats(currentState.books!);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private processReadingProgressStats(books: Book[]): ReadingProgressStats[] {
|
||||
|
||||
@@ -4,7 +4,8 @@ import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operato
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../book/model/book.model';
|
||||
import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
import {ChartConfiguration, ChartData, ChartType, TooltipItem} from 'chart.js';
|
||||
|
||||
interface AuthorStats {
|
||||
author: string;
|
||||
@@ -218,8 +219,16 @@ export class AuthorPopularityChartService implements OnDestroy {
|
||||
return this.processAuthorStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
@@ -290,7 +299,7 @@ export class AuthorPopularityChartService implements OnDestroy {
|
||||
})).filter(stat => stat.bookCount > 0);
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const stats = this.getLastCalculatedStats();
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, Chart, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface QualityScoreStats {
|
||||
category: string;
|
||||
@@ -159,8 +160,16 @@ export class BookQualityScoreChartService implements OnDestroy {
|
||||
return this.processQualityScoreStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -242,7 +251,7 @@ export class BookQualityScoreChartService implements OnDestroy {
|
||||
.sort((a, b) => b.averageScore - a.averageScore);
|
||||
}
|
||||
|
||||
private generateLegendLabels(chart: any) {
|
||||
private generateLegendLabels(chart: Chart) {
|
||||
const data = chart.data;
|
||||
if (!data.labels?.length || !data.datasets?.[0]?.data?.length) {
|
||||
return [];
|
||||
@@ -250,13 +259,13 @@ export class BookQualityScoreChartService implements OnDestroy {
|
||||
|
||||
const dataset = data.datasets[0];
|
||||
|
||||
return data.labels.map((label: string, index: number) => {
|
||||
return data.labels.map((label: unknown, index: number) => {
|
||||
const isVisible = typeof chart.getDataVisibility === 'function'
|
||||
? chart.getDataVisibility(index)
|
||||
: !((chart.getDatasetMeta && chart.getDatasetMeta(0)?.data?.[index]?.hidden) || false);
|
||||
: !((chart.getDatasetMeta && (chart.getDatasetMeta(0)?.data?.[index] as any)?.hidden) || false);
|
||||
|
||||
return {
|
||||
text: label,
|
||||
text: String(label),
|
||||
fillStyle: (dataset.backgroundColor as string[])[index],
|
||||
strokeStyle: '#ffffff',
|
||||
lineWidth: 1,
|
||||
@@ -267,7 +276,7 @@ export class BookQualityScoreChartService implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const qualityStats = this.getLastCalculatedStats();
|
||||
|
||||
@@ -276,8 +285,10 @@ export class BookQualityScoreChartService implements OnDestroy {
|
||||
}
|
||||
|
||||
const stats = qualityStats[dataIndex];
|
||||
const total = context.chart.data.datasets[0].data.reduce((a: number, b: number) => a + b, 0);
|
||||
const percentage = ((stats.count / total) * 100).toFixed(1);
|
||||
// Defensive: filter to numbers only, avoid division by zero
|
||||
const dataArr = (context.chart.data.datasets[0].data as (number | null | undefined)[]).filter((v): v is number => typeof v === 'number');
|
||||
const total = dataArr.reduce((a, b) => a + b, 0);
|
||||
const percentage = total > 0 ? ((stats.count / total) * 100).toFixed(1) : '0.0';
|
||||
|
||||
return `${stats.count} books (${percentage}%) | Average Score: ${stats.averageScore}/10 (${stats.scoreRange})`;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operato
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
|
||||
interface RatingStats {
|
||||
@@ -190,8 +191,16 @@ export class BookRatingChartService implements OnDestroy {
|
||||
return this.processRatingStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
|
||||
@@ -2,10 +2,12 @@ import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface BookSizeStats {
|
||||
title: string;
|
||||
@@ -195,8 +197,16 @@ export class BookSizeChartService implements OnDestroy {
|
||||
return this.processBookSizeStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -224,7 +234,7 @@ export class BookSizeChartService implements OnDestroy {
|
||||
return booksWithSize;
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const stats = this.getLastCalculatedStats();
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, ChartType, Chart, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface BookTypeStats {
|
||||
bookType: string;
|
||||
@@ -154,8 +155,16 @@ export class BookTypeChartService implements OnDestroy {
|
||||
this.updateChartData(stats);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -205,7 +214,7 @@ export class BookTypeChartService implements OnDestroy {
|
||||
return TYPE_MAPPING[type] || type;
|
||||
}
|
||||
|
||||
private generateLegendLabels(chart: any) {
|
||||
private generateLegendLabels(chart: Chart) {
|
||||
const data = chart.data;
|
||||
if (!data.labels?.length || !data.datasets?.[0]?.data?.length) {
|
||||
return [];
|
||||
@@ -214,8 +223,8 @@ export class BookTypeChartService implements OnDestroy {
|
||||
const dataset = data.datasets[0];
|
||||
const dataValues = dataset.data as number[];
|
||||
|
||||
return data.labels.map((label: string, index: number) => ({
|
||||
text: `${label} (${dataValues[index]})`,
|
||||
return data.labels.map((label: unknown, index: number) => ({
|
||||
text: `${String(label)} (${dataValues[index]})`,
|
||||
fillStyle: (dataset.backgroundColor as string[])[index],
|
||||
strokeStyle: '#ffffff',
|
||||
lineWidth: 1,
|
||||
@@ -225,7 +234,7 @@ export class BookTypeChartService implements OnDestroy {
|
||||
}));
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const dataset = context.dataset;
|
||||
const value = dataset.data[dataIndex] as number;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, Chart, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface LanguageStats {
|
||||
language: string;
|
||||
@@ -154,8 +155,16 @@ export class LanguageDistributionChartService implements OnDestroy {
|
||||
return this.processLanguageStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -246,7 +255,7 @@ export class LanguageDistributionChartService implements OnDestroy {
|
||||
.sort((a, b) => b.count - a.count);
|
||||
}
|
||||
|
||||
private generateLegendLabels(chart: any) {
|
||||
private generateLegendLabels(chart: Chart) {
|
||||
const data = chart.data;
|
||||
if (!data.labels?.length || !data.datasets?.[0]?.data?.length) {
|
||||
return [];
|
||||
@@ -255,13 +264,13 @@ export class LanguageDistributionChartService implements OnDestroy {
|
||||
const dataset = data.datasets[0];
|
||||
const dataValues = dataset.data as number[];
|
||||
|
||||
return data.labels.map((label: string, index: number) => {
|
||||
return data.labels.map((label: unknown, index: number) => {
|
||||
const isVisible = typeof chart.getDataVisibility === 'function'
|
||||
? chart.getDataVisibility(index)
|
||||
: !((chart.getDatasetMeta && chart.getDatasetMeta(0)?.data?.[index]?.hidden) || false);
|
||||
: !((chart.getDatasetMeta && (chart.getDatasetMeta(0)?.data?.[index] as any)?.hidden) || false);
|
||||
|
||||
return {
|
||||
text: `${label} (${dataValues[index]})`,
|
||||
text: `${String(label)} (${dataValues[index]})`,
|
||||
fillStyle: (dataset.backgroundColor as string[])[index],
|
||||
strokeStyle: '#ffffff',
|
||||
lineWidth: 1,
|
||||
@@ -272,7 +281,7 @@ export class LanguageDistributionChartService implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const dataset = context.dataset;
|
||||
const value = dataset.data[dataIndex] as number;
|
||||
|
||||
+13
-3
@@ -2,10 +2,12 @@ import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface MonthlyPattern {
|
||||
month: string;
|
||||
@@ -280,8 +282,16 @@ export class MonthlyReadingPatternsChartService implements OnDestroy {
|
||||
return this.processMonthlyPatternsStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -456,7 +466,7 @@ export class MonthlyReadingPatternsChartService implements OnDestroy {
|
||||
return `${monthNames[parseInt(month) - 1]} ${year}`;
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const datasetLabel = context.dataset.label;
|
||||
const value = context.parsed.y;
|
||||
const dataIndex = context.dataIndex;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface PageCountStats {
|
||||
category: string;
|
||||
@@ -179,8 +180,16 @@ export class PageCountChartService implements OnDestroy {
|
||||
return this.processPageCountStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, ChartType, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface PublicationYearStats {
|
||||
year: string;
|
||||
@@ -205,8 +206,16 @@ export class PublicationYearChartService implements OnDestroy {
|
||||
this.updateChartData(stats);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
@@ -244,7 +253,7 @@ export class PublicationYearChartService implements OnDestroy {
|
||||
return yearMatch ? parseInt(yearMatch[1]) : null;
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<any>): string {
|
||||
const value = context.parsed.y;
|
||||
return `${value} book${value === 1 ? '' : 's'} published`;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import {catchError, filter, first, map, switchMap, takeUntil} from 'rxjs/operato
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../book/model/book.model';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
import {ChartConfiguration, ChartData, TooltipItem} from 'chart.js';
|
||||
|
||||
interface CompletionStats {
|
||||
category: string;
|
||||
@@ -216,8 +217,16 @@ export class ReadingCompletionChartService implements OnDestroy {
|
||||
return this.processCompletionStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
@@ -269,7 +278,7 @@ export class ReadingCompletionChartService implements OnDestroy {
|
||||
).join(' ');
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<'bar'>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const stats = this.getLastCalculatedStats();
|
||||
|
||||
|
||||
+14
-5
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface VelocityTimelineData {
|
||||
month: string;
|
||||
@@ -261,8 +262,16 @@ export class ReadingVelocityTimelineChartService implements OnDestroy {
|
||||
return this.processVelocityTimelineStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -353,7 +362,7 @@ export class ReadingVelocityTimelineChartService implements OnDestroy {
|
||||
return `${monthNames[parseInt(month) - 1]} ${year}`;
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<'line'>): string {
|
||||
const datasetLabel = context.dataset.label;
|
||||
const value = context.parsed.y;
|
||||
const dataIndex = context.dataIndex;
|
||||
@@ -371,7 +380,7 @@ export class ReadingVelocityTimelineChartService implements OnDestroy {
|
||||
case 'Avg Pages/Day':
|
||||
return `${value} pages/day | ${monthStats.averagePages} avg pages/book`;
|
||||
case 'Avg Rating (×2)':
|
||||
const actualRating = value / 2;
|
||||
const actualRating = (value ?? 0) / 2;
|
||||
return `${actualRating.toFixed(1)}/5 avg rating | ${monthStats.booksCompleted} books rated`;
|
||||
case 'Reading Velocity':
|
||||
return `${value} books/month | ${monthStats.avgPagesPerDay} pages/day velocity`;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {ChartConfiguration, ChartData, ChartType} from 'chart.js';
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface CategoryStats {
|
||||
category: string;
|
||||
@@ -192,8 +193,16 @@ export class TopCategoriesChartService implements OnDestroy {
|
||||
this.updateChartData(stats);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | number | null): Book[] {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, EMPTY, Observable, Subject} from 'rxjs';
|
||||
import {map, takeUntil, catchError, filter, first, switchMap} from 'rxjs/operators';
|
||||
import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {ChartConfiguration, ChartData, TooltipItem} from 'chart.js';
|
||||
|
||||
import {LibraryFilterService} from './library-filter.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
|
||||
interface SeriesStats {
|
||||
seriesName: string;
|
||||
@@ -190,8 +191,16 @@ export class TopSeriesChartService implements OnDestroy {
|
||||
return this.processTopSeriesStats(filteredBooks);
|
||||
}
|
||||
|
||||
private isValidBookState(state: any): boolean {
|
||||
return state?.loaded && state?.books && Array.isArray(state.books) && state.books.length > 0;
|
||||
private isValidBookState(state: unknown): state is BookState {
|
||||
return (
|
||||
typeof state === 'object' &&
|
||||
state !== null &&
|
||||
'loaded' in state &&
|
||||
typeof (state as {loaded: boolean}).loaded === 'boolean' &&
|
||||
'books' in state &&
|
||||
Array.isArray((state as {books: unknown}).books) &&
|
||||
(state as {books: Book[]}).books.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private filterBooksByLibrary(books: Book[], selectedLibraryId: string | null): Book[] {
|
||||
@@ -241,7 +250,7 @@ export class TopSeriesChartService implements OnDestroy {
|
||||
return colors.slice(0, dataLength);
|
||||
}
|
||||
|
||||
private formatTooltipLabel(context: any): string {
|
||||
private formatTooltipLabel(context: TooltipItem<'bar'>): string {
|
||||
const dataIndex = context.dataIndex;
|
||||
const stats = this.getLastCalculatedStats();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {ReadStatusChartComponent} from '../component/read-status-chart/read-stat
|
||||
export interface UserChartConfig {
|
||||
id: string;
|
||||
title: string;
|
||||
component: any;
|
||||
component: unknown;
|
||||
enabled: boolean;
|
||||
sizeClass: string;
|
||||
order: number;
|
||||
@@ -99,7 +99,7 @@ export class UserChartConfigService {
|
||||
const config = JSON.parse(savedConfig);
|
||||
const charts = JSON.parse(JSON.stringify(this.defaultCharts));
|
||||
|
||||
config.forEach((saved: any) => {
|
||||
config.forEach((saved: Partial<UserChartConfig>) => {
|
||||
const chart = charts.find((c: UserChartConfig) => c.id === saved.id);
|
||||
if (chart) {
|
||||
chart.enabled = saved.enabled;
|
||||
|
||||
@@ -144,13 +144,20 @@ export class BookUploaderComponent implements OnInit {
|
||||
if (filesToUpload.length === 0) return;
|
||||
|
||||
this.isUploading = true;
|
||||
this.uploadBatch(filesToUpload, 0, 5);
|
||||
const destination = this.value;
|
||||
const libraryId = this.selectedLibrary?.id?.toString();
|
||||
const pathId = this.selectedPath?.id?.toString();
|
||||
|
||||
this.uploadBatch(filesToUpload, 0, 1, destination, libraryId, pathId);
|
||||
}
|
||||
|
||||
private uploadBatch(files: UploadingFile[], startIndex: number, batchSize: number): void {
|
||||
private uploadBatch(files: UploadingFile[], startIndex: number, batchSize: number, destination: string, libraryId?: string, pathId?: string): void {
|
||||
const batch = files.slice(startIndex, startIndex + batchSize);
|
||||
if (batch.length === 0) {
|
||||
this.isUploading = false;
|
||||
if (destination === 'bookdrop') {
|
||||
this.ref.close('uploaded_to_bookdrop');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,14 +167,16 @@ export class BookUploaderComponent implements OnInit {
|
||||
uploadFile.status = 'Uploading';
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', uploadFile.file);
|
||||
// Reconstruct the file to ensure strict type and name handling
|
||||
const cleanFile = new File([uploadFile.file], uploadFile.file.name, {type: uploadFile.file.type});
|
||||
formData.append('file', cleanFile, uploadFile.file.name);
|
||||
|
||||
let uploadUrl: string;
|
||||
if (this.value === 'library') {
|
||||
const libraryId = this.selectedLibrary!.id!.toString();
|
||||
const pathId = this.selectedPath!.id!.toString();
|
||||
formData.append('libraryId', libraryId);
|
||||
formData.append('pathId', pathId);
|
||||
if (destination === 'library') {
|
||||
if (libraryId && pathId) {
|
||||
formData.append('libraryId', libraryId);
|
||||
formData.append('pathId', pathId);
|
||||
}
|
||||
uploadUrl = `${API_CONFIG.BASE_URL}/api/v1/files/upload`;
|
||||
} else {
|
||||
uploadUrl = `${API_CONFIG.BASE_URL}/api/v1/files/upload/bookdrop`;
|
||||
@@ -177,7 +186,9 @@ export class BookUploaderComponent implements OnInit {
|
||||
next: () => {
|
||||
uploadFile.status = 'Uploaded';
|
||||
if (--pending === 0) {
|
||||
this.uploadBatch(files, startIndex + batchSize, batchSize);
|
||||
setTimeout(() => {
|
||||
this.uploadBatch(files, startIndex + batchSize, batchSize, destination, libraryId, pathId);
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
@@ -185,7 +196,9 @@ export class BookUploaderComponent implements OnInit {
|
||||
uploadFile.errorMessage = err?.error?.message || 'Upload failed due to unknown error.';
|
||||
console.error('Upload failed for', uploadFile.file.name, err);
|
||||
if (--pending === 0) {
|
||||
this.uploadBatch(files, startIndex + batchSize, batchSize);
|
||||
setTimeout(() => {
|
||||
this.uploadBatch(files, startIndex + batchSize, batchSize, destination, libraryId, pathId);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
styleUrls: ['./directory-picker.component.scss']
|
||||
})
|
||||
export class DirectoryPickerComponent implements OnInit {
|
||||
value: any;
|
||||
value: unknown;
|
||||
paths: string[] = [];
|
||||
filteredPaths: string[] = [];
|
||||
selectedProductName: string = '';
|
||||
|
||||
@@ -103,7 +103,7 @@ export class FileMoverComponent implements OnDestroy {
|
||||
const libraryId =
|
||||
book.libraryId ??
|
||||
book.libraryPath?.id ??
|
||||
(book as any).library?.id ??
|
||||
(book as { library?: { id: number } }).library?.id ??
|
||||
null;
|
||||
if (!booksByLibrary.has(libraryId)) {
|
||||
booksByLibrary.set(libraryId, []);
|
||||
@@ -157,7 +157,7 @@ export class FileMoverComponent implements OnDestroy {
|
||||
|
||||
const relativeOriginalPath = `${fileSubPath}${fileName}`;
|
||||
|
||||
const currentLibraryId = book.libraryId ?? book.libraryPath?.id ?? (book as any).library?.id ?? null;
|
||||
const currentLibraryId = book.libraryId ?? book.libraryPath?.id ?? (book as { library?: { id: number } }).library?.id ?? null;
|
||||
const currentLibraryName = this.getLibraryNameById(currentLibraryId);
|
||||
const currentLibraryPath = this.getLibraryPathById(currentLibraryId);
|
||||
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
private lastUpdateMap = new Map<string, number>();
|
||||
private timeoutHandles = new Map<string, any>();
|
||||
private timeoutHandles = new Map<string, number>();
|
||||
private readonly TASK_STALL_TIMEOUT_MS = 60 * 1000; // 1 minute
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -67,7 +67,7 @@ export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
||||
taskId,
|
||||
setTimeout(() => {
|
||||
this.markTaskStalled(taskId);
|
||||
}, this.TASK_STALL_TIMEOUT_MS)
|
||||
}, this.TASK_STALL_TIMEOUT_MS) as any
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class SetupGuard implements CanActivate {
|
||||
private router = inject(Router);
|
||||
|
||||
canActivate(): Observable<boolean | UrlTree> {
|
||||
return this.http.get<any>(`${this.url}/status`).pipe(
|
||||
return this.http.get<{ data: boolean }>(`${this.url}/status`).pipe(
|
||||
map(response => {
|
||||
if (response?.data === true) {
|
||||
return this.router.createUrlTree(['/login']);
|
||||
|
||||
@@ -22,9 +22,9 @@ export class AppLayoutComponent implements OnDestroy {
|
||||
|
||||
overlayMenuOpenSubscription: Subscription;
|
||||
|
||||
menuOutsideClickListener: any;
|
||||
menuOutsideClickListener: (() => void) | null = null;
|
||||
|
||||
profileMenuOutsideClickListener: any;
|
||||
profileMenuOutsideClickListener: (() => void) | null = null;
|
||||
|
||||
@ViewChild(AppSidebarComponent) appSidebar!: AppSidebarComponent;
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ export class LayoutService {
|
||||
};
|
||||
|
||||
private configUpdate = new Subject<AppConfig>();
|
||||
private overlayOpen = new Subject<any>();
|
||||
private overlayOpen = new Subject<unknown>();
|
||||
overlayOpen$ = this.overlayOpen.asObservable();
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {AppVersion, VersionService} from '../../../service/version.service';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UserService} from '../../../../features/settings/user-management/user.service';
|
||||
import {MagicShelfService, MagicShelfState} from '../../../../features/magic-shelf/service/magic-shelf.service';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
|
||||
@Component({
|
||||
@@ -21,10 +22,10 @@ import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
templateUrl: './app.menu.component.html',
|
||||
})
|
||||
export class AppMenuComponent implements OnInit {
|
||||
libraryMenu$: Observable<any> | undefined;
|
||||
shelfMenu$: Observable<any> | undefined;
|
||||
homeMenu$: Observable<any> | undefined;
|
||||
magicShelfMenu$: Observable<any> | undefined;
|
||||
libraryMenu$: Observable<MenuItem[]> | undefined;
|
||||
shelfMenu$: Observable<MenuItem[]> | undefined;
|
||||
homeMenu$: Observable<MenuItem[]> | undefined;
|
||||
magicShelfMenu$: Observable<MenuItem[]> | undefined;
|
||||
|
||||
versionInfo: AppVersion | null = null;
|
||||
dynamicDialogRef: DynamicDialogRef | undefined | null;
|
||||
@@ -216,8 +217,8 @@ export class AppMenuComponent implements OnInit {
|
||||
|
||||
private sortArray<T>(array: T[], field: 'name' | 'id', order: 'asc' | 'desc'): T[] {
|
||||
return [...array].sort((a, b) => {
|
||||
const aVal = (a as any)[field] ?? '';
|
||||
const bVal = (b as any)[field] ?? '';
|
||||
const aVal = (a as Record<string, unknown>)[field] ?? '';
|
||||
const bVal = (b as Record<string, unknown>)[field] ?? '';
|
||||
let comparison = 0;
|
||||
|
||||
if (typeof aVal === 'string' && typeof bVal === 'string') {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {UserService} from '../../../../features/settings/user-management/user.se
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
import {BookDialogHelperService} from '../../../../features/book/components/book-browser/BookDialogHelperService';
|
||||
import {IconDisplayComponent} from '../../../components/icon-display/icon-display.component';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {IconSelection} from '../../../service/icon-picker.service';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -68,7 +68,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
hasAnyTasks = false;
|
||||
hasPendingBookdropFiles = false;
|
||||
|
||||
private eventTimer: any;
|
||||
private eventTimer: number | undefined;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
private latestTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
||||
@@ -197,7 +197,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
clearTimeout(this.eventTimer);
|
||||
this.eventTimer = setTimeout(() => {
|
||||
this.showPulse = false;
|
||||
}, 4000);
|
||||
}, 4000) as unknown as number;
|
||||
}
|
||||
|
||||
private updateCompletedTaskCount() {
|
||||
|
||||
@@ -347,7 +347,7 @@ export class AppConfigService {
|
||||
}
|
||||
this.saveAppState(state);
|
||||
this.onPresetChange();
|
||||
}, {allowSignalWrites: true});
|
||||
});
|
||||
}
|
||||
|
||||
private loadAppState(): AppState {
|
||||
|
||||
@@ -92,7 +92,7 @@ export class AppSettingsService {
|
||||
}
|
||||
}
|
||||
|
||||
saveSettings(settings: { key: string; newValue: any }[]): Observable<void> {
|
||||
saveSettings(settings: { key: string; newValue: unknown }[]): Observable<void> {
|
||||
const payload = settings.map(setting => ({
|
||||
name: setting.key,
|
||||
value: setting.newValue
|
||||
|
||||
@@ -25,7 +25,7 @@ export class DownloadProgressService {
|
||||
private lastUpdateTime = 0;
|
||||
private updateThrottleMs = 100;
|
||||
private pendingUpdate: DownloadProgress | null = null;
|
||||
private throttleTimer: any = null;
|
||||
private throttleTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
downloadProgress$ = this.downloadProgressSubject.asObservable();
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ export class FileDownloadService {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private handleDownloadError(error: any): void {
|
||||
if (error?.name !== 'AbortError') {
|
||||
private handleDownloadError(error: unknown): void {
|
||||
if ((error as { name?: string })?.name !== 'AbortError') {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Download Failed',
|
||||
|
||||
@@ -66,7 +66,7 @@ export class MetadataProgressService implements OnDestroy {
|
||||
return result;
|
||||
}
|
||||
|
||||
private hasMetadataPermissions(user: any): boolean {
|
||||
private hasMetadataPermissions(user: { permissions: { admin: boolean; canEditMetadata: boolean } } | null): boolean {
|
||||
return !!(user?.permissions?.admin || user?.permissions?.canEditMetadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ export class ReadingSessionService {
|
||||
return this.currentSession !== null;
|
||||
}
|
||||
|
||||
private log(message: string, data?: any): void {
|
||||
private log(message: string, data?: unknown): void {
|
||||
if (data) {
|
||||
console.log(`[ReadingSession] ${message}`, data);
|
||||
} else {
|
||||
@@ -278,7 +278,7 @@ export class ReadingSessionService {
|
||||
}
|
||||
}
|
||||
|
||||
private logError(message: string, error?: any): void {
|
||||
private logError(message: string, error?: unknown): void {
|
||||
if (error) {
|
||||
console.error(`[ReadingSession] ${message}`, error);
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Injectable, Type} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {GithubSupportDialog} from '../components/github-support-dialog/github-support-dialog';
|
||||
import {LibraryCreatorComponent} from '../../features/library-creator/library-creator.component';
|
||||
@@ -37,8 +37,8 @@ export class DialogLauncherService {
|
||||
maximizable: false,
|
||||
}
|
||||
|
||||
openDialog(component: any, options: {}): DynamicDialogRef | null {
|
||||
return this.dialogService.open(component, {
|
||||
openDialog(component: unknown, options: {}): DynamicDialogRef | null {
|
||||
return this.dialogService.open(component as Type<any>, {
|
||||
...this.defaultDialogOptions,
|
||||
...options,
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ export class IconService {
|
||||
});
|
||||
}
|
||||
|
||||
deleteSvgIcon(svgName: string): Observable<any> {
|
||||
deleteSvgIcon(svgName: string): Observable<unknown> {
|
||||
return this.http.delete(`${this.baseUrl}/${encodeURIComponent(svgName)}`).pipe(
|
||||
tap(() => {
|
||||
this.iconCache.removeIcon(svgName);
|
||||
|
||||
@@ -16,7 +16,7 @@ export class NotificationEventService {
|
||||
private notificationHighlightSubject = new BehaviorSubject<boolean>(false);
|
||||
notificationHighlight$ = this.notificationHighlightSubject.asObservable();
|
||||
|
||||
private highlightTimeout: any;
|
||||
private highlightTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
handleNewNotification(notification: LogNotification): void {
|
||||
this.latestNotificationSubject.next(notification);
|
||||
|
||||
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
declare module 'epubjs' {
|
||||
export interface TocItem {
|
||||
id?: string;
|
||||
href: string;
|
||||
label: string;
|
||||
subitems?: TocItem[];
|
||||
}
|
||||
|
||||
export interface Navigation {
|
||||
toc: TocItem[];
|
||||
get(target: string): any;
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
start: {
|
||||
cfi: string;
|
||||
href: string;
|
||||
displayed: {
|
||||
page: number;
|
||||
total: number;
|
||||
};
|
||||
index: number;
|
||||
};
|
||||
end: {
|
||||
cfi: string;
|
||||
href: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Locations {
|
||||
total: number;
|
||||
generate(chars: number): Promise<void>;
|
||||
percentageFromCfi(cfi: string): number;
|
||||
}
|
||||
|
||||
export interface SpineItem {
|
||||
href: string;
|
||||
index: number;
|
||||
cfi: string;
|
||||
document?: Document;
|
||||
cfiFromElement(element: Element): string;
|
||||
}
|
||||
|
||||
export interface Spine {
|
||||
items: SpineItem[];
|
||||
get(href: string): SpineItem | null;
|
||||
}
|
||||
|
||||
export interface Themes {
|
||||
register(name: string, theme: any): void;
|
||||
select(name: string): void;
|
||||
override(property: string, value: string): void;
|
||||
font(name: string): void;
|
||||
fontSize(size: string): void;
|
||||
}
|
||||
|
||||
export interface Rendition {
|
||||
themes: Themes;
|
||||
display(target?: string): Promise<void>;
|
||||
prev(): Promise<void>;
|
||||
next(): Promise<void>;
|
||||
currentLocation(): Location | null;
|
||||
on(event: 'relocated', callback: (location: Location) => void): void;
|
||||
on(event: 'rendered', callback: (section: any) => void): void;
|
||||
on(event: 'keyup', callback: (event: KeyboardEvent) => void): void;
|
||||
on(event: string, callback: any): void;
|
||||
off(event: string, callback: any): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export interface Book {
|
||||
loaded: {
|
||||
navigation: Promise<Navigation>;
|
||||
};
|
||||
navigation: Navigation;
|
||||
spine: Spine;
|
||||
locations: Locations;
|
||||
ready: Promise<void>;
|
||||
rendition: Rendition;
|
||||
renderTo(element: HTMLElement, options: {
|
||||
flow?: string;
|
||||
manager?: string;
|
||||
width?: string;
|
||||
height?: string;
|
||||
spread?: string;
|
||||
allowScriptedContent?: boolean;
|
||||
}): Rendition;
|
||||
canonical(href: string): string;
|
||||
epubProgress?: { cfi: string };
|
||||
}
|
||||
|
||||
export class EpubCFI {
|
||||
compare(cfi1: string, cfi2: string): number;
|
||||
prototype: any; // Allow prototype access if needed
|
||||
}
|
||||
|
||||
export default function ePub(input: string | ArrayBuffer): Book;
|
||||
}
|
||||
Reference in New Issue
Block a user