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