1- import { Component , Input , OnDestroy } from '@angular/core' ;
1+ import { Component , Input , OnDestroy , OnInit } from '@angular/core' ;
22import { ScriptDataService } from '../../../../core/data/processes/script-data.service' ;
33import { ContentSource } from '../../../../core/shared/content-source.model' ;
44import { ProcessDataService } from '../../../../core/data/processes/process-data.service' ;
@@ -29,7 +29,7 @@ import { ContentSourceSetSerializer } from '../../../../core/shared/content-sour
2929 styleUrls : [ './collection-source-controls.component.scss' ] ,
3030 templateUrl : './collection-source-controls.component.html' ,
3131} )
32- export class CollectionSourceControlsComponent implements OnDestroy {
32+ export class CollectionSourceControlsComponent implements OnInit , OnDestroy {
3333
3434 /**
3535 * Should the controls be enabled.
@@ -48,6 +48,7 @@ export class CollectionSourceControlsComponent implements OnDestroy {
4848
4949 contentSource$ : Observable < ContentSource > ;
5050 private subs : Subscription [ ] = [ ] ;
51+ private autoRefreshIDs : string [ ] = [ ] ;
5152
5253 testConfigRunning$ = new BehaviorSubject ( false ) ;
5354 importRunning$ = new BehaviorSubject ( false ) ;
@@ -94,7 +95,10 @@ export class CollectionSourceControlsComponent implements OnDestroy {
9495 } ) ,
9596 // filter out responses that aren't successful since the pinging of the process only needs to happen when the invocation was successful.
9697 filter ( ( rd ) => rd . hasSucceeded && hasValue ( rd . payload ) ) ,
97- switchMap ( ( rd ) => this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ) ,
98+ switchMap ( ( rd ) => {
99+ this . autoRefreshIDs . push ( rd . payload . processId ) ;
100+ return this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ;
101+ } ) ,
98102 map ( ( rd ) => rd . payload )
99103 ) . subscribe ( ( process : Process ) => {
100104 if ( process . processStatus . toString ( ) === ProcessStatus [ ProcessStatus . FAILED ] . toString ( ) ) {
@@ -135,7 +139,10 @@ export class CollectionSourceControlsComponent implements OnDestroy {
135139 }
136140 } ) ,
137141 filter ( ( rd ) => rd . hasSucceeded && hasValue ( rd . payload ) ) ,
138- switchMap ( ( rd ) => this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ) ,
142+ switchMap ( ( rd ) => {
143+ this . autoRefreshIDs . push ( rd . payload . processId ) ;
144+ return this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ;
145+ } ) ,
139146 map ( ( rd ) => rd . payload )
140147 ) . subscribe ( ( process ) => {
141148 if ( process . processStatus . toString ( ) === ProcessStatus [ ProcessStatus . FAILED ] . toString ( ) ) {
@@ -170,7 +177,10 @@ export class CollectionSourceControlsComponent implements OnDestroy {
170177 }
171178 } ) ,
172179 filter ( ( rd ) => rd . hasSucceeded && hasValue ( rd . payload ) ) ,
173- switchMap ( ( rd ) => this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ) ,
180+ switchMap ( ( rd ) => {
181+ this . autoRefreshIDs . push ( rd . payload . processId ) ;
182+ return this . processDataService . autoRefreshUntilCompletion ( rd . payload . processId ) ;
183+ } ) ,
174184 map ( ( rd ) => rd . payload )
175185 ) . subscribe ( ( process ) => {
176186 if ( process . processStatus . toString ( ) === ProcessStatus [ ProcessStatus . FAILED ] . toString ( ) ) {
@@ -191,5 +201,9 @@ export class CollectionSourceControlsComponent implements OnDestroy {
191201 sub . unsubscribe ( ) ;
192202 }
193203 } ) ;
204+
205+ this . autoRefreshIDs . forEach ( ( id ) => {
206+ this . processDataService . stopAutoRefreshing ( id ) ;
207+ } ) ;
194208 }
195209}
0 commit comments