From 99570c5a235b60989100ba9d0fbce630797164e6 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 18 Jul 2018 16:49:11 +0530 Subject: Unsubscribed observables Unsubscribed from observables in param-name-value component. This will release any resources that the subscription holds. Issue-ID: APPC-1049 Change-Id: Ie3aa18bfa9d5129a26abb2f33dd2f80e1cfc8bba Signed-off-by: Arundathi Patil --- .../param-name-value/param-name-value.component.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts index e49140d..bdf0b29 100644 --- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts @@ -3,7 +3,7 @@ =================================================================== Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. =================================================================== -Copyright (C) 2018 IBM. +Copyright (C) 2018 IBM Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -23,8 +23,9 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import { Component, ContentChildren, OnInit, QueryList, ViewChild } from '@angular/core'; +import { Component, ContentChildren, OnInit, QueryList, ViewChild, OnDestroy } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs/Subscription'; import { MappingEditorService } from '../../../../shared/services/mapping-editor.service'; import { HttpUtilService } from '../../../../shared/services/httpUtil/http-util.service'; import { GoldenConfigurationComponent } from '../template-configuration/template-configuration.component'; @@ -50,7 +51,7 @@ declare var $: any; templateUrl: './param-name-value.component.html', styleUrls: ['./param-name-value.component.css'] }) -export class GoldenConfigurationMappingComponent implements OnInit { +export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { enableMappingSave: boolean = false; aceText: string = ''; fileName: string = ''; @@ -99,13 +100,14 @@ export class GoldenConfigurationMappingComponent implements OnInit { @ViewChild('myInputParam') myInputParam: any; @ViewChild(ModalComponent) modalComponent: ModalComponent; @ContentChildren(Tab) tabs: QueryList; - public subscription: any; + public subscription: Subscription; public item: any = {}; vnfType: any = ''; vnfcType: any = ''; protocol: any = ''; refObj: any; public paramsContent = localStorage['paramsContent']; + nameValueSubscription: Subscription; constructor( private buildDesignComponent: BuildDesignComponent, @@ -167,7 +169,7 @@ export class GoldenConfigurationMappingComponent implements OnInit { }; } this.initialAction = this.item.action; - this.activeRoutes.url.subscribe(UrlSegment => { + this.subscription = this.activeRoutes.url.subscribe(UrlSegment => { this.actionType = UrlSegment[0].path; }); @@ -189,6 +191,8 @@ export class GoldenConfigurationMappingComponent implements OnInit { ngOnDestroy() { this.prepareFileName(); + if( this.subscription ) { this.subscription.unsubscribe(); } + if( this.nameValueSubscription ) { this.nameValueSubscription.unsubscribe(); } } //========================== End of ngOnDestroy() Method============================================ @@ -329,7 +333,7 @@ export class GoldenConfigurationMappingComponent implements OnInit { console.log('Retrieve name value from appc payload===>>' + payload); let artifactContent: any; this.ngProgress.start(); - this.httpUtil.post({ + this.nameValueSubscription = this.httpUtil.post({ url: environment.getDesigns, data: input }).subscribe(resp => { @@ -481,4 +485,4 @@ export class GoldenConfigurationMappingComponent implements OnInit { } } -} \ No newline at end of file +} -- cgit 1.2.3-korg