fix(loading): update loading checks to use signal() for reactive state management (#727)
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
[rows]="rows"
|
||||
[first]="currentPage * rows"
|
||||
[totalRecords]="totalRecords"
|
||||
[loading]="loading"
|
||||
[loading]="loading()"
|
||||
[showCurrentPageReport]="true"
|
||||
[currentPageReportTemplate]="t('pageReport')"
|
||||
(onLazyLoad)="onLazyLoad($event)"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, OnInit, signal} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {TableLazyLoadEvent, TableModule} from 'primeng/table';
|
||||
@@ -55,7 +55,7 @@ export class AuditLogsComponent implements OnInit {
|
||||
logs: AuditLog[] = [];
|
||||
totalRecords = 0;
|
||||
rows = 25;
|
||||
loading = false;
|
||||
loading = signal(false);
|
||||
selectedAction: string | null = null;
|
||||
selectedUsername: string | null = null;
|
||||
dateRange: Date[] | null = null;
|
||||
@@ -127,7 +127,7 @@ export class AuditLogsComponent implements OnInit {
|
||||
|
||||
loadLogs(showLoading = true): void {
|
||||
if (showLoading) {
|
||||
this.loading = true;
|
||||
this.loading.set(true);
|
||||
}
|
||||
const action = this.selectedAction || undefined;
|
||||
const username = this.selectedUsername || undefined;
|
||||
@@ -139,10 +139,10 @@ export class AuditLogsComponent implements OnInit {
|
||||
next: (response) => {
|
||||
this.logs = response.content;
|
||||
this.totalRecords = response.page.totalElements;
|
||||
this.loading = false;
|
||||
this.loading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.loading = false;
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+6
-1
@@ -23,7 +23,12 @@
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (emailProviders.length === 0) {
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner/>
|
||||
<p class="loading-text">{{ 'common.loading' | transloco }}</p>
|
||||
</div>
|
||||
} @else if (emailProviders.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-envelope"></i>
|
||||
<p class="empty-title">{{ t('emptyTitle') }}</p>
|
||||
|
||||
+24
-4
@@ -1,5 +1,6 @@
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, OnInit, signal} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {finalize} from 'rxjs';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -13,6 +14,7 @@ import {EmailProvider} from '../email-provider.model';
|
||||
import {UserService} from '../../user-management/user.service';
|
||||
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-email-v2-provider',
|
||||
@@ -25,7 +27,8 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
||||
Tooltip,
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
TranslocoPipe,
|
||||
ProgressSpinner
|
||||
],
|
||||
templateUrl: './email-v2-provider.component.html',
|
||||
styleUrl: './email-v2-provider.component.scss'
|
||||
@@ -40,6 +43,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
private t = inject(TranslocoService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
loading = signal(false);
|
||||
private loadingRequestSeq = 0;
|
||||
private activeLoadingRequestSeq: number | null = null;
|
||||
defaultProviderId: unknown;
|
||||
currentUserId: number | null = null;
|
||||
isAdmin: boolean = false;
|
||||
@@ -56,10 +62,21 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadEmailProviders(): void {
|
||||
const requestSeq = ++this.loadingRequestSeq;
|
||||
this.activeLoadingRequestSeq = requestSeq;
|
||||
this.loading.set(true);
|
||||
|
||||
this.emailProvidersService.getEmailProviders().pipe(
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
finalize(() => {
|
||||
if (this.activeLoadingRequestSeq === requestSeq) {
|
||||
this.loading.set(false);
|
||||
}
|
||||
})
|
||||
).subscribe({
|
||||
next: (emailProviders: EmailProvider[]) => {
|
||||
if (this.activeLoadingRequestSeq !== requestSeq) return;
|
||||
|
||||
this.emailProviders = emailProviders.map((provider) => ({
|
||||
...provider,
|
||||
isEditing: false,
|
||||
@@ -68,6 +85,9 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
this.defaultProviderId = defaultProvider ? defaultProvider.id : null;
|
||||
},
|
||||
error: () => {
|
||||
if (this.activeLoadingRequestSeq !== requestSeq) return;
|
||||
|
||||
this.emailProviders = [];
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
@@ -154,7 +174,7 @@ export class EmailV2ProviderComponent implements OnInit {
|
||||
detail: this.t.translate('settingsEmail.provider.defaultSetDetail', {name: provider.name}),
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
error: (err: unknown) => {
|
||||
console.error('Failed to set default provider', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
|
||||
+6
-1
@@ -23,7 +23,12 @@
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (recipientEmails.length === 0) {
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner/>
|
||||
<p class="loading-text">{{ 'common.loading' | transloco }}</p>
|
||||
</div>
|
||||
} @else if (recipientEmails.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-users"></i>
|
||||
<p class="empty-title">{{ t('emptyTitle') }}</p>
|
||||
|
||||
+23
-3
@@ -1,5 +1,6 @@
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, OnInit, signal} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {finalize} from 'rxjs';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {RadioButton} from 'primeng/radiobutton';
|
||||
@@ -11,6 +12,7 @@ import {EmailV2RecipientService} from './email-v2-recipient.service';
|
||||
import {EmailRecipient} from '../email-recipient.model';
|
||||
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-email-v2-recipient',
|
||||
@@ -22,7 +24,8 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
||||
Tooltip,
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
TranslocoPipe,
|
||||
ProgressSpinner
|
||||
],
|
||||
templateUrl: './email-v2-recipient.component.html',
|
||||
styleUrl: './email-v2-recipient.component.scss'
|
||||
@@ -36,6 +39,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
loading = signal(false);
|
||||
private loadingRequestSeq = 0;
|
||||
private activeLoadingRequestSeq: number | null = null;
|
||||
defaultRecipientId: unknown;
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -43,10 +49,21 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadRecipientEmails(): void {
|
||||
const requestSeq = ++this.loadingRequestSeq;
|
||||
this.activeLoadingRequestSeq = requestSeq;
|
||||
this.loading.set(true);
|
||||
|
||||
this.emailRecipientService.getRecipients().pipe(
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
finalize(() => {
|
||||
if (this.activeLoadingRequestSeq === requestSeq) {
|
||||
this.loading.set(false);
|
||||
}
|
||||
})
|
||||
).subscribe({
|
||||
next: (recipients: EmailRecipient[]) => {
|
||||
if (this.activeLoadingRequestSeq !== requestSeq) return;
|
||||
|
||||
this.recipientEmails = recipients.map((recipient) => ({
|
||||
...recipient,
|
||||
isEditing: false,
|
||||
@@ -55,6 +72,9 @@ export class EmailV2RecipientComponent implements OnInit {
|
||||
this.defaultRecipientId = defaultRecipient ? defaultRecipient.id : null;
|
||||
},
|
||||
error: () => {
|
||||
if (this.activeLoadingRequestSeq !== requestSeq) return;
|
||||
|
||||
this.recipientEmails = [];
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
|
||||
+3
-3
@@ -40,9 +40,9 @@
|
||||
<span class="setting-description">Current size occupied by Cache Storage</span>
|
||||
</div>
|
||||
<div class="setting-control action-buttons">
|
||||
<span class="setting-value">{{ cacheStorageUsageMb | number: '1.2-2' }} MB</span>
|
||||
<span class="setting-value">{{ cacheStorageUsageMb() | number: '1.2-2' }} MB</span>
|
||||
<p-button type="button" label="Refresh" icon="pi pi-refresh" severity="secondary" [outlined]="true"
|
||||
[disabled]="isLoadingCacheStorageUsage" [loading]="isLoadingCacheStorageUsage" (onClick)="loadCacheStorageUsage()">
|
||||
[disabled]="isLoadingCacheStorageUsage()" [loading]="isLoadingCacheStorageUsage()" (onClick)="loadCacheStorageUsage()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -54,7 +54,7 @@
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<p-button type="button" label="Clear Cache" icon="pi pi-trash" severity="danger" [outlined]="true"
|
||||
[disabled]="isClearingCacheStorage" [loading]="isClearingCacheStorage" (onClick)="clearCacheStorage()">
|
||||
[disabled]="isClearingCacheStorage()" [loading]="isClearingCacheStorage()" (onClick)="clearCacheStorage()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit} from "@angular/core";
|
||||
import {Component, inject, OnInit, signal} from "@angular/core";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {DecimalPipe} from "@angular/common";
|
||||
import {Checkbox} from "primeng/checkbox";
|
||||
@@ -28,9 +28,9 @@ export class LocalSettingsComponent implements OnInit {
|
||||
|
||||
protected settings: LocalSettings = this.localSettingsService.get();
|
||||
|
||||
protected isLoadingCacheStorageUsage = false;
|
||||
protected isClearingCacheStorage = false;
|
||||
protected cacheStorageUsageMb = 0;
|
||||
protected isLoadingCacheStorageUsage = signal(false);
|
||||
protected isClearingCacheStorage = signal(false);
|
||||
protected cacheStorageUsageMb = signal(0);
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this.loadCacheStorageUsage();
|
||||
@@ -57,7 +57,7 @@ export class LocalSettingsComponent implements OnInit {
|
||||
severity: "secondary",
|
||||
},
|
||||
accept: async () => {
|
||||
this.isClearingCacheStorage = true;
|
||||
this.isClearingCacheStorage.set(true);
|
||||
try {
|
||||
await this.cacheStorageService.clear();
|
||||
await this.loadCacheStorageUsage();
|
||||
@@ -73,22 +73,22 @@ export class LocalSettingsComponent implements OnInit {
|
||||
detail: "Unable to clear Cache Storage. Please try again.",
|
||||
});
|
||||
} finally {
|
||||
this.isClearingCacheStorage = false;
|
||||
this.isClearingCacheStorage.set(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async loadCacheStorageUsage(): Promise<void> {
|
||||
this.isLoadingCacheStorageUsage = true;
|
||||
this.isLoadingCacheStorageUsage.set(true);
|
||||
try {
|
||||
const totalBytes = await this.cacheStorageService.getCacheSizeInBytes();
|
||||
this.cacheStorageUsageMb = totalBytes / (1024 * 1024);
|
||||
this.cacheStorageUsageMb.set(totalBytes / (1024 * 1024));
|
||||
} catch (error) {
|
||||
console.error("Error loading Cache Storage usage:", error);
|
||||
this.cacheStorageUsageMb = 0;
|
||||
this.cacheStorageUsageMb.set(0);
|
||||
} finally {
|
||||
this.isLoadingCacheStorageUsage = false;
|
||||
this.isLoadingCacheStorageUsage.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@if (userService.currentUser(); as currentUser) {
|
||||
@if (currentUser) {
|
||||
<div class="settings-container">
|
||||
<p-tabs [(value)]="activeTab" lazy scrollable>
|
||||
<p-tabs [(value)]="activeTab" scrollable>
|
||||
<p-tablist>
|
||||
<p-tab [value]="SettingsTab.ReaderSettings">
|
||||
<i class="pi pi-book"></i> {{ t('reader') }}
|
||||
@@ -59,84 +59,93 @@
|
||||
</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels>
|
||||
<!-- [GROUP: Lazy Tabs] -->
|
||||
<p-tabpanel [value]="SettingsTab.ReaderSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.ReaderSettings)) {
|
||||
<app-reader-preferences></app-reader-preferences>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.ViewPreferences">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.ViewPreferences)) {
|
||||
<app-view-preferences-parent></app-view-preferences-parent>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
|
||||
@if (currentUser.permissions.admin || currentUser.permissions.canManageMetadataConfig) {
|
||||
<p-tabpanel [value]="SettingsTab.MetadataSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.MetadataSettings)) {
|
||||
<app-metadata-settings-component></app-metadata-settings-component>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
<p-tabpanel [value]="SettingsTab.LibraryMetadataSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.LibraryMetadataSettings)) {
|
||||
<app-library-metadata-settings-component></app-library-metadata-settings-component>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
@if (currentUser.permissions.admin || currentUser.permissions.canManageGlobalPreferences) {
|
||||
<p-tabpanel [value]="SettingsTab.ApplicationSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.ApplicationSettings)) {
|
||||
<app-global-preferences></app-global-preferences>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
<!-- [GROUP: Eager Tabs (Always Rendered to ensure initialization)] -->
|
||||
@if (currentUser.permissions.admin) {
|
||||
<p-tabpanel [value]="SettingsTab.UserManagement">
|
||||
<ng-template #content>
|
||||
<app-user-management></app-user-management>
|
||||
</ng-template>
|
||||
<app-user-management></app-user-management>
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
<p-tabpanel [value]="SettingsTab.EmailSettingsV2">
|
||||
<ng-template #content>
|
||||
<app-email-v2></app-email-v2>
|
||||
</ng-template>
|
||||
<app-email-v2></app-email-v2>
|
||||
</p-tabpanel>
|
||||
|
||||
<!-- [GROUP: Lazy Tabs Continued] -->
|
||||
@if (currentUser.permissions.admin || currentUser.permissions.canManageMetadataConfig) {
|
||||
<p-tabpanel [value]="SettingsTab.NamingPattern">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.NamingPattern)) {
|
||||
<app-file-naming-pattern></app-file-naming-pattern>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
@if (currentUser.permissions.admin) {
|
||||
<p-tabpanel [value]="SettingsTab.AuthenticationSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.AuthenticationSettings)) {
|
||||
<app-authentication-settings></app-authentication-settings>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
@if (currentUser.permissions.admin || currentUser.permissions.canAccessTaskManager) {
|
||||
<p-tabpanel [value]="SettingsTab.Tasks">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.Tasks)) {
|
||||
<app-task-management></app-task-management>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
@if (currentUser.permissions.admin) {
|
||||
<p-tabpanel [value]="SettingsTab.AuditLogs">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.AuditLogs)) {
|
||||
<app-audit-logs></app-audit-logs>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
}
|
||||
|
||||
<p-tabpanel [value]="SettingsTab.OpdsV2">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.OpdsV2)) {
|
||||
<app-opds-settings></app-opds-settings>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
|
||||
<p-tabpanel [value]="SettingsTab.DeviceSettings">
|
||||
<ng-template #content>
|
||||
@if (visitedTabs().has(SettingsTab.DeviceSettings)) {
|
||||
<app-device-settings-component></app-device-settings-component>
|
||||
</ng-template>
|
||||
}
|
||||
</p-tabpanel>
|
||||
</p-tabpanels>
|
||||
</p-tabs>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, effect, inject, OnInit, signal} from '@angular/core';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {UserService} from './user-management/user.service';
|
||||
import {GlobalPreferencesComponent} from './global-preferences/global-preferences.component';
|
||||
@@ -71,14 +71,19 @@ export class SettingsComponent implements OnInit {
|
||||
SettingsTab = SettingsTab;
|
||||
|
||||
private validTabs = Object.values(SettingsTab);
|
||||
private _activeTab: SettingsTab = SettingsTab.ReaderSettings;
|
||||
private _activeTab = signal<SettingsTab>(SettingsTab.ReaderSettings);
|
||||
|
||||
visitedTabs = signal<Set<SettingsTab>>(new Set([
|
||||
SettingsTab.UserManagement,
|
||||
SettingsTab.EmailSettingsV2
|
||||
]));
|
||||
|
||||
get activeTab(): SettingsTab {
|
||||
return this._activeTab;
|
||||
return this._activeTab();
|
||||
}
|
||||
|
||||
set activeTab(value: SettingsTab) {
|
||||
this._activeTab = value;
|
||||
this._activeTab.set(value);
|
||||
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
@@ -87,22 +92,44 @@ export class SettingsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
const pageTitle = inject(PageTitleService);
|
||||
pageTitle.setPageTitle('Settings');
|
||||
|
||||
effect(() => {
|
||||
const active = this._activeTab();
|
||||
this.visitedTabs.update(set => {
|
||||
if (set.has(active)) return set;
|
||||
const newSet = new Set(set);
|
||||
newSet.add(active);
|
||||
return newSet;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.pageTitle.setPageTitle('Settings');
|
||||
|
||||
// Initialize from snapshot synchronously to ensure p-tabs (lazy) picks up the correct value on first render
|
||||
const initialTab = this.route.snapshot.queryParams['tab'];
|
||||
if (this.validTabs.includes(initialTab)) {
|
||||
this._activeTab.set(initialTab as SettingsTab);
|
||||
}
|
||||
|
||||
this.route.queryParams.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
|
||||
const tabParam = params['tab'];
|
||||
if (this.validTabs.includes(tabParam)) {
|
||||
this._activeTab = tabParam as SettingsTab;
|
||||
this._activeTab.set(tabParam as SettingsTab);
|
||||
} else {
|
||||
this._activeTab = SettingsTab.ReaderSettings;
|
||||
const defaultTab = SettingsTab.ReaderSettings;
|
||||
this._activeTab.set(defaultTab);
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {tab: this._activeTab},
|
||||
queryParams: {tab: defaultTab},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@if (loading && taskInfos.length === 0) {
|
||||
@if (loading() && taskInfos.length === 0) {
|
||||
<div class="loading-state">
|
||||
<i class="pi pi-spin pi-spinner"></i>
|
||||
<span>{{ t('loading') }}</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!loading && taskInfos.length === 0) {
|
||||
@if (!loading() && taskInfos.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<p class="empty-title">{{ t('emptyTitle') }}</p>
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ describe('TaskManagementComponent', () => {
|
||||
id: 'task-1',
|
||||
status: TaskStatus.PENDING,
|
||||
});
|
||||
expect(component.loading).toBe(false);
|
||||
expect(component.loading()).toBe(false);
|
||||
});
|
||||
|
||||
it('reports load failures through the message service', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, OnInit, signal} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Button} from 'primeng/button';
|
||||
import {ProgressBar} from 'primeng/progressbar';
|
||||
@@ -54,7 +54,7 @@ export class TaskManagementComponent implements OnInit {
|
||||
// State
|
||||
taskInfos: TaskInfo[] = [];
|
||||
taskHistories = new Map<string, TaskHistory>();
|
||||
loading = false;
|
||||
loading = signal(false);
|
||||
executingTasks = new Set<string>();
|
||||
|
||||
// Metadata Replace Options
|
||||
@@ -98,13 +98,13 @@ export class TaskManagementComponent implements OnInit {
|
||||
// ============================================================================
|
||||
|
||||
loadTasks(): void {
|
||||
this.loading = true;
|
||||
this.loading.set(true);
|
||||
|
||||
forkJoin({
|
||||
available: this.taskService.getAvailableTasks(),
|
||||
latest: this.taskService.getLatestTasksForEachType()
|
||||
})
|
||||
.pipe(finalize(() => this.loading = false))
|
||||
.pipe(finalize(() => this.loading.set(false)))
|
||||
.subscribe({
|
||||
next: ({available, latest}) => {
|
||||
this.taskInfos = this.sortTasksByDisplayOrder(available);
|
||||
|
||||
Reference in New Issue
Block a user