| 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 SDN Controller Action Component |
| 20 | */ |
| 21 | import { Component, Injector } from '@angular/core'; |
| 22 | import { Router } from '@angular/router'; |
| 23 | import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; |
| 24 | import { MODALCLOSERESPONSEDATA } from 'CommonModel'; |
| 25 | import { DeleteComponent } from 'DeleteComponent'; |
| 26 | import { SDNControllerInfoComponent } from 'SDNControllerInfoComponent'; |
| 27 | import { SDNControllerList } from 'SDNControllerModel'; |
| 28 | import { SharedService } from 'SharedService'; |
| 29 | |
| 30 | /** |
| 31 | * Creating component |
| 32 | * @Component takes SDNControllerActionComponent.html as template url |
| 33 | */ |
| 34 | @Component({ |
| 35 | templateUrl: './SDNControllerActionComponent.html', |
| 36 | styleUrls: ['./SDNControllerActionComponent.scss'] |
| 37 | }) |
| 38 | /** Exporting a class @exports SDNControllerActionComponent */ |
| 39 | export class SDNControllerActionComponent { |
| 40 | /** To get the value from the vnfpackage via valuePrepareFunction default Property of ng-smarttable @public */ |
| 41 | public value: SDNControllerList; |
| 42 | |
| 43 | /** To inject services @public */ |
| 44 | public injector: Injector; |
| 45 | |
| 46 | /** Instance of the modal service @private */ |
| 47 | private modalService: NgbModal; |
| 48 | |
| 49 | /** Variables holds SDN ID @private */ |
| 50 | private sdnID: string; |
| 51 | |
| 52 | /** Contains all methods related to shared @private */ |
| 53 | private sharedService: SharedService; |
| 54 | |
| 55 | constructor(injector: Injector) { |
| 56 | this.injector = injector; |
| 57 | this.modalService = this.injector.get(NgbModal); |
| 58 | this.sharedService = this.injector.get(SharedService); |
| 59 | } |
| 60 | |
| 61 | /** Lifecyle Hooks the trigger before component is instantiate @public */ |
| 62 | public ngOnInit(): void { |
| 63 | this.sdnID = this.value.identifier; |
| 64 | } |
| 65 | |
| 66 | /** Show SDN Controller Information @public */ |
| 67 | public showSDNControllerInfo(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 68 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 69 | this.modalService.open(SDNControllerInfoComponent, { backdrop: 'static' }).componentInstance.params = { |
| 70 | id: this.sdnID, |
| 71 | page: 'sdn-controller' |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | /** Delete SDN Controller @public */ |
| 76 | public deleteSDNController(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 77 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 78 | const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); |
| 79 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 80 | if (result) { |
| 81 | this.sharedService.callData(); |
| 82 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 83 | }).catch((): void => { |
| 84 | // Catch Navigation Error |
| 85 | }); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 86 | } |
| 87 | } |