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