From 6ba50cc051029760770442206b9c56b70c198bb9 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 27 Jul 2018 16:03:14 +0530 Subject: [PATCH] Template-configration-unsubscribed from observable Unsubscribed from subscription in template-configuration component. This will release any resources that the subscription holds when the component is destroyed. Issue-ID: APPC-1049 Change-Id: Icbf3575e034a693f7357782826690d079945faa7 Signed-off-by: Arundathi Patil --- .../template-configuration.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts index a3d55ba..6cae746 100644 --- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts @@ -23,6 +23,7 @@ limitations under the License. */ import { Component, Input, OnInit, ViewChild } from '@angular/core'; +import { Subscription } from 'rxjs/Subscription'; import { HttpUtilService } from '../../../../shared/services/httpUtil/http-util.service'; import { MappingEditorService } from '../../../../shared/services/mapping-editor.service'; import { ArtifactRequest } from '../../../../shared/models/index'; @@ -59,7 +60,8 @@ export class GoldenConfigurationComponent implements OnInit { initialAction: any; public referenceData: Array = []; public scopeName: any; - public subscription: any; + public subscription: Subscription; + public templateSubscription : Subscription; public item: any = {}; public goldenActions: Array = []; public refNameObj = {}; @@ -173,7 +175,7 @@ export class GoldenConfigurationComponent implements OnInit { this.item = { "action": "", "scope": { "vnf-type": "", "vnfc-type": "" }, "vm": [], "protocol": "", "download-dg-reference": "", "user-name": "", "port-number": "", "artifact-list": [], "deviceTemplate": "", "scopeType": "" }; } this.initialAction = this.item.action; - this.activeRoutes.url.subscribe(UrlSegment => { + this.subscription = this.activeRoutes.url.subscribe(UrlSegment => { this.actionType = UrlSegment[0].path }) this.mappingEditorService.fromScreen = 'MappingScreen'; @@ -190,6 +192,9 @@ export class GoldenConfigurationComponent implements OnInit { this.mappingEditorService.changeNavDownloadData(this.downloadDataObject); } } + + if(this.subscription) { this.subscription.unsubscribe(); } + if(this.templateSubscription) { this.templateSubscription.unsubscribe(); } } //========================== End of ngOnDestroy() Method============================================ ngAfterViewInit() { @@ -299,7 +304,7 @@ export class GoldenConfigurationComponent implements OnInit { let input = this.utilityService.createPayloadForRetrieve(false, this.item.action, this.vnfType, fileName); let artifactContent: any; this.ngProgress.start(); - this.httpUtil.post({ + this.templateSubscription = this.httpUtil.post({ url: environment.getDesigns, data: input }).subscribe(resp => { -- 2.16.6