Skip to content

Commit

Permalink
NAS-129891 / 25.04 / Webui cache refresh should report progress of ca…
Browse files Browse the repository at this point in the history
…che fill job (#10847)

* NAS-129891: Webui cache refresh should report progress of cache fill job

* NAS-129891: PR update
  • Loading branch information
AlexKarpov98 authored Oct 12, 2024
1 parent 17fb4d7 commit 75d2fab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('ActiveDirectoryComponent', () => {
}),
mockProvider(DialogService, {
jobDialog: jest.fn(() => ({
afterClosed: () => of(null),
afterClosed: () => of({}),
})),
}),
mockProvider(SnackbarService),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,25 @@ export class ActiveDirectoryComponent implements OnInit {

onRebuildCachePressed(): void {
this.isLoading = true;
this.systemGeneralService.refreshDirServicesCache().pipe(untilDestroyed(this)).subscribe({
next: () => {
this.isLoading = false;
this.snackbarService.success(
this.translate.instant(helptextActiveDirectory.activedirectory_custactions_clearcache_dialog_message),
);
this.cdr.markForCheck();
},
error: (error: unknown) => {
this.isLoading = false;
this.dialogService.error(this.errorHandler.parseError(error));
this.cdr.markForCheck();
},
});
this.dialogService
.jobDialog(this.systemGeneralService.refreshDirServicesCache())
.afterClosed()
.pipe(untilDestroyed(this)).subscribe({
next: ({ description }) => {
this.isLoading = false;
this.snackbarService.success(
this.translate.instant(
description || helptextActiveDirectory.activedirectory_custactions_clearcache_dialog_message,
),
);
this.cdr.markForCheck();
},
error: (error: unknown) => {
this.isLoading = false;
this.dialogService.error(this.errorHandler.parseError(error));
this.cdr.markForCheck();
},
});
}

onLeaveDomainPressed(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('LdapComponent', () => {
}),
mockProvider(DialogService, {
jobDialog: jest.fn(() => ({
afterClosed: () => of(null),
afterClosed: () => of({}),
})),
}),
mockProvider(SnackbarService),
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('LdapComponent', () => {
const rebuildCacheButton = await loader.getHarness(MatButtonHarness.with({ text: 'Rebuild Directory Service Cache' }));
await rebuildCacheButton.click();

expect(spectator.inject(SystemGeneralService).refreshDirServicesCache).toHaveBeenCalled();
expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalledWith(
helptextLdap.ldap_custactions_clearcache_dialog_message,
);
Expand Down
31 changes: 17 additions & 14 deletions src/app/pages/directory-service/components/ldap/ldap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,23 @@ export class LdapComponent implements OnInit {

onRebuildCachePressed(): void {
this.isLoading = true;
this.systemGeneralService.refreshDirServicesCache().pipe(untilDestroyed(this)).subscribe({
next: () => {
this.isLoading = false;
this.snackbar.success(
this.translate.instant(helptextLdap.ldap_custactions_clearcache_dialog_message),
);
this.cdr.markForCheck();
},
error: (error: unknown) => {
this.isLoading = false;
this.dialogService.error(this.errorHandler.parseError(error));
this.cdr.markForCheck();
},
});
this.dialogService
.jobDialog(this.systemGeneralService.refreshDirServicesCache())
.afterClosed()
.pipe(untilDestroyed(this)).subscribe({
next: ({ description }) => {
this.isLoading = false;
this.snackbar.success(
this.translate.instant(description || helptextLdap.ldap_custactions_clearcache_dialog_message),
);
this.cdr.markForCheck();
},
error: (error: unknown) => {
this.isLoading = false;
this.dialogService.error(this.errorHandler.parseError(error));
this.cdr.markForCheck();
},
});
}

onSubmit(): void {
Expand Down

0 comments on commit 75d2fab

Please sign in to comment.