From: Barath Kumar R Date: Fri, 9 Apr 2021 14:46:00 +0000 (+0530) Subject: The NS/VNF package content will shown X-Git-Tag: branch-sol006v331-start~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a22c8631bb481d0bfcf39d72630d57a5846d20ff;p=osm%2FNG-UI.git The NS/VNF package content will shown * Clicking on the content will show the content of packages Change-Id: Ib54437993915171f44acdbc1edb5ea475767afa8 Signed-off-by: Barath Kumar R --- diff --git a/src/app/packages/show-content/ShowContentComponent.html b/src/app/packages/show-content/ShowContentComponent.html index dbb0935..a4c5139 100644 --- a/src/app/packages/show-content/ShowContentComponent.html +++ b/src/app/packages/show-content/ShowContentComponent.html @@ -23,22 +23,17 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i \ No newline at end of file + + \ No newline at end of file diff --git a/src/app/packages/show-content/ShowContentComponent.ts b/src/app/packages/show-content/ShowContentComponent.ts index e2431e8..3b34a42 100644 --- a/src/app/packages/show-content/ShowContentComponent.ts +++ b/src/app/packages/show-content/ShowContentComponent.ts @@ -18,10 +18,12 @@ /** * @file Show content modal */ +import { HttpHeaders } from '@angular/common/http'; import { Component, Injector, Input, OnInit } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { ERRORDATA, URLPARAMS } from 'CommonModel'; +import { ERRORDATA, GETAPIURLHEADER, URLPARAMS } from 'CommonModel'; import { environment } from 'environment'; +import * as jsyaml from 'js-yaml'; import { RestService } from 'RestService'; /** Shows json data in the information modal */ @@ -41,6 +43,9 @@ export class ShowContentComponent implements OnInit { /** To inject services @public */ public injector: Injector; + /** Check the loading results @public */ + public isLoadingResults: boolean = false; + /** Instance for active modal service @public */ public activeModal: NgbActiveModal; @@ -53,6 +58,9 @@ export class ShowContentComponent implements OnInit { /** Instance of the rest service @private */ private restService: RestService; + /** Controls the header form @private */ + private headers: HttpHeaders; + constructor(injector: Injector) { this.injector = injector; this.restService = this.injector.get(RestService); @@ -63,20 +71,31 @@ export class ShowContentComponent implements OnInit { * Lifecyle Hooks the trigger before component is instantiate @public */ public ngOnInit(): void { + this.headers = new HttpHeaders({ + 'Content-Type': 'application/json', + Accept: 'text/plain', + 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0' + }); if (this.params.page === 'nsd') { - this.restService.getResource(environment.NSDESCRIPTORS_URL + '/' + this.params.id + '/artifacts/artifactPath') - .subscribe((nsd: {}[]) => { - this.contents = nsd; - }, (error: ERRORDATA) => { - this.restService.handleError(error, 'get'); - }); + this.getContent(environment.NSDESCRIPTORS_URL + '/' + this.params.id + '/artifacts'); } else if (this.params.page === 'vnfd') { - this.restService.getResource(environment.VNFPACKAGES_URL + '/' + this.params.id + '/artifacts/artifactPath') - .subscribe((vnfd: {}[]) => { - this.contents = vnfd; - }, (error: ERRORDATA) => { - this.restService.handleError(error, 'get'); - }); + this.getContent(environment.VNFPACKAGES_URL + '/' + this.params.id + '/artifacts'); } } + /** Get the NSD Content List @public */ + public getContent(URL: string): void { + this.isLoadingResults = true; + const httpOptions: GETAPIURLHEADER = { + headers: this.headers, + responseType: 'text' + }; + this.restService.getResource(URL, httpOptions).subscribe((content: {}[]): void => { + const getJson: string[] = jsyaml.load(content.toString(), { json: true }); + this.contents = getJson; + this.isLoadingResults = false; + }, (error: ERRORDATA): void => { + this.restService.handleError(error, 'get'); + this.isLoadingResults = false; + }); + } }