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 Netslice-packagesAction Component
21 import { Component, Injector } from '@angular/core';
22 import { Router } from '@angular/router';
23 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
24 import { MODALCLOSERESPONSEDATA } from 'CommonModel';
25 import { DeleteComponent } from 'DeleteComponent';
26 import { InstantiateNetSliceTemplateComponent } from 'InstantiateNetSliceTemplate';
27 import { NetworkSliceData } from 'NetworkSliceModel';
28 import { SharedService } from 'SharedService';
29 import { ShowInfoComponent } from 'ShowInfoComponent';
33 * @Component takes NetslicePackagesActionComponent.html as template url
36 selector: 'app-netslice-packages-action',
37 templateUrl: './NetslicePackagesActionComponent.html',
38 styleUrls: ['./NetslicePackagesActionComponent.scss']
40 /** Exporting a class @exports NetslicePackagesActionComponent */
41 export class NetslicePackagesActionComponent {
42 /** To get the value from the vnfpackage via valuePrepareFunction default Property of ng-smarttable @public */
43 public value: NetworkSliceData;
45 /** To inject services @public */
46 public injector: Injector;
48 /** Instance of the modal service @private */
49 private modalService: NgbModal;
51 /** Contains instance ID @private */
52 private instanceID: string;
54 /** Service holds the router information @private */
55 private router: Router;
57 /** Contains all methods related to shared @private */
58 private sharedService: SharedService;
60 constructor(injector: Injector) {
61 this.injector = injector;
62 this.modalService = this.injector.get(NgbModal);
63 this.router = this.injector.get(Router);
64 this.sharedService = this.injector.get(SharedService);
67 /** Lifecyle Hooks the trigger before component is instantiate @public */
68 public ngOnInit(): void {
69 this.instanceID = this.value.identifier;
72 /** Delete NetSliceTemplate packages @public */
73 public deleteNetSliceTemplate(): void {
74 // eslint-disable-next-line security/detect-non-literal-fs-filename
75 const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, {backdrop: 'static'});
76 modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
78 this.sharedService.callData();
80 }).catch((): void => {
81 // Catch Navigation Error
85 /** Shows information using modalservice @public */
86 public infoNetSlice(): void {
87 // eslint-disable-next-line security/detect-non-literal-fs-filename
88 this.modalService.open(ShowInfoComponent, { backdrop: 'static' }).componentInstance.params = {
90 page: 'net-slice-package',
91 titleName: 'PAGE.NETSLICETEMPLATE.NETSLICETEMPLATEDETAILS'
95 /** Set Edit for the @public */
96 public netSliceEdit(): void {
97 this.router.navigate(['/packages/netslice/edit/', this.instanceID]).catch(() => {
98 // Catch Navigation Error
102 /** Instantiate Net Slice using modalservice @public */
103 public instantiateNetSlice(): void {
104 // eslint-disable-next-line security/detect-non-literal-fs-filename
105 this.modalService.open(InstantiateNetSliceTemplateComponent, { backdrop: 'static' });