diff --git a/apps/red-ui/src/app/common/filter/filter.component.ts b/apps/red-ui/src/app/common/filter/filter.component.ts index 95ea8683b..0ecb46e50 100644 --- a/apps/red-ui/src/app/common/filter/filter.component.ts +++ b/apps/red-ui/src/app/common/filter/filter.component.ts @@ -30,9 +30,11 @@ export class FilterComponent implements OnChanges { if (changes.filters) { const oldFilters = changes.filters.previousValue; this._copySettings(oldFilters, this.filters); - this.filters.forEach((filter) => { - handleCheckedValue(filter); - }); + if (this.filters) { + this.filters.forEach((filter) => { + handleCheckedValue(filter); + }); + } } } diff --git a/apps/red-ui/src/app/notification/notification.service.ts b/apps/red-ui/src/app/notification/notification.service.ts index c15f7fc72..319c1d1ff 100644 --- a/apps/red-ui/src/app/notification/notification.service.ts +++ b/apps/red-ui/src/app/notification/notification.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { ToastrService } from 'ngx-toastr'; +import { ActiveToast, ToastrService } from 'ngx-toastr'; import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config'; export enum NotificationType { @@ -26,20 +26,17 @@ export class NotificationService { title?: string, notificationType: NotificationType = NotificationType.INFO, options?: Partial & { actions: Action[] } - ) { + ): ActiveToast { switch (notificationType) { case NotificationType.ERROR: - this._toastr.error(message, title, options); - break; + return this._toastr.error(message, title, options); case NotificationType.SUCCESS: - this._toastr.success(message, title, options); + return this._toastr.success(message, title, options); break; case NotificationType.WARNING: - this._toastr.warning(message, title, options); - break; + return this._toastr.warning(message, title, options); case NotificationType.INFO: - this._toastr.info(message, title, options); - break; + return this._toastr.info(message, title, options); } } } diff --git a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts index d5b896506..c812b59bd 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts @@ -21,6 +21,7 @@ import { FilterModel } from '../../common/filter/model/filter.model'; import * as moment from 'moment'; import { SortingComponent, SortingOption } from '../../components/sorting/sorting.component'; import { ProjectDetailsComponent } from './project-details/project-details.component'; +import { ActiveToast } from 'ngx-toastr'; @Component({ selector: 'redaction-project-overview-screen', @@ -42,6 +43,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy { @ViewChild('sortingComponent', { static: true }) public sortingComponent: SortingComponent; public sortingOption: SortingOption = { column: 'added', order: 'desc' }; + private _rulesChangedToast: ActiveToast; constructor( public readonly appStateService: AppStateService, @@ -78,6 +80,9 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this._fileDropOverlayService.cleanupFileDropHandling(); + if (this._rulesChangedToast && this._rulesChangedToast.toastRef) { + this._rulesChangedToast.toastRef.close(); + } } public get user() { @@ -112,7 +117,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy { return; } - this._notificationService.showToastNotification( + this._rulesChangedToast = this._notificationService.showToastNotification( `${this._translateService.instant( 'project-overview.new-rule.toast.message.label' )} ${this._translateService.instant(