| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame^] | 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 InstancesAction 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 { NSTInstanceData } from 'NetworkSliceModel'; |
| 27 | import { SharedService } from 'SharedService'; |
| 28 | import { ShowInfoComponent } from 'ShowInfoComponent'; |
| 29 | /** |
| 30 | * Creating component |
| 31 | * @Component takes NetsliceInstancesActionComponent.html as template url |
| 32 | */ |
| 33 | @Component({ |
| 34 | templateUrl: './NetsliceInstancesActionComponent.html', |
| 35 | styleUrls: ['./NetsliceInstancesActionComponent.scss'] |
| 36 | }) |
| 37 | /** Exporting a class @exports NetsliceInstancesActionComponent */ |
| 38 | export class NetsliceInstancesActionComponent { |
| 39 | /** To get the value from the vnfpackage via valuePrepareFunction default Property of ng-smarttable @public */ |
| 40 | public value: NSTInstanceData; |
| 41 | |
| 42 | /** To inject services @public */ |
| 43 | public injector: Injector; |
| 44 | |
| 45 | /** Instance of the modal service @private */ |
| 46 | private modalService: NgbModal; |
| 47 | |
| 48 | /** Contains instance ID @private */ |
| 49 | private instanceID: string; |
| 50 | |
| 51 | /** Service holds the router information @private */ |
| 52 | private router: Router; |
| 53 | |
| 54 | /** Contains all methods related to shared @private */ |
| 55 | private sharedService: SharedService; |
| 56 | |
| 57 | constructor(injector: Injector) { |
| 58 | this.injector = injector; |
| 59 | this.modalService = this.injector.get(NgbModal); |
| 60 | this.router = this.injector.get(Router); |
| 61 | this.sharedService = this.injector.get(SharedService); |
| 62 | } |
| 63 | /** |
| 64 | * Lifecyle Hooks the trigger before component is instantiate |
| 65 | */ |
| 66 | public ngOnInit(): void { |
| 67 | this.instanceID = this.value.identifier; |
| 68 | } |
| 69 | |
| 70 | /** Shows information using modalservice @public */ |
| 71 | public infoNetSliceInstance(): void { |
| 72 | this.modalService.open(ShowInfoComponent, { backdrop: 'static' }).componentInstance.params = { |
| 73 | id: this.instanceID, |
| 74 | page: 'net-slice-instance', |
| 75 | titleName: 'PAGE.NETSLICETEMPLATE.NETSLICETEMPLATEDETAILS' |
| 76 | }; |
| 77 | } |
| 78 | |
| 79 | /** Delete NetSlice Instance packages @public */ |
| 80 | public deleteNetSliceInstance(forceAction: boolean): void { |
| 81 | const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); |
| 82 | modalRef.componentInstance.params = {forceDeleteType: forceAction}; |
| 83 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 84 | if (result) { |
| 85 | this.sharedService.callData(); |
| 86 | } |
| 87 | }).catch(); |
| 88 | } |
| 89 | /** History of operations for an Instanace @public */ |
| 90 | public historyOfOperations(): void { |
| 91 | this.router.navigate(['/instances/netslice/history-operations/', this.instanceID]).catch(() => { |
| 92 | // Catch Navigation Error |
| 93 | }); |
| 94 | } |
| 95 | } |