@@ -54,6 +54,8 @@ import {AlertManagementService} from '../shared/services/alert-management.servic
54
54
import { AlertTagService } from '../shared/services/alert-tag.service' ;
55
55
import { getCurrentAlertStatus , getStatusName } from '../shared/util/alert-util-function' ;
56
56
import { CheckEmailConfigService , ParamShortType } from '../../../shared/services/util/check-email-config.service' ;
57
+ import { Subject } from "rxjs" ;
58
+ import { takeUntil } from "rxjs/operators" ;
57
59
58
60
@Component ( {
59
61
selector : 'app-alert-view' ,
@@ -102,28 +104,24 @@ export class AlertViewComponent implements OnInit, OnDestroy {
102
104
refreshingAlert = false ;
103
105
firstLoad = true ;
104
106
tags : AlertTags [ ] ;
107
+ destroy$ = new Subject < void > ( ) ;
105
108
106
109
constructor ( private elasticDataService : ElasticDataService ,
107
110
private modalService : NgbModal ,
108
111
private utmToastService : UtmToastService ,
109
112
private translate : TranslateService ,
110
- private alertServiceManagement : AlertManagementService ,
111
113
private alertFiltersBehavior : AlertFiltersBehavior ,
112
114
private updateStatusServiceBehavior : AlertStatusBehavior ,
113
115
private activatedRoute : ActivatedRoute ,
114
116
public router : Router ,
115
117
private newAlertBehavior : NewAlertBehavior ,
116
- private alertUpdateTagBehavior : AlertUpdateTagBehavior ,
117
118
private alertDataTypeBehavior : AlertDataTypeBehavior ,
118
119
private alertTagService : AlertTagService ,
119
120
private spinner : NgxSpinnerService ,
120
121
private checkEmailConfigService : CheckEmailConfigService ) {
121
122
// this.tableWidth = this.pageWidth - 300;
122
123
}
123
124
124
- ngOnDestroy ( ) : void {
125
- }
126
-
127
125
ngOnInit ( ) {
128
126
this . checkEmailConfigService . check ( ParamShortType . Alert ) ;
129
127
this . setInitialWidth ( ) ;
@@ -166,7 +164,9 @@ export class AlertViewComponent implements OnInit, OnDestroy {
166
164
this . alertFiltersBehavior . $filters . next ( this . filters ) ;
167
165
}
168
166
} ) ;
169
- this . newAlertBehavior . $alertChange . subscribe ( newAlerts => {
167
+ this . newAlertBehavior . $alertChange
168
+ . pipe ( takeUntil ( this . destroy$ ) )
169
+ . subscribe ( newAlerts => {
170
170
if ( newAlerts && newAlerts !== 0 ) {
171
171
this . incomingAlert = newAlerts ;
172
172
}
@@ -318,6 +318,7 @@ export class AlertViewComponent implements OnInit, OnDestroy {
318
318
this . refreshingAlert = false ;
319
319
} ,
320
320
( res : HttpResponse < any > ) => {
321
+ this . utmToastService . showError ( 'Error' , 'An error occurred while listing the alerts. Please try again later.' ) ;
321
322
}
322
323
) ;
323
324
}
@@ -549,4 +550,9 @@ export class AlertViewComponent implements OnInit, OnDestroy {
549
550
const modal = this . modalService . open ( IrCreateRuleComponent , { size : 'lg' , centered : true } ) ;
550
551
modal . componentInstance . alert = alert ;
551
552
}
553
+
554
+ ngOnDestroy ( ) : void {
555
+ this . destroy$ . next ( ) ;
556
+ this . destroy$ . complete ( ) ;
557
+ }
552
558
}
0 commit comments