blob: 37ae771d298123b5eee0c17ab9febc2d9e59c6e6 [file] [log] [blame]
SANDHYA.JS26570112024-07-05 21:35:46 +05301/*
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 okapackageAction Component
20 */
21import { Component, Injector } from '@angular/core';
22import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
23import { MODALCLOSERESPONSEDATA } from 'CommonModel';
24import { ComposePackages } from 'ComposePackages';
25import { DeleteComponent } from 'DeleteComponent';
26import { SharedService } from 'SharedService';
27import { VNFData } from 'VNFDModel';
28
29/**
30 * Creating component
31 * @Component takes OkaPackagesActionComponent.html as template url
32 */
33@Component({
34 templateUrl: './OkaPackagesActionComponent.html',
35 styleUrls: ['./OkaPackagesActionComponent.scss']
36})
37/** Exporting a class @exports OkaPackagesActionComponent */
38export class OkaPackagesActionComponent {
39 /** To get the value from the vnfpackage via valuePrepareFunction default Property of ng-smarttable @public */
40 public value: VNFData;
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 /** Contains state @public */
52 public state: string;
53
54 /** Instance of the modal service @private */
55 private modalService: NgbModal;
56
57 /** Variables holds oka ID @private */
58 private okaID: string;
59
60 /** Contains all methods related to shared @private */
61 private sharedService: SharedService;
62
63 constructor(injector: Injector) {
64 this.injector = injector;
65 this.sharedService = this.injector.get(SharedService);
66 this.modalService = this.injector.get(NgbModal);
67 }
68
69 /**
70 * Lifecyle Hooks the trigger before component is instantiate
71 */
72 public ngOnInit(): void {
73 this.okaID = this.value.identifier;
74 this.state = this.value.state;
75 }
76
77 /** Delete NS Config oka @public */
SANDHYA.JS52af4802025-05-22 17:00:15 +053078 public deleteoka(forceAction: boolean): void {
SANDHYA.JS26570112024-07-05 21:35:46 +053079 // eslint-disable-next-line security/detect-non-literal-fs-filename
80 const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' });
SANDHYA.JS52af4802025-05-22 17:00:15 +053081 modalRef.componentInstance.params = {
82 forceDeleteType: forceAction
83 };
SANDHYA.JS26570112024-07-05 21:35:46 +053084 modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
85 if (result) {
86 this.sharedService.callData();
87 }
88 }).catch((): void => {
89 // Catch Navigation Error
90 });
91 }
92
93 /** Set instance for oka Edit @public */
94 public okaEdit(): void {
95 // eslint-disable-next-line security/detect-non-literal-fs-filename
96 const modalRef: NgbModalRef = this.modalService.open(ComposePackages, { backdrop: 'static' });
SANDHYA.JSa3ff32a2025-02-13 16:24:46 +053097 modalRef.componentInstance.params = { id: this.okaID, page: 'oka-packages-edit', operationType: 'edit' };
SANDHYA.JS26570112024-07-05 21:35:46 +053098 modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
99 if (result) {
100 this.sharedService.callData();
101 }
102 }).catch((): void => {
103 // Catch Navigation Error
104 });
105 }
106}