Fix Bug 2121: NG-UI uses unmaintained Chokidar version
[osm/NG-UI.git] / src / app / utilities / netslice-packages-action / NetslicePackagesActionComponent.ts
1 /*
2  Copyright 2020 TATA ELXSI
3
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
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
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.
15
16  Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
17 */
18 /**
19  * @file Netslice-packagesAction Component
20  */
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';
30
31 /**
32  * Creating component
33  * @Component takes NetslicePackagesActionComponent.html as template url
34  */
35 @Component({
36     selector: 'app-netslice-packages-action',
37     templateUrl: './NetslicePackagesActionComponent.html',
38     styleUrls: ['./NetslicePackagesActionComponent.scss']
39 })
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;
44
45     /** To inject services @public */
46     public injector: Injector;
47
48     /** Instance of the modal service @private */
49     private modalService: NgbModal;
50
51     /** Contains instance ID @private */
52     private instanceID: string;
53
54     /** Service holds the router information @private */
55     private router: Router;
56
57     /** Contains all methods related to shared @private */
58     private sharedService: SharedService;
59
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);
65     }
66
67     /** Lifecyle Hooks the trigger before component is instantiate @public */
68     public ngOnInit(): void {
69         this.instanceID = this.value.identifier;
70     }
71
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) => {
77             if (result) {
78                 this.sharedService.callData();
79             }
80         }).catch((): void => {
81             // Catch Navigation Error
82         });
83     }
84
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 = {
89             id: this.instanceID,
90             page: 'net-slice-package',
91             titleName: 'PAGE.NETSLICETEMPLATE.NETSLICETEMPLATEDETAILS'
92         };
93     }
94
95     /** Set Edit for the  @public */
96     public netSliceEdit(): void {
97         this.router.navigate(['/packages/netslice/edit/', this.instanceID]).catch(() => {
98             // Catch Navigation Error
99         });
100     }
101
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' });
106     }
107 }