@@ -16,9 +16,7 @@ import {
1616 ALERT_PROTOCOL_FIELD ,
1717 ALERT_SENSOR_FIELD ,
1818 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
2220} from '../../../../../shared/constants/alert/alert-field.constant' ;
2321import { LOG_ROUTE } from '../../../../../shared/constants/app-routes.constant' ;
2422import { 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
3432import { AlertUpdateTagBehavior } from '../../behavior/alert-update-tag.behavior' ;
3533import { AlertHistoryActionEnum } from '../../enums/alert-history-action.enum' ;
3634import { EventDataTypeEnum } from '../../enums/event-data-type.enum' ;
37- import { AlertManagementService } from '../../services/alert-management.service' ;
3835
3936@Component ( {
4037 selector : 'app-alert-view-detail' ,
@@ -47,6 +44,7 @@ export class AlertViewDetailComponent implements OnInit {
4744 @Input ( ) hideEmptyField = false ;
4845 @Input ( ) dataType : EventDataTypeEnum ;
4946 @Input ( ) tags : AlertTags [ ] ;
47+ @Input ( ) timeFilter : ElasticFilterType ;
5048 @Output ( ) refreshData = new EventEmitter < boolean > ( ) ;
5149 ALERT_NAME = ALERT_NAME_FIELD ;
5250 STATUS_FIELD = ALERT_STATUS_FIELD ;
@@ -77,19 +75,17 @@ export class AlertViewDetailComponent implements OnInit {
7775 hideLastChange = false ;
7876 incidentResponse = false ;
7977
80- constructor ( private alertServiceManagement : AlertManagementService ,
81- private utmToastService : UtmToastService ,
82- private alertUpdateHistoryBehavior : AlertUpdateHistoryBehavior ,
78+ constructor ( private alertUpdateHistoryBehavior : AlertUpdateHistoryBehavior ,
8379 private alertUpdateTagBehavior : AlertUpdateTagBehavior ,
8480 private spinner : NgxSpinnerService ,
8581 private elasticDataService : ElasticDataService ,
8682 private moduleService : UtmModulesService ,
87- private router : Router ) {
83+ private router : Router ,
84+ private toastService : UtmToastService ) {
8885 }
8986
9087 ngOnInit ( ) {
9188 this . viewLog = this . fullScreen ;
92- // @ts -ignore
9389 this . logs = this . alert . logs . reverse ( ) ;
9490 this . countRelatedEvents = this . logs . length ;
9591 const ref = this . alert . reference ;
@@ -155,14 +151,18 @@ export class AlertViewDetailComponent implements OnInit {
155151 searchLastLog ( ) {
156152 if ( ! this . log ) {
157153 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+ ] ;
159158 this . elasticDataService . search ( 1 , 1 ,
160- 1 , LOG_INDEX_PATTERN , filter ) . subscribe (
159+ 1 , LOG_INDEX_PATTERN , filters ) . subscribe (
161160 ( res : HttpResponse < any > ) => {
162- this . log = res . body [ 0 ] ;
161+ this . log = res . body [ 0 ] ? res . body [ 0 ] : { } ;
163162 this . getLastLog = false ;
164163 } ,
165164 ( res : HttpResponse < any > ) => {
165+ this . toastService . showError ( 'Error' , 'An error occurred while trying to retrieve the latest log.' ) ;
166166 }
167167 ) ;
168168 }
@@ -171,6 +171,10 @@ export class AlertViewDetailComponent implements OnInit {
171171 viewLastLog ( ) {
172172 this . searchLastLog ( ) ;
173173 }
174+
175+ isEmptyResponse ( ) {
176+ return Object . entries ( this . log ) . length === 0 ;
177+ }
174178}
175179
176180export enum AlertDetailTabEnum {
0 commit comments