refactor(settings): replace unsubscribe logic with takeUntilDestroyed for better resource management (#443)
* refactor(settings): replace unsubscribe logic with takeUntilDestroyed for better resource management * refactor(settings): streamline saveSettings method and improve error handling * fix(settings): improve error handling in saveSetting method * refactor(settings): update tab structure * refactor(settings): implement OnDestroy interface and clean up unused destroyRef instances
This commit is contained in:
@@ -50,6 +50,7 @@ export class AuditLogsComponent implements OnInit {
|
|||||||
private readonly auditLogService = inject(AuditLogService);
|
private readonly auditLogService = inject(AuditLogService);
|
||||||
private readonly route = inject(ActivatedRoute);
|
private readonly route = inject(ActivatedRoute);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
logs: AuditLog[] = [];
|
logs: AuditLog[] = [];
|
||||||
totalRecords = 0;
|
totalRecords = 0;
|
||||||
@@ -61,7 +62,6 @@ export class AuditLogsComponent implements OnInit {
|
|||||||
expandedRows = new Set<number>();
|
expandedRows = new Set<number>();
|
||||||
autoRefresh = false;
|
autoRefresh = false;
|
||||||
private autoRefreshSub?: Subscription;
|
private autoRefreshSub?: Subscription;
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
|
||||||
|
|
||||||
usernameOptions: UsernameOption[] = [{label: 'All Users', value: ''}];
|
usernameOptions: UsernameOption[] = [{label: 'All Users', value: ''}];
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ export class AuditLogsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadUsernames(): void {
|
loadUsernames(): void {
|
||||||
this.auditLogService.getDistinctUsernames().subscribe({
|
this.auditLogService.getDistinctUsernames().pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
||||||
next: (usernames) => {
|
next: (usernames) => {
|
||||||
this.usernameOptions = [
|
this.usernameOptions = [
|
||||||
{label: 'All Users', value: ''},
|
{label: 'All Users', value: ''},
|
||||||
@@ -133,7 +133,9 @@ export class AuditLogsComponent implements OnInit {
|
|||||||
const username = this.selectedUsername || undefined;
|
const username = this.selectedUsername || undefined;
|
||||||
const from = this.dateRange?.[0] ? this.formatDateTime(this.dateRange[0]) : undefined;
|
const from = this.dateRange?.[0] ? this.formatDateTime(this.dateRange[0]) : undefined;
|
||||||
const to = this.dateRange?.[1] ? this.formatDateTime(this.dateRange[1], true) : undefined;
|
const to = this.dateRange?.[1] ? this.formatDateTime(this.dateRange[1], true) : undefined;
|
||||||
this.auditLogService.getAuditLogs(this.currentPage, this.rows, action, username, from, to).subscribe({
|
this.auditLogService.getAuditLogs(this.currentPage, this.rows, action, username, from, to).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.logs = response.content;
|
this.logs = response.content;
|
||||||
this.totalRecords = response.page.totalElements;
|
this.totalRecords = response.page.totalElements;
|
||||||
@@ -167,9 +169,10 @@ export class AuditLogsComponent implements OnInit {
|
|||||||
toggleAutoRefresh(): void {
|
toggleAutoRefresh(): void {
|
||||||
this.autoRefresh = !this.autoRefresh;
|
this.autoRefresh = !this.autoRefresh;
|
||||||
if (this.autoRefresh) {
|
if (this.autoRefresh) {
|
||||||
|
this.autoRefreshSub?.unsubscribe();
|
||||||
this.autoRefreshSub = interval(10000)
|
this.autoRefreshSub = interval(10000)
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe(() => this.loadLogs(false));
|
.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.loadLogs(false));
|
||||||
} else {
|
} else {
|
||||||
this.autoRefreshSub?.unsubscribe();
|
this.autoRefreshSub?.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {take} from 'rxjs/operators';
|
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {CustomFontService} from '../../../shared/service/custom-font.service';
|
import {CustomFontService} from '../../../shared/service/custom-font.service';
|
||||||
@@ -86,7 +85,9 @@ export class CustomFontsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.uploadDialogRef) {
|
if (this.uploadDialogRef) {
|
||||||
this.uploadDialogRef.onClose.pipe(take(1), takeUntilDestroyed(this.destroyRef)).subscribe((font: CustomFont | null) => {
|
this.uploadDialogRef.onClose.pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe((font: CustomFont | null) => {
|
||||||
if (font) {
|
if (font) {
|
||||||
this.customFonts.push(font);
|
this.customFonts.push(font);
|
||||||
}
|
}
|
||||||
@@ -101,7 +102,9 @@ export class CustomFontsComponent implements OnInit {
|
|||||||
header: this.t.translate('settingsReader.fonts.deleteFontHeader'),
|
header: this.t.translate('settingsReader.fonts.deleteFontHeader'),
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.customFontService.deleteFont(font.id).subscribe({
|
this.customFontService.deleteFont(font.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.customFonts = this.customFonts.filter(f => f.id !== font.id);
|
this.customFonts = this.customFonts.filter(f => f.id !== font.id);
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
|
|||||||
+9
-3
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, DestroyRef, effect, inject} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
@@ -31,6 +32,7 @@ export class HardcoverSettingsComponent {
|
|||||||
private readonly hardcoverSyncSettingsService = inject(HardcoverSyncSettingsService);
|
private readonly hardcoverSyncSettingsService = inject(HardcoverSyncSettingsService);
|
||||||
private readonly userService = inject(UserService);
|
private readonly userService = inject(UserService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
hasPermission = false;
|
hasPermission = false;
|
||||||
hardcoverSyncEnabled = false;
|
hardcoverSyncEnabled = false;
|
||||||
@@ -55,7 +57,9 @@ export class HardcoverSettingsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private loadHardcoverSettings() {
|
private loadHardcoverSettings() {
|
||||||
this.hardcoverSyncSettingsService.getSettings().subscribe({
|
this.hardcoverSyncSettingsService.getSettings().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: settings => {
|
next: settings => {
|
||||||
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
|
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
|
||||||
this.hardcoverApiKey = settings.hardcoverApiKey ?? '';
|
this.hardcoverApiKey = settings.hardcoverApiKey ?? '';
|
||||||
@@ -89,7 +93,9 @@ export class HardcoverSettingsComponent {
|
|||||||
this.hardcoverSyncSettingsService.updateSettings({
|
this.hardcoverSyncSettingsService.updateSettings({
|
||||||
hardcoverSyncEnabled: this.hardcoverSyncEnabled,
|
hardcoverSyncEnabled: this.hardcoverSyncEnabled,
|
||||||
hardcoverApiKey: this.hardcoverApiKey
|
hardcoverApiKey: this.hardcoverApiKey
|
||||||
}).subscribe({
|
}).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: settings => {
|
next: settings => {
|
||||||
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
|
this.hardcoverSyncEnabled = settings.hardcoverSyncEnabled ?? false;
|
||||||
this.hardcoverApiKey = settings.hardcoverApiKey ?? '';
|
this.hardcoverApiKey = settings.hardcoverApiKey ?? '';
|
||||||
|
|||||||
+17
-31
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import {KoboService, KoboSyncSettings} from './kobo.service';
|
import {KoboService, KoboSyncSettings} from './kobo.service';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
@@ -7,7 +8,7 @@ import {InputText} from 'primeng/inputtext';
|
|||||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||||
import {UserService} from '../../../user-management/user.service';
|
import {UserService} from '../../../user-management/user.service';
|
||||||
import {Subject} from 'rxjs';
|
import {Subject} from 'rxjs';
|
||||||
import {debounceTime, takeUntil} from 'rxjs/operators';
|
import {debounceTime} from 'rxjs/operators';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {Slider} from 'primeng/slider';
|
import {Slider} from 'primeng/slider';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
@@ -27,7 +28,7 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, Toast, TranslocoDirective],
|
imports: [FormsModule, Button, InputText, ConfirmDialog, ToggleSwitch, Slider, Divider, ExternalDocLinkComponent, Toast, TranslocoDirective],
|
||||||
providers: [MessageService, ConfirmationService]
|
providers: [MessageService, ConfirmationService]
|
||||||
})
|
})
|
||||||
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
export class KoboSyncSettingsComponent implements OnInit {
|
||||||
private koboService = inject(KoboService);
|
private koboService = inject(KoboService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private confirmationService = inject(ConfirmationService);
|
private confirmationService = inject(ConfirmationService);
|
||||||
@@ -37,7 +38,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
private shelfService = inject(ShelfService);
|
private shelfService = inject(ShelfService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
|
||||||
private readonly destroy$ = new Subject<void>();
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly sliderChange$ = new Subject<void>();
|
private readonly sliderChange$ = new Subject<void>();
|
||||||
private readonly progressThresholdChange$ = new Subject<void>();
|
private readonly progressThresholdChange$ = new Subject<void>();
|
||||||
|
|
||||||
@@ -72,14 +73,14 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
private setupSliderDebouncing() {
|
private setupSliderDebouncing() {
|
||||||
this.sliderChange$.pipe(
|
this.sliderChange$.pipe(
|
||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.progressThresholdChange$.pipe(
|
this.progressThresholdChange$.pipe(
|
||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
this.updateKoboSettings(this.t.translate('settingsDevice.kobo.progressUpdated'));
|
this.updateKoboSettings(this.t.translate('settingsDevice.kobo.progressUpdated'));
|
||||||
});
|
});
|
||||||
@@ -114,7 +115,9 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
private loadKoboUserSettings() {
|
private loadKoboUserSettings() {
|
||||||
this.koboService.getUser().subscribe({
|
this.koboService.getUser().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (settings: KoboSyncSettings) => {
|
next: (settings: KoboSyncSettings) => {
|
||||||
this.koboSyncSettings.token = settings.token;
|
this.koboSyncSettings.token = settings.token;
|
||||||
this.koboSyncSettings.syncEnabled = settings.syncEnabled;
|
this.koboSyncSettings.syncEnabled = settings.syncEnabled;
|
||||||
@@ -178,7 +181,9 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private regenerateToken() {
|
private regenerateToken() {
|
||||||
this.koboService.createOrUpdateToken().subscribe({
|
this.koboService.createOrUpdateToken().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (settings) => {
|
next: (settings) => {
|
||||||
this.koboSyncSettings.token = settings.token;
|
this.koboSyncSettings.token = settings.token;
|
||||||
this.credentialsSaved = true;
|
this.credentialsSaved = true;
|
||||||
@@ -233,7 +238,9 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateKoboSettings(successMessage: string) {
|
private updateKoboSettings(successMessage: string) {
|
||||||
this.koboService.updateSettings(this.koboSyncSettings).subscribe({
|
this.koboService.updateSettings(this.koboSyncSettings).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -253,27 +260,6 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveSettings() {
|
saveSettings() {
|
||||||
this.settingsHelperService.saveSetting(AppSettingKey.KOBO_SETTINGS, this.koboSettings)
|
this.settingsHelperService.saveSetting(AppSettingKey.KOBO_SETTINGS, this.koboSettings);
|
||||||
.subscribe({
|
|
||||||
next: () => {
|
|
||||||
this.messageService.add({
|
|
||||||
severity: 'success',
|
|
||||||
summary: this.t.translate('settingsDevice.kobo.settingsSaved'),
|
|
||||||
detail: this.t.translate('settingsDevice.kobo.settingsSuccess')
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: () => {
|
|
||||||
this.messageService.add({
|
|
||||||
severity: 'error',
|
|
||||||
summary: this.t.translate('settingsDevice.kobo.saveFailed'),
|
|
||||||
detail: this.t.translate('settingsDevice.kobo.saveError')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, DestroyRef, effect, inject} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
@@ -42,6 +43,7 @@ export class KoreaderSettingsComponent {
|
|||||||
private readonly koreaderService = inject(KoreaderService);
|
private readonly koreaderService = inject(KoreaderService);
|
||||||
private readonly userService = inject(UserService);
|
private readonly userService = inject(UserService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
hasPermission = false;
|
hasPermission = false;
|
||||||
private prevHasPermission = false;
|
private prevHasPermission = false;
|
||||||
@@ -61,7 +63,9 @@ export class KoreaderSettingsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private loadKoreaderSettings() {
|
private loadKoreaderSettings() {
|
||||||
this.koreaderService.getUser().subscribe({
|
this.koreaderService.getUser().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: koreaderUser => {
|
next: koreaderUser => {
|
||||||
this.koReaderUsername = koreaderUser.username;
|
this.koReaderUsername = koreaderUser.username;
|
||||||
this.koReaderPassword = koreaderUser.password;
|
this.koReaderPassword = koreaderUser.password;
|
||||||
@@ -96,7 +100,9 @@ export class KoreaderSettingsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onToggleEnabled(enabled: boolean) {
|
onToggleEnabled(enabled: boolean) {
|
||||||
this.koreaderService.toggleSync(enabled).subscribe({
|
this.koreaderService.toggleSync(enabled).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.koReaderSyncEnabled = enabled;
|
this.koReaderSyncEnabled = enabled;
|
||||||
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.koreader.syncUpdated'), detail: enabled ? this.t.translate('settingsDevice.koreader.syncEnabled') : this.t.translate('settingsDevice.koreader.syncDisabled')});
|
this.messageService.add({severity: 'success', summary: this.t.translate('settingsDevice.koreader.syncUpdated'), detail: enabled ? this.t.translate('settingsDevice.koreader.syncEnabled') : this.t.translate('settingsDevice.koreader.syncDisabled')});
|
||||||
@@ -108,7 +114,9 @@ export class KoreaderSettingsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onToggleSyncWithGrimmoryReader(enabled: boolean) {
|
onToggleSyncWithGrimmoryReader(enabled: boolean) {
|
||||||
this.koreaderService.toggleSyncProgressWithGrimmoryReader(enabled).subscribe({
|
this.koreaderService.toggleSyncProgressWithGrimmoryReader(enabled).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.syncWithGrimmoryReader = enabled;
|
this.syncWithGrimmoryReader = enabled;
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@@ -134,6 +142,7 @@ export class KoreaderSettingsComponent {
|
|||||||
|
|
||||||
saveCredentials() {
|
saveCredentials() {
|
||||||
this.koreaderService.createUser(this.koReaderUsername, this.koReaderPassword)
|
this.koreaderService.createUser(this.koReaderUsername, this.koReaderPassword)
|
||||||
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.credentialsSaved = true;
|
this.credentialsSaved = true;
|
||||||
|
|||||||
+19
-7
@@ -1,4 +1,5 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Checkbox} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -38,6 +39,7 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private userService = inject(UserService);
|
private userService = inject(UserService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
defaultProviderId: unknown;
|
defaultProviderId: unknown;
|
||||||
currentUserId: number | null = null;
|
currentUserId: number | null = null;
|
||||||
isAdmin: boolean = false;
|
isAdmin: boolean = false;
|
||||||
@@ -54,7 +56,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadEmailProviders(): void {
|
loadEmailProviders(): void {
|
||||||
this.emailProvidersService.getEmailProviders().subscribe({
|
this.emailProvidersService.getEmailProviders().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (emailProviders: EmailProvider[]) => {
|
next: (emailProviders: EmailProvider[]) => {
|
||||||
this.emailProviders = emailProviders.map((provider) => ({
|
this.emailProviders = emailProviders.map((provider) => ({
|
||||||
...provider,
|
...provider,
|
||||||
@@ -83,7 +87,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveProvider(provider: EmailProvider): void {
|
saveProvider(provider: EmailProvider): void {
|
||||||
this.emailProvidersService.updateProvider(provider).subscribe({
|
this.emailProvidersService.updateProvider(provider).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
provider.isEditing = false;
|
provider.isEditing = false;
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@@ -105,7 +111,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
|
|
||||||
deleteProvider(provider: EmailProvider): void {
|
deleteProvider(provider: EmailProvider): void {
|
||||||
if (confirm(this.t.translate('settingsEmail.provider.deleteConfirm', {name: provider.name}))) {
|
if (confirm(this.t.translate('settingsEmail.provider.deleteConfirm', {name: provider.name}))) {
|
||||||
this.emailProvidersService.deleteProvider(provider.id).subscribe({
|
this.emailProvidersService.deleteProvider(provider.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -127,7 +135,7 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
|
|
||||||
openCreateProviderDialog() {
|
openCreateProviderDialog() {
|
||||||
this.ref = this.dialogLauncherService.openEmailProviderDialog();
|
this.ref = this.dialogLauncherService.openEmailProviderDialog();
|
||||||
this.ref?.onClose.subscribe((result) => {
|
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.loadEmailProviders();
|
this.loadEmailProviders();
|
||||||
}
|
}
|
||||||
@@ -135,7 +143,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDefaultProvider(provider: EmailProvider) {
|
setDefaultProvider(provider: EmailProvider) {
|
||||||
this.emailProvidersService.setDefaultProvider(provider.id).subscribe({
|
this.emailProvidersService.setDefaultProvider(provider.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.defaultProviderId = provider.id;
|
this.defaultProviderId = provider.id;
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@@ -160,7 +170,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleShared(provider: EmailProvider): void {
|
toggleShared(provider: EmailProvider): void {
|
||||||
this.emailProvidersService.updateProvider(provider).subscribe({
|
this.emailProvidersService.updateProvider(provider).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
const status = this.t.translate(provider.shared ? 'settingsEmail.provider.sharedStatusOn' : 'settingsEmail.provider.sharedStatusOff');
|
const status = this.t.translate(provider.shared ? 'settingsEmail.provider.sharedStatusOn' : 'settingsEmail.provider.sharedStatusOff');
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
|
|||||||
+16
-6
@@ -1,4 +1,5 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {RadioButton} from 'primeng/radiobutton';
|
import {RadioButton} from 'primeng/radiobutton';
|
||||||
@@ -34,6 +35,7 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
private emailRecipientService = inject(EmailV2RecipientService);
|
private emailRecipientService = inject(EmailV2RecipientService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
defaultRecipientId: unknown;
|
defaultRecipientId: unknown;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -41,7 +43,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadRecipientEmails(): void {
|
loadRecipientEmails(): void {
|
||||||
this.emailRecipientService.getRecipients().subscribe({
|
this.emailRecipientService.getRecipients().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (recipients: EmailRecipient[]) => {
|
next: (recipients: EmailRecipient[]) => {
|
||||||
this.recipientEmails = recipients.map((recipient) => ({
|
this.recipientEmails = recipients.map((recipient) => ({
|
||||||
...recipient,
|
...recipient,
|
||||||
@@ -70,7 +74,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveRecipient(recipient: EmailRecipient): void {
|
saveRecipient(recipient: EmailRecipient): void {
|
||||||
this.emailRecipientService.updateRecipient(recipient).subscribe({
|
this.emailRecipientService.updateRecipient(recipient).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
recipient.isEditing = false;
|
recipient.isEditing = false;
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@@ -92,7 +98,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
|
|
||||||
deleteRecipient(recipient: EmailRecipient): void {
|
deleteRecipient(recipient: EmailRecipient): void {
|
||||||
if (confirm(this.t.translate('settingsEmail.recipient.deleteConfirm', {email: recipient.email}))) {
|
if (confirm(this.t.translate('settingsEmail.recipient.deleteConfirm', {email: recipient.email}))) {
|
||||||
this.emailRecipientService.deleteRecipient(recipient.id).subscribe({
|
this.emailRecipientService.deleteRecipient(recipient.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -114,7 +122,7 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
|
|
||||||
openAddRecipientDialog() {
|
openAddRecipientDialog() {
|
||||||
this.ref = this.dialogLauncherService.openEmailRecipientDialog();
|
this.ref = this.dialogLauncherService.openEmailRecipientDialog();
|
||||||
this.ref?.onClose.subscribe((result) => {
|
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.loadRecipientEmails();
|
this.loadRecipientEmails();
|
||||||
}
|
}
|
||||||
@@ -122,7 +130,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDefaultRecipient(recipient: EmailRecipient) {
|
setDefaultRecipient(recipient: EmailRecipient) {
|
||||||
this.emailRecipientService.setDefaultRecipient(recipient.id).subscribe(() => {
|
this.emailRecipientService.setDefaultRecipient(recipient.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe(() => {
|
||||||
this.defaultRecipientId = recipient.id;
|
this.defaultRecipientId = recipient.id;
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
|
|||||||
+7
-2
@@ -1,4 +1,5 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -41,6 +42,7 @@ export class FileNamingPatternComponent implements OnInit {
|
|||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private libraryService = inject(LibraryService);
|
private libraryService = inject(LibraryService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const settings = this.appSettingsService.appSettings();
|
const settings = this.appSettingsService.appSettings();
|
||||||
@@ -112,6 +114,7 @@ export class FileNamingPatternComponent implements OnInit {
|
|||||||
.saveSettings([
|
.saveSettings([
|
||||||
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
|
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
|
||||||
])
|
])
|
||||||
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
|
next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
|
||||||
error: () => this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.saveError')),
|
error: () => this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.saveError')),
|
||||||
@@ -124,7 +127,9 @@ export class FileNamingPatternComponent implements OnInit {
|
|||||||
catchError(() => of(null))
|
catchError(() => of(null))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
forkJoin(patchRequests).subscribe(results => {
|
forkJoin(patchRequests).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe(results => {
|
||||||
const failures = results.filter(result => result === null);
|
const failures = results.filter(result => result === null);
|
||||||
if (failures.length === 0) {
|
if (failures.length === 0) {
|
||||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.libraryOverrides.saveSuccess'));
|
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.libraryOverrides.saveSuccess'));
|
||||||
|
|||||||
+9
-3
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {MenuItem, MessageService} from 'primeng/api';
|
import {MenuItem, MessageService} from 'primeng/api';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
@@ -46,6 +47,7 @@ export class GlobalPreferencesComponent implements OnInit {
|
|||||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
private readonly syncSettingsEffect = effect(() => {
|
private readonly syncSettingsEffect = effect(() => {
|
||||||
const settings = this.appSettingsService.appSettings();
|
const settings = this.appSettingsService.appSettings();
|
||||||
@@ -103,7 +105,9 @@ export class GlobalPreferencesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
regenerateCovers(missingOnly = false): void {
|
regenerateCovers(missingOnly = false): void {
|
||||||
this.bookMetadataManageService.regenerateCovers(missingOnly).subscribe({
|
this.bookMetadataManageService.regenerateCovers(missingOnly).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () =>
|
next: () =>
|
||||||
this.showMessage('success', this.t.translate('settingsApp.covers.regenerateStarted'), this.t.translate('settingsApp.covers.regenerateStartedDetail')),
|
this.showMessage('success', this.t.translate('settingsApp.covers.regenerateStarted'), this.t.translate('settingsApp.covers.regenerateStartedDetail')),
|
||||||
error: () =>
|
error: () =>
|
||||||
@@ -112,7 +116,9 @@ export class GlobalPreferencesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private saveSetting(key: string, value: unknown): void {
|
private saveSetting(key: string, value: unknown): void {
|
||||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
this.appSettingsService.saveSettings([{key, newValue: value}]).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () =>
|
next: () =>
|
||||||
this.showMessage('success', this.t.translate('settingsApp.settingsSaved'), this.t.translate('settingsApp.settingsSavedDetail')),
|
this.showMessage('success', this.t.translate('settingsApp.settingsSaved'), this.t.translate('settingsApp.settingsSavedDetail')),
|
||||||
error: () =>
|
error: () =>
|
||||||
|
|||||||
+9
-3
@@ -1,4 +1,5 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {MetadataMatchWeightsService} from '../../../../shared/service/metadata-match-weights.service';
|
import {MetadataMatchWeightsService} from '../../../../shared/service/metadata-match-weights.service';
|
||||||
@@ -39,6 +40,7 @@ export class MetadataMatchWeightsComponent implements OnInit {
|
|||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private fb = inject(FormBuilder);
|
private fb = inject(FormBuilder);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
@@ -95,7 +97,9 @@ export class MetadataMatchWeightsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
this.appSettingsService.saveSettings(payload).subscribe({
|
this.appSettingsService.saveSettings(payload).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -117,7 +121,9 @@ export class MetadataMatchWeightsComponent implements OnInit {
|
|||||||
|
|
||||||
recalculate(): void {
|
recalculate(): void {
|
||||||
this.isRecalculating = true;
|
this.isRecalculating = true;
|
||||||
this.weightsService.recalculateAll().subscribe({
|
this.weightsService.recalculateAll().pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
|
|||||||
+6
-2
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, DestroyRef, effect, inject} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
@@ -100,6 +101,7 @@ export class MetadataProviderSettingsComponent {
|
|||||||
private appSettingsService = inject(AppSettingsService);
|
private appSettingsService = inject(AppSettingsService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
private readonly syncSettingsEffect = effect(() => {
|
private readonly syncSettingsEffect = effect(() => {
|
||||||
const settings = this.appSettingsService.appSettings();
|
const settings = this.appSettingsService.appSettings();
|
||||||
@@ -174,7 +176,9 @@ export class MetadataProviderSettingsComponent {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
this.appSettingsService.saveSettings(payload).subscribe({
|
this.appSettingsService.saveSettings(payload).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () =>
|
next: () =>
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
|
|||||||
+15
-5
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject} from '@angular/core';
|
import {Component, DestroyRef, effect, inject} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Accordion, AccordionPanel, AccordionHeader, AccordionContent} from 'primeng/accordion';
|
import {Accordion, AccordionPanel, AccordionHeader, AccordionContent} from 'primeng/accordion';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -28,6 +29,7 @@ export class LibraryMetadataSettingsComponent {
|
|||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private sidecarService = inject(SidecarService);
|
private sidecarService = inject(SidecarService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
defaultMetadataOptions: MetadataRefreshOptions = this.getDefaultMetadataOptions();
|
defaultMetadataOptions: MetadataRefreshOptions = this.getDefaultMetadataOptions();
|
||||||
libraryMetadataOptions: Record<number, MetadataRefreshOptions> = {};
|
libraryMetadataOptions: Record<number, MetadataRefreshOptions> = {};
|
||||||
@@ -102,7 +104,9 @@ export class LibraryMetadataSettingsComponent {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
this.appSettingsService.saveSettings(settingsToSave).subscribe({
|
this.appSettingsService.saveSettings(settingsToSave).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.defaultSettings.saveSuccess'));
|
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.defaultSettings.saveSuccess'));
|
||||||
this.updateLibrariesUsingDefaults();
|
this.updateLibrariesUsingDefaults();
|
||||||
@@ -126,7 +130,9 @@ export class LibraryMetadataSettingsComponent {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
this.appSettingsService.saveSettings(settingsToSave).subscribe({
|
this.appSettingsService.saveSettings(settingsToSave).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.libraryOverrides.saveSuccess'));
|
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsLibMeta.libraryOverrides.saveSuccess'));
|
||||||
},
|
},
|
||||||
@@ -244,7 +250,9 @@ export class LibraryMetadataSettingsComponent {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.sidecarExporting[libraryId] = true;
|
this.sidecarExporting[libraryId] = true;
|
||||||
|
|
||||||
this.sidecarService.bulkExport(libraryId).subscribe({
|
this.sidecarService.bulkExport(libraryId).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.sidecarExporting[libraryId] = false;
|
this.sidecarExporting[libraryId] = false;
|
||||||
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.exportComplete'), this.t.translate('settingsLibMeta.libraryOverrides.exportSuccess', {count: response.exported}));
|
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.exportComplete'), this.t.translate('settingsLibMeta.libraryOverrides.exportSuccess', {count: response.exported}));
|
||||||
@@ -261,7 +269,9 @@ export class LibraryMetadataSettingsComponent {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.sidecarImporting[libraryId] = true;
|
this.sidecarImporting[libraryId] = true;
|
||||||
|
|
||||||
this.sidecarService.bulkImport(libraryId).subscribe({
|
this.sidecarService.bulkImport(libraryId).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.sidecarImporting[libraryId] = false;
|
this.sidecarImporting[libraryId] = false;
|
||||||
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.importComplete'), this.t.translate('settingsLibMeta.libraryOverrides.importSuccess', {count: response.imported}));
|
this.showMessage('success', this.t.translate('settingsLibMeta.libraryOverrides.importComplete'), this.t.translate('settingsLibMeta.libraryOverrides.importSuccess', {count: response.imported}));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
@@ -10,9 +11,9 @@ import {FormsModule} from '@angular/forms';
|
|||||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import {OpdsService, OpdsSortOrder, OpdsUserV2, OpdsUserV2CreateRequest} from './opds.service';
|
import {OpdsService, OpdsSortOrder, OpdsUserV2, OpdsUserV2CreateRequest} from './opds.service';
|
||||||
import {catchError, takeUntil} from 'rxjs/operators';
|
import {catchError} from 'rxjs/operators';
|
||||||
import {UserService} from '../user-management/user.service';
|
import {UserService} from '../user-management/user.service';
|
||||||
import {of, Subject} from 'rxjs';
|
import {of} from 'rxjs';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../shared/service/app-settings.service';
|
||||||
import {AppSettingKey} from '../../../shared/model/app-settings.model';
|
import {AppSettingKey} from '../../../shared/model/app-settings.model';
|
||||||
@@ -40,7 +41,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
|||||||
templateUrl: './opds-settings.html',
|
templateUrl: './opds-settings.html',
|
||||||
styleUrl: './opds-settings.scss'
|
styleUrl: './opds-settings.scss'
|
||||||
})
|
})
|
||||||
export class OpdsSettings implements OnInit, OnDestroy {
|
export class OpdsSettings implements OnInit {
|
||||||
|
|
||||||
opdsEndpoint = `${API_CONFIG.BASE_URL}/api/v1/opds`;
|
opdsEndpoint = `${API_CONFIG.BASE_URL}/api/v1/opds`;
|
||||||
komgaEndpoint = `${API_CONFIG.BASE_URL}/komga`;
|
komgaEndpoint = `${API_CONFIG.BASE_URL}/komga`;
|
||||||
@@ -65,7 +66,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
editingUserId: number | null = null;
|
editingUserId: number | null = null;
|
||||||
editingSortOrder: OpdsSortOrder | null = null;
|
editingSortOrder: OpdsSortOrder | null = null;
|
||||||
|
|
||||||
private readonly destroy$ = new Subject<void>();
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
dummyPassword: string = "***********************";
|
dummyPassword: string = "***********************";
|
||||||
|
|
||||||
sortOrderOptions = [
|
sortOrderOptions = [
|
||||||
@@ -113,7 +114,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private loadUsers(): void {
|
private loadUsers(): void {
|
||||||
this.opdsService.getUser().pipe(
|
this.opdsService.getUser().pipe(
|
||||||
takeUntil(this.destroy$),
|
takeUntilDestroyed(this.destroyRef),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
console.error('Error loading users:', err);
|
console.error('Error loading users:', err);
|
||||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.loadError'));
|
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.loadError'));
|
||||||
@@ -130,7 +131,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
if (!this.newUser.username || !this.newUser.password) return;
|
if (!this.newUser.username || !this.newUser.password) return;
|
||||||
|
|
||||||
this.opdsService.createUser(this.newUser).pipe(
|
this.opdsService.createUser(this.newUser).pipe(
|
||||||
takeUntil(this.destroy$)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: user => {
|
next: user => {
|
||||||
this.users.push(user);
|
this.users.push(user);
|
||||||
@@ -159,7 +160,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
if (!user.id) return;
|
if (!user.id) return;
|
||||||
|
|
||||||
this.opdsService.deleteCredential(user.id).pipe(
|
this.opdsService.deleteCredential(user.id).pipe(
|
||||||
takeUntil(this.destroy$),
|
takeUntilDestroyed(this.destroyRef),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
console.error('Error deleting user:', err);
|
console.error('Error deleting user:', err);
|
||||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.deleteError'));
|
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.deleteError'));
|
||||||
@@ -206,7 +207,9 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleKomgaGroupUnknown(): void {
|
toggleKomgaGroupUnknown(): void {
|
||||||
this.appSettingsService.saveSettings([{key: AppSettingKey.KOMGA_GROUP_UNKNOWN, newValue: this.komgaGroupUnknown}]).subscribe({
|
this.appSettingsService.saveSettings([{key: AppSettingKey.KOMGA_GROUP_UNKNOWN, newValue: this.komgaGroupUnknown}]).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
const successMessage = (this.komgaGroupUnknown === true)
|
const successMessage = (this.komgaGroupUnknown === true)
|
||||||
? this.t.translate('settingsOpds.groupEnabled')
|
? this.t.translate('settingsOpds.groupEnabled')
|
||||||
@@ -220,7 +223,9 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private saveSetting(key: string, value: unknown): void {
|
private saveSetting(key: string, value: unknown): void {
|
||||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
this.appSettingsService.saveSettings([{key, newValue: value}]).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
const successMessage = (value === true)
|
const successMessage = (value === true)
|
||||||
? this.t.translate('settingsOpds.opdsEnabled')
|
? this.t.translate('settingsOpds.opdsEnabled')
|
||||||
@@ -234,7 +239,9 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private saveKomgaSetting(key: string, value: unknown): void {
|
private saveKomgaSetting(key: string, value: unknown): void {
|
||||||
this.appSettingsService.saveSettings([{key, newValue: value}]).subscribe({
|
this.appSettingsService.saveSettings([{key, newValue: value}]).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
const successMessage = (value === true)
|
const successMessage = (value === true)
|
||||||
? this.t.translate('settingsOpds.komgaEnabled')
|
? this.t.translate('settingsOpds.komgaEnabled')
|
||||||
@@ -276,7 +283,7 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
if (!this.editingSortOrder || !user.id) return;
|
if (!this.editingSortOrder || !user.id) return;
|
||||||
|
|
||||||
this.opdsService.updateUser(user.id, this.editingSortOrder).pipe(
|
this.opdsService.updateUser(user.id, this.editingSortOrder).pipe(
|
||||||
takeUntil(this.destroy$),
|
takeUntilDestroyed(this.destroyRef),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
console.error('Error updating sort order:', err);
|
console.error('Error updating sort order:', err);
|
||||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.sortUpdateError'));
|
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsOpds.sortUpdateError'));
|
||||||
@@ -293,9 +300,4 @@ export class OpdsSettings implements OnInit, OnDestroy {
|
|||||||
this.cancelEdit();
|
this.cancelEdit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-9
@@ -1,5 +1,5 @@
|
|||||||
import {DecimalPipe} from '@angular/common';
|
import {DecimalPipe} from '@angular/common';
|
||||||
import {Component, effect, inject, Input, OnDestroy} from '@angular/core';
|
import {Component, effect, inject, Input} from '@angular/core';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TranslocoDirective} from '@jsverse/transloco';
|
import {TranslocoDirective} from '@jsverse/transloco';
|
||||||
@@ -8,7 +8,6 @@ import {UserSettings} from '../../user-management/user.service';
|
|||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {CustomFontService} from '../../../../shared/service/custom-font.service';
|
import {CustomFontService} from '../../../../shared/service/custom-font.service';
|
||||||
import {CustomFont} from '../../../../shared/model/custom-font.model';
|
import {CustomFont} from '../../../../shared/model/custom-font.model';
|
||||||
import {Subject} from 'rxjs';
|
|
||||||
import {addCustomFontsToDropdown} from '../../../../shared/util/custom-font.util';
|
import {addCustomFontsToDropdown} from '../../../../shared/util/custom-font.util';
|
||||||
import {Skeleton} from 'primeng/skeleton';
|
import {Skeleton} from 'primeng/skeleton';
|
||||||
import {themes} from '../../../readers/ebook-reader/state/themes.constant';
|
import {themes} from '../../../readers/ebook-reader/state/themes.constant';
|
||||||
@@ -26,13 +25,12 @@ import {themes} from '../../../readers/ebook-reader/state/themes.constant';
|
|||||||
templateUrl: './epub-reader-preferences-component.html',
|
templateUrl: './epub-reader-preferences-component.html',
|
||||||
styleUrl: './epub-reader-preferences-component.scss'
|
styleUrl: './epub-reader-preferences-component.scss'
|
||||||
})
|
})
|
||||||
export class EpubReaderPreferencesComponent implements OnDestroy {
|
export class EpubReaderPreferencesComponent {
|
||||||
|
|
||||||
@Input() userSettings!: UserSettings;
|
@Input() userSettings!: UserSettings;
|
||||||
|
|
||||||
private readonly readerPreferencesService = inject(ReaderPreferencesService);
|
private readonly readerPreferencesService = inject(ReaderPreferencesService);
|
||||||
private readonly customFontService = inject(CustomFontService);
|
private readonly customFontService = inject(CustomFontService);
|
||||||
private readonly destroy$ = new Subject<void>();
|
|
||||||
|
|
||||||
customFonts: CustomFont[] = [];
|
customFonts: CustomFont[] = [];
|
||||||
|
|
||||||
@@ -59,11 +57,6 @@ export class EpubReaderPreferencesComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async onFontsChanged(fonts: CustomFont[]): Promise<void> {
|
private async onFontsChanged(fonts: CustomFont[]): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const selectedFontDeleted = this.isCurrentlySelectedFontDeleted(fonts);
|
const selectedFontDeleted = this.isCurrentlySelectedFontDeleted(fonts);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||||
import {UserService} from './user-management/user.service';
|
import {UserService} from './user-management/user.service';
|
||||||
import {GlobalPreferencesComponent} from './global-preferences/global-preferences.component';
|
import {GlobalPreferencesComponent} from './global-preferences/global-preferences.component';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {Subscription} from 'rxjs';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {UserManagementComponent} from './user-management/user-management.component';
|
import {UserManagementComponent} from './user-management/user-management.component';
|
||||||
import {AuthenticationSettingsComponent} from '../../core/security/oauth2-management/authentication-settings.component';
|
import {AuthenticationSettingsComponent} from '../../core/security/oauth2-management/authentication-settings.component';
|
||||||
import {ViewPreferencesParentComponent} from './view-preferences-parent/view-preferences-parent.component';
|
import {ViewPreferencesParentComponent} from './view-preferences-parent/view-preferences-parent.component';
|
||||||
@@ -61,13 +61,12 @@ export enum SettingsTab {
|
|||||||
templateUrl: './settings.component.html',
|
templateUrl: './settings.component.html',
|
||||||
styleUrl: './settings.component.scss'
|
styleUrl: './settings.component.scss'
|
||||||
})
|
})
|
||||||
export class SettingsComponent implements OnInit, OnDestroy {
|
export class SettingsComponent implements OnInit {
|
||||||
protected userService = inject(UserService);
|
protected userService = inject(UserService);
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
private pageTitle = inject(PageTitleService);
|
private pageTitle = inject(PageTitleService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
private routeSub!: Subscription;
|
|
||||||
|
|
||||||
SettingsTab = SettingsTab;
|
SettingsTab = SettingsTab;
|
||||||
|
|
||||||
@@ -91,7 +90,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.pageTitle.setPageTitle('Settings');
|
this.pageTitle.setPageTitle('Settings');
|
||||||
|
|
||||||
this.routeSub = this.route.queryParams.subscribe(params => {
|
this.route.queryParams.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
|
||||||
const tabParam = params['tab'];
|
const tabParam = params['tab'];
|
||||||
if (this.validTabs.includes(tabParam)) {
|
if (this.validTabs.includes(tabParam)) {
|
||||||
this._activeTab = tabParam as SettingsTab;
|
this._activeTab = tabParam as SettingsTab;
|
||||||
@@ -106,8 +105,4 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.routeSub.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {ProgressBar} from 'primeng/progressbar';
|
import {ProgressBar} from 'primeng/progressbar';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -19,7 +20,6 @@ import {
|
|||||||
} from './task.service';
|
} from './task.service';
|
||||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||||
import {finalize, forkJoin} from 'rxjs';
|
import {finalize, forkJoin} from 'rxjs';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|
||||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|||||||
+12
-4
@@ -1,4 +1,5 @@
|
|||||||
import {Component, computed, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
|
import {Component, computed, DestroyRef, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
@@ -38,6 +39,7 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
|
|||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
private destroyRef = inject(DestroyRef);
|
||||||
private readonly sortedMetadata = computed(() => {
|
private readonly sortedMetadata = computed(() => {
|
||||||
const md = this.bookService.uniqueMetadata();
|
const md = this.bookService.uniqueMetadata();
|
||||||
return {
|
return {
|
||||||
@@ -87,7 +89,9 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
|
|||||||
loadRestrictions() {
|
loadRestrictions() {
|
||||||
if (!this.userId) return;
|
if (!this.userId) return;
|
||||||
|
|
||||||
this.contentRestrictionService.getUserRestrictions(this.userId).subscribe({
|
this.contentRestrictionService.getUserRestrictions(this.userId).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (restrictions) => {
|
next: (restrictions) => {
|
||||||
this.restrictions = restrictions;
|
this.restrictions = restrictions;
|
||||||
this.restrictionsChanged.emit(this.restrictions);
|
this.restrictionsChanged.emit(this.restrictions);
|
||||||
@@ -150,7 +154,9 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
|
|||||||
value: this.newRestriction.value!
|
value: this.newRestriction.value!
|
||||||
};
|
};
|
||||||
|
|
||||||
this.contentRestrictionService.addRestriction(this.userId, restriction).subscribe({
|
this.contentRestrictionService.addRestriction(this.userId, restriction).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: (added) => {
|
next: (added) => {
|
||||||
this.restrictions.push(added);
|
this.restrictions.push(added);
|
||||||
this.restrictionsChanged.emit(this.restrictions);
|
this.restrictionsChanged.emit(this.restrictions);
|
||||||
@@ -174,7 +180,9 @@ export class ContentRestrictionsEditorComponent implements OnInit, OnChanges {
|
|||||||
removeRestriction(restriction: ContentRestriction) {
|
removeRestriction(restriction: ContentRestriction) {
|
||||||
if (!restriction.id) return;
|
if (!restriction.id) return;
|
||||||
|
|
||||||
this.contentRestrictionService.deleteRestriction(this.userId, restriction.id).subscribe({
|
this.contentRestrictionService.deleteRestriction(this.userId, restriction.id).pipe(
|
||||||
|
takeUntilDestroyed(this.destroyRef)
|
||||||
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.restrictions = this.restrictions.filter(r => r.id !== restriction.id);
|
this.restrictions = this.restrictions.filter(r => r.id !== restriction.id);
|
||||||
this.restrictionsChanged.emit(this.restrictions);
|
this.restrictionsChanged.emit(this.restrictions);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
@@ -13,7 +14,6 @@ import {LibraryService} from '../../book/service/library.service';
|
|||||||
import {Dialog} from 'primeng/dialog';
|
import {Dialog} from 'primeng/dialog';
|
||||||
import {Password} from 'primeng/password';
|
import {Password} from 'primeng/password';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {Subject} from 'rxjs';
|
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {DialogLauncherService} from '../../../shared/services/dialog-launcher.service';
|
import {DialogLauncherService} from '../../../shared/services/dialog-launcher.service';
|
||||||
import {ContentRestrictionsEditorComponent} from './content-restrictions-editor/content-restrictions-editor.component';
|
import {ContentRestrictionsEditorComponent} from './content-restrictions-editor/content-restrictions-editor.component';
|
||||||
@@ -46,14 +46,14 @@ interface UserWithEditing extends User {
|
|||||||
templateUrl: './user-management.component.html',
|
templateUrl: './user-management.component.html',
|
||||||
styleUrls: ['./user-management.component.scss'],
|
styleUrls: ['./user-management.component.scss'],
|
||||||
})
|
})
|
||||||
export class UserManagementComponent implements OnInit, OnDestroy {
|
export class UserManagementComponent implements OnInit {
|
||||||
ref: DynamicDialogRef | undefined | null;
|
ref: DynamicDialogRef | undefined | null;
|
||||||
private dialogLauncherService = inject(DialogLauncherService);
|
private dialogLauncherService = inject(DialogLauncherService);
|
||||||
private userService = inject(UserService);
|
private userService = inject(UserService);
|
||||||
private libraryService = inject(LibraryService);
|
private libraryService = inject(LibraryService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
private readonly destroy$ = new Subject<void>();
|
private destroyRef = inject(DestroyRef);
|
||||||
get allLibraries() { return this.libraryService.libraries(); }
|
get allLibraries() { return this.libraryService.libraries(); }
|
||||||
|
|
||||||
users: UserWithEditing[] = [];
|
users: UserWithEditing[] = [];
|
||||||
@@ -78,14 +78,9 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
loadUsers() {
|
loadUsers() {
|
||||||
this.userService.getUsers().subscribe({
|
this.userService.getUsers().pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.users = data.map((user) => ({
|
this.users = data.map((user) => ({
|
||||||
...user,
|
...user,
|
||||||
@@ -107,7 +102,7 @@ export class UserManagementComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
openCreateUserDialog() {
|
openCreateUserDialog() {
|
||||||
this.ref = this.dialogLauncherService.openCreateUserDialog();
|
this.ref = this.dialogLauncherService.openCreateUserDialog();
|
||||||
this.ref?.onClose.subscribe((result) => {
|
this.ref?.onClose.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.loadUsers();
|
this.loadUsers();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-11
@@ -1,10 +1,9 @@
|
|||||||
import {Component, effect, inject, OnDestroy, OnInit} from '@angular/core';
|
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Select} from 'primeng/select';
|
import {Select} from 'primeng/select';
|
||||||
import {SidebarLibrarySorting, SidebarMagicShelfSorting, SidebarShelfSorting, User, UserService, UserSettings} from '../../user-management/user.service';
|
import {SidebarLibrarySorting, SidebarMagicShelfSorting, SidebarShelfSorting, User, UserService, UserSettings} from '../../user-management/user.service';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {Subject} from 'rxjs';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {takeUntil} from 'rxjs/operators';
|
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
type MutableSettingsBranch = Record<string, unknown>;
|
type MutableSettingsBranch = Record<string, unknown>;
|
||||||
@@ -19,7 +18,7 @@ type MutableSettingsBranch = Record<string, unknown>;
|
|||||||
templateUrl: './sidebar-sorting-preferences.component.html',
|
templateUrl: './sidebar-sorting-preferences.component.html',
|
||||||
styleUrl: './sidebar-sorting-preferences.component.scss'
|
styleUrl: './sidebar-sorting-preferences.component.scss'
|
||||||
})
|
})
|
||||||
export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
export class SidebarSortingPreferencesComponent implements OnInit {
|
||||||
|
|
||||||
private readonly sortingOptionDefs = [
|
private readonly sortingOptionDefs = [
|
||||||
{value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'},
|
{value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'},
|
||||||
@@ -37,7 +36,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
private readonly userService = inject(UserService);
|
private readonly userService = inject(UserService);
|
||||||
private readonly messageService = inject(MessageService);
|
private readonly messageService = inject(MessageService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
private readonly destroy$ = new Subject<void>();
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
private currentUser: User | null = null;
|
private currentUser: User | null = null;
|
||||||
private hasInitialized = false;
|
private hasInitialized = false;
|
||||||
@@ -55,12 +54,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.buildSortingOptions();
|
this.buildSortingOptions();
|
||||||
this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => this.buildSortingOptions());
|
this.t.langChanges$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.buildSortingOptions());
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildSortingOptions(): void {
|
private buildSortingOptions(): void {
|
||||||
|
|||||||
+5
-11
@@ -1,4 +1,5 @@
|
|||||||
import {Component, effect, ElementRef, inject, Injector, OnDestroy, OnInit, viewChild} from '@angular/core';
|
import {Component, DestroyRef, effect, ElementRef, inject, Injector, OnInit, viewChild} from '@angular/core';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
|
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
@@ -8,11 +9,9 @@ import {DEFAULT_VISIBLE_SORT_FIELDS, SortCriterion, User, UserService} from '../
|
|||||||
import {LibraryService} from '../../../book/service/library.service';
|
import {LibraryService} from '../../../book/service/library.service';
|
||||||
import {ShelfService} from '../../../book/service/shelf.service';
|
import {ShelfService} from '../../../book/service/shelf.service';
|
||||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||||
import {Subject} from 'rxjs';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
|
|
||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {takeUntil} from 'rxjs/operators';
|
|
||||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||||
import {SortDirection, SortOption} from '../../../book/model/sort.model';
|
import {SortDirection, SortOption} from '../../../book/model/sort.model';
|
||||||
@@ -40,7 +39,7 @@ import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from
|
|||||||
templateUrl: './view-preferences.component.html',
|
templateUrl: './view-preferences.component.html',
|
||||||
styleUrl: './view-preferences.component.scss'
|
styleUrl: './view-preferences.component.scss'
|
||||||
})
|
})
|
||||||
export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
export class ViewPreferencesComponent implements OnInit {
|
||||||
private t = inject(TranslocoService);
|
private t = inject(TranslocoService);
|
||||||
|
|
||||||
private readonly sortOptionDefs: {field: string; translationKey: string}[] = [
|
private readonly sortOptionDefs: {field: string; translationKey: string}[] = [
|
||||||
@@ -125,7 +124,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
private user: User | null = null;
|
private user: User | null = null;
|
||||||
private readonly destroy$ = new Subject<void>();
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly injector = inject(Injector);
|
private readonly injector = inject(Injector);
|
||||||
|
|
||||||
private libraryService = inject(LibraryService);
|
private libraryService = inject(LibraryService);
|
||||||
@@ -138,7 +137,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.rebuildTranslatedLabels();
|
this.rebuildTranslatedLabels();
|
||||||
this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
this.t.langChanges$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||||
this.rebuildTranslatedLabels();
|
this.rebuildTranslatedLabels();
|
||||||
this.allSortAsOptions = this.sortOptions.map(o => ({
|
this.allSortAsOptions = this.sortOptions.map(o => ({
|
||||||
label: this.t.translate('settingsView.librarySort.' + o.translationKey),
|
label: this.t.translate('settingsView.librarySort.' + o.translationKey),
|
||||||
@@ -217,11 +216,6 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
getAvailableEntities(index: number, type: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF') {
|
getAvailableEntities(index: number, type: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF') {
|
||||||
const selected = this.overrides.map((o, i) => i !== index ? o.library : null);
|
const selected = this.overrides.map((o, i) => i !== index ? o.library : null);
|
||||||
let source: { label: string; value: number }[];
|
let source: { label: string; value: number }[];
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { AuthService } from '../../service/auth.service';
|
|||||||
import { UserService } from '../../../features/settings/user-management/user.service';
|
import { UserService } from '../../../features/settings/user-management/user.service';
|
||||||
import { Popover } from 'primeng/popover';
|
import { Popover } from 'primeng/popover';
|
||||||
import { MetadataProgressService } from '../../service/metadata-progress.service';
|
import { MetadataProgressService } from '../../service/metadata-progress.service';
|
||||||
|
|
||||||
import { MetadataBatchProgressNotification } from '../../model/metadata-batch-progress.model';
|
import { MetadataBatchProgressNotification } from '../../model/metadata-batch-progress.model';
|
||||||
import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
|
import { BookdropFileService } from '../../../features/bookdrop/service/bookdrop-file.service';
|
||||||
import { DialogLauncherService } from '../../services/dialog-launcher.service';
|
import { DialogLauncherService } from '../../services/dialog-launcher.service';
|
||||||
@@ -69,8 +68,8 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
hasAnyTasks = false;
|
hasAnyTasks = false;
|
||||||
hasPendingBookdropFiles = false;
|
hasPendingBookdropFiles = false;
|
||||||
|
|
||||||
private eventTimer: number | undefined;
|
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
private eventTimer: number | undefined;
|
||||||
|
|
||||||
private latestTasks: Record<string, MetadataBatchProgressNotification> = {};
|
private latestTasks: Record<string, MetadataBatchProgressNotification> = {};
|
||||||
private latestHasPendingFiles = false;
|
private latestHasPendingFiles = false;
|
||||||
@@ -85,6 +84,8 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
this.subscribeToMetadataProgress();
|
this.subscribeToMetadataProgress();
|
||||||
this.subscribeToNotifications();
|
this.subscribeToNotifications();
|
||||||
|
|
||||||
|
this.destroyRef.onDestroy(() => clearTimeout(this.eventTimer));
|
||||||
|
|
||||||
this.metadataProgressService.activeTasks$
|
this.metadataProgressService.activeTasks$
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe((tasks) => {
|
.subscribe((tasks) => {
|
||||||
@@ -158,7 +159,7 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
|
|
||||||
switchLanguage(lang: string) {
|
switchLanguage(lang: string) {
|
||||||
if (lang === this.activeLang) return;
|
if (lang === this.activeLang) return;
|
||||||
this.translocoService.load(lang).subscribe(() => {
|
this.translocoService.load(lang).pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||||
this.translocoService.setActiveLang(lang);
|
this.translocoService.setActiveLang(lang);
|
||||||
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
localStorage.setItem(LANG_STORAGE_KEY, lang);
|
||||||
this.activeLang = lang;
|
this.activeLang = lang;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {computed, effect, inject, Injectable} from '@angular/core';
|
import {computed, effect, inject, Injectable} from '@angular/core';
|
||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient} from '@angular/common/http';
|
||||||
import {lastValueFrom, Observable, of} from 'rxjs';
|
import {lastValueFrom, Observable} from 'rxjs';
|
||||||
import {catchError, map, switchMap} from 'rxjs/operators';
|
import {map, switchMap} from 'rxjs/operators';
|
||||||
import {API_CONFIG} from '../../core/config/api-config';
|
import {API_CONFIG} from '../../core/config/api-config';
|
||||||
import {AppSettings, OidcProviderDetails, OidcTestResult} from '../model/app-settings.model';
|
import {AppSettings, OidcProviderDetails, OidcTestResult} from '../model/app-settings.model';
|
||||||
import {AuthService} from './auth.service';
|
import {AuthService} from './auth.service';
|
||||||
@@ -99,15 +99,8 @@ export class AppSettingsService {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
return this.http.put<void>(this.apiUrl, payload).pipe(
|
return this.http.put<void>(this.apiUrl, payload).pipe(
|
||||||
switchMap(() => {
|
switchMap(() => this.queryClient.invalidateQueries({queryKey: APP_SETTINGS_QUERY_KEY})),
|
||||||
void this.queryClient.invalidateQueries({queryKey: APP_SETTINGS_QUERY_KEY});
|
map(() => void 0)
|
||||||
return of(void 0);
|
|
||||||
}),
|
|
||||||
map(() => void 0),
|
|
||||||
catchError(err => {
|
|
||||||
console.error('Error saving settings:', err);
|
|
||||||
return of();
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +114,6 @@ export class AppSettingsService {
|
|||||||
this.queryClient.setQueryData(APP_SETTINGS_QUERY_KEY, updated);
|
this.queryClient.setQueryData(APP_SETTINGS_QUERY_KEY, updated);
|
||||||
this.syncPublicSettings(updated);
|
this.syncPublicSettings(updated);
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
catchError(err => {
|
|
||||||
console.error('Error toggling OIDC:', err);
|
|
||||||
return of();
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {firstValueFrom, of, throwError} from 'rxjs';
|
import {of, throwError} from 'rxjs';
|
||||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
import {TranslocoService} from '@jsverse/transloco';
|
import {TranslocoService} from '@jsverse/transloco';
|
||||||
|
|
||||||
@@ -39,10 +39,10 @@ describe('SettingsHelperService', () => {
|
|||||||
service = TestBed.inject(SettingsHelperService);
|
service = TestBed.inject(SettingsHelperService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('saves a setting and shows a success message', async () => {
|
it('saves a setting and shows a success message', () => {
|
||||||
appSettingsService.saveSettings.mockReturnValue(of(undefined));
|
appSettingsService.saveSettings.mockReturnValue(of(undefined));
|
||||||
|
|
||||||
await firstValueFrom(service.saveSetting('theme', 'dark'));
|
service.saveSetting('theme', 'dark');
|
||||||
|
|
||||||
expect(appSettingsService.saveSettings).toHaveBeenCalledWith([{key: 'theme', newValue: 'dark'}]);
|
expect(appSettingsService.saveSettings).toHaveBeenCalledWith([{key: 'theme', newValue: 'dark'}]);
|
||||||
expect(messageService.add).toHaveBeenCalledWith({
|
expect(messageService.add).toHaveBeenCalledWith({
|
||||||
@@ -52,12 +52,12 @@ describe('SettingsHelperService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows an error message when saving fails', async () => {
|
it('shows an error message when saving fails', () => {
|
||||||
const error = new Error('save failed');
|
const error = new Error('save failed');
|
||||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||||
appSettingsService.saveSettings.mockReturnValue(throwError(() => error));
|
appSettingsService.saveSettings.mockReturnValue(throwError(() => error));
|
||||||
|
|
||||||
await expect(firstValueFrom(service.saveSetting('theme', 'dark'))).rejects.toThrow('save failed');
|
service.saveSetting('theme', 'dark');
|
||||||
|
|
||||||
expect(errorSpy).toHaveBeenCalledWith('Failed to save setting:', error);
|
expect(errorSpy).toHaveBeenCalledWith('Failed to save setting:', error);
|
||||||
expect(messageService.add).toHaveBeenCalledWith({
|
expect(messageService.add).toHaveBeenCalledWith({
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import {Injectable, inject} from '@angular/core';
|
import {Injectable, inject} from '@angular/core';
|
||||||
|
import {of} from 'rxjs';
|
||||||
import {AppSettingsService} from './app-settings.service';
|
import {AppSettingsService} from './app-settings.service';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {TranslocoService} from '@jsverse/transloco';
|
import {TranslocoService} from '@jsverse/transloco';
|
||||||
import {Observable} from 'rxjs';
|
import {catchError, map} from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -13,18 +14,20 @@ export class SettingsHelperService {
|
|||||||
private readonly messageService = inject(MessageService);
|
private readonly messageService = inject(MessageService);
|
||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
|
|
||||||
saveSetting(key: string, value: unknown): Observable<void> {
|
saveSetting(key: string, value: unknown): void {
|
||||||
const observable = this.appSettingsService.saveSettings([{key, newValue: value}]);
|
this.appSettingsService.saveSettings([{key, newValue: value}]).pipe(
|
||||||
|
map(() => true),
|
||||||
observable.subscribe({
|
catchError((error) => {
|
||||||
next: () => this.showSuccessMessage(),
|
|
||||||
error: (error) => {
|
|
||||||
console.error('Failed to save setting:', error);
|
console.error('Failed to save setting:', error);
|
||||||
|
return of(false);
|
||||||
|
})
|
||||||
|
).subscribe((saved) => {
|
||||||
|
if (saved) {
|
||||||
|
this.showSuccessMessage();
|
||||||
|
} else {
|
||||||
this.showErrorMessage();
|
this.showErrorMessage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return observable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private showSuccessMessage(): void {
|
private showSuccessMessage(): void {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export class NotificationEventService {
|
|||||||
notificationHighlight$ = this.notificationHighlightSubject.asObservable();
|
notificationHighlight$ = this.notificationHighlightSubject.asObservable();
|
||||||
|
|
||||||
private highlightTimeout: ReturnType<typeof setTimeout> | undefined;
|
private highlightTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
private clearTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|
||||||
handleNewNotification(notification: LogNotification): void {
|
handleNewNotification(notification: LogNotification): void {
|
||||||
this.latestNotificationSubject.next(notification);
|
this.latestNotificationSubject.next(notification);
|
||||||
@@ -25,12 +26,15 @@ export class NotificationEventService {
|
|||||||
if (this.highlightTimeout) {
|
if (this.highlightTimeout) {
|
||||||
clearTimeout(this.highlightTimeout);
|
clearTimeout(this.highlightTimeout);
|
||||||
}
|
}
|
||||||
|
if (this.clearTimeout) {
|
||||||
|
clearTimeout(this.clearTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
this.highlightTimeout = setTimeout(() => {
|
this.highlightTimeout = setTimeout(() => {
|
||||||
this.notificationHighlightSubject.next(false);
|
this.notificationHighlightSubject.next(false);
|
||||||
}, 7500);
|
}, 7500);
|
||||||
|
|
||||||
setTimeout(() => {
|
this.clearTimeout = setTimeout(() => {
|
||||||
if (!this.notificationHighlightSubject.value) {
|
if (!this.notificationHighlightSubject.value) {
|
||||||
this.latestNotificationSubject.next(null);
|
this.latestNotificationSubject.next(null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user