chore: mechanical lint fixes (#2933)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -48,13 +48,13 @@
|
||||
</svg>
|
||||
<h1>{{ t('offline') }}</h1>
|
||||
<p>{{ t('connectionLost') }}</p>
|
||||
<button class="retry-btn" (click)="reload()">{{ 'common.retry' | transloco }}</button>
|
||||
<button type="button" class="retry-btn" (click)="reload()">{{ 'common.retry' | transloco }}</button>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<p-confirmDialog />
|
||||
<p-toast></p-toast>
|
||||
<p-toast />
|
||||
<app-command-palette />
|
||||
<router-outlet></router-outlet>
|
||||
<router-outlet />
|
||||
}
|
||||
</ng-container>
|
||||
|
||||
@@ -31,28 +31,27 @@ import {RxStompState} from '@stomp/rx-stomp';
|
||||
imports: [ConfirmDialog, Toast, RouterOutlet, TranslocoDirective, TranslocoPipe, CommandPaletteComponent]
|
||||
})
|
||||
export class AppComponent implements OnInit, OnDestroy {
|
||||
|
||||
loading = signal(true);
|
||||
offline = signal(false);
|
||||
private subscriptions: Subscription[] = [];
|
||||
private subscriptionsInitialized = false;
|
||||
|
||||
private appThemeService = inject(AppThemeService); // DO NOT REMOVE: Used to initialize app theme on startup
|
||||
private authInit = inject(AuthInitializationService);
|
||||
private bookService = inject(BookService);
|
||||
private authorService = inject(AuthorService);
|
||||
private rxStompService = inject(RxStompService);
|
||||
private notificationEventService = inject(NotificationEventService);
|
||||
private metadataProgressService = inject(MetadataProgressService);
|
||||
private bookdropFileService = inject(BookdropFileService);
|
||||
private taskService = inject(TaskService);
|
||||
private metadataRefreshSubmissionService = inject(MetadataRefreshSubmissionService);
|
||||
private libraryHealthService = inject(LibraryHealthService);
|
||||
private authService = inject(AuthService);
|
||||
private commandPaletteService = inject(CommandPaletteService);
|
||||
private readonly appThemeService = inject(AppThemeService); // DO NOT REMOVE: Used to initialize app theme on startup
|
||||
private readonly authInit = inject(AuthInitializationService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly rxStompService = inject(RxStompService);
|
||||
private readonly notificationEventService = inject(NotificationEventService);
|
||||
private readonly metadataProgressService = inject(MetadataProgressService);
|
||||
private readonly bookdropFileService = inject(BookdropFileService);
|
||||
private readonly taskService = inject(TaskService);
|
||||
private readonly metadataRefreshSubmissionService = inject(MetadataRefreshSubmissionService);
|
||||
private readonly libraryHealthService = inject(LibraryHealthService);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly commandPaletteService = inject(CommandPaletteService);
|
||||
private readonly libraryImportProgressService = inject(LibraryImportProgressService);
|
||||
private readonly translocoService = inject(TranslocoService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly loading = signal(true);
|
||||
readonly offline = signal(false);
|
||||
private readonly subscriptions: Subscription[] = [];
|
||||
private subscriptionsInitialized = false;
|
||||
private readonly syncAuthInitializationEffect = effect(() => {
|
||||
const ready = this.authInit.initialized();
|
||||
this.loading.set(!ready);
|
||||
@@ -79,7 +78,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
this.destroyRef.onDestroy(() => document.removeEventListener('keydown', this.onGlobalKeydown));
|
||||
}
|
||||
|
||||
private onGlobalKeydown = (event: KeyboardEvent): void => {
|
||||
private readonly onGlobalKeydown = (event: KeyboardEvent): void => {
|
||||
if (event.repeat) return;
|
||||
const combo = (event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey;
|
||||
if (!combo) return;
|
||||
@@ -88,11 +87,11 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
this.commandPaletteService.toggle();
|
||||
};
|
||||
|
||||
private onOnline = () => {
|
||||
private readonly onOnline = () => {
|
||||
this.offline.set(false);
|
||||
};
|
||||
|
||||
private onOffline = () => {
|
||||
private readonly onOffline = () => {
|
||||
this.checkServerReachable().then(reachable => {
|
||||
this.offline.set(!reachable);
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('TranslocoInlineLoader', () => {
|
||||
const translation = await firstValueFrom(loader.getTranslation('en'));
|
||||
|
||||
expect(translation).toBe(EN_TRANSLATIONS);
|
||||
expect(translation['auth']['login']['sessionRevoked']).toBe(en['auth']['login']['sessionRevoked']);
|
||||
expect(translation['auth']['login']['sessionRevoked']).toBe(en.auth.login.sessionRevoked);
|
||||
});
|
||||
|
||||
it('falls back to english for unsupported languages', async () => {
|
||||
@@ -25,9 +25,9 @@ describe('TranslocoInlineLoader', () => {
|
||||
const loader = new TranslocoInlineLoader();
|
||||
const translation = await firstValueFrom(loader.getTranslation('de'));
|
||||
|
||||
expect(translation['auth']['login']['oidcInitError']).toBe(de['auth']['login']['oidcInitError']);
|
||||
expect(translation['auth']['login']['sessionRevoked']).toBe(de['auth']['login']['sessionRevoked']);
|
||||
expect(translation['auth']['login']['oidcErrors']['providerUnreachable']).toBe(de['auth']['login']['oidcErrors']['providerUnreachable']);
|
||||
expect(translation['auth']['login']['oidcInitError']).toBe(de.auth.login.oidcInitError);
|
||||
expect(translation['auth']['login']['sessionRevoked']).toBe(de.auth.login.sessionRevoked);
|
||||
expect(translation['auth']['login']['oidcErrors']['providerUnreachable']).toBe(de.auth.login.oidcErrors.providerUnreachable);
|
||||
});
|
||||
|
||||
it('exposes the available language metadata', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Service} from '@angular/core';
|
||||
import {Translation, TranslocoLoader} from '@jsverse/transloco';
|
||||
import {from, of, Observable} from 'rxjs';
|
||||
import en from '../../../i18n/en.json';
|
||||
@@ -68,7 +68,7 @@ function deepMerge(base: Record<string, Translation>, override: Record<string, T
|
||||
return result;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class TranslocoInlineLoader implements TranslocoLoader {
|
||||
getTranslation(lang: string): Observable<Translation> {
|
||||
if (lang === 'en') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Service} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, BaseRouteReuseStrategy, Params} from '@angular/router';
|
||||
|
||||
function paramsMatch(a: Params, b: Params): boolean {
|
||||
@@ -7,9 +7,7 @@ function paramsMatch(a: Params, b: Params): boolean {
|
||||
return aKeys.length === bKeys.length && aKeys.every(key => a[key] === b[key]);
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class CustomReuseStrategy extends BaseRouteReuseStrategy {
|
||||
override shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
|
||||
return future.routeConfig === curr.routeConfig && paramsMatch(future.params, curr.params);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
import {Service, signal} from '@angular/core';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class AuthInitializationService {
|
||||
private readonly _initialized = signal(false);
|
||||
readonly initialized = this._initialized.asReadonly();
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('initializeAuthFactory', () => {
|
||||
};
|
||||
|
||||
const queryClient = {
|
||||
fetchQuery: vi.fn(),
|
||||
query: vi.fn(),
|
||||
};
|
||||
|
||||
const appSettingsService = {
|
||||
@@ -40,13 +40,13 @@ describe('initializeAuthFactory', () => {
|
||||
authService.getInternalAccessToken.mockReset();
|
||||
authService.remoteLogin.mockReset();
|
||||
authService.initializeWebSocketConnection.mockReset();
|
||||
queryClient.fetchQuery.mockReset();
|
||||
queryClient.query.mockReset();
|
||||
appSettingsService.getPublicSettingsQueryOptions.mockClear();
|
||||
});
|
||||
|
||||
it('marks auth initialized when public settings are unavailable', async () => {
|
||||
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
queryClient.fetchQuery.mockResolvedValue(null);
|
||||
queryClient.query.mockResolvedValue(null);
|
||||
|
||||
const injector = Injector.create({
|
||||
providers: [
|
||||
@@ -65,7 +65,7 @@ describe('initializeAuthFactory', () => {
|
||||
});
|
||||
|
||||
it('initializes websocket auth when local auth is active and a token exists', async () => {
|
||||
queryClient.fetchQuery.mockResolvedValue({...settingsBase, remoteAuthEnabled: false});
|
||||
queryClient.query.mockResolvedValue({...settingsBase, remoteAuthEnabled: false});
|
||||
authService.getInternalAccessToken.mockReturnValue('access-token');
|
||||
|
||||
const injector = Injector.create({
|
||||
@@ -84,7 +84,7 @@ describe('initializeAuthFactory', () => {
|
||||
});
|
||||
|
||||
it('skips websocket initialization when local auth is active and no token exists', async () => {
|
||||
queryClient.fetchQuery.mockResolvedValue({...settingsBase, remoteAuthEnabled: false});
|
||||
queryClient.query.mockResolvedValue({...settingsBase, remoteAuthEnabled: false});
|
||||
authService.getInternalAccessToken.mockReturnValue(null);
|
||||
|
||||
const injector = Injector.create({
|
||||
@@ -103,7 +103,7 @@ describe('initializeAuthFactory', () => {
|
||||
});
|
||||
|
||||
it('performs remote login when remote auth is enabled', async () => {
|
||||
queryClient.fetchQuery.mockResolvedValue({...settingsBase, remoteAuthEnabled: true});
|
||||
queryClient.query.mockResolvedValue({...settingsBase, remoteAuthEnabled: true});
|
||||
authService.remoteLogin.mockReturnValue(of({
|
||||
accessToken: 'access',
|
||||
refreshToken: 'refresh',
|
||||
@@ -127,7 +127,7 @@ describe('initializeAuthFactory', () => {
|
||||
|
||||
it('marks auth initialized even when remote login fails', async () => {
|
||||
const error = new Error('remote login failed');
|
||||
queryClient.fetchQuery.mockResolvedValue({...settingsBase, remoteAuthEnabled: true});
|
||||
queryClient.query.mockResolvedValue({...settingsBase, remoteAuthEnabled: true});
|
||||
authService.remoteLogin.mockReturnValue(throwError(() => error));
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export function initializeAuthFactory() {
|
||||
const authInitService = inject(AuthInitializationService);
|
||||
const queryClient = inject(QueryClient);
|
||||
|
||||
const settingsPromise = queryClient.fetchQuery(appSettingsService.getPublicSettingsQueryOptions());
|
||||
const settingsPromise = queryClient.query(appSettingsService.getPublicSettingsQueryOptions());
|
||||
const timeoutPromise = new Promise<null>(resolve =>
|
||||
setTimeout(() => resolve(null), SETTINGS_TIMEOUT_MS)
|
||||
);
|
||||
|
||||
+24
-42
@@ -41,8 +41,7 @@
|
||||
<p-checkbox
|
||||
[(ngModel)]="internalAuthEnabled"
|
||||
[binary]="true"
|
||||
[disabled]="true">
|
||||
</p-checkbox>
|
||||
[disabled]="true" />
|
||||
</div>
|
||||
|
||||
<div class="auth-method-item border-l-(--p-content-border-color) [&.is-active]:border-l-emerald-500 dark:[&.is-active]:border-l-emerald-300" [class.is-active]="oidcEnabled">
|
||||
@@ -62,7 +61,7 @@
|
||||
</div>
|
||||
<p class="auth-method-description">
|
||||
{{ t('oidc.description') }}
|
||||
<app-external-doc-link docType="authentication"></app-external-doc-link>
|
||||
<app-external-doc-link docType="authentication" />
|
||||
@if (!isOidcFormComplete() && !oidcEnabled) {
|
||||
<span class="config-hint">{{ t('oidc.configHint') }}</span>
|
||||
}
|
||||
@@ -71,8 +70,7 @@
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="oidcEnabled"
|
||||
[disabled]="!isOidcFormComplete()"
|
||||
(onChange)="toggleOidcEnabled()">
|
||||
</p-toggleswitch>
|
||||
(onChange)="toggleOidcEnabled()" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -158,8 +156,7 @@
|
||||
[showButtons]="true"
|
||||
[placeholder]="t('providerConfig.sessionDurationPlaceholder')"
|
||||
mode="decimal"
|
||||
[useGrouping]="false">
|
||||
</p-inputNumber>
|
||||
[useGrouping]="false" />
|
||||
<span class="field-hint">{{ t('providerConfig.sessionDurationHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -225,8 +222,7 @@
|
||||
[label]="redirectUri"
|
||||
[removable]="true"
|
||||
[attr.aria-label]="t('mobileRedirectUris.removeLabel', {uri: redirectUri})"
|
||||
(onRemove)="removeMobileRedirectUri(index)">
|
||||
</p-chip>
|
||||
(onRemove)="removeMobileRedirectUri(index)" />
|
||||
}
|
||||
<input
|
||||
pInputText
|
||||
@@ -279,8 +275,7 @@
|
||||
severity="info"
|
||||
size="small"
|
||||
(click)="testConnection()"
|
||||
[disabled]="!oidcProvider.issuerUri || isTestingConnection()">
|
||||
</p-button>
|
||||
[disabled]="!oidcProvider.issuerUri || isTestingConnection()" />
|
||||
<p-button
|
||||
[outlined]="true"
|
||||
[label]="'common.save' | transloco"
|
||||
@@ -288,8 +283,7 @@
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveOidcProvider()"
|
||||
[disabled]="!isOidcFormComplete()">
|
||||
</p-button>
|
||||
[disabled]="!isOidcFormComplete()" />
|
||||
</div>
|
||||
</div>
|
||||
@if (testConnectionResult() && showTestDetails()) {
|
||||
@@ -309,6 +303,7 @@
|
||||
@case ('SKIP') {
|
||||
<i class="pi pi-minus-circle text-(--color-text-muted)"></i>
|
||||
}
|
||||
@default never;
|
||||
}
|
||||
<span class="check-name">{{ check.name }}</span>
|
||||
<span class="check-message">{{ check.message }}</span>
|
||||
@@ -342,8 +337,7 @@
|
||||
severity="secondary"
|
||||
size="small"
|
||||
[style]="{'min-width': '2rem'}"
|
||||
(click)="copyToClipboard(item.value)">
|
||||
</p-button>
|
||||
(click)="copyToClipboard(item.value)" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -384,8 +378,7 @@
|
||||
</div>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="oidcForceOnlyMode"
|
||||
(onChange)="toggleOidcForceOnlyMode()">
|
||||
</p-toggleswitch>
|
||||
(onChange)="toggleOidcForceOnlyMode()" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -421,8 +414,7 @@
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="autoUserProvisioningEnabled"
|
||||
inputId="autoProvision"
|
||||
(onChange)="saveOidcAutoProvisionSettings()">
|
||||
</p-toggleswitch>
|
||||
(onChange)="saveOidcAutoProvisionSettings()" />
|
||||
</div>
|
||||
|
||||
<div class="provisioning-toggle">
|
||||
@@ -446,8 +438,7 @@
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="allowLocalAccountLinking"
|
||||
inputId="linkLocal"
|
||||
(onChange)="saveOidcAutoProvisionSettings()">
|
||||
</p-toggleswitch>
|
||||
(onChange)="saveOidcAutoProvisionSettings()" />
|
||||
</div>
|
||||
|
||||
@if (autoUserProvisioningEnabled) {
|
||||
@@ -460,8 +451,7 @@
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
[ngModel]="true"
|
||||
inputId="permissionRead">
|
||||
</p-checkbox>
|
||||
inputId="permissionRead" />
|
||||
<label for="permissionRead">{{ t('provisioning.readBooks') }}</label>
|
||||
</div>
|
||||
<ng-container *transloco="let a; prefix: 'settingsUsers'">
|
||||
@@ -470,8 +460,7 @@
|
||||
<p-checkbox
|
||||
[(ngModel)]="perm.selected"
|
||||
[binary]="true"
|
||||
[inputId]="perm.value">
|
||||
</p-checkbox>
|
||||
[inputId]="perm.value" />
|
||||
<label [for]="perm.value">{{ a(perm.translationKey) }}</label>
|
||||
</div>
|
||||
}
|
||||
@@ -490,16 +479,14 @@
|
||||
[placeholder]="t('provisioning.selectLibraries')"
|
||||
appendTo="body"
|
||||
class="libraries-select"
|
||||
style="flex: 1;">
|
||||
</p-multiSelect>
|
||||
style="flex: 1;" />
|
||||
<p-button
|
||||
icon="pi pi-save"
|
||||
[label]="'common.save' | transloco"
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveOidcAutoProvisionSettings()">
|
||||
</p-button>
|
||||
(click)="saveOidcAutoProvisionSettings()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -526,8 +513,7 @@
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="openNewGroupMapping()">
|
||||
</p-button>
|
||||
(click)="openNewGroupMapping()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -542,8 +528,7 @@
|
||||
[options]="groupSyncModeOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
appendTo="body" />
|
||||
<span class="field-hint">{{ t('groupMapping.syncModeHint') }}</span>
|
||||
</div>
|
||||
<div class="config-item" style="display: flex; align-items: flex-end;">
|
||||
@@ -553,8 +538,7 @@
|
||||
icon="pi pi-save"
|
||||
severity="success"
|
||||
size="small"
|
||||
(click)="saveGroupSyncMode()">
|
||||
</p-button>
|
||||
(click)="saveGroupSyncMode()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -591,8 +575,8 @@
|
||||
<td>{{ mapping.description }}</td>
|
||||
<td>
|
||||
<div style="display: flex; gap: 0.4375rem;">
|
||||
<p-button icon="pi pi-pencil" [rounded]="true" [text]="true" severity="info" size="small" (click)="openEditGroupMapping(mapping)"></p-button>
|
||||
<p-button icon="pi pi-trash" [rounded]="true" [text]="true" severity="danger" size="small" (click)="deleteGroupMapping(mapping)"></p-button>
|
||||
<p-button icon="pi pi-pencil" [rounded]="true" [text]="true" severity="info" size="small" (click)="openEditGroupMapping(mapping)" />
|
||||
<p-button icon="pi pi-trash" [rounded]="true" [text]="true" severity="danger" size="small" (click)="deleteGroupMapping(mapping)" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -634,7 +618,7 @@
|
||||
<h4 class="group-title">{{ t('groupMapping.permissionsLabel') }}</h4>
|
||||
<div class="permissions-grid">
|
||||
<div class="permission-item">
|
||||
<p-checkbox [binary]="true" [disabled]="true" [ngModel]="true" inputId="gmPermRead"></p-checkbox>
|
||||
<p-checkbox [binary]="true" [disabled]="true" [ngModel]="true" inputId="gmPermRead" />
|
||||
<label for="gmPermRead">{{ t('provisioning.readBooks') }}</label>
|
||||
</div>
|
||||
<ng-container *transloco="let a; prefix: 'settingsUsers'">
|
||||
@@ -663,8 +647,7 @@
|
||||
(ngModelChange)="updateGroupMappingDraft({libraryIds: $event})"
|
||||
[placeholder]="t('provisioning.selectLibraries')"
|
||||
appendTo="body"
|
||||
class="libraries-select">
|
||||
</p-multiSelect>
|
||||
class="libraries-select" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -673,8 +656,7 @@
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-check"
|
||||
(click)="saveGroupMapping()"
|
||||
[disabled]="!groupMappingDraft()?.oidcGroupClaim">
|
||||
</p-button>
|
||||
[disabled]="!groupMappingDraft()?.oidcGroupClaim" />
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
}
|
||||
|
||||
+5
-6
@@ -45,6 +45,11 @@ import {Chip} from '@openng/optimus-ui/chip';
|
||||
styleUrls: ['./authentication-settings.component.scss']
|
||||
})
|
||||
export class AuthenticationSettingsComponent {
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
private readonly groupMappingService = inject(OidcGroupMappingService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
readonly defaultMobileRedirectUri = 'grimmory://oauth2-callback';
|
||||
readonly wildcardMobileRedirectUri = '*';
|
||||
availablePermissions = [
|
||||
@@ -127,12 +132,6 @@ export class AuthenticationSettingsComponent {
|
||||
groups: ''
|
||||
}
|
||||
};
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private groupMappingService = inject(OidcGroupMappingService);
|
||||
private t = inject(TranslocoService);
|
||||
get allLibraries() { return this.libraryService.libraries(); }
|
||||
|
||||
private readonly loadSettingsEffect = effect(() => {
|
||||
|
||||
@@ -11,9 +11,9 @@ import {AuthService} from '../../../shared/service/auth.service';
|
||||
imports: [TranslocoPipe]
|
||||
})
|
||||
export class OidcCallbackComponent implements OnInit {
|
||||
private router = inject(Router);
|
||||
private oidcService = inject(OidcService);
|
||||
private authService = inject(AuthService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly oidcService = inject(OidcService);
|
||||
private readonly authService = inject(AuthService);
|
||||
|
||||
ngOnInit(): void {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../config/api-config';
|
||||
@@ -17,11 +17,11 @@ interface OidcTokenResponse {
|
||||
expires?: number
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class OidcService {
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
|
||||
async generatePkce(): Promise<{codeVerifier: string; codeChallenge: string}> {
|
||||
const array = new Uint8Array(32);
|
||||
|
||||
@@ -9,8 +9,8 @@ import { map } from 'rxjs/operators';
|
||||
pure: true
|
||||
})
|
||||
export class SecurePipe implements PipeTransform {
|
||||
private http = inject(HttpClient);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
|
||||
transform(url: string): Observable<SafeUrl> {
|
||||
return this.http.get(url, { responseType: 'blob' }).pipe(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Service } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class LoadingService {
|
||||
private activeLoaders: HTMLElement[] = [];
|
||||
|
||||
@@ -48,7 +46,7 @@ export class LoadingService {
|
||||
}
|
||||
|
||||
hide(loader: HTMLElement): void {
|
||||
if (loader && loader.parentNode) {
|
||||
if (loader?.parentNode) {
|
||||
loader.parentNode.removeChild(loader);
|
||||
|
||||
const index = this.activeLoaders.indexOf(loader);
|
||||
@@ -64,7 +62,7 @@ export class LoadingService {
|
||||
|
||||
hideAll(): void {
|
||||
this.activeLoaders.forEach(loader => {
|
||||
if (loader && loader.parentNode) {
|
||||
if (loader?.parentNode) {
|
||||
loader.parentNode.removeChild(loader);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import {Injectable, inject, Injector} from '@angular/core';
|
||||
import {Service, inject, Injector} from '@angular/core';
|
||||
import {defer, from, Observable} from 'rxjs';
|
||||
import {StartupService} from '../../shared/service/startup.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class PostLoginInitializerService {
|
||||
private readonly injector = inject(Injector);
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { inject, Service } from '@angular/core';
|
||||
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class PwaUpdateService {
|
||||
private swUpdate = inject(SwUpdate);
|
||||
private readonly swUpdate = inject(SwUpdate);
|
||||
|
||||
constructor() {
|
||||
if (this.swUpdate.isEnabled) {
|
||||
@@ -36,7 +34,7 @@ export class PwaUpdateService {
|
||||
const guardStr = sessionStorage.getItem(key);
|
||||
const guard = guardStr ? JSON.parse(guardStr) : null;
|
||||
|
||||
if (guard && guard.reason === reason && now - guard.timestamp < 10000) {
|
||||
if (guard?.reason === reason && now - guard.timestamp < 10000) {
|
||||
console.error(`PWA reload guard triggered for reason: ${reason}. Stopped reloading to avoid loop.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export function createQueryClientHarness(): QueryClientHarness {
|
||||
}
|
||||
|
||||
export function flushSignalAndQueryEffects(): void {
|
||||
TestBed.flushEffects();
|
||||
TestBed.tick();
|
||||
}
|
||||
|
||||
export function observeActiveQuery(queryClient: QueryClient, queryKey: readonly unknown[], data: unknown) {
|
||||
@@ -82,12 +82,12 @@ export function observeActiveQuery(queryClient: QueryClient, queryKey: readonly
|
||||
export async function flushQueryAsync(rounds = 5): Promise<void> {
|
||||
const appRef = TestBed.inject(ApplicationRef);
|
||||
for (let i = 0; i < rounds; i++) {
|
||||
TestBed.flushEffects();
|
||||
TestBed.tick();
|
||||
appRef.tick();
|
||||
await Promise.resolve();
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
}
|
||||
TestBed.flushEffects();
|
||||
TestBed.tick();
|
||||
appRef.tick();
|
||||
}
|
||||
|
||||
|
||||
+19
-33
@@ -6,12 +6,11 @@
|
||||
[style]="{'width': '60px', 'height': '60px'}"
|
||||
strokeWidth="3"
|
||||
fill="transparent"
|
||||
animationDuration="1.5s">
|
||||
</p-progressSpinner>
|
||||
animationDuration="1.5s" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading()) {
|
||||
@else {
|
||||
<div class="browse-header">
|
||||
<h2 class="browse-title">{{ t('browseAllAuthors') }}</h2>
|
||||
|
||||
@@ -35,14 +34,13 @@
|
||||
(ngModelChange)="onSortChange($event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="sort-dropdown">
|
||||
</p-select>
|
||||
class="sort-dropdown" />
|
||||
|
||||
<button class="sort-direction-btn" (click)="toggleSortDirection()">
|
||||
<button type="button" class="sort-direction-btn" (click)="toggleSortDirection()">
|
||||
<i class="pi" [class.pi-arrow-up]="sortDirection() === 'asc'" [class.pi-arrow-down]="sortDirection() === 'desc'"></i>
|
||||
</button>
|
||||
|
||||
<button class="filter-btn" (click)="filterPopover.toggle($event)">
|
||||
<button type="button" class="filter-btn" (click)="filterPopover.toggle($event)">
|
||||
<i class="pi pi-filter"></i>
|
||||
@if (activeFilterCount() > 0) {
|
||||
<span class="filter-badge"></span>
|
||||
@@ -84,8 +82,7 @@
|
||||
(ngModelChange)="onFilterChange('matchStatus', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
@@ -100,8 +97,7 @@
|
||||
(ngModelChange)="onFilterChange('photoStatus', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
@@ -118,8 +114,7 @@
|
||||
(ngModelChange)="onFilterChange('readStatus', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
@@ -142,8 +137,7 @@
|
||||
(ngModelChange)="onFilterChange('bookCount', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
@@ -154,8 +148,7 @@
|
||||
(ngModelChange)="onFilterChange('library', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
@@ -166,8 +159,7 @@
|
||||
(ngModelChange)="onFilterChange('genre', $event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="filter-dropdown">
|
||||
</p-select>
|
||||
class="filter-dropdown" />
|
||||
</div>
|
||||
|
||||
@if (activeFilterCount() > 0) {
|
||||
@@ -178,8 +170,7 @@
|
||||
[outlined]="true"
|
||||
size="small"
|
||||
(onClick)="resetFilters()"
|
||||
class="filter-reset-btn">
|
||||
</p-button>
|
||||
class="filter-reset-btn" />
|
||||
}
|
||||
</div>
|
||||
</p-popover>
|
||||
@@ -214,8 +205,7 @@
|
||||
(editAuthor)="navigateToAuthorEdit($event)"
|
||||
(deleteAuthor)="deleteAuthor($event)"
|
||||
(quickMatched)="onAuthorQuickMatched($event)"
|
||||
(checkboxClick)="onCheckboxClicked($event)">
|
||||
</app-author-card>
|
||||
(checkboxClick)="onCheckboxClicked($event)" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -233,7 +223,7 @@
|
||||
<span class="selected-label">{{ t('footer.selected') }}</span>
|
||||
</div>
|
||||
@if (canEditMetadata || canDeleteBook) {
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-divider layout="vertical" />
|
||||
<div class="action-buttons-group">
|
||||
@if (canEditMetadata) {
|
||||
<p-button
|
||||
@@ -242,8 +232,7 @@
|
||||
severity="info"
|
||||
(onClick)="autoMatchSelected()"
|
||||
[pTooltip]="t('footer.autoMatch')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
@if (canDeleteBook) {
|
||||
<p-button
|
||||
@@ -252,12 +241,11 @@
|
||||
severity="danger"
|
||||
(onClick)="deleteSelected()"
|
||||
[pTooltip]="t('footer.deleteSelected')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-divider layout="vertical" />
|
||||
<div class="action-buttons-group">
|
||||
<p-button
|
||||
outlined="true"
|
||||
@@ -265,16 +253,14 @@
|
||||
severity="success"
|
||||
(click)="selectAllAuthors()"
|
||||
[pTooltip]="t('footer.selectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllAuthors()"
|
||||
[pTooltip]="t('footer.deselectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+25
-25
@@ -84,17 +84,17 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
private static readonly MIN_SCALE = 0.7;
|
||||
private static readonly MAX_SCALE = 1.3;
|
||||
|
||||
private authorService = inject(AuthorService);
|
||||
private bookService = inject(BookService);
|
||||
private messageService = inject(MessageService);
|
||||
private pageTitle = inject(PageTitleService);
|
||||
private scrollService = inject(RouteScrollPositionService);
|
||||
private t = inject(TranslocoService);
|
||||
private router = inject(Router);
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private localStorageService = inject(LocalStorageService);
|
||||
private layoutService = inject(LayoutService);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly pageTitle = inject(PageTitleService);
|
||||
private readonly scrollService = inject(RouteScrollPositionService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly localStorageService = inject(LocalStorageService);
|
||||
private readonly layoutService = inject(LayoutService);
|
||||
protected userService = inject(UserService);
|
||||
protected selectionService = inject(AuthorSelectionService);
|
||||
|
||||
@@ -123,17 +123,17 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
|
||||
readonly screenWidth = signal(typeof window !== 'undefined' ? window.innerWidth : 1024);
|
||||
thumbnailCacheBusters = new Map<number, number>();
|
||||
private selectedAuthors = this.selectionService.selectedAuthors;
|
||||
private allAuthorsState = signal<AuthorSummary[] | null>(null);
|
||||
private readonly selectedAuthors = this.selectionService.selectedAuthors;
|
||||
private readonly allAuthorsState = signal<AuthorSummary[] | null>(null);
|
||||
|
||||
loading = computed(() => this.allAuthorsState() === null || this.bookService.isBooksLoading());
|
||||
readonly loading = computed(() => this.allAuthorsState() === null || this.bookService.isBooksLoading());
|
||||
protected currentUser = this.userService.currentUser;
|
||||
selectedCount = computed(() => this.selectedAuthors().size);
|
||||
searchTerm = signal('');
|
||||
sortBy = signal('name');
|
||||
sortDirection = signal<SortDirection>('asc');
|
||||
filters = signal<AuthorFilters>({...DEFAULT_AUTHOR_FILTERS});
|
||||
private enrichedAuthors = computed(() => {
|
||||
readonly selectedCount = computed(() => this.selectedAuthors().size);
|
||||
readonly searchTerm = signal('');
|
||||
readonly sortBy = signal('name');
|
||||
readonly sortDirection = signal<SortDirection>('asc');
|
||||
readonly filters = signal<AuthorFilters>({...DEFAULT_AUTHOR_FILTERS});
|
||||
private readonly enrichedAuthors = computed(() => {
|
||||
const authors = this.allAuthorsState();
|
||||
if (!authors) {
|
||||
return [];
|
||||
@@ -141,7 +141,7 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
|
||||
return this.enrichAuthors(authors, this.bookService.books());
|
||||
});
|
||||
libraryOptions = computed<FilterOption[]>(() => {
|
||||
readonly libraryOptions = computed<FilterOption[]>(() => {
|
||||
const allLabel = this.t.translate('authorBrowser.filters.all');
|
||||
const librarySet = new Set<string>();
|
||||
|
||||
@@ -156,7 +156,7 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
...[...librarySet].sort().map(library => ({label: library, value: library}))
|
||||
];
|
||||
});
|
||||
genreOptions = computed<FilterOption[]>(() => {
|
||||
readonly genreOptions = computed<FilterOption[]>(() => {
|
||||
const allLabel = this.t.translate('authorBrowser.filters.all');
|
||||
const genreSet = new Set<string>();
|
||||
|
||||
@@ -171,7 +171,7 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
...[...genreSet].sort().map(category => ({label: category, value: category}))
|
||||
];
|
||||
});
|
||||
activeFilterCount = computed(() => {
|
||||
readonly activeFilterCount = computed(() => {
|
||||
const filters = this.filters();
|
||||
let count = 0;
|
||||
if (filters.matchStatus !== 'all') count++;
|
||||
@@ -182,7 +182,7 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
if (filters.genre !== 'all') count++;
|
||||
return count;
|
||||
});
|
||||
filteredAuthors = computed<EnrichedAuthor[]>(() => {
|
||||
readonly filteredAuthors = computed<EnrichedAuthor[]>(() => {
|
||||
let result = this.enrichedAuthors();
|
||||
const search = this.searchTerm().trim().toLowerCase();
|
||||
|
||||
@@ -443,7 +443,7 @@ export class AuthorBrowserComponent implements OnInit {
|
||||
}
|
||||
|
||||
return authors.map(author => {
|
||||
const authorBooks = booksByAuthor.get(author.name.toLowerCase()) || [];
|
||||
const authorBooks = booksByAuthor.get(author.name.toLowerCase()) ?? [];
|
||||
|
||||
const libraryIds = new Set<number>();
|
||||
const libraryNameSet = new Set<string>();
|
||||
|
||||
+3
-5
@@ -28,8 +28,7 @@
|
||||
class="select-checkbox"
|
||||
(click)="captureMouseEvent($event)"
|
||||
[ngModel]="isSelected"
|
||||
(onChange)="toggleSelection($event)">
|
||||
</p-checkbox>
|
||||
(onChange)="toggleSelection($event)" />
|
||||
}
|
||||
|
||||
<div class="card-overlay">
|
||||
@@ -38,14 +37,13 @@
|
||||
}
|
||||
<h4 class="author-name" [pTooltip]="author.name" tooltipPosition="bottom">{{ author.name }}</h4>
|
||||
<div class="menu-button-container">
|
||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()" />
|
||||
<p-button
|
||||
class="card-menu-btn"
|
||||
size="small"
|
||||
[text]="true"
|
||||
(click)="onMenuToggle($event, menu)"
|
||||
icon="pi pi-ellipsis-v">
|
||||
</p-button>
|
||||
icon="pi pi-ellipsis-v" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+12
-13
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectorRef, Component, EventEmitter, inject, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
||||
import {ChangeDetectorRef, Component, inject, Input, OnChanges, output, SimpleChanges} from '@angular/core';
|
||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {Tooltip} from '@openng/optimus-ui/tooltip';
|
||||
import {CheckboxChangeEvent, Checkbox} from '@openng/optimus-ui/checkbox';
|
||||
@@ -17,26 +17,25 @@ import {AuthorService} from '../../service/author.service';
|
||||
imports: [TranslocoPipe, Tooltip, Checkbox, FormsModule, TieredMenu, Button]
|
||||
})
|
||||
export class AuthorCardComponent implements OnChanges {
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly cdr = inject(ChangeDetectorRef);
|
||||
|
||||
@Input({required: true}) author!: AuthorSummary;
|
||||
@Input() canQuickMatch = false;
|
||||
@Input() canDelete = false;
|
||||
@Input() isCheckboxEnabled = false;
|
||||
@Input() isSelected = false;
|
||||
@Output() cardClick = new EventEmitter<AuthorSummary>();
|
||||
@Output() quickMatched = new EventEmitter<AuthorSummary>();
|
||||
@Output() checkboxClick = new EventEmitter<{ index: number; author: AuthorSummary; selected: boolean; shiftKey: boolean }>();
|
||||
@Output() viewAuthor = new EventEmitter<AuthorSummary>();
|
||||
@Output() editAuthor = new EventEmitter<AuthorSummary>();
|
||||
@Output() deleteAuthor = new EventEmitter<AuthorSummary>();
|
||||
@Output() menuToggled = new EventEmitter<boolean>();
|
||||
readonly cardClick = output<AuthorSummary>();
|
||||
readonly quickMatched = output<AuthorSummary>();
|
||||
readonly checkboxClick = output<{ index: number; author: AuthorSummary; selected: boolean; shiftKey: boolean }>();
|
||||
readonly viewAuthor = output<AuthorSummary>();
|
||||
readonly editAuthor = output<AuthorSummary>();
|
||||
readonly deleteAuthor = output<AuthorSummary>();
|
||||
readonly menuToggled = output<boolean>();
|
||||
@Input() index = 0;
|
||||
@Input() cacheBuster = 0;
|
||||
|
||||
private authorService = inject(AuthorService);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
private cdr = inject(ChangeDetectorRef);
|
||||
private lastShiftKey = false;
|
||||
|
||||
hasPhoto = false;
|
||||
|
||||
+9
-15
@@ -1,8 +1,7 @@
|
||||
<ng-container *transloco="let t; prefix: 'authorBrowser.detail'">
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
|
||||
</p-progressSpinner>
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s" />
|
||||
<p style="color: var(--primary-color);">{{ t('loading') }}</p>
|
||||
</div>
|
||||
}
|
||||
@@ -50,13 +49,13 @@
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="asin-link">
|
||||
<p-tag [value]="'ASIN: ' + author.asin" severity="info"></p-tag>
|
||||
<p-tag [value]="'ASIN: ' + author.asin" severity="info" />
|
||||
</a>
|
||||
<a [href]="'https://www.audible.com/author/' + author.asin"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="asin-link">
|
||||
<p-tag value="Audible" severity="warn"></p-tag>
|
||||
<p-tag value="Audible" severity="warn" />
|
||||
</a>
|
||||
}
|
||||
@if (canEditMetadata) {
|
||||
@@ -68,15 +67,14 @@
|
||||
[disabled]="quickMatching"
|
||||
(onClick)="quickMatch()"
|
||||
[pTooltip]="t('quickMatchTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (author.description) {
|
||||
<div class="description-box">
|
||||
<div #descriptionContent
|
||||
[ngClass]="{'line-clamp-5': !isExpanded}"
|
||||
[class.line-clamp-5]="!isExpanded"
|
||||
class="description-container">
|
||||
<div class="readonly-editor">{{ author.description }}</div>
|
||||
</div>
|
||||
@@ -87,8 +85,7 @@
|
||||
iconPos="right"
|
||||
size="small"
|
||||
text
|
||||
(click)="toggleExpand()">
|
||||
</p-button>
|
||||
(click)="toggleExpand()" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -120,8 +117,7 @@
|
||||
[index]="virtualItem.index"
|
||||
[book]="book"
|
||||
[isSeriesCollapsed]="false"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||
</app-legacy-book-card>
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -138,15 +134,13 @@
|
||||
<app-author-editor
|
||||
[authorId]="author.id"
|
||||
[author]="author"
|
||||
(authorUpdated)="onAuthorUpdated($event)">
|
||||
</app-author-editor>
|
||||
(authorUpdated)="onAuthorUpdated($event)" />
|
||||
</p-tabpanel>
|
||||
<p-tabpanel value="match">
|
||||
<app-author-match
|
||||
[authorId]="author.id"
|
||||
[authorName]="author.name"
|
||||
(authorMatched)="onAuthorUpdated($event)">
|
||||
</app-author-match>
|
||||
(authorMatched)="onAuthorUpdated($event)" />
|
||||
</p-tabpanel>
|
||||
}
|
||||
</p-tabpanels>
|
||||
|
||||
+10
-12
@@ -1,6 +1,5 @@
|
||||
import { AfterViewChecked, Component, computed, ElementRef, inject, OnInit, signal, viewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NgClass } from '@angular/common';
|
||||
import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@openng/optimus-ui/tabs';
|
||||
import { ProgressSpinner } from '@openng/optimus-ui/progressspinner';
|
||||
import { Button } from '@openng/optimus-ui/button';
|
||||
@@ -26,7 +25,6 @@ import { createVirtualGrid } from '../../../../shared/util/virtual-grid.util';
|
||||
templateUrl: './author-detail.component.html',
|
||||
styleUrls: ['./author-detail.component.scss'],
|
||||
imports: [
|
||||
NgClass,
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
@@ -46,30 +44,30 @@ export class AuthorDetailComponent implements OnInit, AfterViewChecked {
|
||||
|
||||
private static readonly GRID_GAP = 21;
|
||||
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private authorService = inject(AuthorService);
|
||||
private bookService = inject(BookService);
|
||||
private messageService = inject(MessageService);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
|
||||
protected bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||
protected userService = inject(UserService);
|
||||
private pageTitle = inject(PageTitleService);
|
||||
private t = inject(TranslocoService);
|
||||
private readonly pageTitle = inject(PageTitleService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
readonly descriptionContentRef = viewChild<ElementRef<HTMLElement>>('descriptionContent');
|
||||
private readonly scrollElement = viewChild<ElementRef<HTMLElement>>('scrollElement');
|
||||
|
||||
loading = signal(true);
|
||||
readonly loading = signal(true);
|
||||
tab = 'books';
|
||||
isExpanded = false;
|
||||
isOverflowing = false;
|
||||
hasPhoto = true;
|
||||
photoTimestamp = Date.now();
|
||||
quickMatching = false;
|
||||
private authorState = signal<AuthorDetails | null>(null);
|
||||
private readonly authorState = signal<AuthorDetails | null>(null);
|
||||
author = this.authorState.asReadonly();
|
||||
authorBooks = computed(() => {
|
||||
readonly authorBooks = computed(() => {
|
||||
const authorName = this.author()?.name?.toLowerCase();
|
||||
if (!authorName) {
|
||||
return [];
|
||||
|
||||
+20
-26
@@ -8,8 +8,7 @@
|
||||
width="200"
|
||||
appendTo="body"
|
||||
[preview]="true"
|
||||
(onImageError)="onPhotoError()">
|
||||
</p-image>
|
||||
(onImageError)="onPhotoError()" />
|
||||
} @else {
|
||||
<div class="photo-placeholder">
|
||||
<i class="pi pi-user"></i>
|
||||
@@ -17,7 +16,7 @@
|
||||
}
|
||||
|
||||
@if (isUploading()) {
|
||||
<p-progressSpinner class="upload-spinner" strokeWidth="4" fill="transparent" animationDuration=".8s"></p-progressSpinner>
|
||||
<p-progressSpinner class="upload-spinner" strokeWidth="4" fill="transparent" animationDuration=".8s" />
|
||||
}
|
||||
|
||||
<div class="cover-actions">
|
||||
@@ -34,8 +33,7 @@
|
||||
(onUpload)="onUpload()"
|
||||
(onError)="onUploadError()"
|
||||
[auto]="true"
|
||||
(onBeforeUpload)="onBeforeUpload()">
|
||||
</p-fileupload>
|
||||
(onBeforeUpload)="onBeforeUpload()" />
|
||||
|
||||
<p-button
|
||||
[pTooltip]="t('searchPhotoTooltip')"
|
||||
@@ -45,8 +43,7 @@
|
||||
[outlined]="true"
|
||||
[disabled]="form.get('photoLocked')?.value"
|
||||
(onClick)="openPhotoSearch()"
|
||||
severity="info">
|
||||
</p-button>
|
||||
severity="info" />
|
||||
|
||||
@if (!form.get('photoLocked')?.value) {
|
||||
<p-button
|
||||
@@ -56,10 +53,9 @@
|
||||
icon="pi pi-lock-open"
|
||||
[outlined]="true"
|
||||
(onClick)="togglePhotoLock()"
|
||||
severity="success">
|
||||
</p-button>
|
||||
severity="success" />
|
||||
}
|
||||
@if (form.get('photoLocked')?.value) {
|
||||
@else {
|
||||
<p-button
|
||||
[pTooltip]="t('unlockField')"
|
||||
tooltipPosition="top"
|
||||
@@ -67,8 +63,7 @@
|
||||
icon="pi pi-lock"
|
||||
[outlined]="true"
|
||||
(onClick)="togglePhotoLock()"
|
||||
severity="warn">
|
||||
</p-button>
|
||||
severity="warn" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,10 +74,10 @@
|
||||
<div class="field-with-lock">
|
||||
<input pInputText id="authorName" formControlName="name"/>
|
||||
@if (!form.get('nameLocked')?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('name')" severity="success"></p-button>
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('name')" severity="success" />
|
||||
}
|
||||
@if (form.get('nameLocked')?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('name')" severity="warn"></p-button>
|
||||
@else {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('name')" severity="warn" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -92,10 +87,10 @@
|
||||
<div class="field-with-lock">
|
||||
<input pInputText id="authorAsin" formControlName="asin"/>
|
||||
@if (!form.get('asinLocked')?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success"></p-button>
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('asin')" severity="success" />
|
||||
}
|
||||
@if (form.get('asinLocked')?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn"></p-button>
|
||||
@else {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('asin')" severity="warn" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,26 +101,25 @@
|
||||
<textarea pTextarea id="authorDescription" formControlName="description"
|
||||
[rows]="8" [autoResize]="true"></textarea>
|
||||
@if (!form.get('descriptionLocked')?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success" size="small"></p-button>
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success" size="small" />
|
||||
}
|
||||
@if (form.get('descriptionLocked')?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn" size="small"></p-button>
|
||||
@else {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn" size="small" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-footer">
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
<div class="footer-actions">
|
||||
<p-button [label]="t('unlockAllBtn')" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button [label]="t('lockAllBtn')" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-button [label]="t('unlockAllBtn')" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()" />
|
||||
<p-button [label]="t('lockAllBtn')" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()" />
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button
|
||||
type="submit"
|
||||
[label]="isSaving() ? t('saving') : t('saveBtn')"
|
||||
[icon]="isSaving() ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[disabled]="isSaving()">
|
||||
</p-button>
|
||||
[disabled]="isSaving()" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+8
-9
@@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, inject, Input, OnChanges, OnInit, Output, signal, SimpleChanges} from '@angular/core';
|
||||
import {Component, inject, Input, OnChanges, OnInit, output, signal, SimpleChanges} from '@angular/core';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Button} from '@openng/optimus-ui/button';
|
||||
@@ -35,19 +35,18 @@ import {AuthorPhotoSearchComponent} from '../author-photo-search/author-photo-se
|
||||
providers: [DialogService]
|
||||
})
|
||||
export class AuthorEditorComponent implements OnInit, OnChanges {
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly dialogService = inject(DialogService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
@Input({required: true}) authorId!: number;
|
||||
@Input({required: true}) author!: AuthorDetails;
|
||||
@Output() authorUpdated = new EventEmitter<AuthorDetails>();
|
||||
|
||||
private authorService = inject(AuthorService);
|
||||
private messageService = inject(MessageService);
|
||||
private dialogService = inject(DialogService);
|
||||
private t = inject(TranslocoService);
|
||||
readonly authorUpdated = output<AuthorDetails>();
|
||||
|
||||
form!: FormGroup;
|
||||
isSaving = signal(false);
|
||||
isUploading = signal(false);
|
||||
readonly isSaving = signal(false);
|
||||
readonly isUploading = signal(false);
|
||||
hasPhoto = true;
|
||||
photoTimestamp = Date.now();
|
||||
|
||||
|
||||
+4
-8
@@ -19,8 +19,7 @@
|
||||
(ngModelChange)="selectedRegion.set($event)"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="region-dropdown">
|
||||
</p-select>
|
||||
class="region-dropdown" />
|
||||
</div>
|
||||
<div class="field search-btn-field">
|
||||
<p-button
|
||||
@@ -28,8 +27,7 @@
|
||||
icon="pi pi-search"
|
||||
(onClick)="search()"
|
||||
[loading]="searching()"
|
||||
[disabled]="!canSearch()">
|
||||
</p-button>
|
||||
[disabled]="!canSearch()" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,8 +38,7 @@
|
||||
[style]="{'width': '40px', 'height': '40px'}"
|
||||
strokeWidth="3"
|
||||
fill="transparent"
|
||||
animationDuration="1.5s">
|
||||
</p-progressSpinner>
|
||||
animationDuration="1.5s" />
|
||||
<span>{{ t('searching') }}</span>
|
||||
</div>
|
||||
}
|
||||
@@ -91,8 +88,7 @@
|
||||
icon="pi pi-link"
|
||||
severity="success"
|
||||
[loading]="matching()"
|
||||
(onClick)="matchAuthor(result)">
|
||||
</p-button>
|
||||
(onClick)="matchAuthor(result)" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
+13
-14
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, computed, EventEmitter, inject, Input, OnInit, Output, signal} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, computed, inject, Input, OnInit, output, signal} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from '@openng/optimus-ui/button';
|
||||
import {InputText} from '@openng/optimus-ui/inputtext';
|
||||
@@ -30,24 +30,23 @@ interface RegionOption {
|
||||
]
|
||||
})
|
||||
export class AuthorMatchComponent implements OnInit {
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
@Input({required: true}) authorId!: number;
|
||||
@Input({required: true}) authorName!: string;
|
||||
@Output() authorMatched = new EventEmitter<AuthorDetails>();
|
||||
readonly authorMatched = output<AuthorDetails>();
|
||||
|
||||
private authorService = inject(AuthorService);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
readonly searchQuery = signal('');
|
||||
readonly asinQuery = signal('');
|
||||
readonly selectedRegion = signal('us');
|
||||
readonly searching = signal(false);
|
||||
readonly matching = signal(false);
|
||||
readonly results = signal<AuthorSearchResult[]>([]);
|
||||
readonly hasSearched = signal(false);
|
||||
|
||||
searchQuery = signal('');
|
||||
asinQuery = signal('');
|
||||
selectedRegion = signal('us');
|
||||
searching = signal(false);
|
||||
matching = signal(false);
|
||||
results = signal<AuthorSearchResult[]>([]);
|
||||
hasSearched = signal(false);
|
||||
|
||||
canSearch = computed(() => !!this.searchQuery().trim() || !!this.asinQuery().trim());
|
||||
readonly canSearch = computed(() => !!this.searchQuery().trim() || !!this.asinQuery().trim());
|
||||
|
||||
regionOptions: RegionOption[] = [
|
||||
{label: 'US', value: 'us'},
|
||||
|
||||
+5
-9
@@ -21,8 +21,7 @@
|
||||
[label]="t('searchBtn')"
|
||||
icon="pi pi-search"
|
||||
[loading]="searching"
|
||||
[disabled]="searchForm.invalid">
|
||||
</p-button>
|
||||
[disabled]="searchForm.invalid" />
|
||||
<p-button
|
||||
type="button"
|
||||
icon="pi pi-refresh"
|
||||
@@ -31,8 +30,7 @@
|
||||
severity="secondary"
|
||||
(click)="onClear()"
|
||||
[pTooltip]="t('resetTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -49,7 +47,7 @@
|
||||
</div>
|
||||
} @else if (searching) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner strokeWidth="3" animationDuration="1s"></p-progressSpinner>
|
||||
<p-progressSpinner strokeWidth="3" animationDuration="1s" />
|
||||
<p>{{ t('searching') }}</p>
|
||||
</div>
|
||||
} @else if (photos.length === 0) {
|
||||
@@ -76,8 +74,7 @@
|
||||
[src]="photo.url"
|
||||
[alt]="t('photoAlt', { index: i + 1 })"
|
||||
appendTo="body"
|
||||
[preview]="true">
|
||||
</p-image>
|
||||
[preview]="true" />
|
||||
@if (photo.width && photo.height) {
|
||||
<div class="resolution-badge">
|
||||
{{ photo.width }} x {{ photo.height }}
|
||||
@@ -88,8 +85,7 @@
|
||||
(click)="selectAndUploadPhoto(photo)"
|
||||
[label]="t('selectBtn')"
|
||||
icon="pi pi-check"
|
||||
size="small">
|
||||
</p-button>
|
||||
size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-7
@@ -27,18 +27,17 @@ import {AuthorPhotoResult} from '../../model/author.model';
|
||||
]
|
||||
})
|
||||
export class AuthorPhotoSearchComponent implements OnInit {
|
||||
private readonly fb = inject(FormBuilder);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
protected dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
searchForm: FormGroup;
|
||||
photos: AuthorPhotoResult[] = [];
|
||||
searching = false;
|
||||
hasSearched = false;
|
||||
|
||||
private fb = inject(FormBuilder);
|
||||
private authorService = inject(AuthorService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
protected dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
private authorId!: number;
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, Injectable, signal} from '@angular/core';
|
||||
import {computed, Service, signal} from '@angular/core';
|
||||
import {AuthorSummary} from '../model/author.model';
|
||||
|
||||
export interface AuthorCheckboxClickEvent {
|
||||
@@ -8,7 +8,7 @@ export interface AuthorCheckboxClickEvent {
|
||||
shiftKey: boolean;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class AuthorSelectionService {
|
||||
private readonly _selectedAuthors = signal<Set<number>>(new Set());
|
||||
readonly selectedAuthors = this._selectedAuthors.asReadonly();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, DestroyRef, effect, inject, Injectable} from '@angular/core';
|
||||
import {computed, DestroyRef, effect, inject, Service} from '@angular/core';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {lastValueFrom, Observable} from 'rxjs';
|
||||
import {map, tap} from 'rxjs/operators';
|
||||
@@ -12,29 +12,27 @@ import {AUTHORS_QUERY_KEY} from './author-query-keys';
|
||||
import {invalidateAuthorsQuery, patchAuthorInCache} from './author-query-cache';
|
||||
import {invalidateAllBookCaches} from '../../book/service/legacy-book-cache';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class AuthorService {
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private authService = inject(AuthService);
|
||||
private sseClient = inject(SseClient);
|
||||
private queryClient = inject(QueryClient);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly sseClient = inject(SseClient);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1/authors`;
|
||||
private readonly mediaBaseUrl = `${API_CONFIG.BASE_URL}/api/v1/media`;
|
||||
private readonly token = this.authService.token;
|
||||
private readonly authorInvalidationDebounceMs = 200;
|
||||
private authorInvalidationTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
private authorsQuery = injectQuery(() => ({
|
||||
private readonly authorsQuery = injectQuery(() => ({
|
||||
...this.getAuthorsQueryOptions(),
|
||||
enabled: !!this.token(),
|
||||
}));
|
||||
|
||||
allAuthors = computed(() => this.authorsQuery.data() ?? null);
|
||||
isAuthorsLoading = computed(() => !!this.token() && this.authorsQuery.isPending());
|
||||
readonly allAuthors = computed(() => this.authorsQuery.data() ?? null);
|
||||
readonly isAuthorsLoading = computed(() => !!this.token() && this.authorsQuery.isPending());
|
||||
|
||||
constructor() {
|
||||
this.destroyRef.onDestroy(() => this.clearAuthorInvalidationTimer());
|
||||
|
||||
@@ -60,14 +60,13 @@ const NO_OVERFLOW: ReadonlySet<string> = new Set();
|
||||
templateUrl: './book-browse-bulk-bar.component.html',
|
||||
})
|
||||
export class BookBrowseBulkBarComponent {
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly shelfDefinitionQuery = inject(ShelfDefinitionQueryService);
|
||||
readonly selection = input.required<BrowseSelection>();
|
||||
readonly books = input.required<readonly BookSummary[]>();
|
||||
readonly total = input.required<number | null>();
|
||||
readonly fetchIds = input.required<() => Promise<readonly number[]>>();
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly shelfDefinitionQuery = inject(ShelfDefinitionQueryService);
|
||||
protected readonly commands = createBookBrowseBulkCommands({
|
||||
selection: this.selection,
|
||||
books: this.books,
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Service, inject} from '@angular/core';
|
||||
|
||||
import {LocalStorageService} from '../../../shared/service/local-storage.service';
|
||||
|
||||
const STORAGE_KEY = 'browseTableColumnWidths';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookBrowseColumnWidthPreferenceService {
|
||||
private readonly localStorage = inject(LocalStorageService);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Service, inject} from '@angular/core';
|
||||
import {toSignal} from '@angular/core/rxjs-interop';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@@ -7,7 +7,7 @@ import {type BookSummary} from '../data/book-response.models';
|
||||
import {formatBookValue} from './book-browse-columns';
|
||||
import {type BookColumnKind, type BookColumnValue, type BookDetailLineSortKey} from './book-browse-fields';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookBrowseDetailLineService {
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly activeLang = toSignal(this.transloco.langChanges$, {
|
||||
|
||||
@@ -120,6 +120,14 @@ const BODY_CELL_CLASS =
|
||||
},
|
||||
})
|
||||
export class BookBrowseTableComponent {
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly locationStrategy = inject(LocationStrategy);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly scrollPosition = inject(RouteScrollPositionService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly columnWidthPreference = inject(BookBrowseColumnWidthPreferenceService);
|
||||
readonly books = input.required<readonly BookSummary[]>();
|
||||
readonly status = input.required<BrowseStatus>();
|
||||
readonly hasNextPage = input.required<boolean>();
|
||||
@@ -146,15 +154,6 @@ export class BookBrowseTableComponent {
|
||||
|
||||
readonly emptyDef = contentChild.required(BrowseEmptyDef);
|
||||
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly locationStrategy = inject(LocationStrategy);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly scrollPosition = inject(RouteScrollPositionService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly columnWidthPreference = inject(BookBrowseColumnWidthPreferenceService);
|
||||
|
||||
private readonly initialColumnSizing: ColumnSizingState = this.columnWidthPreference.load();
|
||||
private readonly selectColumnVisible = computed(() => this.selection() !== null);
|
||||
private readonly sortOptionsById = computed(() =>
|
||||
|
||||
+3
-6
@@ -112,8 +112,7 @@
|
||||
[placeholder]="t('authorsPlaceholder')"
|
||||
(completeMethod)="filterAuthors($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('authors', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)">
|
||||
</p-autoComplete>
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -192,8 +191,7 @@
|
||||
[(ngModel)]="pageCount"
|
||||
[useGrouping]="false"
|
||||
[placeholder]="t('pageCountPlaceholder')"
|
||||
class="input-full">
|
||||
</p-inputnumber>
|
||||
class="input-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -217,8 +215,7 @@
|
||||
[placeholder]="t('categoriesPlaceholder')"
|
||||
(completeMethod)="filterCategories($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('categories', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('categories', $event)">
|
||||
</p-autoComplete>
|
||||
(onSelect)="onAutoCompleteSelect('categories', $event)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+8
-8
@@ -34,12 +34,12 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
styleUrl: './add-physical-book-dialog.component.scss',
|
||||
})
|
||||
export class AddPhysicalBookDialogComponent {
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dialogConfig = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private sources = inject(MetadataSourceQueryService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private readonly dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly dialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly sources = inject(MetadataSourceQueryService);
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
|
||||
selectedLibraryId: number | null = null;
|
||||
title: string = '';
|
||||
@@ -59,8 +59,8 @@ export class AddPhysicalBookDialogComponent {
|
||||
filteredCategories: string[] = [];
|
||||
|
||||
coverUrl: string | null = null;
|
||||
isLoading = signal(false);
|
||||
isFetchingMetadata = signal(false);
|
||||
readonly isLoading = signal(false);
|
||||
readonly isFetchingMetadata = signal(false);
|
||||
readonly metadataLookupMessage = signal<'metadataNotFound' | 'metadataLookupFailed' | null>(null);
|
||||
private readonly initializeSelectedLibraryEffect = effect(() => {
|
||||
const libraries = this.libraries;
|
||||
|
||||
+4
-4
@@ -14,8 +14,7 @@
|
||||
[text]="true"
|
||||
severity="secondary"
|
||||
(click)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@@ -29,7 +28,7 @@
|
||||
[placeholder]="t('selectFileType')"
|
||||
class="full-width"
|
||||
[disabled]="isUploading"
|
||||
></p-select>
|
||||
/>
|
||||
|
||||
<!-- File Upload -->
|
||||
<p-fileupload class="file-upload" name="file"
|
||||
@@ -109,6 +108,7 @@
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@default never;
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -118,7 +118,7 @@
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #file></ng-template>
|
||||
<ng-template #file />
|
||||
<ng-template #empty>
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-cloud-upload empty-icon"></i>
|
||||
|
||||
+8
-8
@@ -42,12 +42,12 @@ interface UploadingFile {
|
||||
})
|
||||
export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
private readonly t = inject(TranslocoService);
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private config = inject(DynamicDialogConfig);
|
||||
private bookFileService = inject(BookFileService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private cdr = inject(ChangeDetectorRef);
|
||||
private readonly dialogRef = inject(DynamicDialogRef);
|
||||
private readonly config = inject(DynamicDialogConfig);
|
||||
private readonly bookFileService = inject(BookFileService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly cdr = inject(ChangeDetectorRef);
|
||||
|
||||
book!: Book;
|
||||
files: UploadingFile[] = [];
|
||||
@@ -60,8 +60,8 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
fileTypeOptions: FileTypeOption[] = [];
|
||||
|
||||
@ViewChild(FileUpload) private fileUpload!: FileUpload;
|
||||
private destroy$ = new Subject<void>();
|
||||
@ViewChild(FileUpload) private readonly fileUpload!: FileUpload;
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.book = this.config.data.book;
|
||||
|
||||
+2
-3
@@ -20,8 +20,7 @@
|
||||
[rounded]="true"
|
||||
[pTooltip]="book.metadata?.title"
|
||||
tooltipPosition="top"
|
||||
[ngClass]="{ 'is-visible': isHovered }"
|
||||
(onClick)="openBookInfo(book)">
|
||||
</p-button>
|
||||
[class.is-visible]="isHovered"
|
||||
(onClick)="openBookInfo(book)" />
|
||||
}
|
||||
</div>
|
||||
|
||||
+5
-8
@@ -5,7 +5,6 @@ import {CoverComponent} from '../../../../shared/components/cover/cover.componen
|
||||
import {Button} from '@openng/optimus-ui/button';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {BookMetadataHostService} from '../../../../shared/service/book-metadata-host.service';
|
||||
import {Tooltip} from '@openng/optimus-ui/tooltip';
|
||||
|
||||
@@ -14,7 +13,6 @@ import {Tooltip} from '@openng/optimus-ui/tooltip';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [
|
||||
Button,
|
||||
NgClass,
|
||||
Tooltip,
|
||||
CoverComponent
|
||||
],
|
||||
@@ -22,16 +20,15 @@ import {Tooltip} from '@openng/optimus-ui/tooltip';
|
||||
styleUrl: './book-card-lite-component.scss'
|
||||
})
|
||||
export class BookCardLiteComponent {
|
||||
private readonly router = inject(Router);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly bookMetadataHostService = inject(BookMetadataHostService);
|
||||
@Input() book!: Book;
|
||||
@Input() isActive: boolean = false;
|
||||
@Input() showSeriesNumber: boolean = false;
|
||||
|
||||
private router = inject(Router);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private userService = inject(UserService);
|
||||
private bookMetadataHostService = inject(BookMetadataHostService);
|
||||
|
||||
private metadataCenterViewMode = computed(() =>
|
||||
private readonly metadataCenterViewMode = computed(() =>
|
||||
this.userService.currentUser()?.userSettings.metadataCenterViewMode ?? 'route'
|
||||
);
|
||||
isHovered: boolean = false;
|
||||
|
||||
+4
-8
@@ -9,8 +9,7 @@
|
||||
<p class="panel-description">{{ isBulkMode ? t('descriptionBulk') : t('description') }}</p>
|
||||
</div>
|
||||
<p-button icon="pi pi-times" [rounded]="true" [text]="true" severity="secondary" (click)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@@ -61,8 +60,7 @@
|
||||
|
||||
<!-- Options -->
|
||||
<div class="delete-option">
|
||||
<p-checkbox [(ngModel)]="moveFiles" [binary]="true" inputId="moveFiles" [disabled]="isAttaching">
|
||||
</p-checkbox>
|
||||
<p-checkbox [(ngModel)]="moveFiles" [binary]="true" inputId="moveFiles" [disabled]="isAttaching" />
|
||||
<label for="moveFiles" class="delete-label">
|
||||
{{ t('moveFilesLabel') }}
|
||||
</label>
|
||||
@@ -84,11 +82,9 @@
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons">
|
||||
<p-button [label]="'common.cancel' | transloco" [outlined]="true" severity="secondary" (click)="closeDialog()"
|
||||
[disabled]="isAttaching">
|
||||
</p-button>
|
||||
[disabled]="isAttaching" />
|
||||
<p-button [label]="isBulkMode ? t('attachFilesBulk') : t('attachFile')" icon="pi pi-link" (click)="attach()"
|
||||
[disabled]="!canAttach()" [loading]="isAttaching">
|
||||
</p-button>
|
||||
[disabled]="!canAttach()" [loading]="isAttaching" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+8
-9
@@ -34,6 +34,13 @@ export interface BookFileAttacherSourceBook {
|
||||
styleUrls: ['./book-file-attacher.component.scss']
|
||||
})
|
||||
export class BookFileAttacherComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly dialogRef = inject(DynamicDialogRef);
|
||||
private readonly config = inject(DynamicDialogConfig);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly bookFileService = inject(BookFileService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
@ViewChild('autocompleteWrapper') autocompleteWrapper!: ElementRef;
|
||||
|
||||
sourceBooks: readonly BookFileAttacherSourceBook[] = [];
|
||||
@@ -44,17 +51,9 @@ export class BookFileAttacherComponent implements OnInit, AfterViewInit, OnDestr
|
||||
filteredBooks: Book[] = [];
|
||||
autocomplePanelStyle: Record<string, string> = {};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private allBooks: Signal<Book[]> = signal([]);
|
||||
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private config = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private bookFileService = inject(BookFileService);
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
setTimeout(() => {
|
||||
const width = this.autocompleteWrapper?.nativeElement?.offsetWidth;
|
||||
|
||||
@@ -101,11 +101,6 @@ const BOOK_MENU_READ_ACTION_LABEL_KEYS: Readonly<Record<BookReadAction, string>>
|
||||
templateUrl: './book-menu.component.html',
|
||||
})
|
||||
export class BookMenuComponent {
|
||||
readonly books = input<readonly BookSummary[]>([]);
|
||||
readonly openInNewTab = input(false, {transform: booleanAttribute});
|
||||
|
||||
readonly deleted = output<readonly number[]>();
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly fileDownload = inject(FileDownloadService);
|
||||
@@ -119,6 +114,10 @@ export class BookMenuComponent {
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly router = inject(Router);
|
||||
readonly books = input<readonly BookSummary[]>([]);
|
||||
readonly openInNewTab = input(false, {transform: booleanAttribute});
|
||||
|
||||
readonly deleted = output<readonly number[]>();
|
||||
|
||||
private readonly rootMenu = viewChild.required(AppMenuComponent);
|
||||
private readonly bookSnapshot = signal<BookSummary | null>(null);
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
(click)="openCreateDialog()"
|
||||
pTooltip="Add New Note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn floating-btn">
|
||||
</p-button>
|
||||
class="action-btn floating-btn" />
|
||||
</div>
|
||||
<p class="empty-state-title">No notes yet for this book</p>
|
||||
<p class="empty-state-subtitle">
|
||||
@@ -55,8 +54,7 @@
|
||||
(onClick)="openEditDialog(note)"
|
||||
pTooltip="Edit note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn-hover">
|
||||
</p-button>
|
||||
class="action-btn-hover" />
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
size="small"
|
||||
@@ -65,8 +63,7 @@
|
||||
(onClick)="deleteNote(note)"
|
||||
pTooltip="Delete note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn-hover">
|
||||
</p-button>
|
||||
class="action-btn-hover" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,8 +88,7 @@
|
||||
severity="success"
|
||||
(click)="openCreateDialog()"
|
||||
pTooltip="Add New Note"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
tooltipPosition="left" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -136,15 +132,13 @@
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined
|
||||
(onClick)="cancelCreate()">
|
||||
</p-button>
|
||||
(onClick)="cancelCreate()" />
|
||||
<p-button
|
||||
outlined
|
||||
severity="success"
|
||||
label="Save Note"
|
||||
icon="pi pi-save"
|
||||
(onClick)="createNote()">
|
||||
</p-button>
|
||||
(onClick)="createNote()" />
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
@@ -189,18 +183,16 @@
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined
|
||||
(onClick)="cancelEdit()">
|
||||
</p-button>
|
||||
(onClick)="cancelEdit()" />
|
||||
<p-button
|
||||
outlined
|
||||
severity="success"
|
||||
label="Update Note"
|
||||
icon="pi pi-save"
|
||||
(onClick)="updateNote()">
|
||||
</p-button>
|
||||
(onClick)="updateNote()" />
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-confirmDialog key="deleteNote"></p-confirmDialog>
|
||||
<p-confirmDialog key="deleteNote" />
|
||||
</div>
|
||||
|
||||
@@ -29,16 +29,15 @@ import {BookNote, BookNoteService, CreateBookNoteRequest} from '../../../../shar
|
||||
styleUrl: './book-notes-component.scss'
|
||||
})
|
||||
export class BookNotesComponent implements OnInit, OnChanges {
|
||||
private readonly bookNoteService = inject(BookNoteService);
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
@Input() bookId!: number;
|
||||
|
||||
private bookNoteService = inject(BookNoteService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private messageService = inject(MessageService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
notes: BookNote[] = [];
|
||||
loading = signal(false);
|
||||
readonly loading = signal(false);
|
||||
showCreateDialog = false;
|
||||
showEditDialog = false;
|
||||
selectedNote: BookNote | null = null;
|
||||
@@ -62,7 +61,7 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['bookId'] && changes['bookId'].currentValue) {
|
||||
if (changes['bookId']?.currentValue) {
|
||||
this.loadNotes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../../../../core/config/api-config';
|
||||
@@ -17,13 +17,11 @@ export interface BookReview {
|
||||
textReviewsCount?: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class BookReviewService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/reviews`;
|
||||
private http = inject(HttpClient);
|
||||
|
||||
getByBookId(bookId: number): Observable<BookReview[]> {
|
||||
return this.http.get<BookReview[]>(`${this.url}/book/${bookId}`);
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
(click)="fetchNewReviews()"
|
||||
[pTooltip]="t('tooltip.fetchReviews')"
|
||||
tooltipPosition="top"
|
||||
class="action-btn floating-btn">
|
||||
</p-button>
|
||||
class="action-btn floating-btn" />
|
||||
}
|
||||
</div>
|
||||
<p class="empty-state-title">{{ t('empty.noReviews') }}</p>
|
||||
|
||||
@@ -25,27 +25,26 @@ import {MetadataCatalogService} from '../../../../shared/metadata/metadata-catal
|
||||
styleUrl: './book-reviews.component.scss'
|
||||
})
|
||||
export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
private readonly reviewService = inject(BookReviewService);
|
||||
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
protected readonly catalog = inject(MetadataCatalogService);
|
||||
@Input() bookId!: number;
|
||||
@Input() reviews: BookReview[] | undefined = [];
|
||||
@Input() active: boolean = false;
|
||||
@Input() reviewsLocked = false;
|
||||
|
||||
private reviewService = inject(BookReviewService);
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private messageService = inject(MessageService);
|
||||
private userService = inject(UserService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
protected readonly catalog = inject(MetadataCatalogService);
|
||||
private loadingBookId: number | null = null;
|
||||
private loadingRequestSeq = 0;
|
||||
private activeLoadingRequestSeq: number | null = null;
|
||||
|
||||
|
||||
|
||||
loading = signal(false);
|
||||
readonly loading = signal(false);
|
||||
hasPermission = false;
|
||||
revealedSpoilers = new Set<number>();
|
||||
sortAscending = false;
|
||||
@@ -58,7 +57,7 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['bookId'] && changes['bookId'].currentValue) {
|
||||
if (changes['bookId']?.currentValue) {
|
||||
this.loadReviews();
|
||||
}
|
||||
}
|
||||
@@ -320,7 +319,7 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private updateSpoilerState(): void {
|
||||
const spoilerReviews = this.reviews?.filter(r => r.spoiler) || [];
|
||||
const spoilerReviews = this.reviews?.filter(r => r.spoiler) ?? [];
|
||||
const revealedSpoilerReviews = spoilerReviews.filter(r => r.id && this.revealedSpoilers.has(r.id));
|
||||
this.allSpoilersRevealed = spoilerReviews.length > 0 && spoilerReviews.length === revealedSpoilerReviews.length;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
[text]="true"
|
||||
severity="secondary"
|
||||
(click)="dynamicDialogRef.close()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@@ -29,8 +28,7 @@
|
||||
[placeholder]="t('selectProvider')"
|
||||
[(ngModel)]="selectedProvider"
|
||||
appendTo="body"
|
||||
class="full-width">
|
||||
</p-select>
|
||||
class="full-width" />
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
@@ -43,8 +41,7 @@
|
||||
[(ngModel)]="selectedRecipient"
|
||||
[disabled]="!selectedProvider"
|
||||
appendTo="body"
|
||||
class="full-width">
|
||||
</p-select>
|
||||
class="full-width" />
|
||||
</div>
|
||||
|
||||
@if (emailableFiles.length > 0) {
|
||||
@@ -79,8 +76,7 @@
|
||||
icon="pi pi-envelope"
|
||||
[label]="t('sendBook')"
|
||||
[disabled]="!selectedProvider || !selectedRecipient"
|
||||
(onClick)="sendBook()">
|
||||
</p-button>
|
||||
(onClick)="sendBook()" />
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
@@ -41,13 +41,13 @@ const LARGE_FILE_THRESHOLD_KB = 25 * 1024; // 25MB
|
||||
})
|
||||
export class BookSenderComponent implements OnInit {
|
||||
|
||||
private emailProviderService = inject(EmailV2ProviderService);
|
||||
private emailRecipientService = inject(EmailV2RecipientService);
|
||||
private emailService = inject(EmailService);
|
||||
private messageService = inject(MessageService);
|
||||
private readonly emailProviderService = inject(EmailV2ProviderService);
|
||||
private readonly emailRecipientService = inject(EmailV2RecipientService);
|
||||
private readonly emailService = inject(EmailService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
|
||||
book: BookSenderSource = this.dynamicDialogConfig.data.book;
|
||||
|
||||
|
||||
+1
@@ -217,6 +217,7 @@
|
||||
@case ('created') { <i class="pi pi-check-circle"></i> }
|
||||
@case ('created-no-metadata') { <i class="pi pi-exclamation-triangle"></i> }
|
||||
@case ('failed') { <i class="pi pi-times-circle"></i> }
|
||||
@default never;
|
||||
}
|
||||
</div>
|
||||
<code class="progress-item-isbn">{{ entry.isbn }}</code>
|
||||
|
||||
+16
-16
@@ -60,29 +60,29 @@ type ImportPhase = 'upload' | 'processing' | 'summary';
|
||||
styleUrl: './bulk-isbn-import-dialog.component.scss',
|
||||
})
|
||||
export class BulkIsbnImportDialogComponent {
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dialogConfig = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private sources = inject(MetadataSourceQueryService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private readonly dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly dialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly sources = inject(MetadataSourceQueryService);
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
|
||||
selectedLibraryId: number | null = null;
|
||||
|
||||
phase: WritableSignal<ImportPhase> = signal('upload');
|
||||
readonly phase: WritableSignal<ImportPhase> = signal('upload');
|
||||
pasteText = '';
|
||||
entries: WritableSignal<IsbnEntry[]> = signal([]);
|
||||
skipped: WritableSignal<SkippedEntry[]> = signal([]);
|
||||
duplicatesRemoved = signal(0);
|
||||
readonly entries: WritableSignal<IsbnEntry[]> = signal([]);
|
||||
readonly skipped: WritableSignal<SkippedEntry[]> = signal([]);
|
||||
readonly duplicatesRemoved = signal(0);
|
||||
showSkipped = false;
|
||||
|
||||
processedCount = signal(0);
|
||||
createdCount = signal(0);
|
||||
noMetadataCount = signal(0);
|
||||
failedCount = signal(0);
|
||||
readonly processedCount = signal(0);
|
||||
readonly createdCount = signal(0);
|
||||
readonly noMetadataCount = signal(0);
|
||||
readonly failedCount = signal(0);
|
||||
cancelled = false;
|
||||
|
||||
parseError = signal('');
|
||||
readonly parseError = signal('');
|
||||
readonly maxIsbnCount = MAX_ISBN_COUNT;
|
||||
private readonly initializeSelectedLibraryEffect = effect(() => {
|
||||
const libraries = this.libraries;
|
||||
@@ -218,7 +218,7 @@ export class BulkIsbnImportDialogComponent {
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
|
||||
progressPercent = computed(
|
||||
readonly progressPercent = computed(
|
||||
() => this.entries().length > 0 ? Math.round((this.processedCount() / this.entries().length) * 100) : 0
|
||||
);
|
||||
|
||||
|
||||
@@ -70,6 +70,11 @@ export function bookCardCoverSrc(
|
||||
templateUrl: './book-card.component.html',
|
||||
})
|
||||
export class BookCardComponent {
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly locationStrategy = inject(LocationStrategy);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
readonly book = input.required<BookSummary>();
|
||||
readonly squareCovers = input(false, {transform: booleanAttribute});
|
||||
readonly showBadge = input(true, {transform: booleanAttribute});
|
||||
@@ -89,12 +94,6 @@ export class BookCardComponent {
|
||||
readonly action = output<void>();
|
||||
readonly menuRequested = output<ContextMenuRequest>();
|
||||
readonly detailRequested = output<void>();
|
||||
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly transloco = inject(TranslocoService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly locationStrategy = inject(LocationStrategy);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly activeLang = toSignal(this.transloco.langChanges$, {
|
||||
initialValue: this.transloco.getActiveLang(),
|
||||
});
|
||||
|
||||
+20
-31
@@ -14,8 +14,7 @@
|
||||
[text]="true"
|
||||
severity="secondary"
|
||||
(click)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@@ -27,13 +26,12 @@
|
||||
(onChange)="onPresetChange()"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
[disabled]="isScanning() || isMerging()">
|
||||
</p-selectButton>
|
||||
[disabled]="isScanning() || isMerging()" />
|
||||
</div>
|
||||
|
||||
<!-- Advanced Toggles -->
|
||||
<div class="advanced-section">
|
||||
<button class="advanced-toggle" (click)="showAdvanced = !showAdvanced">
|
||||
<button type="button" class="advanced-toggle" (click)="showAdvanced = !showAdvanced">
|
||||
<i class="pi" [class.pi-chevron-right]="!showAdvanced" [class.pi-chevron-down]="showAdvanced"></i>
|
||||
{{ t('advanced') }}
|
||||
</button>
|
||||
@@ -41,23 +39,23 @@
|
||||
@if (showAdvanced) {
|
||||
<div class="signal-checkboxes">
|
||||
<div class="signal-checkbox">
|
||||
<p-checkbox [(ngModel)]="matchByIsbn" [binary]="true" inputId="isbn" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="matchByIsbn" [binary]="true" inputId="isbn" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()" />
|
||||
<label for="isbn">{{ t('signalIsbn') }}</label>
|
||||
</div>
|
||||
<div class="signal-checkbox">
|
||||
<p-checkbox [(ngModel)]="matchByExternalId" [binary]="true" inputId="externalId" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="matchByExternalId" [binary]="true" inputId="externalId" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()" />
|
||||
<label for="externalId">{{ t('signalExternalId') }}</label>
|
||||
</div>
|
||||
<div class="signal-checkbox">
|
||||
<p-checkbox [(ngModel)]="matchByTitleAuthor" [binary]="true" inputId="titleAuthor" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="matchByTitleAuthor" [binary]="true" inputId="titleAuthor" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()" />
|
||||
<label for="titleAuthor">{{ t('signalTitleAuthor') }}</label>
|
||||
</div>
|
||||
<div class="signal-checkbox">
|
||||
<p-checkbox [(ngModel)]="matchByDirectory" [binary]="true" inputId="directory" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="matchByDirectory" [binary]="true" inputId="directory" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()" />
|
||||
<label for="directory">{{ t('signalDirectory') }}</label>
|
||||
</div>
|
||||
<div class="signal-checkbox">
|
||||
<p-checkbox [(ngModel)]="matchByFilename" [binary]="true" inputId="filename" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="matchByFilename" [binary]="true" inputId="filename" (onChange)="onSignalToggle()" [disabled]="isScanning() || isMerging()" />
|
||||
<label for="filename">{{ t('signalFilename') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -72,8 +70,7 @@
|
||||
icon="pi pi-search"
|
||||
(click)="scan()"
|
||||
[disabled]="!canScan"
|
||||
[loading]="isScanning()">
|
||||
</p-button>
|
||||
[loading]="isScanning()" />
|
||||
</div>
|
||||
<div class="action-bar-right">
|
||||
<div class="delete-option">
|
||||
@@ -81,8 +78,7 @@
|
||||
[(ngModel)]="moveFiles"
|
||||
[binary]="true"
|
||||
inputId="moveFiles"
|
||||
[disabled]="isMerging()">
|
||||
</p-checkbox>
|
||||
[disabled]="isMerging()" />
|
||||
<label for="moveFiles">{{ 'book.fileAttacher.moveFilesLabel' | transloco }}</label>
|
||||
</div>
|
||||
@if (activeGroups.length > 0) {
|
||||
@@ -92,15 +88,14 @@
|
||||
severity="success"
|
||||
(click)="mergeAll()"
|
||||
[disabled]="isMerging()"
|
||||
[loading]="isMerging()">
|
||||
</p-button>
|
||||
[loading]="isMerging()" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Merge Progress -->
|
||||
@if (isMerging()) {
|
||||
<p-progressBar [value]="mergeTotal() > 0 ? (mergeProgress() / mergeTotal()) * 100 : 0" [showValue]="false"></p-progressBar>
|
||||
<p-progressBar [value]="mergeTotal() > 0 ? (mergeProgress() / mergeTotal()) * 100 : 0" [showValue]="false" />
|
||||
}
|
||||
|
||||
<!-- Help Text -->
|
||||
@@ -139,9 +134,9 @@
|
||||
<div class="duplicate-group">
|
||||
<div class="group-header">
|
||||
<span class="group-label">{{ t('groupLabel', { index: pageFirst + $index + 1 }) }}</span>
|
||||
<p-tag [value]="getMatchReasonLabel(group.matchReason)" [severity]="getMatchReasonSeverity(group.matchReason)"></p-tag>
|
||||
<p-tag [value]="getMatchReasonLabel(group.matchReason)" [severity]="getMatchReasonSeverity(group.matchReason)" />
|
||||
@if (hasSameFormatConflict(group)) {
|
||||
<p-tag [value]="t('sameFormatWarning')" severity="warn" icon="pi pi-exclamation-triangle"></p-tag>
|
||||
<p-tag [value]="t('sameFormatWarning')" severity="warn" icon="pi pi-exclamation-triangle" />
|
||||
}
|
||||
<div class="group-actions">
|
||||
<p-button
|
||||
@@ -150,8 +145,7 @@
|
||||
size="small"
|
||||
severity="success"
|
||||
(click)="mergeGroup(group)"
|
||||
[disabled]="isMerging()">
|
||||
</p-button>
|
||||
[disabled]="isMerging()" />
|
||||
@if (getDeleteSelectedCount(group) > 0) {
|
||||
<p-button
|
||||
[label]="t('deleteSelected', { count: getDeleteSelectedCount(group) })"
|
||||
@@ -160,8 +154,7 @@
|
||||
severity="danger"
|
||||
[outlined]="true"
|
||||
(click)="deleteGroup(group)"
|
||||
[disabled]="isMerging()">
|
||||
</p-button>
|
||||
[disabled]="isMerging()" />
|
||||
}
|
||||
<p-button
|
||||
[label]="t('dismiss')"
|
||||
@@ -170,8 +163,7 @@
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(click)="dismissGroup(group)"
|
||||
[disabled]="isMerging()">
|
||||
</p-button>
|
||||
[disabled]="isMerging()" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="group-books">
|
||||
@@ -183,8 +175,7 @@
|
||||
[ngModel]="group.selectedForDeletion.has(book.id)"
|
||||
(onChange)="toggleDeleteSelection(group, book.id)"
|
||||
[disabled]="isMerging()"
|
||||
class="delete-checkbox">
|
||||
</p-checkbox>
|
||||
class="delete-checkbox" />
|
||||
}
|
||||
<app-cover class="book-cover"
|
||||
aria-hidden="true"
|
||||
@@ -222,8 +213,7 @@
|
||||
[value]="book.id"
|
||||
[(ngModel)]="group.selectedTargetBookId"
|
||||
(onClick)="onTargetChange(group)"
|
||||
[disabled]="isMerging()">
|
||||
</p-radioButton>
|
||||
[disabled]="isMerging()" />
|
||||
@if (book.id === group.selectedTargetBookId) {
|
||||
<span class="target-label">{{ t('target') }}</span>
|
||||
}
|
||||
@@ -241,8 +231,7 @@
|
||||
[totalRecords]="activeGroups.length"
|
||||
[first]="pageFirst"
|
||||
(onPageChange)="onPageChange($event)"
|
||||
[rowsPerPageOptions]="[10, 20, 50]">
|
||||
</p-paginator>
|
||||
[rowsPerPageOptions]="[10, 20, 50]" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
+29
-31
@@ -8,7 +8,7 @@ import {SelectButton} from '@openng/optimus-ui/selectbutton';
|
||||
import {ProgressBar} from '@openng/optimus-ui/progressbar';
|
||||
import {Tag} from '@openng/optimus-ui/tag';
|
||||
import {Paginator, PaginatorState} from '@openng/optimus-ui/paginator';
|
||||
import {Subject, takeUntil} from 'rxjs';
|
||||
import {lastValueFrom, Subject, takeUntil} from 'rxjs';
|
||||
import {BookFileService} from '../../service/book-file.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {Book, DuplicateDetectionRequest, DuplicateGroup} from '../../model/book.model';
|
||||
@@ -46,30 +46,6 @@ interface DisplayGroup extends DuplicateGroup {
|
||||
styleUrls: ['./duplicate-merger.component.scss']
|
||||
})
|
||||
export class DuplicateMergerComponent implements OnInit, OnDestroy {
|
||||
libraryId!: number;
|
||||
presetMode: PresetMode = 'balanced';
|
||||
showAdvanced = false;
|
||||
|
||||
matchByIsbn = true;
|
||||
matchByExternalId = true;
|
||||
matchByTitleAuthor = true;
|
||||
matchByDirectory = false;
|
||||
matchByFilename = false;
|
||||
|
||||
isScanning = signal(false);
|
||||
isMerging = signal(false);
|
||||
hasScanned = signal(false);
|
||||
moveFiles = false;
|
||||
mergeProgress = signal(0);
|
||||
mergeTotal = signal(0);
|
||||
|
||||
groups: DisplayGroup[] = [];
|
||||
presetOptions: { label: string; value: PresetMode }[] = [];
|
||||
|
||||
pageFirst = 0;
|
||||
pageSize = 20;
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private readonly bookFileService = inject(BookFileService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
@@ -80,6 +56,30 @@ export class DuplicateMergerComponent implements OnInit, OnDestroy {
|
||||
readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly changeDetectorRef = inject(ChangeDetectorRef);
|
||||
libraryId!: number;
|
||||
presetMode: PresetMode = 'balanced';
|
||||
showAdvanced = false;
|
||||
|
||||
matchByIsbn = true;
|
||||
matchByExternalId = true;
|
||||
matchByTitleAuthor = true;
|
||||
matchByDirectory = false;
|
||||
matchByFilename = false;
|
||||
|
||||
readonly isScanning = signal(false);
|
||||
readonly isMerging = signal(false);
|
||||
readonly hasScanned = signal(false);
|
||||
moveFiles = false;
|
||||
readonly mergeProgress = signal(0);
|
||||
readonly mergeTotal = signal(0);
|
||||
|
||||
groups: DisplayGroup[] = [];
|
||||
presetOptions: { label: string; value: PresetMode }[] = [];
|
||||
|
||||
pageFirst = 0;
|
||||
pageSize = 20;
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.libraryId = this.config.data.libraryId;
|
||||
@@ -298,9 +298,8 @@ export class DuplicateMergerComponent implements OnInit, OnDestroy {
|
||||
|
||||
group.dismissed = true;
|
||||
try {
|
||||
await this.bookFileService.attachBookFiles(targetId, sourceIds, this.moveFiles)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.toPromise();
|
||||
await lastValueFrom(this.bookFileService.attachBookFiles(targetId, sourceIds, this.moveFiles)
|
||||
.pipe(takeUntil(this.destroy$)), {defaultValue: undefined});
|
||||
} catch {
|
||||
group.dismissed = false;
|
||||
this.messageService.add({
|
||||
@@ -335,9 +334,8 @@ export class DuplicateMergerComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
try {
|
||||
await this.bookFileService.attachBookFiles(targetId, sourceIds, this.moveFiles)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.toPromise();
|
||||
await lastValueFrom(this.bookFileService.attachBookFiles(targetId, sourceIds, this.moveFiles)
|
||||
.pipe(takeUntil(this.destroy$)), {defaultValue: undefined});
|
||||
group.dismissed = true;
|
||||
successCount++;
|
||||
} catch {
|
||||
|
||||
+4
-8
@@ -1,13 +1,11 @@
|
||||
import {effect, inject, Injectable, signal} from '@angular/core';
|
||||
import {effect, inject, Service, signal} from '@angular/core';
|
||||
import {EntityViewPreference, UserService} from '../../../settings/user-management/user.service';
|
||||
|
||||
interface LegacyOverlayPreference extends Partial<EntityViewPreference> {
|
||||
showBookTypePill?: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class BookCardOverlayPreferenceService {
|
||||
private static readonly PERSIST_DELAY_MS = 500;
|
||||
|
||||
@@ -16,7 +14,7 @@ export class BookCardOverlayPreferenceService {
|
||||
private readonly _showBookTypePill = signal(true);
|
||||
readonly showBookTypePill = this._showBookTypePill.asReadonly();
|
||||
|
||||
private currentContext: { type: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF', id: number } | null = null;
|
||||
private readonly currentContext: { type: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF', id: number } | null = null;
|
||||
private persistTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
constructor() {
|
||||
@@ -90,9 +88,7 @@ export class BookCardOverlayPreferenceService {
|
||||
overrides: []
|
||||
});
|
||||
|
||||
if (!prefs.overrides) {
|
||||
prefs.overrides = [];
|
||||
}
|
||||
prefs.overrides ??= [];
|
||||
|
||||
if (this.currentContext) {
|
||||
let override = prefs.overrides.find(o =>
|
||||
|
||||
+9
-10
@@ -5,7 +5,7 @@
|
||||
(click)="onCardClick($event)"
|
||||
(keydown.enter)="onCardClick($event)">
|
||||
|
||||
<div class="cover-container" [ngClass]="{ 'center-info-btn': isSeriesViewActive() || !hasDigitalFile(), 'audiobook-cover': isAudiobook(), 'square-library-cover': useSquareCovers() }">
|
||||
<div class="cover-container" [class]="{ 'center-info-btn': isSeriesViewActive() || !hasDigitalFile(), 'audiobook-cover': isAudiobook(), 'square-library-cover': useSquareCovers() }">
|
||||
<app-cover
|
||||
class="book-cover"
|
||||
[class.square-cover]="isAudiobook() || useSquareCovers()"
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<div class="top-left-overlay-stack">
|
||||
@if (showBookTypePill() && displayFormat(); as fmt) {
|
||||
<div class="book-type-pill-overlay" [ngClass]="'book-type-' + fmt.toLowerCase()">
|
||||
<div class="book-type-pill-overlay" [class]="'book-type-' + fmt.toLowerCase()">
|
||||
{{ fmt }}
|
||||
</div>
|
||||
}
|
||||
@@ -59,24 +59,23 @@
|
||||
class="select-checkbox"
|
||||
(click)="captureMouseEvent($event)"
|
||||
[ngModel]="isSelected()"
|
||||
(onChange)="toggleSelection($event)">
|
||||
</p-checkbox>
|
||||
(onChange)="toggleSelection($event)" />
|
||||
}
|
||||
|
||||
@if (hasProgress()) {
|
||||
<div class="cover-progress-bar-container" [pTooltip]="progressTooltip()" tooltipPosition="top">
|
||||
@if (progressPercentage() !== null) {
|
||||
<div class="cover-progress-bar" [ngClass]="{ 'progress-complete': progressPercentage() === 100, 'progress-incomplete': progressPercentage()! < 100 }">
|
||||
<div class="cover-progress-bar" [class]="{ 'progress-complete': progressPercentage() === 100, 'progress-incomplete': progressPercentage()! < 100 }">
|
||||
<div class="progress-fill" [style.width.%]="progressPercentage()!"></div>
|
||||
</div>
|
||||
}
|
||||
@if (koProgressPercentage() !== null) {
|
||||
<div class="cover-progress-bar" [ngClass]="koProgressPercentage() === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'">
|
||||
<div class="cover-progress-bar" [class]="koProgressPercentage() === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'">
|
||||
<div class="progress-fill" [style.width.%]="koProgressPercentage()!"></div>
|
||||
</div>
|
||||
}
|
||||
@if (koboProgressPercentage() !== null) {
|
||||
<div class="cover-progress-bar" [ngClass]="koboProgressPercentage() === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'">
|
||||
<div class="cover-progress-bar" [class]="koboProgressPercentage() === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'">
|
||||
<div class="progress-fill" [style.width.%]="koboProgressPercentage()!"></div>
|
||||
</div>
|
||||
}
|
||||
@@ -87,7 +86,7 @@
|
||||
@if (!bottomBarHidden()) {
|
||||
<div class="book-title-container">
|
||||
<div class="read-status-indicator"
|
||||
[ngClass]="readStatusClass()"
|
||||
[class]="readStatusClass()"
|
||||
[pTooltip]="readStatusTooltip()"
|
||||
tooltipPosition="bottom"
|
||||
(click)="toggleReadStatusMenu($event, readStatusMenu)"
|
||||
@@ -97,13 +96,13 @@
|
||||
[attr.aria-label]="'book.card.alt.readStatusMenu' | transloco">
|
||||
<i [class]="readStatusIcon()" style="font-size: 0.9rem"></i>
|
||||
</div>
|
||||
<p-tieredmenu #readStatusMenu [model]="readStatusMenuItems()" [popup]="true" appendTo="body"></p-tieredmenu>
|
||||
<p-tieredmenu #readStatusMenu [model]="readStatusMenuItems()" [popup]="true" appendTo="body" />
|
||||
<h4 class="book-title"
|
||||
tooltipPosition="bottom"
|
||||
[pTooltip]="titleTooltip()">
|
||||
{{ displayTitle() }}
|
||||
</h4>
|
||||
<p-tieredmenu #menu [model]="items()" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
||||
<p-tieredmenu #menu [model]="items()" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()" />
|
||||
<button pButton type="button"
|
||||
class="p-button p-component p-button-text p-button-sm custom-button-padding"
|
||||
(click)="onMenuToggle($event, menu)"
|
||||
|
||||
+2
-2
@@ -148,7 +148,7 @@ describe('LegacyBookCardComponent', () => {
|
||||
appSettings: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
let queryClient: {
|
||||
fetchQuery: ReturnType<typeof vi.fn>;
|
||||
query: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -204,7 +204,7 @@ describe('LegacyBookCardComponent', () => {
|
||||
appSettings: vi.fn(() => ({diskType: 'LOCAL'})),
|
||||
};
|
||||
queryClient = {
|
||||
fetchQuery: vi.fn(),
|
||||
query: vi.fn(),
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
|
||||
+21
-23
@@ -10,7 +10,6 @@ import {FormsModule} from '@angular/forms';
|
||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
import {CoverComponent} from '../../../../shared/components/cover/cover.component';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {EmailService} from '../../../settings/email-v2/email.service';
|
||||
import {TieredMenu} from '@openng/optimus-ui/tieredmenu';
|
||||
@@ -31,11 +30,28 @@ import {ButtonDirective} from '@openng/optimus-ui/button';
|
||||
selector: 'app-legacy-book-card',
|
||||
templateUrl: './legacy-book-card.component.html',
|
||||
styleUrls: ['./legacy-book-card.component.scss'],
|
||||
imports: [ButtonDirective, Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverComponent],
|
||||
imports: [ButtonDirective, Checkbox, FormsModule, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverComponent],
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class LegacyBookCardComponent {
|
||||
private readonly overlayService = inject(BookCardOverlayPreferenceService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly bookFileService = inject(BookFileService);
|
||||
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private readonly taskHelperService = inject(TaskHelperService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly emailService = inject(EmailService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
private readonly bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly bookNavigationService = inject(BookNavigationService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
protected readStatusHelper = inject(ReadStatusHelper);
|
||||
|
||||
// --- Inputs ---
|
||||
readonly book = input.required<Book>();
|
||||
@@ -47,7 +63,6 @@ export class LegacyBookCardComponent {
|
||||
readonly seriesViewEnabled = input(false);
|
||||
readonly isSeriesCollapsed = input(false);
|
||||
readonly overlayPreferenceService = input<BookCardOverlayPreferenceService | undefined>();
|
||||
private readonly overlayService = inject(BookCardOverlayPreferenceService);
|
||||
readonly showBookTypePill = computed(() => (this.overlayPreferenceService() ?? this.overlayService).showBookTypePill());
|
||||
readonly forceEbookMode = input(false);
|
||||
readonly useSquareCovers = input(false);
|
||||
@@ -63,25 +78,8 @@ export class LegacyBookCardComponent {
|
||||
private menuBookId: number | undefined;
|
||||
private menuInitialized = false;
|
||||
|
||||
private bookService = inject(BookService);
|
||||
private bookFileService = inject(BookFileService);
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private taskHelperService = inject(TaskHelperService);
|
||||
private userService = inject(UserService);
|
||||
private emailService = inject(EmailService);
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
private urlHelper = inject(UrlHelperService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private bookNavigationService = inject(BookNavigationService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private queryClient = inject(QueryClient);
|
||||
protected readStatusHelper = inject(ReadStatusHelper);
|
||||
|
||||
private readonly currentUser = computed(() => this.userService.currentUser());
|
||||
private readonly metadataCenterViewMode = computed(() => this.currentUser()?.userSettings?.metadataCenterViewMode ?? 'route' as 'route' | 'dialog');
|
||||
private readonly metadataCenterViewMode = computed(() => this.currentUser()?.userSettings?.metadataCenterViewMode ?? 'route');
|
||||
private readonly diskType = computed(() => this.appSettingsService.appSettings()?.diskType ?? 'LOCAL');
|
||||
|
||||
|
||||
@@ -257,7 +255,7 @@ export class LegacyBookCardComponent {
|
||||
if (!this.additionalFilesLoaded() && !this.isSubMenuLoading() && this.needsAdditionalFilesData()) {
|
||||
this.isSubMenuLoading.set(true);
|
||||
const requestedBookId = currentBookId;
|
||||
void this.queryClient.fetchQuery(this.bookService.bookDetailQueryOptions(requestedBookId, true))
|
||||
void this.queryClient.query(this.bookService.bookDetailQueryOptions(requestedBookId, true))
|
||||
.then((fetchedBook) => {
|
||||
if (this.book().id !== requestedBookId) return;
|
||||
this.additionalFilesLoaded.set(true);
|
||||
@@ -629,7 +627,7 @@ export class LegacyBookCardComponent {
|
||||
const items: MenuItem[] = [];
|
||||
|
||||
items.push({
|
||||
label: `${b.fileName || 'Book File'}`,
|
||||
label: b.fileName || 'Book File',
|
||||
icon: 'pi pi-file',
|
||||
command: () => this.bookFileService.downloadFile(this.book())
|
||||
});
|
||||
|
||||
+1
-2
@@ -128,10 +128,9 @@ export function libraryShelfMenuAvailable(
|
||||
`,
|
||||
})
|
||||
export class LibraryShelfMenuItemsComponent {
|
||||
readonly target = input.required<LibraryShelfMenuTarget>();
|
||||
|
||||
private readonly currentUser = inject(UserService).currentUser;
|
||||
protected readonly actions = inject(LibraryShelfMenuService);
|
||||
readonly target = input.required<LibraryShelfMenuTarget>();
|
||||
|
||||
protected readonly canManageShelf = computed(() => {
|
||||
const target = this.target();
|
||||
|
||||
+1
-2
@@ -26,6 +26,7 @@ import {libraryShelfMenuAvailable, LibraryShelfMenuItemsComponent} from './libra
|
||||
`,
|
||||
})
|
||||
export class LibraryShelfMenuComponent {
|
||||
private readonly currentUser = inject(UserService).currentUser;
|
||||
readonly target = input.required<LibraryShelfMenuTarget>();
|
||||
readonly ariaLabel = input.required<string>();
|
||||
|
||||
@@ -33,8 +34,6 @@ export class LibraryShelfMenuComponent {
|
||||
readonly closed = output<void>();
|
||||
readonly menu = viewChild.required(AppMenuComponent);
|
||||
|
||||
private readonly currentUser = inject(UserService).currentUser;
|
||||
|
||||
readonly available = computed(
|
||||
() => libraryShelfMenuAvailable(this.target(), this.currentUser()),
|
||||
);
|
||||
|
||||
+7
-8
@@ -14,8 +14,7 @@
|
||||
[text]="true"
|
||||
severity="secondary"
|
||||
(click)="dialogRef.close()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@@ -29,7 +28,7 @@
|
||||
[icon]="getLockIcon(field)"
|
||||
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
|
||||
(click)="cycleLockState(field)"
|
||||
></p-button>
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -37,13 +36,13 @@
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-actions">
|
||||
<p-button icon="pi pi-refresh" [label]="t('reset')" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
|
||||
<p-button icon="pi pi-refresh" [label]="t('reset')" outlined="true" severity="warn" (onClick)="resetFieldLocks()" />
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button icon="pi pi-lock" [label]="t('lockAll')" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')"></p-button>
|
||||
<p-button icon="pi pi-lock-open" [label]="t('unlockAll')" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')"></p-button>
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-button [label]="isSaving ? t('saving') : t('save')" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving"></p-button>
|
||||
<p-button icon="pi pi-lock" [label]="t('lockAll')" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')" />
|
||||
<p-button icon="pi pi-lock-open" [label]="t('unlockAll')" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')" />
|
||||
<p-divider layout="vertical" />
|
||||
<p-button [label]="isSaving ? t('saving') : t('save')" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+5
-6
@@ -24,18 +24,17 @@ import {MetadataProviderFieldsService} from '../../../../shared/metadata';
|
||||
styleUrl: './lock-unlock-metadata-dialog.component.scss'
|
||||
})
|
||||
export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private readonly dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
dialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly loadingService = inject(LoadingService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly providerFields = inject(MetadataProviderFieldsService);
|
||||
fieldLocks: Record<string, boolean | undefined> = {};
|
||||
|
||||
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
||||
|
||||
private readonly providerFields = inject(MetadataProviderFieldsService);
|
||||
|
||||
lockableFields: string[] = [
|
||||
'titleLocked', 'subtitleLocked', 'publisherLocked', 'publishedDateLocked', 'descriptionLocked',
|
||||
'isbn13Locked', 'isbn10Locked', 'pageCountLocked', 'thumbnailLocked', 'languageLocked', 'coverLocked',
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.seriesPage'">
|
||||
@if (isBooksLoading()) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
|
||||
</p-progressSpinner>
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s" />
|
||||
<p style="color: var(--primary-color);">
|
||||
{{ t('loadingSeriesDetails') }}
|
||||
</p>
|
||||
@@ -207,8 +206,7 @@
|
||||
<p-progressBar
|
||||
[value]="nextUp.progressPercent"
|
||||
[showValue]="false"
|
||||
class="next-up-progress">
|
||||
</p-progressBar>
|
||||
class="next-up-progress" />
|
||||
<span class="next-up-percent">{{ nextUp.progressPercent }}%</span>
|
||||
</div>
|
||||
}
|
||||
@@ -223,7 +221,7 @@
|
||||
<div class="read-progress-bar">
|
||||
@for (seg of segments; track seg.status) {
|
||||
<div class="read-progress-segment"
|
||||
[ngStyle]="{'width': seg.percent + '%', 'background-color': getStatusColor(seg.status)}"
|
||||
[style]="{'width': seg.percent + '%', 'background-color': getStatusColor(seg.status)}"
|
||||
[pTooltip]="getStatusLabel(seg.status) + ': ' + seg.count">
|
||||
</div>
|
||||
}
|
||||
@@ -231,9 +229,9 @@
|
||||
<div class="read-progress-legend">
|
||||
@for (seg of segments; track seg.status) {
|
||||
<span class="legend-item"
|
||||
[ngStyle]="{'border-color': getStatusColor(seg.status)}">
|
||||
[style.border-color]="getStatusColor(seg.status)">
|
||||
<span class="legend-dot"
|
||||
[ngStyle]="{'background-color': getStatusColor(seg.status)}"></span>
|
||||
[style.background-color]="getStatusColor(seg.status)"></span>
|
||||
{{ getStatusLabel(seg.status) }} ({{ seg.count }})
|
||||
</span>
|
||||
}
|
||||
@@ -259,15 +257,15 @@
|
||||
<span>{{ t('synopsis') }}</span>
|
||||
</div>
|
||||
<div class="description-body">
|
||||
<div #descriptionContent [ngClass]="{ 'description-content-collapsed': !isExpanded() }"
|
||||
<div #descriptionContent [class.description-content-collapsed]="!isExpanded()"
|
||||
class="description-content">
|
||||
<div class="description-html"
|
||||
[innerHTML]="firstDescription() || t('noDescription')"></div>
|
||||
</div>
|
||||
@if (isExpanded() || isOverflowing()) {
|
||||
<button class="expand-toggle" (click)="toggleExpand()">
|
||||
<button type="button" class="expand-toggle" (click)="toggleExpand()">
|
||||
{{ isExpanded() ? t('showLess') : t('showMore') }}
|
||||
<i class="pi" [ngClass]="isExpanded() ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
|
||||
<i class="pi" [class]="isExpanded() ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@@ -295,8 +293,7 @@
|
||||
(checkboxClick)="onCheckboxClicked($event)"
|
||||
[isSelected]="isBookSelected(book)"
|
||||
[useSquareCovers]="seriesCardsUseSquareCovers"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||
</app-legacy-book-card>
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService" />
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -345,7 +342,7 @@
|
||||
@if (getBookProgress(book); as progress) {
|
||||
<div class="list-progress-row">
|
||||
<div class="list-progress-bar">
|
||||
<div class="list-progress-fill" [ngStyle]="{'width': progress + '%'}"></div>
|
||||
<div class="list-progress-fill" [style.width]="progress + '%'"></div>
|
||||
</div>
|
||||
<span class="list-progress-text">{{ progress }}%</span>
|
||||
</div>
|
||||
@@ -354,7 +351,7 @@
|
||||
<div class="list-rating-row">
|
||||
@for (star of [1,2,3,4,5]; track star) {
|
||||
<i class="pi list-star"
|
||||
[ngClass]="book.personalRating! >= star * 2 ? 'pi-star-fill' : (book.personalRating! >= star * 2 - 1 ? 'pi-star-half-fill' : 'pi-star')">
|
||||
[class]="book.personalRating! >= star * 2 ? 'pi-star-fill' : (book.personalRating! >= star * 2 - 1 ? 'pi-star-half-fill' : 'pi-star')">
|
||||
</i>
|
||||
}
|
||||
<span class="list-rating-value">{{ book.personalRating }}/10</span>
|
||||
@@ -364,7 +361,7 @@
|
||||
<div class="list-right-col">
|
||||
<div class="list-badges">
|
||||
<span class="list-status-badge"
|
||||
[ngStyle]="{'background-color': getStatusColor(book.readStatus)}">
|
||||
[style.background-color]="getStatusColor(book.readStatus)">
|
||||
{{ getStatusLabel(book.readStatus) }}
|
||||
</span>
|
||||
@if (book.primaryFile?.bookType; as bookType) {
|
||||
@@ -377,11 +374,11 @@
|
||||
}
|
||||
</div>
|
||||
<div class="list-actions">
|
||||
<button class="list-action-btn btn-read" (click)="readBook(book.id); $event.stopPropagation()"
|
||||
<button type="button" class="list-action-btn btn-read" (click)="readBook(book.id); $event.stopPropagation()"
|
||||
[pTooltip]="t('readButton')" tooltipPosition="top">
|
||||
<i class="pi pi-book"></i>
|
||||
</button>
|
||||
<button class="list-action-btn btn-details" (click)="viewBookDetails(book.id); $event.stopPropagation()"
|
||||
<button type="button" class="list-action-btn btn-details" (click)="viewBookDetails(book.id); $event.stopPropagation()"
|
||||
[pTooltip]="t('viewDetails')" tooltipPosition="top">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
</button>
|
||||
@@ -389,7 +386,7 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (books.length === 0) {
|
||||
@empty {
|
||||
<div class="empty-state">{{ t('noBooksFound') }}</div>
|
||||
}
|
||||
</div>
|
||||
@@ -418,8 +415,7 @@
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
icon="pi pi-database">
|
||||
</p-button>
|
||||
icon="pi pi-database" />
|
||||
}
|
||||
<p-button
|
||||
icon="pi pi-bookmark-fill"
|
||||
@@ -427,8 +423,7 @@
|
||||
severity="info"
|
||||
(onClick)="openShelfAssigner()"
|
||||
[pTooltip]="t('tooltip.assignToShelf')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
@if (user.permissions.canBulkLockUnlockMetadata) {
|
||||
<p-button
|
||||
outlined="true"
|
||||
@@ -436,8 +431,7 @@
|
||||
severity="info"
|
||||
(click)="lockUnlockMetadata()"
|
||||
[pTooltip]="t('tooltip.lockUnlockMetadata')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
@if (user.permissions.canMoveOrganizeFiles && appSettings()?.diskType === 'LOCAL') {
|
||||
<p-button
|
||||
@@ -446,8 +440,7 @@
|
||||
severity="info"
|
||||
(click)="moveFiles()"
|
||||
[pTooltip]="t('tooltip.organizeFiles')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
@if (hasMoreActionsItems) {
|
||||
<div class="more-actions-wrapper">
|
||||
@@ -457,13 +450,12 @@
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
icon="pi pi-ellipsis-v">
|
||||
</p-button>
|
||||
icon="pi pi-ellipsis-v" />
|
||||
<p-tieredMenu #moreActionsMenu [model]="moreActionsMenuItems()" [popup]="true" appendTo="body"/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-divider layout="vertical" />
|
||||
<div class="footer-action-group">
|
||||
<p-button
|
||||
outlined="true"
|
||||
@@ -471,27 +463,24 @@
|
||||
severity="success"
|
||||
(click)="selectAllBooks()"
|
||||
[pTooltip]="t('tooltip.selectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()"
|
||||
[pTooltip]="t('tooltip.deselectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
@if (user.permissions.admin || user.permissions.canDeleteBook) {
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-divider layout="vertical" />
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
(click)="confirmDeleteBooks()"
|
||||
[pTooltip]="t('tooltip.deleteSelected')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
}
|
||||
</div>
|
||||
<div class="footer-right"></div>
|
||||
|
||||
@@ -2,7 +2,7 @@ import {FormsModule} from "@angular/forms";
|
||||
import {Button} from "@openng/optimus-ui/button";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {toSignal} from '@angular/core/rxjs-interop';
|
||||
import {DecimalPipe, KeyValuePipe, NgClass, NgStyle} from "@angular/common";
|
||||
import {DecimalPipe, KeyValuePipe} from "@angular/common";
|
||||
import {finalize, map, take} from "rxjs/operators";
|
||||
import {Book, BookType, computeSeriesReadStatus, ReadStatus} from "../../model/book.model";
|
||||
import {BookService} from "../../service/book.service";
|
||||
@@ -75,8 +75,6 @@ interface SeriesStats {
|
||||
KeyValuePipe,
|
||||
Button,
|
||||
FormsModule,
|
||||
NgStyle,
|
||||
NgClass,
|
||||
LegacyBookCardComponent,
|
||||
ProgressSpinner,
|
||||
ProgressBar,
|
||||
@@ -94,32 +92,32 @@ interface SeriesStats {
|
||||
],
|
||||
})
|
||||
export class SeriesPageComponent implements AfterViewChecked {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly languageResolver = inject(LanguageResolverService);
|
||||
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private readonly router = inject(Router);
|
||||
protected userService = inject(UserService);
|
||||
private readonly bookMenuService = inject(BookMenuService);
|
||||
protected confirmationService = inject(ConfirmationService);
|
||||
private readonly loadingService = inject(LoadingService);
|
||||
private readonly dialogHelperService = inject(BookDialogHelperService);
|
||||
protected taskHelperService = inject(TaskHelperService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
protected bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||
protected appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private readonly authorService = inject(AuthorService);
|
||||
private readonly layoutService = inject(LayoutService);
|
||||
|
||||
private readonly DEFAULT_SERIES_CARD_WIDTH = 135;
|
||||
private readonly DEFAULT_SERIES_CARD_HEIGHT = 220;
|
||||
private readonly DESKTOP_SERIES_GRID_GAP = 21;
|
||||
private readonly MOBILE_SERIES_GRID_GAP = 8;
|
||||
private readonly MOBILE_GRID_COLUMNS = 2;
|
||||
private route = inject(ActivatedRoute);
|
||||
private bookService = inject(BookService);
|
||||
private languageResolver = inject(LanguageResolverService);
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private metadataCenterViewMode: "route" | "dialog" = "route";
|
||||
private readonly metadataCenterViewMode: "route" | "dialog" = "route";
|
||||
private dialogRef?: DynamicDialogRef | null;
|
||||
private router = inject(Router);
|
||||
protected userService = inject(UserService);
|
||||
private bookMenuService = inject(BookMenuService);
|
||||
protected confirmationService = inject(ConfirmationService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private dialogHelperService = inject(BookDialogHelperService);
|
||||
protected taskHelperService = inject(TaskHelperService);
|
||||
private messageService = inject(MessageService);
|
||||
protected bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||
protected appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private authorService = inject(AuthorService);
|
||||
private layoutService = inject(LayoutService);
|
||||
|
||||
private readonly descriptionContentRef = viewChild<ElementRef<HTMLElement>>('descriptionContent');
|
||||
private readonly seriesGridElement = viewChild<ElementRef<HTMLElement>>('seriesGrid');
|
||||
@@ -143,11 +141,11 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
protected readonly seriesCardsUseSquareCovers = false;
|
||||
protected readonly onSeriesBookCardSelect = this.handleBookSelect.bind(this);
|
||||
|
||||
private seriesParam = toSignal(this.route.paramMap.pipe(
|
||||
private readonly seriesParam = toSignal(this.route.paramMap.pipe(
|
||||
map((params) => params.get("seriesName") || ""),
|
||||
), {initialValue: ""});
|
||||
|
||||
filteredBooks = computed(() => {
|
||||
readonly filteredBooks = computed(() => {
|
||||
const seriesName = this.seriesParam().trim().toLowerCase();
|
||||
const inSeries = this.bookService.books().filter(
|
||||
(book) => book.metadata?.seriesName?.trim().toLowerCase() === seriesName
|
||||
@@ -177,16 +175,16 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
this.seriesCardSizeForWidth(this.seriesGridCardWidth()).height
|
||||
);
|
||||
|
||||
coverBook = computed(() => this.filteredBooks()[0] ?? null);
|
||||
private firstBookId = computed(() => this.coverBook()?.id ?? null);
|
||||
private firstBookDetailQuery = injectQuery(() => ({
|
||||
readonly coverBook = computed(() => this.filteredBooks()[0] ?? null);
|
||||
private readonly firstBookId = computed(() => this.coverBook()?.id ?? null);
|
||||
private readonly firstBookDetailQuery = injectQuery(() => ({
|
||||
...this.bookService.bookDetailQueryOptions(this.firstBookId() ?? -1, true),
|
||||
enabled: this.firstBookId() != null,
|
||||
}));
|
||||
|
||||
seriesTitle = computed(() => this.filteredBooks()[0]?.metadata?.seriesName || this.seriesParam());
|
||||
readonly seriesTitle = computed(() => this.filteredBooks()[0]?.metadata?.seriesName || this.seriesParam());
|
||||
|
||||
yearsRange = computed(() => {
|
||||
readonly yearsRange = computed(() => {
|
||||
const years = this.filteredBooks()
|
||||
.map((book) => book.metadata?.publishedDate)
|
||||
.filter((date): date is string => !!date)
|
||||
@@ -202,18 +200,18 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return min === max ? String(min) : `${min}-${max}`;
|
||||
});
|
||||
|
||||
firstBookWithDesc = computed(() => this.firstBookDetailQuery.data() ?? null);
|
||||
firstDescription = computed(() => this.firstBookWithDesc()?.metadata?.description || "");
|
||||
readonly firstBookWithDesc = computed(() => this.firstBookDetailQuery.data() ?? null);
|
||||
readonly firstDescription = computed(() => this.firstBookWithDesc()?.metadata?.description || "");
|
||||
|
||||
seriesReadStatus = computed(() => computeSeriesReadStatus(this.filteredBooks()));
|
||||
readonly seriesReadStatus = computed(() => computeSeriesReadStatus(this.filteredBooks()));
|
||||
|
||||
seriesReadProgress = computed(() => {
|
||||
readonly seriesReadProgress = computed(() => {
|
||||
const books = this.filteredBooks();
|
||||
const readCount = books.filter((book) => book.readStatus === ReadStatus.READ).length;
|
||||
return `${readCount}/${books.length}`;
|
||||
});
|
||||
|
||||
allAuthors = computed(() => {
|
||||
readonly allAuthors = computed(() => {
|
||||
const authors = new Set<string>();
|
||||
for (const book of this.filteredBooks()) {
|
||||
book.metadata?.authors?.forEach((author) => authors.add(author));
|
||||
@@ -221,7 +219,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return Array.from(authors);
|
||||
});
|
||||
|
||||
allCategories = computed(() => {
|
||||
readonly allCategories = computed(() => {
|
||||
const categories = new Set<string>();
|
||||
for (const book of this.filteredBooks()) {
|
||||
book.metadata?.categories?.forEach((category) => categories.add(category));
|
||||
@@ -229,7 +227,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return Array.from(categories);
|
||||
});
|
||||
|
||||
allPublishers = computed(() => {
|
||||
readonly allPublishers = computed(() => {
|
||||
const publishers = new Set<string>();
|
||||
for (const book of this.filteredBooks()) {
|
||||
if (book.metadata?.publisher) {
|
||||
@@ -239,7 +237,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return Array.from(publishers);
|
||||
});
|
||||
|
||||
allLanguages = computed(() => {
|
||||
readonly allLanguages = computed(() => {
|
||||
const languages = new Set<string>();
|
||||
for (const book of this.filteredBooks()) {
|
||||
if (book.metadata?.language) {
|
||||
@@ -249,7 +247,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return Array.from(languages);
|
||||
});
|
||||
|
||||
seriesCompletion = computed<SeriesCompletion | null>(() => {
|
||||
readonly seriesCompletion = computed<SeriesCompletion | null>(() => {
|
||||
const totals = this.filteredBooks()
|
||||
.map((book) => book.metadata?.seriesTotal)
|
||||
.filter((total): total is number => total != null && total > 0);
|
||||
@@ -276,7 +274,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
};
|
||||
});
|
||||
|
||||
readStatusBreakdown = computed(() => {
|
||||
readonly readStatusBreakdown = computed(() => {
|
||||
const books = this.filteredBooks();
|
||||
if (books.length === 0) return [];
|
||||
|
||||
@@ -294,14 +292,14 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return segments;
|
||||
});
|
||||
|
||||
nextUp = computed<NextUpBook | null>(() => {
|
||||
readonly nextUp = computed<NextUpBook | null>(() => {
|
||||
const books = this.filteredBooks();
|
||||
const reading = books.find(book =>
|
||||
book.readStatus === ReadStatus.READING ||
|
||||
book.readStatus === ReadStatus.RE_READING ||
|
||||
book.readStatus === ReadStatus.PAUSED
|
||||
);
|
||||
const target = reading || books.find(book => book.readStatus === ReadStatus.UNREAD || !book.readStatus);
|
||||
const target = reading ?? books.find(book => book.readStatus === ReadStatus.UNREAD || !book.readStatus);
|
||||
if (!target) return null;
|
||||
|
||||
const isAudiobook = target.primaryFile?.bookType === 'AUDIOBOOK';
|
||||
@@ -330,7 +328,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
||||
return {book: target, thumbnailUrl, isReading, progressPercent};
|
||||
});
|
||||
|
||||
seriesStats = computed<SeriesStats>(() => {
|
||||
readonly seriesStats = computed<SeriesStats>(() => {
|
||||
let totalPages = 0;
|
||||
const personalRatings: number[] = [];
|
||||
const goodreadsRatings: number[] = [];
|
||||
|
||||
+1
-2
@@ -20,8 +20,7 @@
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="shelves-container">
|
||||
|
||||
+9
-9
@@ -37,18 +37,18 @@ import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-sele
|
||||
})
|
||||
export class ShelfAssignerComponent {
|
||||
|
||||
private shelfService = inject(ShelfService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
private bookDialogHelper = inject(BookDialogHelperService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private userService = inject(UserService);
|
||||
private readonly shelfService = inject(ShelfService);
|
||||
private readonly dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly bookDialogHelper = inject(BookDialogHelperService);
|
||||
private readonly loadingService = inject(LoadingService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
searchQuery = '';
|
||||
private currentUser = this.userService.currentUser;
|
||||
private readonly currentUser = this.userService.currentUser;
|
||||
|
||||
book: Book = this.dynamicDialogConfig.data.book;
|
||||
selectedShelves: Shelf[] = [];
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@
|
||||
{{ t('visibilityLabel') }}
|
||||
</span>
|
||||
<div class="input-wrapper" style="display: flex; align-items: center; gap: 0.4375rem;">
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf" />
|
||||
<label for="publicShelf" style="cursor: pointer">{{ t('makePublicLabel') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,11 +30,11 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
styleUrl: './shelf-creator.component.scss',
|
||||
})
|
||||
export class ShelfCreatorComponent {
|
||||
private shelfService = inject(ShelfService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
private userService = inject(UserService);
|
||||
private readonly shelfService = inject(ShelfService);
|
||||
private readonly dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly iconPickerService = inject(IconPickerService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
shelfName: string = '';
|
||||
|
||||
+5
-6
@@ -16,8 +16,7 @@
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
class="close-button" />
|
||||
</div>
|
||||
|
||||
<div class="shelf-container">
|
||||
@@ -31,10 +30,10 @@
|
||||
<span class="label">{{ t('shelfIconLabel') }}</span>
|
||||
<div class="icon-section">
|
||||
@if (!selectedIcon) {
|
||||
<p-button [label]="t('selectIcon')" icon="pi pi-search" [outlined]="true" severity="info" (onClick)="openIconPicker()"></p-button>
|
||||
<p-button [label]="t('selectIcon')" icon="pi pi-search" [outlined]="true" severity="info" (onClick)="openIconPicker()" />
|
||||
}
|
||||
|
||||
@if (selectedIcon) {
|
||||
@else {
|
||||
<div class="icon-container">
|
||||
<div class="icon-wrapper">
|
||||
<app-icon-display
|
||||
@@ -43,7 +42,7 @@
|
||||
iconClass="icon"
|
||||
/>
|
||||
</div>
|
||||
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" severity="danger"></p-button>
|
||||
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" severity="danger" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -53,7 +52,7 @@
|
||||
<div class="shelf-row">
|
||||
<span class="label">{{ t('visibilityLabel') }}</span>
|
||||
<div class="visibility-section" style="display: flex; align-items: center; gap: 0.4375rem;">
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf"></p-checkbox>
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf" />
|
||||
<label for="publicShelf" style="cursor: pointer; user-select: none;">{{ t('publicShelfLabel') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-6
@@ -31,12 +31,12 @@ import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-sele
|
||||
})
|
||||
export class ShelfEditDialogComponent implements OnInit {
|
||||
|
||||
private shelfService = inject(ShelfService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
private userService = inject(UserService);
|
||||
private readonly shelfService = inject(ShelfService);
|
||||
private readonly dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private readonly dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly iconPickerService = inject(IconPickerService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly injector = inject(Injector);
|
||||
private shelfInitialized = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {mutationOptions} from '@tanstack/angular-query-experimental';
|
||||
import {lastValueFrom} from 'rxjs';
|
||||
|
||||
@@ -7,7 +7,7 @@ import {API_CONFIG} from '../../../core/config/api-config';
|
||||
import {bookBackgroundSubmissionKeys} from './book-background-submission-keys';
|
||||
import {ChangeCoversVariables, QuickSendBookVariables} from './book-background-submission.models';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookBackgroundSubmissionService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {lastValueFrom} from 'rxjs';
|
||||
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
@@ -34,7 +34,7 @@ const RESET_PROGRESS_BACKEND_TYPES = {
|
||||
KOBO: 'KOBO',
|
||||
} as const satisfies Record<BookProgressSource, string>;
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookCommandService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {effect, inject, Injectable} from '@angular/core';
|
||||
import {effect, inject, Service} from '@angular/core';
|
||||
import {
|
||||
type InfiniteData,
|
||||
infiniteQueryOptions,
|
||||
@@ -30,7 +30,7 @@ import {BookDetail, BookRecommendation, BookSummary} from './book-response.model
|
||||
import {abortSignal, QUERY_DEFAULTS} from '../../../core/data/query-transport';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookQueryService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly authService = inject(AuthService);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {lastValueFrom} from 'rxjs';
|
||||
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
@@ -14,7 +14,7 @@ import {BookShelf} from './book-response.models';
|
||||
import {applyBookQueryChangeSet} from './book-query-cache';
|
||||
import {invalidateShelfDefinitions} from './shelf-definition-query-cache';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookShelfCommandService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly membershipUrl = `${API_CONFIG.BASE_URL}/api/v1/books/shelves`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {effect, inject, Injectable} from '@angular/core';
|
||||
import {effect, inject, Service} from '@angular/core';
|
||||
import {queryOptions, QueryClient} from '@tanstack/angular-query-experimental';
|
||||
import {lastValueFrom, takeUntil} from 'rxjs';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {ShelfDefinition} from './shelf-definition.models';
|
||||
import {shelfDefinitionQueryKeys} from './shelf-definition-query-keys';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class ShelfDefinitionQueryService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly authService = inject(AuthService);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Service} from '@angular/core';
|
||||
import {ReadStatus} from '../model/book.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class ReadStatusHelper {
|
||||
|
||||
getReadStatusIcon(readStatus: ReadStatus | undefined): string {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
|
||||
import {DialogLauncherService, DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
@@ -12,10 +12,10 @@ interface MetadataRefreshDialogContext {
|
||||
libraryId?: number;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookDialogHelperService {
|
||||
|
||||
private dialogLauncherService = inject(DialogLauncherService);
|
||||
private readonly dialogLauncherService = inject(DialogLauncherService);
|
||||
|
||||
private openDialog(component: unknown, options: object): DynamicDialogRef | null {
|
||||
return this.dialogLauncherService.openDialog(component, options);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {Observable, throwError, from} from 'rxjs';
|
||||
import {HttpClient, HttpEventType, HttpRequest} from '@angular/common/http';
|
||||
import {catchError, filter, map, tap} from 'rxjs/operators';
|
||||
@@ -13,21 +13,18 @@ import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
import {patchAttachedBookFilesInCache, patchBookInCacheWith, upsertBooksInCache} from './legacy-book-cache';
|
||||
import {mitigateWebkitUploadBug} from '../../../shared/util/mitigate-webkit-upload-bug';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class BookFileService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly fileDownloadService = inject(FileDownloadService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly cacheStorageService = inject(CacheStorageService);
|
||||
private readonly localSettingsService = inject(LocalSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private messageService = inject(MessageService);
|
||||
private fileDownloadService = inject(FileDownloadService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private cacheStorageService = inject(CacheStorageService);
|
||||
private localSettingsService = inject(LocalSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
getFileContent(bookId: number, bookType?: string): Observable<Blob> {
|
||||
let url = `${this.url}/${bookId}/content`;
|
||||
if (bookType) {
|
||||
@@ -81,7 +78,7 @@ export class BookFileService {
|
||||
tap(() => {
|
||||
patchBookInCacheWith(this.queryClient, bookId, book => {
|
||||
if (isPrimary) {
|
||||
const remaining = book.alternativeFormats?.filter(f => f.id !== fileId) || [];
|
||||
const remaining = book.alternativeFormats?.filter(f => f.id !== fileId) ?? [];
|
||||
const [newPrimary, ...rest] = remaining;
|
||||
return {...book, primaryFile: newPrimary, alternativeFormats: rest};
|
||||
}
|
||||
@@ -143,9 +140,9 @@ export class BookFileService {
|
||||
.pipe(tap(newFile => {
|
||||
patchBookInCacheWith(this.queryClient, bookId, book => {
|
||||
if (fileType === AdditionalFileType.ALTERNATIVE_FORMAT) {
|
||||
return {...book, alternativeFormats: [...(book.alternativeFormats || []), newFile]};
|
||||
return {...book, alternativeFormats: [...(book.alternativeFormats ?? []), newFile]};
|
||||
}
|
||||
return {...book, supplementaryFiles: [...(book.supplementaryFiles || []), newFile]};
|
||||
return {...book, supplementaryFiles: [...(book.supplementaryFiles ?? []), newFile]};
|
||||
});
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
@@ -166,8 +163,8 @@ export class BookFileService {
|
||||
|
||||
downloadAdditionalFile(book: Book, fileId: number): void {
|
||||
const additionalFile = [
|
||||
...(book.alternativeFormats || []),
|
||||
...(book.supplementaryFiles || [])
|
||||
...(book.alternativeFormats ?? []),
|
||||
...(book.supplementaryFiles ?? [])
|
||||
].find((f: AdditionalFile) => f.id === fileId);
|
||||
const downloadUrl = `${this.url}/${book.id}/files/${fileId}/download`;
|
||||
this.fileDownloadService.downloadFile(downloadUrl, additionalFile?.fileName ?? 'file');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {ConfirmationService, MenuItem, MessageService} from '@openng/optimus-ui/api';
|
||||
import {BookService} from './book.service';
|
||||
import {BookMetadataManageService} from './book-metadata-manage.service';
|
||||
@@ -12,9 +12,7 @@ import {APIException} from '../../../shared/models/api-exception.model';
|
||||
import {HttpErrorResponse} from '@angular/common/http';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class BookMenuService {
|
||||
|
||||
confirmationService = inject(ConfirmationService);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {HttpClient, HttpEventType, HttpParams, HttpRequest} from '@angular/common/http';
|
||||
import {catchError, filter, map, tap, mergeMap} from 'rxjs/operators';
|
||||
@@ -10,18 +10,15 @@ import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
import {invalidateAllBookCaches, invalidateBooksById, patchBookMetadataInCache, patchBooksInCacheWith} from './legacy-book-cache';
|
||||
import {mitigateWebkitUploadBug} from '../../../shared/util/mitigate-webkit-upload-bug';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class BookMetadataManageService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private messageService = inject(MessageService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
updateBookMetadata(bookId: number | undefined, wrapper: MetadataUpdateWrapper, mergeCategories: boolean, replaceMode: 'REPLACE_ALL' | 'REPLACE_WHEN_PROVIDED' = 'REPLACE_ALL'): Observable<BookMetadata> {
|
||||
const params = new HttpParams().set('mergeCategories', mergeCategories.toString()).set('replaceMode', replaceMode);
|
||||
return this.http.put<BookMetadata>(`${this.url}/${bookId}/metadata`, wrapper, {params}).pipe(
|
||||
@@ -201,7 +198,7 @@ export class BookMetadataManageService {
|
||||
}
|
||||
|
||||
supportsDualCovers(book: Book): boolean {
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats ?? [])].filter(f => f?.bookType);
|
||||
const hasAudiobook = allFiles.some(f => f!.bookType === 'AUDIOBOOK');
|
||||
const hasEbook = allFiles.some(f => f!.bookType !== 'AUDIOBOOK');
|
||||
return hasAudiobook && hasEbook;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, inject, Injectable, signal} from '@angular/core';
|
||||
import {computed, inject, Service, signal} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
@@ -10,9 +10,7 @@ export interface BookNavigationState {
|
||||
currentIndex: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class BookNavigationService {
|
||||
private readonly router = inject(Router);
|
||||
private readonly userService = inject(UserService);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {Observable, Subject} from 'rxjs';
|
||||
import {distinctUntilChanged, exhaustMap, share, tap} from 'rxjs/operators';
|
||||
@@ -32,18 +32,15 @@ function getResetProgressFields(type: ResetProgressType): Partial<Book> {
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class BookPatchService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private queryClient = inject(QueryClient);
|
||||
private readonly epubProgressSubject = new Subject<{ bookId: number; cfi: string; href: string; percentage: number; bookFileId?: number }>();
|
||||
|
||||
private epubProgressSubject = new Subject<{ bookId: number; cfi: string; href: string; percentage: number; bookFileId?: number }>();
|
||||
|
||||
private epubProgress$ = this.epubProgressSubject.pipe(
|
||||
private readonly epubProgress$ = this.epubProgressSubject.pipe(
|
||||
distinctUntilChanged((prev, curr) =>
|
||||
prev.bookId === curr.bookId &&
|
||||
prev.cfi === curr.cfi &&
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {DestroyRef, inject, Injectable} from '@angular/core';
|
||||
import {DestroyRef, inject, Service} from '@angular/core';
|
||||
import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||
|
||||
import {invalidateBookRecommendations} from '../data/book-query-cache';
|
||||
import {TaskProgressPayload} from '../../settings/task-management/task.service';
|
||||
import {TaskProgressPayload, TaskStatus} from '../../settings/task-management/task.service';
|
||||
import {Book} from '../model/book.model';
|
||||
import {
|
||||
BookCoverPatch,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
function isBookIdArray(payload: Book | readonly number[]): payload is readonly number[] {
|
||||
return Array.isArray(payload);
|
||||
}
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class BookSocketService {
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
@@ -55,7 +55,7 @@ export class BookSocketService {
|
||||
}
|
||||
|
||||
handleTaskProgress(payload: TaskProgressPayload): void {
|
||||
if (payload.taskType !== 'UPDATE_BOOK_RECOMMENDATIONS' || payload.taskStatus !== 'COMPLETED') {
|
||||
if (payload.taskType !== 'UPDATE_BOOK_RECOMMENDATIONS' || payload.taskStatus !== TaskStatus.COMPLETED) {
|
||||
return;
|
||||
}
|
||||
void Promise.all([
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, effect, inject, Injectable} from '@angular/core';
|
||||
import {computed, effect, inject, Service} from '@angular/core';
|
||||
import {first, from, lastValueFrom, Observable, throwError} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {catchError, map, tap} from 'rxjs/operators';
|
||||
@@ -26,29 +26,26 @@ import {
|
||||
patchBooksInCache,
|
||||
} from './legacy-book-cache';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Service()
|
||||
export class BookService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly bookSocketService = inject(BookSocketService);
|
||||
private readonly bookPatchService = inject(BookPatchService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/books`;
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private messageService = inject(MessageService);
|
||||
private authService = inject(AuthService);
|
||||
private router = inject(Router);
|
||||
private bookSocketService = inject(BookSocketService);
|
||||
private bookPatchService = inject(BookPatchService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly token = this.authService.token;
|
||||
|
||||
private booksQuery = injectQuery(() => ({
|
||||
private readonly booksQuery = injectQuery(() => ({
|
||||
...this.getBooksQueryOptions(),
|
||||
enabled: !!this.token(),
|
||||
}));
|
||||
|
||||
books = computed(() => this.booksQuery.data() ?? []);
|
||||
readonly books = computed(() => this.booksQuery.data() ?? []);
|
||||
|
||||
/** Pre-computed unique metadata values for autocomplete across the app. */
|
||||
readonly uniqueMetadata = computed(() => {
|
||||
@@ -81,7 +78,7 @@ export class BookService {
|
||||
};
|
||||
});
|
||||
|
||||
booksError = computed<string | null>(() => {
|
||||
readonly booksError = computed<string | null>(() => {
|
||||
if (!this.token() || !this.booksQuery.isError()) {
|
||||
return null;
|
||||
}
|
||||
@@ -90,7 +87,7 @@ export class BookService {
|
||||
return error instanceof Error ? error.message : 'Failed to load books';
|
||||
});
|
||||
|
||||
isBooksLoading = computed(() => !!this.token() && this.booksQuery.isPending());
|
||||
readonly isBooksLoading = computed(() => !!this.token() && this.booksQuery.isPending());
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
@@ -121,7 +118,7 @@ export class BookService {
|
||||
}
|
||||
|
||||
ensureBookDetail(bookId: number, withDescription: boolean): Promise<Book> {
|
||||
return this.queryClient.ensureQueryData(this.bookDetailQueryOptions(bookId, withDescription));
|
||||
return this.queryClient.query({...this.bookDetailQueryOptions(bookId, withDescription), staleTime: 'static'});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +129,7 @@ export class BookService {
|
||||
* this network request is necessary to pick up progress saved on another device or browser.
|
||||
*/
|
||||
fetchFreshBookDetail(bookId: number, withDescription: boolean): Promise<Book> {
|
||||
return this.queryClient.fetchQuery({
|
||||
return this.queryClient.query({
|
||||
...this.bookDetailQueryOptions(bookId, withDescription),
|
||||
staleTime: 0,
|
||||
});
|
||||
@@ -170,7 +167,7 @@ export class BookService {
|
||||
}
|
||||
|
||||
getBooksInSeries(bookId: number): Observable<Book[]> {
|
||||
return from(this.queryClient.ensureQueryData(this.getBooksQueryOptions())).pipe(
|
||||
return from(this.queryClient.query({...this.getBooksQueryOptions(), staleTime: 'static'})).pipe(
|
||||
map(books => {
|
||||
const currentBook = books.find(book => book.id === bookId);
|
||||
if (!currentBook?.metadata?.seriesName) {
|
||||
@@ -185,7 +182,7 @@ export class BookService {
|
||||
}
|
||||
|
||||
getBookRecommendations(bookId: number, limit: number = 20): Observable<BookRecommendation[]> {
|
||||
return from(this.queryClient.ensureQueryData(this.bookRecommendationsQueryOptions(bookId, limit)));
|
||||
return from(this.queryClient.query({...this.bookRecommendationsQueryOptions(bookId, limit), staleTime: 'static'}));
|
||||
}
|
||||
|
||||
/*------------------ Book Operations ------------------*/
|
||||
@@ -290,7 +287,7 @@ export class BookService {
|
||||
case 'EPUB':
|
||||
baseUrl = 'ebook-reader';
|
||||
if (reader === 'epub-streaming') {
|
||||
queryParams['streaming'] = true;
|
||||
queryParams.streaming = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -315,7 +312,7 @@ export class BookService {
|
||||
}
|
||||
|
||||
if (isAlternativeFormat) {
|
||||
queryParams['bookType'] = bookType;
|
||||
queryParams.bookType = bookType;
|
||||
}
|
||||
|
||||
const hasQueryParams = Object.keys(queryParams).length > 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Service, inject} from '@angular/core';
|
||||
import {API_CONFIG} from '../../../core/config/api-config';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
|
||||
@@ -8,13 +8,13 @@ export interface CbxPageInfo {
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class CbxReaderService {
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
private readonly pagesUrl = `${API_CONFIG.BASE_URL}/api/v1/cbx`;
|
||||
private readonly imageUrl = `${API_CONFIG.BASE_URL}/api/v1/media/book`;
|
||||
private authService = inject(AuthService);
|
||||
private http = inject(HttpClient);
|
||||
|
||||
private getToken(): string | null {
|
||||
return this.authService.getInternalAccessToken();
|
||||
|
||||
@@ -32,9 +32,9 @@ describe('LibraryHealthService', () => {
|
||||
});
|
||||
|
||||
async function fetchHealth(): Promise<void> {
|
||||
const fetchQuerySpy = vi.spyOn(queryClient, 'fetchQuery');
|
||||
const querySpy = vi.spyOn(queryClient, 'query');
|
||||
service.fetchHealth();
|
||||
await fetchQuerySpy.mock.results[0]?.value;
|
||||
await querySpy.mock.results[0]?.value;
|
||||
}
|
||||
|
||||
it('fetches health', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, inject, Injectable, DestroyRef} from '@angular/core';
|
||||
import {computed, inject, Service, DestroyRef} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {lastValueFrom} from 'rxjs';
|
||||
@@ -8,22 +8,22 @@ import {injectQuery, queryOptions, QueryClient} from '@tanstack/angular-query-ex
|
||||
|
||||
const LIBRARY_HEALTH_QUERY_KEY = ['libraryHealth'] as const;
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class LibraryHealthService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly rxStompService = inject(RxStompService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/libraries/health`;
|
||||
private http = inject(HttpClient);
|
||||
private rxStompService = inject(RxStompService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
|
||||
private socketInitialized = false;
|
||||
|
||||
private healthQuery = injectQuery(() => ({
|
||||
private readonly healthQuery = injectQuery(() => ({
|
||||
...this.getHealthQueryOptions(),
|
||||
enabled: false, // manually triggered via initialize()
|
||||
}));
|
||||
|
||||
health = computed(() => this.healthQuery.data() ?? {});
|
||||
readonly health = computed(() => this.healthQuery.data() ?? {});
|
||||
|
||||
private getHealthQueryOptions() {
|
||||
return queryOptions({
|
||||
@@ -33,7 +33,7 @@ export class LibraryHealthService {
|
||||
}
|
||||
|
||||
fetchHealth(): void {
|
||||
void this.queryClient.fetchQuery(this.getHealthQueryOptions());
|
||||
void this.queryClient.query(this.getHealthQueryOptions());
|
||||
}
|
||||
|
||||
initWebsocket(): void {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {ConfirmationService, MessageService} from '@openng/optimus-ui/api';
|
||||
@@ -15,7 +15,7 @@ import {ShelfService} from './shelf.service';
|
||||
|
||||
type LibraryShelfActionTarget = Readonly<{id: number; name: string}>;
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class LibraryShelfMenuService {
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
@@ -102,7 +102,7 @@ describe('LibraryService', () => {
|
||||
expect(queryClientHarness.queryClient.removeQueries).toHaveBeenCalledWith({queryKey: libraryFormatCountsQueryKey(4), exact: true});
|
||||
});
|
||||
|
||||
it('hydrates format counts through ensureQueryData', async () => {
|
||||
it('hydrates format counts through query', async () => {
|
||||
httpTestingController.expectOne(req => req.url.endsWith('/api/v1/libraries')).flush([]);
|
||||
|
||||
const resultPromise = new Promise<Record<string, number>>((resolve, reject) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, effect, inject, Injectable} from '@angular/core';
|
||||
import {computed, effect, inject, Service} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {from, lastValueFrom, Observable} from 'rxjs';
|
||||
import {tap} from 'rxjs/operators';
|
||||
@@ -13,22 +13,22 @@ import {invalidateShelfDefinitions} from '../data/shelf-definition-query-cache';
|
||||
import {invalidateAllBookCaches} from './legacy-book-cache';
|
||||
import {SHELVES_QUERY_KEY} from './shelf-query-keys';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class LibraryService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/libraries`;
|
||||
private http = inject(HttpClient);
|
||||
private authService = inject(AuthService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private readonly token = this.authService.token;
|
||||
|
||||
private librariesQuery = injectQuery(() => ({
|
||||
private readonly librariesQuery = injectQuery(() => ({
|
||||
...this.getLibrariesQueryOptions(),
|
||||
enabled: !!this.token(),
|
||||
}));
|
||||
|
||||
libraries = computed(() => this.librariesQuery.data() ?? []);
|
||||
readonly libraries = computed(() => this.librariesQuery.data() ?? []);
|
||||
|
||||
librariesError = computed<string | null>(() => {
|
||||
readonly librariesError = computed<string | null>(() => {
|
||||
if (!this.token() || !this.librariesQuery.isError()) {
|
||||
return null;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ export class LibraryService {
|
||||
return error instanceof Error ? error.message : 'Failed to load libraries';
|
||||
});
|
||||
|
||||
isLibrariesLoading = computed(() => !!this.token() && this.librariesQuery.isPending());
|
||||
readonly isLibrariesLoading = computed(() => !!this.token() && this.librariesQuery.isPending());
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
@@ -126,7 +126,7 @@ export class LibraryService {
|
||||
}
|
||||
|
||||
getBookCountsByFormat(libraryId: number): Observable<Record<string, number>> {
|
||||
return from(this.queryClient.ensureQueryData(this.getLibraryFormatCountsQueryOptions(libraryId)));
|
||||
return from(this.queryClient.query({...this.getLibraryFormatCountsQueryOptions(libraryId), staleTime: 'static'}));
|
||||
}
|
||||
|
||||
private sortLibraries(libraries: Library[]): Library[] {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {inject, Service} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, map} from 'rxjs';
|
||||
import {BookMetadata} from '../model/book.model';
|
||||
@@ -35,13 +35,11 @@ export interface MetadataFetchTask {
|
||||
proposals: FetchedProposal[];
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Service()
|
||||
export class MetadataTaskService {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/metadata/tasks`;
|
||||
private http = inject(HttpClient);
|
||||
|
||||
getTaskWithProposals(taskId: string): Observable<MetadataFetchTask> {
|
||||
return this.http.get<{ task: MetadataFetchTask }>(`${this.url}/${taskId}`)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {computed, effect, inject, Injectable} from '@angular/core';
|
||||
import {computed, effect, inject, Service} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {lastValueFrom, Observable} from 'rxjs';
|
||||
import {tap} from 'rxjs/operators';
|
||||
@@ -16,23 +16,23 @@ import {AuthService} from '../../../shared/service/auth.service';
|
||||
const KOBO_SHELF_NAME = 'Kobo';
|
||||
const KOBO_SHELF_ICON = 'pi pi-tablet';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Service()
|
||||
export class ShelfService {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly queryClient = inject(QueryClient);
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/shelves`;
|
||||
private http = inject(HttpClient);
|
||||
private bookService = inject(BookService);
|
||||
private authService = inject(AuthService);
|
||||
private queryClient = inject(QueryClient);
|
||||
private readonly token = this.authService.token;
|
||||
|
||||
private shelvesQuery = injectQuery(() => ({
|
||||
private readonly shelvesQuery = injectQuery(() => ({
|
||||
...this.getShelvesQueryOptions(),
|
||||
enabled: !!this.token(),
|
||||
}));
|
||||
|
||||
shelves = computed(() => this.shelvesQuery.data() ?? []);
|
||||
readonly shelves = computed(() => this.shelvesQuery.data() ?? []);
|
||||
|
||||
shelvesError = computed<string | null>(() => {
|
||||
readonly shelvesError = computed<string | null>(() => {
|
||||
if (!this.token() || !this.shelvesQuery.isError()) {
|
||||
return null;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export class ShelfService {
|
||||
return error instanceof Error ? error.message : 'Failed to load shelves';
|
||||
});
|
||||
|
||||
isShelvesLoading = computed(() => !!this.token() && this.shelvesQuery.isPending());
|
||||
readonly isShelvesLoading = computed(() => !!this.token() && this.shelvesQuery.isPending());
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
|
||||
+11
-18
@@ -5,7 +5,7 @@
|
||||
<span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></span>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
|
||||
<div class="fields-section">
|
||||
<h4>{{ t('textFieldsTitle') }}</h4>
|
||||
@@ -16,8 +16,7 @@
|
||||
[binary]="true"
|
||||
[ngModel]="isFieldEnabled(field.name)"
|
||||
(ngModelChange)="toggleField(field.name)"
|
||||
[ariaLabel]="t('enableField', { label: field.label })">
|
||||
</p-checkbox>
|
||||
[ariaLabel]="t('enableField', { label: field.label })" />
|
||||
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
|
||||
<input
|
||||
pInputText
|
||||
@@ -30,7 +29,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
|
||||
<div class="fields-section">
|
||||
<h4>{{ t('numberFieldsTitle') }}</h4>
|
||||
@@ -41,8 +40,7 @@
|
||||
[binary]="true"
|
||||
[ngModel]="isFieldEnabled(field.name)"
|
||||
(ngModelChange)="toggleField(field.name)"
|
||||
[ariaLabel]="t('enableField', { label: field.label })">
|
||||
</p-checkbox>
|
||||
[ariaLabel]="t('enableField', { label: field.label })" />
|
||||
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
|
||||
<input
|
||||
pInputText
|
||||
@@ -56,7 +54,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
|
||||
<div class="fields-section">
|
||||
<div class="section-header">
|
||||
@@ -68,8 +66,7 @@
|
||||
[(ngModel)]="mergeArrays"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
ariaLabelledBy="merge-mode-label">
|
||||
</p-selectButton>
|
||||
ariaLabelledBy="merge-mode-label" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="helper-text"><i class="pi pi-info-circle"></i> {{ t('helperText') }}</p>
|
||||
@@ -80,8 +77,7 @@
|
||||
[binary]="true"
|
||||
[ngModel]="isFieldEnabled(field.name)"
|
||||
(ngModelChange)="toggleField(field.name)"
|
||||
[ariaLabel]="t('enableField', { label: field.label })">
|
||||
</p-checkbox>
|
||||
[ariaLabel]="t('enableField', { label: field.label })" />
|
||||
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
|
||||
<p-autoComplete
|
||||
[formControl]="getControl(field.controlName)"
|
||||
@@ -92,29 +88,26 @@
|
||||
[dropdown]="false"
|
||||
[ariaLabel]="field.label"
|
||||
(onBlur)="onAutoCompleteBlur(field.name, $event)"
|
||||
class="field-input">
|
||||
</p-autoComplete>
|
||||
class="field-input" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
|
||||
<div class="dialog-footer">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
icon="pi pi-times"
|
||||
severity="secondary"
|
||||
(click)="cancel()">
|
||||
</p-button>
|
||||
(click)="cancel()" />
|
||||
<p-button
|
||||
[label]="t('applyToSelected')"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
[disabled]="!hasEnabledFields"
|
||||
(click)="apply()">
|
||||
</p-button>
|
||||
(click)="apply()" />
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+26
-70
@@ -52,10 +52,8 @@
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
[ngClass]="{
|
||||
'changed': isValueCopied('thumbnailUrl'),
|
||||
}"
|
||||
></p-image>
|
||||
[class.changed]="isValueCopied('thumbnailUrl')"
|
||||
/>
|
||||
}
|
||||
@else {
|
||||
<div class="thumbnail no-cover-text">{{ t('noCoverImage') }}</div>
|
||||
@@ -80,7 +78,7 @@
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
></p-image>
|
||||
/>
|
||||
}
|
||||
@else {
|
||||
<div class="thumbnail no-cover-text">{{ t('coverImageNotFound') }}</div>
|
||||
@@ -100,17 +98,13 @@
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
class="dest"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
/>
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (isValueChanged(field.controlName) || !fetchedMetadata[field.fetchedKey] ? 'pi pi-refresh' : 'pi pi-angle-left')"
|
||||
[outlined]="true"
|
||||
[ngClass]="{
|
||||
'nosrc' : !fetchedMetadata[field.fetchedKey]
|
||||
}"
|
||||
[class.nosrc]="!fetchedMetadata[field.fetchedKey]"
|
||||
class="arrow-button"
|
||||
[severity]="isValueChanged(field.controlName) ? 'warn' : null"
|
||||
[disabled]="!isFetchedDifferent(field.controlName) && !isValueChanged(field.controlName)"
|
||||
@@ -123,9 +117,7 @@
|
||||
[value]="fetchedMetadata[field.fetchedKey] ?? null"
|
||||
class="src"
|
||||
disabled
|
||||
[ngClass]="{
|
||||
'diff': isFetchedDifferent(field.controlName),
|
||||
}"
|
||||
[class.diff]="isFetchedDifferent(field.controlName)"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -147,17 +139,12 @@
|
||||
[iconDisplay]="'input'"
|
||||
appendTo="body"
|
||||
class="dest"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}">
|
||||
</p-datepicker>
|
||||
[class.changed]="isValueChanged(field.controlName)" />
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (isValueChanged(field.controlName) || !fetchedMetadata[field.fetchedKey] ? 'pi pi-refresh' : 'pi pi-angle-left')"
|
||||
[outlined]="true"
|
||||
[ngClass]="{
|
||||
'nosrc' : !fetchedMetadata[field.fetchedKey]
|
||||
}"
|
||||
[class.nosrc]="!fetchedMetadata[field.fetchedKey]"
|
||||
class="arrow-button"
|
||||
[severity]="isValueChanged(field.controlName) ? 'warn' : null"
|
||||
[disabled]="!isFetchedDifferent(field.controlName) && !isValueChanged(field.controlName)"
|
||||
@@ -170,9 +157,7 @@
|
||||
[value]="fetchedMetadata[field.fetchedKey] ?? null"
|
||||
class="src"
|
||||
disabled
|
||||
[ngClass]="{
|
||||
'diff': isFetchedDifferent(field.controlName),
|
||||
}"
|
||||
[class.diff]="isFetchedDifferent(field.controlName)"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -186,7 +171,7 @@
|
||||
<div class="author-chips-container dest full-width"
|
||||
cdkDropList cdkDropListOrientation="mixed"
|
||||
(cdkDropListDropped)="dropAuthor($event)"
|
||||
[ngClass]="{ 'changed': isValueChanged('authors') }">
|
||||
[class.changed]="isValueChanged('authors')">
|
||||
@for (author of metadataForm.get('authors')!.value; track $index) {
|
||||
<span class="author-chip" [class.main-author]="$index === 0" cdkDrag>
|
||||
@if ($index === 0) { <span class="main-author-badge">m</span> }
|
||||
@@ -220,9 +205,7 @@
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
class="dest full-width"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
(onBlur)="onAutoCompleteBlur(field.controlName, $event)"
|
||||
/>
|
||||
}
|
||||
@@ -230,9 +213,7 @@
|
||||
size="small"
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (isValueChanged(field.controlName) || !fetchedMetadata[field.fetchedKey] ? 'pi pi-refresh' : 'pi pi-angle-left')"
|
||||
[outlined]="true"
|
||||
[ngClass]="{
|
||||
'nosrc' : !fetchedMetadata[field.fetchedKey]
|
||||
}"
|
||||
[class.nosrc]="!fetchedMetadata[field.fetchedKey]"
|
||||
class="arrow-button"
|
||||
[severity]="isValueChanged(field.controlName) ? 'warn' : null"
|
||||
[disabled]="!isFetchedDifferent(field.controlName) && !isValueChanged(field.controlName)"
|
||||
@@ -249,9 +230,7 @@
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
class="src full-width"
|
||||
[ngClass]="{
|
||||
'diff': isFetchedDifferent(field.controlName),
|
||||
}"
|
||||
[class.diff]="isFetchedDifferent(field.controlName)"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -268,17 +247,13 @@
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
class="dest"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
></textarea>
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (isValueChanged(field.controlName) || !fetchedMetadata[field.fetchedKey] ? 'pi pi-refresh' : 'pi pi-angle-left')"
|
||||
[outlined]="true"
|
||||
[ngClass]="{
|
||||
'nosrc' : !fetchedMetadata[field.fetchedKey]
|
||||
}"
|
||||
[class.nosrc]="!fetchedMetadata[field.fetchedKey]"
|
||||
class="arrow-button"
|
||||
[severity]="isValueChanged(field.controlName) ? 'warn' : null"
|
||||
[disabled]="!isFetchedDifferent(field.controlName) && !isValueChanged(field.controlName)"
|
||||
@@ -292,9 +267,7 @@
|
||||
[value]="fetchedMetadata[field.fetchedKey] ?? null"
|
||||
class="src"
|
||||
disabled
|
||||
[ngClass]="{
|
||||
'diff': isFetchedDifferent(field.controlName),
|
||||
}"
|
||||
[class.diff]="isFetchedDifferent(field.controlName)"
|
||||
></textarea>
|
||||
}
|
||||
</div>
|
||||
@@ -310,17 +283,13 @@
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
class="dest"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
/>
|
||||
<p-button
|
||||
size="small"
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (isValueChanged(field.controlName) || !fetchedMetadata[field.fetchedKey] ? 'pi pi-refresh' : 'pi pi-angle-left')"
|
||||
[outlined]="true"
|
||||
[ngClass]="{
|
||||
'nosrc' : !fetchedMetadata[field.fetchedKey]
|
||||
}"
|
||||
[class.nosrc]="!fetchedMetadata[field.fetchedKey]"
|
||||
class="arrow-button"
|
||||
[severity]="isValueChanged(field.controlName) ? 'warn' : null"
|
||||
[disabled]="!isFetchedDifferent(field.controlName) && !isValueChanged(field.controlName)"
|
||||
@@ -333,9 +302,7 @@
|
||||
[value]="fetchedMetadata[field.fetchedKey] ?? null"
|
||||
class="src"
|
||||
disabled
|
||||
[ngClass]="{
|
||||
'diff': isFetchedDifferent(field.controlName),
|
||||
}"
|
||||
[class.diff]="isFetchedDifferent(field.controlName)"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
@@ -359,7 +326,7 @@
|
||||
[pTooltip]="t('resetAllTooltip')"
|
||||
tooltipPosition="left"
|
||||
(onClick)="confirmReset()"
|
||||
></p-button>
|
||||
/>
|
||||
</div>
|
||||
<div class="metabody">
|
||||
<div class="editor-thumbnail-wrapper">
|
||||
@@ -383,9 +350,7 @@
|
||||
pInputText
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
/>
|
||||
<p-button
|
||||
size="small"
|
||||
@@ -416,10 +381,7 @@
|
||||
[iconDisplay]="'input'"
|
||||
appendTo="body"
|
||||
class="full-width"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}">
|
||||
</p-datepicker>
|
||||
[class.changed]="isValueChanged(field.controlName)" />
|
||||
<p-button
|
||||
size="small"
|
||||
icon="pi pi-refresh"
|
||||
@@ -441,7 +403,7 @@
|
||||
<div class="author-chips-container full-width"
|
||||
cdkDropList cdkDropListOrientation="mixed"
|
||||
(cdkDropListDropped)="dropAuthor($event)"
|
||||
[ngClass]="{ 'changed': isValueChanged('authors') }">
|
||||
[class.changed]="isValueChanged('authors')">
|
||||
@for (author of metadataForm.get('authors')!.value; track $index) {
|
||||
<span class="author-chip" [class.main-author]="$index === 0" cdkDrag>
|
||||
@if ($index === 0) { <span class="main-author-badge">m</span> }
|
||||
@@ -475,9 +437,7 @@
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
class="full-width"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
(onBlur)="onAutoCompleteBlur(field.controlName, $event)"
|
||||
/>
|
||||
}
|
||||
@@ -505,9 +465,7 @@
|
||||
pSize="small"
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
></textarea>
|
||||
<p-button
|
||||
size="small"
|
||||
@@ -532,9 +490,7 @@
|
||||
pInputText
|
||||
id="{{field.controlName}}"
|
||||
formControlName="{{field.controlName}}"
|
||||
[ngClass]="{
|
||||
'changed': isValueChanged(field.controlName),
|
||||
}"
|
||||
[class.changed]="isValueChanged(field.controlName)"
|
||||
/>
|
||||
<p-button
|
||||
size="small"
|
||||
|
||||
+2
-4
@@ -1,7 +1,6 @@
|
||||
import {Component, computed, effect, EventEmitter, inject, Input, Output, signal} from '@angular/core';
|
||||
import {Component, computed, effect, inject, Input, output, signal} from '@angular/core';
|
||||
import {FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Button} from '@openng/optimus-ui/button';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {Tooltip} from '@openng/optimus-ui/tooltip';
|
||||
import {InputText} from '@openng/optimus-ui/inputtext';
|
||||
import {BookMetadata} from '../../../book/model/book.model';
|
||||
@@ -27,7 +26,6 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
Button,
|
||||
Tooltip,
|
||||
InputText,
|
||||
NgClass,
|
||||
FormsModule,
|
||||
Textarea,
|
||||
AutoComplete,
|
||||
@@ -57,7 +55,7 @@ export class BookdropFileMetadataPickerComponent {
|
||||
@Input() savedFields: Record<string, boolean> = {};
|
||||
@Input() bookdropFileId!: number;
|
||||
|
||||
@Output() metadataCopied = new EventEmitter<boolean>();
|
||||
readonly metadataCopied = output<boolean>();
|
||||
|
||||
authorInputValue = '';
|
||||
|
||||
|
||||
+28
-47
@@ -23,8 +23,7 @@
|
||||
outlined
|
||||
(click)="rescanBookdrop()"
|
||||
[pTooltip]="t('rescanTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@@ -54,7 +53,7 @@
|
||||
@if (bookdropFileUis.length !== 0) {
|
||||
<div class="controls-row">
|
||||
<div class="action-buttons">
|
||||
<p-inputgroup class="importmetadata" [ngClass]="!hasSelectedFiles ? 'disabled' : ''">
|
||||
<p-inputgroup class="importmetadata" [class]="!hasSelectedFiles ? 'disabled' : ''">
|
||||
<p-button
|
||||
size="small"
|
||||
outlined
|
||||
@@ -64,15 +63,13 @@
|
||||
[disabled]="!hasSelectedFiles"
|
||||
(click)="copyMetadata()"
|
||||
[pTooltip]="t('importMetadataTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
<p-inputgroup-addon [pTooltip]="t('includeCoversTooltip')" tooltipPosition="top">
|
||||
<p-checkbox
|
||||
inputId="includecovers"
|
||||
[disabled]="!hasSelectedFiles"
|
||||
[binary]="true"
|
||||
[(ngModel)]="includeCoversOnCopy">
|
||||
</p-checkbox>
|
||||
[(ngModel)]="includeCoversOnCopy" />
|
||||
<label for="includecovers"><i class="pi pi-image icon-padding-left"></i></label>
|
||||
</p-inputgroup-addon>
|
||||
</p-inputgroup>
|
||||
@@ -87,8 +84,7 @@
|
||||
[disabled]="!hasSelectedFiles"
|
||||
(click)="openBulkEditDialog()"
|
||||
[pTooltip]="t('bulkEditTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
@@ -100,8 +96,7 @@
|
||||
[disabled]="!hasSelectedFiles"
|
||||
(click)="openPatternExtractDialog()"
|
||||
[pTooltip]="t('extractPatternTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
|
||||
<div class="default-controls">
|
||||
@@ -116,8 +111,7 @@
|
||||
optionValue="value"
|
||||
[placeholder]="t('libraryPlaceholder')"
|
||||
appendTo="body"
|
||||
[(ngModel)]="defaultLibraryId">
|
||||
</p-select>
|
||||
[(ngModel)]="defaultLibraryId" />
|
||||
|
||||
<p-select
|
||||
size="small"
|
||||
@@ -126,8 +120,7 @@
|
||||
optionValue="value"
|
||||
[placeholder]="t('subpathPlaceholder')"
|
||||
appendTo="body"
|
||||
[(ngModel)]="defaultPathId">
|
||||
</p-select>
|
||||
[(ngModel)]="defaultPathId" />
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
@@ -136,28 +129,22 @@
|
||||
[disabled]="!canApplyDefaults"
|
||||
(click)="applyLibraryDefaults()"
|
||||
[pTooltip]="t('applyLibraryTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="content-area">
|
||||
@if (bookdropFileUis.length === 0) {
|
||||
<div class="empty-state">
|
||||
{{ t('emptyState') }}
|
||||
</div>
|
||||
} @else {
|
||||
|
||||
@for (file of bookdropFileUis; track file.file.id) {
|
||||
|
||||
<div class="file-item">
|
||||
<div class="file-row" [ngClass]="file.showDetails ? ' expanded' : ''">
|
||||
<div class="file-row" [class]="file.showDetails ? ' expanded' : ''">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[(ngModel)]="file.selected"
|
||||
(ngModelChange)="toggleFileSelection(file.file.id, $event)">
|
||||
</p-checkbox>
|
||||
(ngModelChange)="toggleFileSelection(file.file.id, $event)" />
|
||||
|
||||
@if (file.metadataForm.get('thumbnailUrl')?.value) {
|
||||
<img
|
||||
@@ -221,8 +208,7 @@
|
||||
class="library-select"
|
||||
appendTo="body"
|
||||
[(ngModel)]="file.selectedLibraryId"
|
||||
(onChange)="onLibraryChange(file)">
|
||||
</p-select>
|
||||
(onChange)="onLibraryChange(file)" />
|
||||
|
||||
<p-select
|
||||
size="small"
|
||||
@@ -232,8 +218,7 @@
|
||||
[placeholder]="t('subpathPlaceholder')"
|
||||
class="path-select"
|
||||
appendTo="body"
|
||||
[(ngModel)]="file.selectedPathId">
|
||||
</p-select>
|
||||
[(ngModel)]="file.selectedPathId" />
|
||||
|
||||
<p-button
|
||||
size="small"
|
||||
@@ -245,8 +230,7 @@
|
||||
: file.file.fetchedMetadata?.title
|
||||
? t('reviewMetadataTooltip')
|
||||
: t('showMetadataTooltip')"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
tooltipPosition="left" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -259,18 +243,21 @@
|
||||
[copiedFields]="file.copiedFields"
|
||||
[savedFields]="file.savedFields"
|
||||
[bookdropFileId]="file.file.id"
|
||||
(metadataCopied)="onMetadataCopied(file.file.id, $event)">
|
||||
</app-bookdrop-file-metadata-picker-component>
|
||||
(metadataCopied)="onMetadataCopied(file.file.id, $event)" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
} @empty {
|
||||
<div class="empty-state">
|
||||
{{ t('emptyState') }}
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!loading()) {
|
||||
<p-divider></p-divider>
|
||||
<p-divider />
|
||||
|
||||
<div class="footer">
|
||||
|
||||
@@ -287,8 +274,7 @@
|
||||
(click)="selectAll(true)"
|
||||
outlined
|
||||
[pTooltip]="t('selectAllTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</p-inputgroup>
|
||||
|
||||
<p-button
|
||||
@@ -299,8 +285,7 @@
|
||||
(click)="selectAll(false)"
|
||||
outlined
|
||||
[pTooltip]="t('clearTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
} @else {
|
||||
<div class="spacer"></div>
|
||||
}
|
||||
@@ -316,8 +301,7 @@
|
||||
[showJumpToPageDropdown]="true"
|
||||
[showPageLinks]="false"
|
||||
[showFirstLastIcon]="false"
|
||||
currentPageReportTemplate="Page {currentPage} of {totalPages}">
|
||||
</p-paginator>
|
||||
currentPageReportTemplate="Page {currentPage} of {totalPages}" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -330,8 +314,7 @@
|
||||
outlined
|
||||
(click)="confirmReset()"
|
||||
[pTooltip]="t('resetTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
<p-button
|
||||
[label]="t('delete')"
|
||||
icon="pi pi-times"
|
||||
@@ -340,8 +323,7 @@
|
||||
outlined
|
||||
(click)="confirmDelete()"
|
||||
[pTooltip]="t('deleteTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
<p-button
|
||||
[label]="t('finalize')"
|
||||
[icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'"
|
||||
@@ -350,8 +332,7 @@
|
||||
[disabled]="!canFinalize || saving"
|
||||
(click)="confirmFinalize()"
|
||||
[pTooltip]="t('finalizeTooltip')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
tooltipPosition="top" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user