| SANDHYA.JS | 07decc0 | 2024-07-01 21:50:48 +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: SANDHYA JS (sandhya.j@tataelxsi.co.in) |
| 17 | */ |
| 18 | /** |
| 19 | * @file NSConfigTemplateAction Component |
| 20 | */ |
| 21 | import { Component, Injector } from '@angular/core'; |
| 22 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; |
| 23 | import { MODALCLOSERESPONSEDATA } from 'CommonModel'; |
| 24 | import { ComposePackages } from 'ComposePackages'; |
| 25 | import { DeleteComponent } from 'DeleteComponent'; |
| 26 | import { NSConfigData } from 'NSCONFIGTEMPLATEMODEL'; |
| 27 | import { SharedService } from 'SharedService'; |
| 28 | |
| 29 | /** |
| 30 | * Creating component |
| 31 | * @Component takes NSConfigTemplateActionComponent.html as template url |
| 32 | */ |
| 33 | @Component({ |
| 34 | templateUrl: './NSConfigTemplateActionComponent.html', |
| 35 | styleUrls: ['./NSConfigTemplateActionComponent.scss'] |
| 36 | }) |
| 37 | /** Exporting a class @exports NSConfigTemplateActionComponent */ |
| 38 | export class NSConfigTemplateActionComponent { |
| 39 | /** To get the value from the vnfpackage via valuePrepareFunction default Property of ng-smarttable @public */ |
| 40 | public value: NSConfigData; |
| 41 | |
| 42 | /** To inject services @public */ |
| 43 | public injector: Injector; |
| 44 | |
| 45 | /** Check the loading results for loader status @public */ |
| 46 | public isLoadingDownloadResult: boolean = false; |
| 47 | |
| 48 | /** Give the message for the loading @public */ |
| 49 | public message: string = 'PLEASEWAIT'; |
| 50 | |
| 51 | /** Instance of the modal service @private */ |
| 52 | private modalService: NgbModal; |
| 53 | |
| 54 | /** Variables holds Template ID @private */ |
| 55 | private templateID: string; |
| 56 | |
| 57 | /** Contains all methods related to shared @private */ |
| 58 | private sharedService: SharedService; |
| 59 | |
| 60 | constructor(injector: Injector) { |
| 61 | this.injector = injector; |
| 62 | this.sharedService = this.injector.get(SharedService); |
| 63 | this.modalService = this.injector.get(NgbModal); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Lifecyle Hooks the trigger before component is instantiate |
| 68 | */ |
| 69 | public ngOnInit(): void { |
| 70 | this.templateID = this.value.identifier; |
| 71 | } |
| 72 | |
| 73 | /** Delete NS Config template @public */ |
| 74 | public deleteTemplate(): void { |
| 75 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| 76 | const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); |
| 77 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 78 | if (result) { |
| 79 | this.sharedService.callData(); |
| 80 | } |
| 81 | }).catch((): void => { |
| 82 | // Catch Navigation Error |
| 83 | }); |
| 84 | } |
| 85 | |
| 86 | /** Set instance for Template Edit @public */ |
| 87 | public templateEdit(): void { |
| 88 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| 89 | const modalRef: NgbModalRef = this.modalService.open(ComposePackages, { backdrop: 'static' }); |
| 90 | modalRef.componentInstance.params = {id: this.templateID, page: 'ns-config-template-edit'}; |
| 91 | modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { |
| 92 | if (result) { |
| 93 | this.sharedService.callData(); |
| 94 | } |
| 95 | }).catch((): void => { |
| 96 | // Catch Navigation Error |
| 97 | }); |
| 98 | } |
| 99 | } |