From 897c4b711252ac4bdc8301458005ec0786a5bd09 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 17 Jul 2018 16:05:00 +0530 Subject: unsubscribed from observables Unsubscribed from observables in ngOndestroy method of myvnfs component. This will release the resources held by the subscription. Issue-ID: APPC-1049 Change-Id: I7cc7bd5aabeeb20934332541b99314a611d66f93 Signed-off-by: Arundathi Patil --- src/app/vnfs/myvnfs/myvnfs.component.ts | 43 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/app/vnfs/myvnfs/myvnfs.component.ts b/src/app/vnfs/myvnfs/myvnfs.component.ts index c747a7e..1a27135 100644 --- a/src/app/vnfs/myvnfs/myvnfs.component.ts +++ b/src/app/vnfs/myvnfs/myvnfs.component.ts @@ -21,9 +21,10 @@ limitations under the License. ============LICENSE_END============================================ */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { HttpUtilService } from '../../shared/services/httpUtil/http-util.service'; +import { Subscription } from 'rxjs/Subscription'; import { MappingEditorService } from '../../shared/services/mapping-editor.service'; import { ParamShareService } from '../../shared/services/paramShare.service'; import { environment } from '../../../environments/environment'; @@ -32,7 +33,7 @@ import { NgProgress } from 'ngx-progressbar'; import { NotificationsService } from 'angular2-notifications'; @Component({ selector: 'app-myvnfs', templateUrl: './myvnfs.component.html', styleUrls: ['./myvnfs.component.css'] }) -export class MyvnfsComponent implements OnInit { +export class MyvnfsComponent implements OnInit, OnDestroy { vnfData: Array = []; sortOrder = false; noData = true; @@ -42,15 +43,16 @@ export class MyvnfsComponent implements OnInit { vnfType: any; vnfcType: any; options = { - timeOut: 1000, - showProgressBar: true, - pauseOnHover: true, - clickToClose: true, - maxLength: 200 + timeOut: 1000, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 200 } + subscription: Subscription; - constructor (private paramShareService: ParamShareService, private ngProgress: NgProgress, private httpUtil: HttpUtilService, private router: Router, private activeROute: ActivatedRoute, - private mappingEditorService: MappingEditorService, private modalService: NgbModal,private nService: NotificationsService) { + constructor(private paramShareService: ParamShareService, private ngProgress: NgProgress, private httpUtil: HttpUtilService, private router: Router, private activeROute: ActivatedRoute, + private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService) { } ngOnInit() { @@ -76,14 +78,18 @@ export class MyvnfsComponent implements OnInit { this.clearCache(); } + ngOnDestroy() { + if (this.subscription) { this.subscription.unsubscribe() }; + } + getArtifacts(data) { this.ngProgress.start(); - this.httpUtil.post({ + this.subscription = this.httpUtil.post({ url: environment.getDesigns, data: data }) .subscribe(resp => { - console.log("resp:",resp); + console.log("resp:", resp); const tempObj = JSON.parse(resp.output.data.block); this.vnfData = tempObj.designInfo; if (this.vnfData == undefined || this.vnfData == null || this.vnfData.length == 0) { @@ -96,13 +102,14 @@ export class MyvnfsComponent implements OnInit { console.log(this.noData); this.ngProgress.done(); } - , - error => { - - this.nService.error("Error", "Error in connecting to APPC Server")} - - ); - + , + error => { + + this.nService.error("Error", "Error in connecting to APPC Server") + } + + ); + this.filter = ['vnf-type', 'vnfc-type', 'artifact-name']; setTimeout(() => { this.ngProgress.done(); -- cgit 1.2.3-korg