| 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 NS InstancesAction Component |
| 20 | */ |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 21 | import { isNullOrUndefined } from 'util'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 22 | import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector } from '@angular/core'; |
| 23 | import { Router } from '@angular/router'; |
| 24 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; |
| 25 | import { TranslateService } from '@ngx-translate/core'; |
| 26 | import { NotifierService } from 'angular-notifier'; |
| 27 | import { ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel'; |
| 28 | import { DeleteComponent } from 'DeleteComponent'; |
| 29 | import { environment } from 'environment'; |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 30 | import { HealingComponent } from 'HealingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 31 | import { NSDDetails } from 'NSDModel'; |
| 32 | import { NSDInstanceData } from 'NSInstanceModel'; |
| 33 | import { NSPrimitiveComponent } from 'NSPrimitiveComponent'; |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 34 | import { NsUpdateComponent } from 'NsUpdateComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 35 | import { RestService } from 'RestService'; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 36 | import { forkJoin, Observable } from 'rxjs'; |
| 37 | import { ScalingComponent } from 'ScalingComponent'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 38 | import { SharedService } from 'SharedService'; |
| 39 | import { ShowInfoComponent } from 'ShowInfoComponent'; |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 40 | import { StartStopRebuildComponent } from 'StartStopRebuildComponent'; |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 41 | import { VerticalScalingComponent } from 'VerticalScalingComponent'; |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 42 | import { VmMigrationComponent } from 'VmMigrationComponent'; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 43 | import { DF, VDU, VNFD } from 'VNFDModel'; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 44 | /** |
| 45 | * Creating component |
| 46 | * @Component takes NSInstancesActionComponent.html as template url |
| 47 | */ |
| 48 | @Component({ |
| 49 | templateUrl: './NSInstancesActionComponent.html', |
| 50 | styleUrls: ['./NSInstancesActionComponent.scss'], |
| 51 | changeDetection: ChangeDetectionStrategy.OnPush |
| 52 | }) |
| 53 | /** Exporting a class @exports NSInstancesActionComponent */ |
| 54 | export class NSInstancesActionComponent { |
| 55 | /** To get the value from the nspackage via valuePrepareFunction default Property of ng-smarttable @public */ |
| 56 | public value: NSDInstanceData; |
| 57 | |
| 58 | /** Invoke service injectors @public */ |
| 59 | public injector: Injector; |
| 60 | |
| 61 | /** Instance of the modal service @public */ |
| 62 | public restService: RestService; |
| 63 | |
| 64 | /** Config Status Check @public */ |
| 65 | public configStatus: string; |
| 66 | |
| 67 | /** Operational Status Check @public */ |
| 68 | public operationalStatus: string; |
| 69 | |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 70 | /** CNF Status Check @public */ |
| 71 | public k8sStatus: boolean = false; |
| 72 | |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 73 | /** get Admin Details @public */ |
| 74 | public getAdminDetails: {}; |
| 75 | |
| 76 | /** Scaling is accepted @public */ |
| 77 | public isScalingPresent: boolean = false; |
| 78 | |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 79 | /** Check the loading results for loader status @public */ |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 80 | public isLoadingNSInstanceAction: boolean = false; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 81 | |
| 82 | /** Give the message for the loading @public */ |
| 83 | public message: string = 'PLEASEWAIT'; |
| 84 | |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 85 | /** Assign the VNF Details @public */ |
| 86 | public vnfDetails: VNFD[] = []; |
| 87 | |
| Barath Kumar R | f2ae546 | 2021-03-01 12:52:33 +0530 | [diff] [blame] | 88 | /** Contains instance ID @public */ |
| 89 | public instanceID: string; |
| 90 | |
| 91 | /** Contains operational dashboard view @public */ |
| 92 | public isShowOperationalDashboard: boolean = false; |
| 93 | |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 94 | /** Instance of the modal service @private */ |
| 95 | private modalService: NgbModal; |
| 96 | |
| 97 | /** Holds teh instance of AuthService class of type AuthService @private */ |
| 98 | private router: Router; |
| 99 | |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 100 | /** Contains all methods related to shared @private */ |
| 101 | private sharedService: SharedService; |
| 102 | |
| 103 | /** Notifier service to popup notification @private */ |
| 104 | private notifierService: NotifierService; |
| 105 | |
| 106 | /** Contains tranlsate instance @private */ |
| 107 | private translateService: TranslateService; |
| 108 | |
| 109 | /** Detect changes for the User Input */ |
| 110 | private cd: ChangeDetectorRef; |
| 111 | |
| 112 | /** Set timeout @private */ |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 113 | // eslint-disable-next-line @typescript-eslint/no-magic-numbers |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 114 | private timeOut: number = 100; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 115 | |
| 116 | constructor(injector: Injector) { |
| 117 | this.injector = injector; |
| 118 | this.modalService = this.injector.get(NgbModal); |
| 119 | this.restService = this.injector.get(RestService); |
| 120 | this.router = this.injector.get(Router); |
| 121 | this.sharedService = this.injector.get(SharedService); |
| 122 | this.notifierService = this.injector.get(NotifierService); |
| 123 | this.translateService = this.injector.get(TranslateService); |
| 124 | this.cd = this.injector.get(ChangeDetectorRef); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Lifecyle Hooks the trigger before component is instantiate |
| 129 | */ |
| 130 | public ngOnInit(): void { |
| 131 | this.configStatus = this.value.ConfigStatus; |
| 132 | this.operationalStatus = this.value.OperationalStatus; |
| 133 | this.instanceID = this.value.identifier; |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 134 | this.getAdminDetails = this.value.adminDetails; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 135 | for (const key of Object.keys(this.getAdminDetails)) { |
| 136 | if (key === 'deployed') { |
| 137 | // eslint-disable-next-line security/detect-object-injection |
| 138 | const adminData: {} = this.getAdminDetails[key]; |
| 139 | for (const k8sData of Object.keys(adminData)) { |
| 140 | if (k8sData === 'K8s') { |
| 141 | // eslint-disable-next-line security/detect-object-injection |
| 142 | if (adminData[k8sData].length !== 0) { |
| 143 | this.k8sStatus = true; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | } |
| Barath Kumar R | f2ae546 | 2021-03-01 12:52:33 +0530 | [diff] [blame] | 149 | this.isShowOperationalDashboard = !isNullOrUndefined(this.value.vcaStatus) ? |
| 150 | Object.keys(this.value.vcaStatus).length === 0 && typeof this.value.vcaStatus === 'object' : true; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /** Shows information using modalservice @public */ |
| 154 | public infoNs(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 155 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 156 | this.modalService.open(ShowInfoComponent, { backdrop: 'static' }).componentInstance.params = { |
| 157 | id: this.instanceID, |
| 158 | page: 'ns-instance', |
| 159 | titleName: 'INSTANCEDETAILS' |
| 160 | }; |
| 161 | } |
| 162 | |
| 163 | /** Delete NS Instanace @public */ |
| 164 | public deleteNSInstance(forceAction: boolean): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 165 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 166 | const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); |
| 167 | modalRef.componentInstance.params = { forceDeleteType: forceAction }; |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 168 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 169 | if (result) { |
| 170 | this.sharedService.callData(); |
| 171 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 172 | }).catch((): void => { |
| 173 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 174 | }); |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | /** History of operations for an Instanace @public */ |
| 178 | public historyOfOperations(): void { |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 179 | this.router.navigate(['/instances/ns/history-operations/', this.instanceID]).catch((): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 180 | // Catch Navigation Error |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | /** NS Topology */ |
| 185 | public nsTopology(): void { |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 186 | this.router.navigate(['/instances/ns/', this.instanceID]).catch((): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 187 | // Catch Navigation Error |
| 188 | }); |
| 189 | } |
| 190 | |
| 191 | /** Exec NS Primitive @public */ |
| 192 | public execNSPrimitiveModal(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 193 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| Barath Kumar R | d3ce0c5 | 2020-08-13 11:44:01 +0530 | [diff] [blame] | 194 | this.modalService.open(NSPrimitiveComponent, { backdrop: 'static' }).componentInstance.params = { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 195 | memberIndex: this.value.memberIndex, |
| Barath Kumar R | 54d693c | 2020-07-13 20:54:13 +0530 | [diff] [blame] | 196 | nsConfig: this.value.nsConfig, |
| SANDHYA.JS | 1584e3e | 2022-10-31 20:11:50 +0530 | [diff] [blame] | 197 | name: this.value.NsdName, |
| 198 | id: this.value.constituent |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 199 | }; |
| 200 | } |
| 201 | |
| 202 | /** Redirect to Grafana Metrics @public */ |
| 203 | public metrics(): void { |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 204 | this.isLoadingNSInstanceAction = true; |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 205 | this.restService.getResource(environment.NSDINSTANCES_URL + '/' + this.instanceID).subscribe((nsData: NSDDetails[]): void => { |
| 206 | nsData['vnfd-id'].forEach((vnfdID: string[]): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 207 | this.restService.getResource(environment.VNFPACKAGES_URL + '/' + vnfdID) |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 208 | .subscribe((vnfd: VNFD): void => { |
| 209 | vnfd.vdu.forEach((vduData: VDU): void => { |
| 210 | if (vduData['monitoring-parameter'] !== undefined && vduData['monitoring-parameter'].length > 0) { |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 211 | this.isLoadingNSInstanceAction = false; |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 212 | const location: string = environment.GRAFANA_URL + '/' + this.instanceID + '/osm-ns-metrics-metrics'; |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 213 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 214 | window.open(location); |
| 215 | } else { |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 216 | this.isLoadingNSInstanceAction = false; |
| SANDHYA.JS | 9bae460 | 2022-04-05 07:28:32 +0530 | [diff] [blame] | 217 | this.notifierService.notify('error', this.translateService.instant('PAGE.NSMETRIC.METRICERROR')); |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 218 | } |
| 219 | }); |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 220 | this.doChanges(); |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 221 | }, (error: ERRORDATA): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 222 | this.restService.handleError(error, 'get'); |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 223 | this.isLoadingNSInstanceAction = false; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 224 | }); |
| 225 | }); |
| Barath Kumar R | 1a34b83 | 2021-03-05 11:32:19 +0530 | [diff] [blame] | 226 | }, (error: ERRORDATA): void => { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 227 | this.restService.handleError(error, 'get'); |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 228 | this.isLoadingNSInstanceAction = false; |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 229 | }); |
| 230 | } |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 231 | |
| 232 | /** |
| 233 | * Do the manual scaling |
| 234 | * Here we are going to get a list of VNFD ID used in the instances |
| 235 | * and have this in array with URL created then pass to checkscaling method for forkjoin to get the data @public |
| 236 | */ |
| 237 | public manualScaling(): void { |
| 238 | this.isLoadingNSInstanceAction = true; |
| 239 | const tempURL: Observable<{}>[] = []; |
| 240 | this.value.vnfID.forEach((id: string): void => { |
| 241 | const apiUrl: string = environment.VNFPACKAGESCONTENT_URL + '/' + id; |
| 242 | tempURL.push(this.restService.getResource(apiUrl)); |
| 243 | }); |
| 244 | this.checkScaling(tempURL); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Used to forkjoin to all the request to send parallely, get the data and check 'scaling-aspect' key is present @public |
| 249 | */ |
| 250 | public checkScaling(URLS: Observable<{}>[]): void { |
| 251 | forkJoin(URLS).subscribe((data: VNFD[]): void => { |
| 252 | this.vnfDetails = data; |
| 253 | if (this.vnfDetails.length > 0) { |
| 254 | this.vnfDetails.forEach((vnfdData: VNFD): void => { |
| 255 | vnfdData.df.forEach((dfData: DF): void => { |
| 256 | if (!isNullOrUndefined(dfData['scaling-aspect']) && dfData['scaling-aspect'].length > 0) { |
| 257 | this.isScalingPresent = true; |
| 258 | } |
| 259 | }); |
| 260 | }); |
| 261 | } |
| 262 | this.isLoadingNSInstanceAction = false; |
| 263 | if (this.isScalingPresent) { |
| 264 | this.openScaling(); |
| 265 | } else { |
| 266 | this.notifierService.notify('error', this.translateService.instant('SCALINGNOTFOUND')); |
| 267 | } |
| 268 | this.doChanges(); |
| 269 | }); |
| 270 | } |
| 271 | |
| 272 | /** Open the scaling pop-up @public */ |
| 273 | public openScaling(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 274 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 275 | const modalRef: NgbModalRef = this.modalService.open(ScalingComponent, { backdrop: 'static' }); |
| 276 | modalRef.componentInstance.params = { |
| 277 | id: this.instanceID, |
| 278 | vnfID: this.value.vnfID, |
| 279 | nsID: this.value['nsd-id'], |
| 280 | nsd: this.value.nsd, |
| 281 | data: this.vnfDetails |
| 282 | }; |
| 283 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 284 | if (result) { |
| 285 | this.sharedService.callData(); |
| 286 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 287 | }).catch((): void => { |
| 288 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 289 | }); |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 290 | } |
| 291 | |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 292 | /** To open VM Migration in NS Instances */ |
| 293 | public openVmMigration(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 294 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 295 | const modalRef: NgbModalRef = this.modalService.open(VmMigrationComponent, { backdrop: 'static' }); |
| 296 | modalRef.componentInstance.params = { |
| 297 | id: this.instanceID |
| 298 | }; |
| 299 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 300 | if (result) { |
| 301 | this.sharedService.callData(); |
| 302 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 303 | }).catch((): void => { |
| 304 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 305 | }); |
| SANDHYA.JS | fced3d4 | 2022-04-28 20:28:17 +0530 | [diff] [blame] | 306 | } |
| 307 | |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 308 | /** To open the Ns Update pop-up */ |
| 309 | public openNsUpdate(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 310 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 311 | const modalRef: NgbModalRef = this.modalService.open(NsUpdateComponent, { backdrop: 'static' }); |
| 312 | modalRef.componentInstance.params = { |
| 313 | id: this.instanceID |
| 314 | }; |
| 315 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 316 | if (result) { |
| 317 | this.sharedService.callData(); |
| 318 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 319 | }).catch((): void => { |
| 320 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 321 | }); |
| SANDHYA.JS | 9914458 | 2022-04-27 17:22:35 +0530 | [diff] [blame] | 322 | } |
| 323 | |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 324 | /** To open the Start, Stop & Rebuild pop-up */ |
| 325 | public openStart(actionType: string): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 326 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 327 | const modalRef: NgbModalRef = this.modalService.open(StartStopRebuildComponent, { backdrop: 'static' }); |
| 328 | modalRef.componentInstance.params = { |
| 329 | id: this.instanceID |
| 330 | }; |
| 331 | if (actionType === 'start') { |
| 332 | modalRef.componentInstance.instanceTitle = this.translateService.instant('START'); |
| 333 | } else if (actionType === 'stop') { |
| 334 | modalRef.componentInstance.instanceTitle = this.translateService.instant('STOP'); |
| 335 | } else { |
| 336 | modalRef.componentInstance.instanceTitle = this.translateService.instant('REBUILD'); |
| 337 | } |
| 338 | modalRef.componentInstance.instanceType = actionType; |
| 339 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 340 | if (result) { |
| 341 | this.sharedService.callData(); |
| 342 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 343 | }).catch((): void => { |
| 344 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 345 | }); |
| SANDHYA.JS | 3d81a28 | 2022-05-02 08:25:39 +0530 | [diff] [blame] | 346 | } |
| 347 | |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 348 | /** To open the vertical Scaling pop-up */ |
| 349 | public openVerticalScaling(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 350 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 351 | const modalRef: NgbModalRef = this.modalService.open(VerticalScalingComponent, { backdrop: 'static' }); |
| 352 | modalRef.componentInstance.params = { |
| 353 | id: this.instanceID |
| 354 | }; |
| 355 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 356 | if (result) { |
| 357 | this.sharedService.callData(); |
| 358 | } |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 359 | }).catch((): void => { |
| 360 | // Catch Navigation Error |
| SANDHYA.JS | 219fe61 | 2024-01-23 15:52:43 +0530 | [diff] [blame^] | 361 | }); |
| 362 | } |
| 363 | |
| 364 | /** Open the Healing pop-up @public */ |
| 365 | public openHealing(): void { |
| 366 | // eslint-disable-next-line security/detect-non-literal-fs-filename |
| 367 | const modalRef: NgbModalRef = this.modalService.open(HealingComponent, { backdrop: 'static' }); |
| 368 | modalRef.componentInstance.params = { |
| 369 | id: this.instanceID |
| 370 | }; |
| 371 | modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { |
| 372 | if (result) { |
| 373 | this.sharedService.callData(); |
| 374 | } |
| 375 | }).catch((): void => { |
| 376 | // Catch Navigation Error |
| 377 | }); |
| SANDHYA.JS | 017df36 | 2022-05-02 06:57:11 +0530 | [diff] [blame] | 378 | } |
| 379 | |
| Barath Kumar R | 07698ab | 2021-03-30 11:50:42 +0530 | [diff] [blame] | 380 | /** |
| 381 | * Check any changes in the child component @public |
| 382 | */ |
| 383 | public doChanges(): void { |
| 384 | setTimeout((): void => { |
| 385 | this.cd.detectChanges(); |
| 386 | }, this.timeOut); |
| 387 | } |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 388 | } |