@@ -54,6 +54,8 @@ import {AlertManagementService} from '../shared/services/alert-management.servic
5454import { AlertTagService } from '../shared/services/alert-tag.service' ;
5555import { getCurrentAlertStatus , getStatusName } from '../shared/util/alert-util-function' ;
5656import { CheckEmailConfigService , ParamShortType } from '../../../shared/services/util/check-email-config.service' ;
57+ import { Subject } from "rxjs" ;
58+ import { takeUntil } from "rxjs/operators" ;
5759
5860@Component ( {
5961 selector : 'app-alert-view' ,
@@ -102,28 +104,24 @@ export class AlertViewComponent implements OnInit, OnDestroy {
102104 refreshingAlert = false ;
103105 firstLoad = true ;
104106 tags : AlertTags [ ] ;
107+ destroy$ = new Subject < void > ( ) ;
105108
106109 constructor ( private elasticDataService : ElasticDataService ,
107110 private modalService : NgbModal ,
108111 private utmToastService : UtmToastService ,
109112 private translate : TranslateService ,
110- private alertServiceManagement : AlertManagementService ,
111113 private alertFiltersBehavior : AlertFiltersBehavior ,
112114 private updateStatusServiceBehavior : AlertStatusBehavior ,
113115 private activatedRoute : ActivatedRoute ,
114116 public router : Router ,
115117 private newAlertBehavior : NewAlertBehavior ,
116- private alertUpdateTagBehavior : AlertUpdateTagBehavior ,
117118 private alertDataTypeBehavior : AlertDataTypeBehavior ,
118119 private alertTagService : AlertTagService ,
119120 private spinner : NgxSpinnerService ,
120121 private checkEmailConfigService : CheckEmailConfigService ) {
121122 // this.tableWidth = this.pageWidth - 300;
122123 }
123124
124- ngOnDestroy ( ) : void {
125- }
126-
127125 ngOnInit ( ) {
128126 this . checkEmailConfigService . check ( ParamShortType . Alert ) ;
129127 this . setInitialWidth ( ) ;
@@ -166,7 +164,9 @@ export class AlertViewComponent implements OnInit, OnDestroy {
166164 this . alertFiltersBehavior . $filters . next ( this . filters ) ;
167165 }
168166 } ) ;
169- this . newAlertBehavior . $alertChange . subscribe ( newAlerts => {
167+ this . newAlertBehavior . $alertChange
168+ . pipe ( takeUntil ( this . destroy$ ) )
169+ . subscribe ( newAlerts => {
170170 if ( newAlerts && newAlerts !== 0 ) {
171171 this . incomingAlert = newAlerts ;
172172 }
@@ -318,6 +318,7 @@ export class AlertViewComponent implements OnInit, OnDestroy {
318318 this . refreshingAlert = false ;
319319 } ,
320320 ( res : HttpResponse < any > ) => {
321+ this . utmToastService . showError ( 'Error' , 'An error occurred while listing the alerts. Please try again later.' ) ;
321322 }
322323 ) ;
323324 }
@@ -549,4 +550,9 @@ export class AlertViewComponent implements OnInit, OnDestroy {
549550 const modal = this . modalService . open ( IrCreateRuleComponent , { size : 'lg' , centered : true } ) ;
550551 modal . componentInstance . alert = alert ;
551552 }
553+
554+ ngOnDestroy ( ) : void {
555+ this . destroy$ . next ( ) ;
556+ this . destroy$ . complete ( ) ;
557+ }
552558}
0 commit comments