refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
+197
@@ -0,0 +1,197 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsApp'">
|
||||
<div class="main-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-cog"></i>
|
||||
{{ t('title') }}
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-content">
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-image"></i>
|
||||
{{ t('covers.sectionTitle') }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('covers.regenerate') }}</label>
|
||||
<p-splitbutton
|
||||
[label]="t('covers.regenerateAllBtn')"
|
||||
icon="pi pi-refresh"
|
||||
outlined="true"
|
||||
size="small"
|
||||
severity="info"
|
||||
[model]="regenerateCoverMenuItems"
|
||||
(onClick)="regenerateCovers()">
|
||||
</p-splitbutton>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('covers.regenerateDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('covers.verticalCropping') }}</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="coverCroppingSettings.verticalCroppingEnabled"
|
||||
(onChange)="onCoverCroppingChange()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('covers.verticalCroppingDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('covers.horizontalCropping') }}</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="coverCroppingSettings.horizontalCroppingEnabled"
|
||||
(onChange)="onCoverCroppingChange()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('covers.horizontalCroppingDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('covers.aspectRatio', {value: coverCroppingSettings.aspectRatioThreshold}) }}</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
[(ngModel)]="coverCroppingSettings.aspectRatioThreshold"
|
||||
[min]="1.5"
|
||||
[max]="3"
|
||||
[step]="0.1"
|
||||
(onSlideEnd)="onCoverCroppingChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('covers.aspectRatioDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('covers.smartCropping') }}</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="coverCroppingSettings.smartCroppingEnabled"
|
||||
(onChange)="onCoverCroppingChange()">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('covers.smartCroppingDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-search"></i>
|
||||
{{ t('search.sectionTitle') }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('search.autoBookSearch') }}</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.autoBookSearch"
|
||||
(onChange)="onToggleChange('autoBookSearch', $event.checked)">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('search.autoBookSearchDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('search.similarBook') }}</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.similarBookRecommendation"
|
||||
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)">
|
||||
</p-toggleswitch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('search.similarBookDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-upload"></i>
|
||||
{{ t('fileManagement.sectionTitle') }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('fileManagement.maxUploadSize') }}</label>
|
||||
<div class="input-group">
|
||||
<div class="input-with-unit">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="maxFileUploadSizeInMb"
|
||||
[placeholder]="t('fileManagement.maxUploadPlaceholder')"/>
|
||||
<span class="unit">MB</span>
|
||||
</div>
|
||||
<p-button [label]="'common.save' | transloco" outlined severity="success" (onClick)="saveFileSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('fileManagement.maxUploadDesc') }}
|
||||
</p>
|
||||
<div class="warning-message">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<span>{{ t('fileManagement.restartWarning') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
@use '../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.main-container {
|
||||
@include settings.settings-page-container;
|
||||
}
|
||||
|
||||
@include settings.settings-page-header;
|
||||
|
||||
.settings-title {
|
||||
@include settings.settings-page-title;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.settings-description {
|
||||
@include settings.settings-page-description;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.preferences-section {
|
||||
@media (min-width: 768px) {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.setting-label {
|
||||
display: block;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-color);
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.setting-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
align-items: flex-end;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.input-with-unit {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
input {
|
||||
padding-right: 2.5rem;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.unit {
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.warning-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-muted-color);
|
||||
margin-top: 0.5rem;
|
||||
|
||||
.pi {
|
||||
color: var(--p-orange-500);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
max-width: 300px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
min-width: 180px;
|
||||
max-width: 250px;
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
import {Component, effect, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
|
||||
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
||||
import {BookMetadataManageService} from '../../book/service/book-metadata-manage.service';
|
||||
import {AppSettingKey, CoverCroppingSettings} from '../../../shared/model/app-settings.model';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-preferences',
|
||||
standalone: true,
|
||||
imports: [
|
||||
Button,
|
||||
ToggleSwitch,
|
||||
FormsModule,
|
||||
InputText,
|
||||
Slider,
|
||||
SplitButton,
|
||||
ExternalDocLinkComponent,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './global-preferences.component.html',
|
||||
styleUrl: './global-preferences.component.scss'
|
||||
})
|
||||
export class GlobalPreferencesComponent implements OnInit {
|
||||
|
||||
toggles = {
|
||||
autoBookSearch: false,
|
||||
similarBookRecommendation: false,
|
||||
};
|
||||
|
||||
coverCroppingSettings: CoverCroppingSettings = {
|
||||
verticalCroppingEnabled: false,
|
||||
horizontalCroppingEnabled: false,
|
||||
aspectRatioThreshold: 2.5,
|
||||
smartCroppingEnabled: false
|
||||
};
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
private readonly syncSettingsEffect = effect(() => {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (!settings) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.maxFileUploadSizeInMb) {
|
||||
this.maxFileUploadSizeInMb = settings.maxFileUploadSizeInMb;
|
||||
}
|
||||
if (settings.coverCroppingSettings) {
|
||||
this.coverCroppingSettings = {...settings.coverCroppingSettings};
|
||||
}
|
||||
this.toggles.autoBookSearch = settings.autoBookSearch ?? false;
|
||||
this.toggles.similarBookRecommendation = settings.similarBookRecommendation ?? false;
|
||||
});
|
||||
|
||||
maxFileUploadSizeInMb?: number;
|
||||
regenerateCoverMenuItems: MenuItem[] = [];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.regenerateCoverMenuItems = [
|
||||
{
|
||||
label: this.t.translate('settingsApp.covers.regenerateMissingBtn'),
|
||||
icon: 'pi pi-images',
|
||||
command: () => this.regenerateCovers(true)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
onToggleChange(settingKey: keyof typeof this.toggles, checked: boolean): void {
|
||||
this.toggles[settingKey] = checked;
|
||||
const toggleKeyMap: Record<string, AppSettingKey> = {
|
||||
autoBookSearch: AppSettingKey.AUTO_BOOK_SEARCH,
|
||||
similarBookRecommendation: AppSettingKey.SIMILAR_BOOK_RECOMMENDATION,
|
||||
};
|
||||
const keyToSend = toggleKeyMap[settingKey];
|
||||
if (keyToSend) {
|
||||
this.saveSetting(keyToSend, checked);
|
||||
} else {
|
||||
console.warn(`Unknown toggle key: ${settingKey}`);
|
||||
}
|
||||
}
|
||||
|
||||
onCoverCroppingChange(): void {
|
||||
this.saveSetting(AppSettingKey.COVER_CROPPING_SETTINGS, this.coverCroppingSettings);
|
||||
}
|
||||
|
||||
saveFileSize() {
|
||||
if (!this.maxFileUploadSizeInMb || this.maxFileUploadSizeInMb <= 0) {
|
||||
this.showMessage('error', this.t.translate('settingsApp.fileManagement.invalidInput'), this.t.translate('settingsApp.fileManagement.invalidInputDetail'));
|
||||
return;
|
||||
}
|
||||
this.saveSetting(AppSettingKey.MAX_FILE_UPLOAD_SIZE_IN_MB, this.maxFileUploadSizeInMb);
|
||||
}
|
||||
|
||||
regenerateCovers(missingOnly = false): void {
|
||||
this.bookMetadataManageService.regenerateCovers(missingOnly).subscribe({
|
||||
next: () =>
|
||||
this.showMessage('success', this.t.translate('settingsApp.covers.regenerateStarted'), this.t.translate('settingsApp.covers.regenerateStartedDetail')),
|
||||
error: () =>
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsApp.covers.regenerateError'))
|
||||
});
|
||||
}
|
||||
|
||||
private saveSetting(key: string, value: unknown): void {
|
||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
||||
next: () =>
|
||||
this.showMessage('success', this.t.translate('settingsApp.settingsSaved'), this.t.translate('settingsApp.settingsSavedDetail')),
|
||||
error: () =>
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsApp.settingsError'))
|
||||
});
|
||||
}
|
||||
|
||||
private showMessage(severity: 'success' | 'error', summary: string, detail: string): void {
|
||||
this.messageService.add({severity, summary, detail});
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsMeta.matchWeights'">
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-sliders-h"></i>
|
||||
{{ t('sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="setting-item action-item">
|
||||
<div class="action-row">
|
||||
<div class="action-info">
|
||||
<span class="action-label">{{ t('recalculateLabel') }}</span>
|
||||
<span class="action-description">{{ t('recalculateDesc') }}</span>
|
||||
</div>
|
||||
<p-button
|
||||
type="button"
|
||||
icon="pi pi-refresh"
|
||||
[label]="t('recalculateBtn')"
|
||||
[disabled]="isRecalculating"
|
||||
(click)="recalculate()"
|
||||
outlined>
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item weights-item">
|
||||
<div class="weights-header">
|
||||
<span class="weights-icon pi pi-sliders-v"></span>
|
||||
<h4 class="weights-label">{{ t('fieldWeights') }}</h4>
|
||||
</div>
|
||||
|
||||
<form [formGroup]="form" class="weights-form">
|
||||
<div class="weights-grid">
|
||||
@for (key of orderedKeys; track key) {
|
||||
<div class="weight-field">
|
||||
<label class="field-label">{{ getFieldLabel(key) }}</label>
|
||||
<p-inputNumber
|
||||
size="small"
|
||||
[formControlName]="key"
|
||||
[min]="0"
|
||||
[max]="10"
|
||||
fluid
|
||||
[showButtons]="true"/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<p-button
|
||||
type="button"
|
||||
severity="success"
|
||||
[label]="t('saveWeights')"
|
||||
icon="pi pi-save"
|
||||
outlined
|
||||
[disabled]="isSaving"
|
||||
(click)="save()">
|
||||
</p-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
.settings-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 1rem;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
margin: 0 0 0.5rem 0;
|
||||
|
||||
.pi {
|
||||
color: var(--primary-color);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
color: var(--p-text-muted-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding-left: 1rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
padding: 0.875rem 1rem;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid var(--primary-color);
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.action-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.action-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.action-label {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.action-description {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-muted-color);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.weights-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.weights-icon {
|
||||
color: var(--primary-color);
|
||||
font-size: 0.875rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.weights-label {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.weights-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.weights-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
||||
gap: 0.625rem;
|
||||
padding-top: 0.5rem;
|
||||
border-top: 1px dashed var(--p-content-border-color);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.weight-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.625rem;
|
||||
background: var(--ground-background);
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 4px;
|
||||
|
||||
.field-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
::ng-deep p-inputnumber {
|
||||
width: 6rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-top: 0.75rem;
|
||||
border-top: 1px dashed var(--p-content-border-color);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
p-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {MetadataMatchWeightsService} from '../../../../shared/service/metadata-match-weights.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AppSettingKey, AppSettings} from '../../../../shared/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {InputNumber} from 'primeng/inputnumber';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-match-weights-component',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Button,
|
||||
InputNumber,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './metadata-match-weights-component.html',
|
||||
styleUrl: './metadata-match-weights-component.scss'
|
||||
})
|
||||
export class MetadataMatchWeightsComponent implements OnInit {
|
||||
|
||||
readonly orderedFieldKeys: string[] = [
|
||||
'title', 'subtitle', 'authors', 'description', 'publisher', 'publishedDate',
|
||||
'categories', 'coverImage', 'seriesName', 'seriesNumber', 'seriesTotal',
|
||||
'language', 'isbn13', 'isbn10', 'pageCount',
|
||||
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'audibleRating', 'audibleReviewCount',
|
||||
'doubanRating', 'doubanReviewCount', 'ranobedbRating'
|
||||
];
|
||||
|
||||
form!: FormGroup;
|
||||
isSaving = false;
|
||||
isRecalculating = false;
|
||||
|
||||
private weightsService = inject(MetadataMatchWeightsService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private fb = inject(FormBuilder);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.fb.group({
|
||||
title: [0, [Validators.required, Validators.min(0)]],
|
||||
subtitle: [0, [Validators.required, Validators.min(0)]],
|
||||
description: [0, [Validators.required, Validators.min(0)]],
|
||||
publisher: [0, [Validators.required, Validators.min(0)]],
|
||||
publishedDate: [0, [Validators.required, Validators.min(0)]],
|
||||
authors: [0, [Validators.required, Validators.min(0)]],
|
||||
categories: [0, [Validators.required, Validators.min(0)]],
|
||||
seriesName: [0, [Validators.required, Validators.min(0)]],
|
||||
seriesNumber: [0, [Validators.required, Validators.min(0)]],
|
||||
seriesTotal: [0, [Validators.required, Validators.min(0)]],
|
||||
isbn13: [0, [Validators.required, Validators.min(0)]],
|
||||
isbn10: [0, [Validators.required, Validators.min(0)]],
|
||||
pageCount: [0, [Validators.required, Validators.min(0)]],
|
||||
language: [0, [Validators.required, Validators.min(0)]],
|
||||
amazonRating: [0, [Validators.required, Validators.min(0)]],
|
||||
amazonReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
goodreadsRating: [0, [Validators.required, Validators.min(0)]],
|
||||
goodreadsReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverRating: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
doubanRating: [0, [Validators.required, Validators.min(0)]],
|
||||
doubanReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
ranobedbRating: [0, [Validators.required, Validators.min(0)]],
|
||||
audibleRating: [0, [Validators.required, Validators.min(0)]],
|
||||
audibleReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
coverImage: [0, [Validators.required, Validators.min(0)]],
|
||||
});
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings?.metadataMatchWeights) {
|
||||
this.form.patchValue(settings.metadataMatchWeights);
|
||||
}
|
||||
}
|
||||
|
||||
get orderedKeys(): string[] {
|
||||
return this.orderedFieldKeys;
|
||||
}
|
||||
|
||||
getFieldLabel(key: string): string {
|
||||
return this.t.translate('settingsMeta.matchWeights.fields.' + key);
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (this.form.invalid) return;
|
||||
|
||||
this.isSaving = true;
|
||||
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.METADATA_MATCH_WEIGHTS,
|
||||
newValue: this.form.value
|
||||
}
|
||||
];
|
||||
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsMeta.matchWeights.saveSuccess')
|
||||
});
|
||||
this.isSaving = false;
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsMeta.matchWeights.saveError')
|
||||
});
|
||||
this.isSaving = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
recalculate(): void {
|
||||
this.isRecalculating = true;
|
||||
this.weightsService.recalculateAll().subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsMeta.matchWeights.recalcSuccess')
|
||||
});
|
||||
this.isRecalculating = false;
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsMeta.matchWeights.recalcError')
|
||||
});
|
||||
this.isRecalculating = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsMeta.providers'">
|
||||
<div class="metadata-settings">
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-cloud"></i>
|
||||
{{ t('sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="configurable-providers-section">
|
||||
<h4 class="provider-group-title">{{ t('configurableTitle') }}</h4>
|
||||
|
||||
<div class="configurable-providers-list">
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="amazonEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Amazon</label>
|
||||
</div>
|
||||
@if (amazonEnabled) {
|
||||
<div class="setting-options">
|
||||
<div class="config-field">
|
||||
<label class="config-label">{{ t('region') }}</label>
|
||||
<p-select
|
||||
[options]="amazonDomains"
|
||||
[(ngModel)]="selectedAmazonDomain"
|
||||
[placeholder]="t('selectDomain')"
|
||||
class="config-select">
|
||||
</p-select>
|
||||
</div>
|
||||
<div class="config-field">
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">{{ t('cookieLabel') }}</label>
|
||||
<app-external-doc-link docType="amazonCookie"></app-external-doc-link>
|
||||
</div>
|
||||
<p class="config-description">{{ t('cookieDesc') }}</p>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[placeholder]="t('cookiePlaceholder')"
|
||||
[(ngModel)]="amazonCookie"
|
||||
class="config-input"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="googleEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Google Books</label>
|
||||
</div>
|
||||
@if (googleEnabled) {
|
||||
<div class="setting-options">
|
||||
<div class="config-field">
|
||||
<label class="config-label">{{ t('languageRestriction') }}</label>
|
||||
<p-select
|
||||
[options]="googleLanguages"
|
||||
[(ngModel)]="selectedGoogleLanguage"
|
||||
[showClear]="!!selectedGoogleLanguage"
|
||||
[placeholder]="t('selectLanguage')"
|
||||
class="config-select">
|
||||
</p-select>
|
||||
</div>
|
||||
<div class="config-field">
|
||||
<label class="config-label">{{ t('apiKeyOptional') }}</label>
|
||||
<p class="config-description">{{ t('googleApiDesc') }}</p>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[placeholder]="t('googleApiPlaceholder')"
|
||||
[(ngModel)]="googleApiKey"
|
||||
class="config-input"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="hardcoverEnabled"
|
||||
[disabled]="!hardcoverToken">
|
||||
</p-toggleswitch>
|
||||
<label class="setting-label">Hardcover</label>
|
||||
</div>
|
||||
<div class="setting-options">
|
||||
<div class="config-field">
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">{{ t('apiToken') }}</label>
|
||||
<app-external-doc-link docType="hardcover"></app-external-doc-link>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[placeholder]="t('hardcoverPlaceholder')"
|
||||
[(ngModel)]="hardcoverToken"
|
||||
(ngModelChange)="onTokenChange($event)"
|
||||
class="config-input"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="comicvineEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Comic Vine</label>
|
||||
</div>
|
||||
@if (comicvineEnabled) {
|
||||
<div class="setting-options">
|
||||
<div class="config-field">
|
||||
<label class="config-label">{{ t('apiToken') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[placeholder]="t('comicvinePlaceholder')"
|
||||
[(ngModel)]="comicvineToken"
|
||||
(ngModelChange)="onComicTokenChange($event)"
|
||||
class="config-input"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="audibleEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Audible</label>
|
||||
</div>
|
||||
@if (audibleEnabled) {
|
||||
<div class="setting-options">
|
||||
<div class="config-field">
|
||||
<label class="config-label">{{ t('region') }}</label>
|
||||
<p-select
|
||||
[options]="audibleDomains"
|
||||
[(ngModel)]="selectedAudibleDomain"
|
||||
[placeholder]="t('selectDomain')"
|
||||
class="config-select">
|
||||
</p-select>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="simple-providers-section">
|
||||
<h4 class="provider-group-title">{{ t('readyToUseTitle') }}</h4>
|
||||
|
||||
<div class="simple-providers-grid">
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="goodreadsEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Goodreads</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="doubanEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Douban</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="lubimyCzytacEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Lubimyczytac</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="ranobedbEnabled"></p-toggleswitch>
|
||||
<label class="setting-label">Ranobedb</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-actions">
|
||||
<p-button [label]="t('saveConfigurations')" icon="pi pi-save" severity="success" [outlined]="true" (click)="saveSettings()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
@use '../../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.metadata-settings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
@include settings.settings-section-description;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
@include settings.settings-section-body;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.configurable-providers-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.configurable-providers-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.simple-providers-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.provider-group-title {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-muted-color);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.025em;
|
||||
margin: 0 0 0.25rem 0;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
@include settings.settings-item;
|
||||
}
|
||||
|
||||
.setting-header {
|
||||
@include settings.settings-item-header;
|
||||
}
|
||||
|
||||
.setting-label {
|
||||
@include settings.settings-label;
|
||||
}
|
||||
|
||||
.setting-options {
|
||||
@include settings.settings-options;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.config-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.config-label {
|
||||
font-weight: settings.$settings-label-weight;
|
||||
color: var(--text-color);
|
||||
font-size: settings.$settings-description-size;
|
||||
}
|
||||
|
||||
.config-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.config-description {
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-description-size;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
::ng-deep .config-select {
|
||||
width: 100%;
|
||||
max-width: 20rem;
|
||||
}
|
||||
|
||||
.config-input {
|
||||
width: 100%;
|
||||
max-width: 40rem;
|
||||
padding: 0.375rem 0.625rem;
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
border-radius: 4px;
|
||||
background: var(--ground-background);
|
||||
color: var(--text-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
transition: border-color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
|
||||
.simple-providers-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.simple-provider {
|
||||
padding: 0.625rem 0.875rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-top: 0.5rem;
|
||||
border-top: 1px solid var(--p-content-border-color);
|
||||
}
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingKey} from '../../../../shared/model/app-settings.model';
|
||||
import {Select} from 'primeng/select';
|
||||
import {ExternalDocLinkComponent} from '../../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import { ToggleSwitchModule } from 'primeng/toggleswitch';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-provider-settings',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
TableModule,
|
||||
InputText,
|
||||
Button,
|
||||
FormsModule,
|
||||
Select,
|
||||
ExternalDocLinkComponent,
|
||||
ToggleSwitchModule,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './metadata-provider-settings.component.html',
|
||||
styleUrl: './metadata-provider-settings.component.scss'
|
||||
})
|
||||
export class MetadataProviderSettingsComponent implements OnInit {
|
||||
|
||||
amazonDomains = [
|
||||
{label: 'amazon.com', value: 'com'},
|
||||
{label: 'amazon.de', value: 'de'},
|
||||
{label: 'amazon.co.uk', value: 'co.uk'},
|
||||
{label: 'amazon.co.jp', value: 'co.jp'},
|
||||
{label: 'amazon.ca', value: 'ca'},
|
||||
{label: 'amazon.in', value: 'in'},
|
||||
{label: 'amazon.com.au', value: 'com.au'},
|
||||
{label: 'amazon.fr', value: 'fr'},
|
||||
{label: 'amazon.it', value: 'it'},
|
||||
{label: 'amazon.es', value: 'es'},
|
||||
{label: 'amazon.nl', value: 'nl'},
|
||||
{label: 'amazon.se', value: 'se'},
|
||||
{label: 'amazon.com.br', value: 'com.br'},
|
||||
{label: 'amazon.sg', value: 'sg'},
|
||||
{label: 'amazon.com.mx', value: 'com.mx'},
|
||||
{label: 'amazon.pl', value: 'pl'},
|
||||
{label: 'amazon.ae', value: 'ae'},
|
||||
{label: 'amazon.sa', value: 'sa'},
|
||||
{label: 'amazon.tr', value: 'tr'}
|
||||
];
|
||||
|
||||
selectedAmazonDomain = 'com';
|
||||
|
||||
googleLanguages = [
|
||||
{label: 'Dutch', value: 'nl'},
|
||||
{label: 'English', value: 'en'},
|
||||
{label: 'French', value: 'fr'},
|
||||
{label: 'German', value: 'de'},
|
||||
{label: 'Italian', value: 'it'},
|
||||
{label: 'Japanese', value: 'ja'},
|
||||
{label: 'Polish', value: 'pl'},
|
||||
{label: 'Portuguese', value: 'pt'},
|
||||
{label: 'Spanish', value: 'es'},
|
||||
{label: 'Swedish', value: 'sv'}
|
||||
];
|
||||
|
||||
selectedGoogleLanguage = '';
|
||||
|
||||
audibleDomains = [
|
||||
{label: 'audible.com', value: 'com'},
|
||||
{label: 'audible.co.uk', value: 'co.uk'},
|
||||
{label: 'audible.de', value: 'de'},
|
||||
{label: 'audible.fr', value: 'fr'},
|
||||
{label: 'audible.it', value: 'it'},
|
||||
{label: 'audible.es', value: 'es'},
|
||||
{label: 'audible.ca', value: 'ca'},
|
||||
{label: 'audible.com.au', value: 'com.au'},
|
||||
{label: 'audible.co.jp', value: 'co.jp'},
|
||||
{label: 'audible.in', value: 'in'}
|
||||
];
|
||||
|
||||
selectedAudibleDomain = 'com';
|
||||
audibleEnabled: boolean = false;
|
||||
|
||||
hardcoverToken: string = '';
|
||||
amazonCookie: string = '';
|
||||
hardcoverEnabled: boolean = false;
|
||||
amazonEnabled: boolean = false;
|
||||
goodreadsEnabled: boolean = false;
|
||||
googleEnabled: boolean = false;
|
||||
comicvineEnabled: boolean = false;
|
||||
comicvineToken: string = '';
|
||||
doubanEnabled: boolean = false;
|
||||
lubimyCzytacEnabled: boolean = false;
|
||||
ranobedbEnabled: boolean = false;
|
||||
googleApiKey: string = '';
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
private readonly syncSettingsEffect = effect(() => {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings) {
|
||||
this.applySettings(settings);
|
||||
}
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
private applySettings(settings: NonNullable<ReturnType<typeof this.appSettingsService.appSettings>>): void {
|
||||
const metadataProviderSettings = settings.metadataProviderSettings;
|
||||
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
||||
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
|
||||
this.selectedAmazonDomain = metadataProviderSettings?.amazon?.domain ?? 'com';
|
||||
this.goodreadsEnabled = metadataProviderSettings?.goodReads?.enabled ?? false;
|
||||
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
||||
this.selectedGoogleLanguage = metadataProviderSettings?.google?.language ?? '';
|
||||
this.googleApiKey = metadataProviderSettings?.google?.apiKey ?? '';
|
||||
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
||||
this.hardcoverEnabled = metadataProviderSettings?.hardcover?.enabled ?? false;
|
||||
this.comicvineEnabled = metadataProviderSettings?.comicvine?.enabled ?? false;
|
||||
this.comicvineToken = metadataProviderSettings?.comicvine?.apiKey ?? '';
|
||||
this.doubanEnabled = metadataProviderSettings?.douban?.enabled ?? false;
|
||||
this.lubimyCzytacEnabled = metadataProviderSettings?.lubimyczytac?.enabled ?? false;
|
||||
this.ranobedbEnabled = metadataProviderSettings?.ranobedb?.enabled ?? false;
|
||||
this.audibleEnabled = metadataProviderSettings?.audible?.enabled ?? false;
|
||||
this.selectedAudibleDomain = metadataProviderSettings?.audible?.domain ?? 'com';
|
||||
}
|
||||
|
||||
onTokenChange(newToken: string): void {
|
||||
this.hardcoverToken = newToken;
|
||||
if (!newToken.trim()) {
|
||||
this.hardcoverEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
onComicTokenChange(newToken: string): void {
|
||||
this.comicvineToken = newToken;
|
||||
}
|
||||
|
||||
saveSettings(): void {
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.METADATA_PROVIDER_SETTINGS,
|
||||
newValue: {
|
||||
amazon: {
|
||||
enabled: this.amazonEnabled,
|
||||
cookie: this.amazonCookie,
|
||||
domain: this.selectedAmazonDomain
|
||||
},
|
||||
comicvine: {
|
||||
enabled: this.comicvineEnabled,
|
||||
apiKey: this.comicvineToken.trim()
|
||||
},
|
||||
goodReads: {enabled: this.goodreadsEnabled},
|
||||
google: {
|
||||
enabled: this.googleEnabled,
|
||||
language: this.selectedGoogleLanguage,
|
||||
apiKey: this.googleApiKey.trim()
|
||||
},
|
||||
hardcover: {
|
||||
enabled: this.hardcoverEnabled,
|
||||
apiKey: this.hardcoverToken.trim()
|
||||
},
|
||||
douban: {enabled: this.doubanEnabled},
|
||||
lubimyczytac: {enabled: this.lubimyCzytacEnabled},
|
||||
ranobedb: {enabled: this.ranobedbEnabled},
|
||||
audible: {
|
||||
enabled: this.audibleEnabled,
|
||||
domain: this.selectedAudibleDomain
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () =>
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('settingsMeta.providers.saveSuccess')
|
||||
}),
|
||||
error: () =>
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('settingsMeta.providers.saveError')
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user