feat(metadata): add configurable enabled fields for metadata editor and picker + UI tweaks (#2299)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { MetadataRefreshOptions } from '../../features/metadata/model/request/metadata-refresh-options.model';
|
||||
import {MetadataRefreshOptions} from '../../features/metadata/model/request/metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataMatchWeights {
|
||||
title: number;
|
||||
@@ -158,6 +158,26 @@ export interface AppSettings {
|
||||
coverCroppingSettings: CoverCroppingSettings;
|
||||
metadataDownloadOnBookdrop: boolean;
|
||||
telemetryEnabled: boolean;
|
||||
metadataProviderSpecificFields: MetadataProviderSpecificFields;
|
||||
}
|
||||
|
||||
export interface MetadataProviderSpecificFields {
|
||||
asin: boolean;
|
||||
amazonRating: boolean;
|
||||
amazonReviewCount: boolean;
|
||||
googleId: boolean;
|
||||
goodreadsId: boolean;
|
||||
goodreadsRating: boolean;
|
||||
goodreadsReviewCount: boolean;
|
||||
hardcoverId: boolean;
|
||||
hardcoverBookId: boolean;
|
||||
hardcoverRating: boolean;
|
||||
hardcoverReviewCount: boolean;
|
||||
comicvineId: boolean;
|
||||
lubimyczytacId: boolean;
|
||||
lubimyczytacRating: boolean;
|
||||
ranobedbId: boolean;
|
||||
ranobedbRating: boolean;
|
||||
}
|
||||
|
||||
export enum AppSettingKey {
|
||||
@@ -179,4 +199,5 @@ export enum AppSettingKey {
|
||||
KOBO_SETTINGS = 'KOBO_SETTINGS',
|
||||
COVER_CROPPING_SETTINGS = 'COVER_CROPPING_SETTINGS',
|
||||
TELEMETRY_ENABLED = 'TELEMETRY_ENABLED',
|
||||
METADATA_PROVIDER_SPECIFIC_FIELDS = 'METADATA_PROVIDER_SPECIFIC_FIELDS',
|
||||
}
|
||||
|
||||
@@ -105,7 +105,25 @@ describe('AppSettingsService', () => {
|
||||
smartCroppingEnabled: false
|
||||
},
|
||||
metadataDownloadOnBookdrop: false,
|
||||
telemetryEnabled: false
|
||||
telemetryEnabled: false,
|
||||
metadataProviderSpecificFields: {
|
||||
asin: false,
|
||||
amazonRating: false,
|
||||
amazonReviewCount: false,
|
||||
googleId: false,
|
||||
goodreadsId: false,
|
||||
goodreadsRating: false,
|
||||
goodreadsReviewCount: false,
|
||||
hardcoverId: false,
|
||||
hardcoverBookId: false,
|
||||
hardcoverRating: false,
|
||||
hardcoverReviewCount: false,
|
||||
comicvineId: false,
|
||||
lubimyczytacId: false,
|
||||
lubimyczytacRating: false,
|
||||
ranobedbId: false,
|
||||
ranobedbRating: false
|
||||
}
|
||||
};
|
||||
|
||||
const mockPublicSettings: PublicAppSettings = {
|
||||
@@ -457,7 +475,25 @@ describe('AppSettingsService - API Contract Tests', () => {
|
||||
smartCroppingEnabled: false
|
||||
},
|
||||
metadataDownloadOnBookdrop: false,
|
||||
telemetryEnabled: false
|
||||
telemetryEnabled: false,
|
||||
metadataProviderSpecificFields: {
|
||||
asin: false,
|
||||
amazonRating: false,
|
||||
amazonReviewCount: false,
|
||||
googleId: false,
|
||||
goodreadsId: false,
|
||||
goodreadsRating: false,
|
||||
goodreadsReviewCount: false,
|
||||
hardcoverId: false,
|
||||
hardcoverBookId: false,
|
||||
hardcoverRating: false,
|
||||
hardcoverReviewCount: false,
|
||||
comicvineId: false,
|
||||
lubimyczytacId: false,
|
||||
lubimyczytacRating: false,
|
||||
ranobedbId: false,
|
||||
ranobedbRating: false
|
||||
}
|
||||
};
|
||||
httpClientMock.get.mockReturnValue(of(mockSettings));
|
||||
service['fetchAppSettings']().subscribe(settings => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {inject, Injectable, Injector} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable, of} from 'rxjs';
|
||||
import {catchError, finalize, shareReplay, tap} from 'rxjs/operators';
|
||||
import {catchError, finalize, map, shareReplay, switchMap, tap} from 'rxjs/operators';
|
||||
import {API_CONFIG} from '../../core/config/api-config';
|
||||
import {AppSettings, OidcProviderDetails} from '../model/app-settings.model';
|
||||
import {AuthService} from './auth.service';
|
||||
@@ -99,20 +99,8 @@ export class AppSettingsService {
|
||||
}));
|
||||
|
||||
return this.http.put<void>(this.apiUrl, payload).pipe(
|
||||
tap(() => {
|
||||
const current = this.appSettingsSubject.value;
|
||||
if (current) {
|
||||
settings.forEach(s => (current as any)[s.key] = s.newValue);
|
||||
this.appSettingsSubject.next({...current});
|
||||
this.syncPublicSettings(current);
|
||||
} else {
|
||||
this.loading$ = this.fetchAppSettings().pipe(
|
||||
shareReplay(1),
|
||||
finalize(() => (this.loading$ = null))
|
||||
);
|
||||
this.loading$.subscribe();
|
||||
}
|
||||
}),
|
||||
switchMap(() => this.fetchAppSettings()),
|
||||
map(() => void 0),
|
||||
catchError(err => {
|
||||
console.error('Error saving settings:', err);
|
||||
return of();
|
||||
|
||||
Reference in New Issue
Block a user