@@ -6,6 +6,7 @@ import {MonitorDeploymentService} from "@app/core/services/monitor-deployment.se
66import { DeploymentWorkflowExecutionService } from "@app/core/services/workflow-execution.service" ;
77import {
88 ApplicationDeploymentService ,
9+ ApplicationEnvironmentService ,
910 DeploymentStatus ,
1011 MonitoredDeploymentDTO ,
1112 WorkflowExecutionDTO ,
@@ -50,6 +51,7 @@ export class ActiveDeploymentComponent extends WizardFormComponent implements On
5051 private monitorDeploymentService : MonitorDeploymentService ,
5152 private deploymentWorkflowExecutionService : DeploymentWorkflowExecutionService ,
5253 private applicationDeploymentService : ApplicationDeploymentService ,
54+ private applicationEnvironmentService : ApplicationEnvironmentService ,
5355 private websocketService : WebsocketSubscriptionManager ,
5456 private dialog : MatDialog ,
5557 private runtimeService : RuntimeService ,
@@ -78,12 +80,6 @@ export class ActiveDeploymentComponent extends WizardFormComponent implements On
7880 }
7981 ) ;
8082
81- if ( this . fsmContext . deploymentStatus && DeploymentStatus . isPendingStatus ( this . fsmContext . deploymentStatus ) ) {
82- this . fsmContext . progessBarData = new ProgessBarData ( ) ;
83- this . fsmContext . progessBarData . workflowInProgress = true ;
84- this . monitorWorkflow ( ) ;
85- }
86-
8783 // we filter workflows that have steps and exclude install and uninstall
8884 for ( const [ key , wf ] of Object . entries ( this . fsmContext . deploymentTopology . topology . workflows ) ) {
8985 console . log ( `Workflow ${ key } : ${ wf . name } ` ) ;
@@ -99,6 +95,14 @@ export class ActiveDeploymentComponent extends WizardFormComponent implements On
9995
10096 this . getDeployedTopology ( ) ;
10197 this . getInstanceInformation ( ) ;
98+
99+ // sometimes the status has changed before the subscription to ws channel has been subscribed. In such case, just query the status.
100+ if ( ! this . detectPendingDeploymentStatusChanged ( ) ) {
101+ this . applicationEnvironmentService . getApplicationEnvironmentStatus ( this . fsmContext . application . id , this . fsmContext . environment . id ) . subscribe ( status => {
102+ this . fsmContext . deploymentStatus = status ;
103+ this . detectPendingDeploymentStatusChanged ( ) ;
104+ } ) ;
105+ }
102106 }
103107
104108 ngOnDestroy ( ) : void {
@@ -109,9 +113,21 @@ export class ActiveDeploymentComponent extends WizardFormComponent implements On
109113 this . wsSubscription . unsubscribe ( ) ;
110114 }
111115
116+ private detectPendingDeploymentStatusChanged ( ) : boolean {
117+ if ( this . fsmContext . deploymentStatus && DeploymentStatus . isPendingStatus ( this . fsmContext . deploymentStatus ) ) {
118+ this . fsmContext . progessBarData = new ProgessBarData ( ) ;
119+ this . fsmContext . progessBarData . workflowInProgress = true ;
120+ this . monitorWorkflow ( ) ;
121+ return true ;
122+ } else {
123+ return false ;
124+ }
125+ }
126+
112127 private monitorWorkflow ( ) {
113128 if ( ! this . workflowMonitoringSubscription || this . workflowMonitoringSubscription . closed ) {
114129 this . monitorDeploymentService . getMonitoredDeploymentDTO ( this . fsmContext . application . id , this . fsmContext . environment . id ) . subscribe ( e => {
130+ console . log ( e ) ;
115131 console . log ( "deploymentID is : " + e . deployment . id ) ;
116132 let deploymentId = e . deployment . id ;
117133 console . log ( "Motitored deployement: " , JSON . stringify ( e ) ) ;
0 commit comments