2 Copyright 2020 TATA ELXSI
4 Licensed under the Apache License, Version 2.0 (the 'License');
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
19 * @file Show content modal
21 import { Component, Injector, Input, OnInit } from '@angular/core';
22 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
23 import { ERRORDATA, URLPARAMS } from 'CommonModel';
24 import { environment } from 'environment';
25 import { RestService } from 'RestService';
27 /** Shows json data in the information modal */
28 const defaults: {} = { 'text/json': '' };
32 * @Component takes ShowContentComponent.html as template url
35 selector: 'app-show-content',
36 templateUrl: './ShowContentComponent.html',
37 styleUrls: ['./ShowContentComponent.scss']
39 /** Exporting a class @exports ShowContentComponent */
40 export class ShowContentComponent implements OnInit {
41 /** To inject services @public */
42 public injector: Injector;
44 /** Instance for active modal service @public */
45 public activeModal: NgbActiveModal;
47 /** Contains files information @public */
48 public contents: {}[];
50 /** Input contains component objects @public */
51 @Input() public params: URLPARAMS;
53 /** Instance of the rest service @private */
54 private restService: RestService;
56 constructor(injector: Injector) {
57 this.injector = injector;
58 this.restService = this.injector.get(RestService);
59 this.activeModal = this.injector.get(NgbActiveModal);
63 * Lifecyle Hooks the trigger before component is instantiate @public
65 public ngOnInit(): void {
66 if (this.params.page === 'nsd') {
67 this.restService.getResource(environment.NSDESCRIPTORS_URL + '/' + this.params.id + '/artifacts/artifactPath')
68 .subscribe((nsd: {}[]) => {
70 }, (error: ERRORDATA) => {
71 this.restService.handleError(error, 'get');
73 } else if (this.params.page === 'vnfd') {
74 this.restService.getResource(environment.VNFPACKAGES_URL + '/' + this.params.id + '/artifacts/artifactPath')
75 .subscribe((vnfd: {}[]) => {
77 }, (error: ERRORDATA) => {
78 this.restService.handleError(error, 'get');