Template-configration-unsubscribed from observable 13/57813/2
authorArundathi Patil <arundpil@in.ibm.com>
Fri, 27 Jul 2018 10:33:14 +0000 (16:03 +0530)
committerTakamune Cho <tc012c@att.com>
Thu, 9 Aug 2018 12:13:41 +0000 (12:13 +0000)
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 <arundpil@in.ibm.com>
src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts

index a3d55ba..6cae746 100644 (file)
@@ -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<Object> = [];
   public scopeName: any;
-  public subscription: any;
+  public subscription: Subscription;
+  public templateSubscription : Subscription;
   public item: any = {};
   public goldenActions: Array<string> = [];
   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 => {