@@ -16,9 +16,7 @@ import {
16
16
ALERT_PROTOCOL_FIELD ,
17
17
ALERT_SENSOR_FIELD ,
18
18
ALERT_SEVERITY_FIELD_LABEL ,
19
- ALERT_STATUS_FIELD ,
20
- ALERT_TACTIC_FIELD ,
21
- ALERT_TIMESTAMP_FIELD
19
+ ALERT_STATUS_FIELD , ALERT_TACTIC_FIELD , ALERT_TIMESTAMP_FIELD
22
20
} from '../../../../../shared/constants/alert/alert-field.constant' ;
23
21
import { LOG_ROUTE } from '../../../../../shared/constants/app-routes.constant' ;
24
22
import { LOG_INDEX_PATTERN , LOG_INDEX_PATTERN_ID } from '../../../../../shared/constants/main-index-pattern.constant' ;
@@ -34,7 +32,6 @@ import {AlertUpdateHistoryBehavior} from '../../behavior/alert-update-history.be
34
32
import { AlertUpdateTagBehavior } from '../../behavior/alert-update-tag.behavior' ;
35
33
import { AlertHistoryActionEnum } from '../../enums/alert-history-action.enum' ;
36
34
import { EventDataTypeEnum } from '../../enums/event-data-type.enum' ;
37
- import { AlertManagementService } from '../../services/alert-management.service' ;
38
35
39
36
@Component ( {
40
37
selector : 'app-alert-view-detail' ,
@@ -47,6 +44,7 @@ export class AlertViewDetailComponent implements OnInit {
47
44
@Input ( ) hideEmptyField = false ;
48
45
@Input ( ) dataType : EventDataTypeEnum ;
49
46
@Input ( ) tags : AlertTags [ ] ;
47
+ @Input ( ) timeFilter : ElasticFilterType ;
50
48
@Output ( ) refreshData = new EventEmitter < boolean > ( ) ;
51
49
ALERT_NAME = ALERT_NAME_FIELD ;
52
50
STATUS_FIELD = ALERT_STATUS_FIELD ;
@@ -77,19 +75,17 @@ export class AlertViewDetailComponent implements OnInit {
77
75
hideLastChange = false ;
78
76
incidentResponse = false ;
79
77
80
- constructor ( private alertServiceManagement : AlertManagementService ,
81
- private utmToastService : UtmToastService ,
82
- private alertUpdateHistoryBehavior : AlertUpdateHistoryBehavior ,
78
+ constructor ( private alertUpdateHistoryBehavior : AlertUpdateHistoryBehavior ,
83
79
private alertUpdateTagBehavior : AlertUpdateTagBehavior ,
84
80
private spinner : NgxSpinnerService ,
85
81
private elasticDataService : ElasticDataService ,
86
82
private moduleService : UtmModulesService ,
87
- private router : Router ) {
83
+ private router : Router ,
84
+ private toastService : UtmToastService ) {
88
85
}
89
86
90
87
ngOnInit ( ) {
91
88
this . viewLog = this . fullScreen ;
92
- // @ts -ignore
93
89
this . logs = this . alert . logs . reverse ( ) ;
94
90
this . countRelatedEvents = this . logs . length ;
95
91
const ref = this . alert . reference ;
@@ -155,14 +151,18 @@ export class AlertViewDetailComponent implements OnInit {
155
151
searchLastLog ( ) {
156
152
if ( ! this . log ) {
157
153
this . getLastLog = true ;
158
- const filter : ElasticFilterType [ ] = [ { field : ALERT_ID_FIELD , operator : ElasticOperatorsEnum . IS , value : this . logs [ 0 ] } ] ;
154
+ const filters : ElasticFilterType [ ] = [
155
+ ...( this . timeFilter ? [ this . timeFilter ] : [ ] ) ,
156
+ { field : ALERT_ID_FIELD , operator : ElasticOperatorsEnum . IS , value : this . logs [ 0 ] }
157
+ ] ;
159
158
this . elasticDataService . search ( 1 , 1 ,
160
- 1 , LOG_INDEX_PATTERN , filter ) . subscribe (
159
+ 1 , LOG_INDEX_PATTERN , filters ) . subscribe (
161
160
( res : HttpResponse < any > ) => {
162
- this . log = res . body [ 0 ] ;
161
+ this . log = res . body [ 0 ] ? res . body [ 0 ] : { } ;
163
162
this . getLastLog = false ;
164
163
} ,
165
164
( res : HttpResponse < any > ) => {
165
+ this . toastService . showError ( 'Error' , 'An error occurred while trying to retrieve the latest log.' ) ;
166
166
}
167
167
) ;
168
168
}
@@ -171,6 +171,10 @@ export class AlertViewDetailComponent implements OnInit {
171
171
viewLastLog ( ) {
172
172
this . searchLastLog ( ) ;
173
173
}
174
+
175
+ isEmptyResponse ( ) {
176
+ return Object . entries ( this . log ) . length === 0 ;
177
+ }
174
178
}
175
179
176
180
export enum AlertDetailTabEnum {
0 commit comments