Skip to content

Commit

Permalink
NAS-129891 / 24.10.1 / Webui cache refresh should report progress of …
Browse files Browse the repository at this point in the history
…cache fill job (by AlexKarpov98) (#10857)

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

(cherry picked from commit dbb15a0)

* NAS-129891: PR update

(cherry picked from commit fb91e18)

---------

Co-authored-by: Alex Karpov <[email protected]>
  • Loading branch information
bugclerk and AlexKarpov98 authored Oct 14, 2024
1 parent f044815 commit a0a7f96
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 @@ -84,7 +84,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 @@ -96,20 +96,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 @@ -74,7 +74,7 @@ describe('LdapComponent', () => {
}),
mockProvider(DialogService, {
jobDialog: jest.fn(() => ({
afterClosed: () => of(null),
afterClosed: () => of({}),
})),
}),
mockProvider(SnackbarService),
Expand Down Expand Up @@ -134,7 +134,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 @@ -90,20 +90,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 a0a7f96

Please sign in to comment.