diff --git a/claims/linking/insertClaim/insertClaim.component.ts b/claims/linking/insertClaim/insertClaim.component.ts index 17c920ba..a8c113b1 100644 --- a/claims/linking/insertClaim/insertClaim.component.ts +++ b/claims/linking/insertClaim/insertClaim.component.ts @@ -1,5 +1,5 @@ -import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; -import {Router, ActivatedRoute} from '@angular/router'; +import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; import {ClaimsService} from '../../claim-utils/service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; import {AlertModal} from '../../../utils/modal/alert'; @@ -63,6 +63,7 @@ export class ClaimInsertComponent { private userManagementService: UserManagementService, private _logService: LogService) { } subscriptions = []; + timerSubscription; ngOnDestroy() { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { @@ -88,13 +89,12 @@ export class ClaimInsertComponent { }) ).subscribe(); this.subscriptions.push(loadingTimerSubscription); - - let timerSubscription = timer(0, 10000).pipe( + this.timerSubscription = timer(0, 10000).pipe( map(() => { this.getStatus(); // load data contains the http request }) ).subscribe(); - this.subscriptions.push(timerSubscription); + this.subscriptions.push(this.timerSubscription); }else{ this.claimsJob = null; } @@ -274,12 +274,12 @@ export class ClaimInsertComponent { } } this.saveLocalStorage(); - let timerSubscription = timer(0, 10000).pipe( + this.timerSubscription = timer(0, 10000).pipe( map(() => { this.getStatus(); // load data contains the http request }) ).subscribe(); - this.subscriptions.push(timerSubscription); + this.subscriptions.push(this.timerSubscription); }, err => { err = err && err.error?err.error:err; @@ -599,11 +599,10 @@ export class ClaimInsertComponent { } getStatus(){ - if(this.feedRecordsJob && ! (this.feedRecordsJob.status == "COMPLETE" || this.feedRecordsJob.status == "ERROR") ) { - this.subscriptions.push(this.claimService.getStatus(this.feedRecordsJob.id, this.properties.claimsAPIURL).subscribe(data => { + if(this.feedRecordsJob && ! (this.feedRecordsJob.status == "COMPLETE" || this.feedRecordsJob.status == "FAILED") ) { + this.subscriptions.push(this.claimService.getStatus(this.feedRecordsJob.id, this.properties.claimsAPIURL).subscribe(data => { this.feedRecordsJob = data.data; - // console.log("feed", this.feedRecordsJob.status); - if (this.feedRecordsJob.status == "COMPLETE" || data.data.status == "ERROR") { + if (this.feedRecordsJob.status == "COMPLETE" || this.feedRecordsJob.status == "FAILED") { this.insertedRecords = this.feedRecordsJob.insertedIds; this.errorInRecords = this.feedRecordsJob.errorInClaims; } @@ -622,8 +621,8 @@ export class ClaimInsertComponent { if(this.claimsJob) { this.subscriptions.push(this.claimService.getStatus(this.claimsJob.id, this.properties.claimsAPIURL).subscribe(data => { this.claimsJob = data.data; - // console.log("claim: ", this.claimsJob.status, this.feedRecordsJob.status?this.feedRecordsJob.status:" no feed job"); - if ((this.claimsJob.status == "COMPLETE" || data.data.status == "ERROR") && ( !this.feedRecordsJob || (this.feedRecordsJob.status == "COMPLETE" || data.data.status == "ERROR")) ) { + if ((this.claimsJob.status == "COMPLETE" || this.claimsJob.status == "FAILED") && + ( !this.feedRecordsJob || (this.feedRecordsJob.status == "COMPLETE" || data.data.status == "FAILED"))) { this.insertedClaims = this.claimsJob.insertedIds; this.errorInClaims = this.claimsJob.errorInClaims; @@ -636,7 +635,7 @@ export class ClaimInsertComponent { this.errors.push(error); } this.afterclaimsInsertion(); - + this.timerSubscription.unsubscribe(); } }, err => {