11import { HttpResponse } from '@angular/common/http' ;
2- import { Component , Input , OnDestroy , OnInit } from '@angular/core' ;
2+ import { Component , Input , OnDestroy , OnInit , ChangeDetectorRef } from '@angular/core' ;
33import { UtmToastService } from '../../../../../shared/alert/utm-toast.service' ;
44import { LOG_INDEX_PATTERN , SOC_AI_INDEX_PATTERN } from '../../../../../shared/constants/main-index-pattern.constant' ;
55import { ElasticOperatorsEnum } from '../../../../../shared/enums/elastic-operators.enum' ;
@@ -26,6 +26,7 @@ export class AlertSocAiComponent implements OnInit, OnDestroy {
2626
2727 constructor ( private elasticDataService : ElasticDataService ,
2828 private alertSocAiService : AlertSocAiService ,
29+ private cdt :ChangeDetectorRef ,
2930 private utmToastService : UtmToastService ) { }
3031
3132 ngOnInit ( ) {
@@ -36,6 +37,7 @@ export class AlertSocAiComponent implements OnInit, OnDestroy {
3637
3738 getSocAiResponse ( ) {
3839 this . loading = true ;
40+ this . cdt . markForCheck ( )
3941 const filter : ElasticFilterType [ ] = [ {
4042 field : 'activityId' ,
4143 operator : ElasticOperatorsEnum . IS ,
@@ -44,6 +46,7 @@ export class AlertSocAiComponent implements OnInit, OnDestroy {
4446 this . elasticDataService . search ( 1 , 1 , 1 , SOC_AI_INDEX_PATTERN , filter )
4547 . subscribe ( ( res : HttpResponse < any > ) => {
4648 this . loading = false ;
49+ this . cdt . markForCheck ( )
4750 if ( ! res || res . body . length === 0 ) {
4851 this . socAiResponse = res . body ;
4952 } else {
@@ -60,8 +63,9 @@ export class AlertSocAiComponent implements OnInit, OnDestroy {
6063 }
6164 }
6265 } ,
63- ( res : HttpResponse < any > ) => {
66+ ( _res : HttpResponse < any > ) => {
6467 this . loading = false ;
68+ this . cdt . markForCheck ( )
6569 }
6670 ) ;
6771 }
@@ -83,15 +87,17 @@ export class AlertSocAiComponent implements OnInit, OnDestroy {
8387 }
8488
8589 this . loadingProcess = true ;
90+ this . cdt . markForCheck ( )
8691 this . alertSocAiService . analyzeAlert ( this . alert )
8792 . subscribe ( ( res ) => {
8893 this . utmToastService . showSuccessBottom ( 'Alert submitted for SOC-AI analysis' ) ;
8994 setTimeout ( ( ) => {
9095 this . loadingProcess = false ;
96+ this . cdt . markForCheck ( )
9197 this . getSocAiResponse ( ) ;
9298 } , 3000 ) ;
9399 } ,
94- ( error ) => {
100+ ( _error ) => {
95101 this . utmToastService . showError ( 'Error' , 'An error occurred while processing the alert. Please try again later.' ) ;
96102 this . loadingProcess = false ;
97103 } ) ;
0 commit comments