Feature: 11055 Support of several node groups in clusters created by OSM
- Added control plane support in managed post
- When aws vim account is selected paylaod will get differed
- Added details page in clusters to view node and ksu for
specified cluster
- Fixed Bug 2402 - Unable to create Ns Config template from Ui
bug by chnaging api
Change-Id: I4eb327fd86b0c4a706b05a8ed10524e4d2c5bc95
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts
index 2a87382..ed14e47 100644
--- a/src/services/SharedService.ts
+++ b/src/services/SharedService.ts
@@ -20,7 +20,7 @@
*/
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { EventEmitter, Injectable, Output } from '@angular/core';
-import { FormArray, FormGroup } from '@angular/forms';
+import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import {
@@ -370,24 +370,27 @@
}
/** Clean the form before submit @public */
- public cleanForm(formGroup: FormGroup, formName?: String): void {
+ public cleanForm(formGroup: FormGroup | FormArray, formName?: string): void {
Object.keys(formGroup.controls).forEach((key: string) => {
- if ((!isNullOrUndefined((formGroup.get(key) as FormArray | FormGroup).controls)) && key !== 'config') {
- // eslint-disable-next-line @typescript-eslint/no-shadow
- for (const { item, index } of (formGroup.get(key).value).map((item: {}, index: number) => ({ item, index }))) {
- // eslint-disable-next-line security/detect-object-injection
- const newFormGroup: FormGroup = (formGroup.get(key) as FormArray).controls[index] as FormGroup;
- this.cleanForm(newFormGroup);
- }
- } else if (formGroup.get(key).value !== undefined && formGroup.get(key).value !== null && key !== 'config') {
- if (!Array.isArray(formGroup.get(key).value)) {
- if (typeof formGroup.get(key).value === 'string') {
- formGroup.get(key).setValue(formGroup.get(key).value.trim());
+ const control = formGroup.get(key);
+ if (control instanceof FormArray && key !== 'config') {
+ control.controls.forEach((ctrl, index) => {
+ if (ctrl instanceof FormGroup) {
+ this.cleanForm(ctrl);
+ } else if (ctrl instanceof FormControl) {
+ if (typeof ctrl.value === 'string') {
+ ctrl.setValue(ctrl.value.trim());
+ }
}
+ });
+ } else if (control instanceof FormGroup && key !== 'config') {
+ this.cleanForm(control);
+ } else if (control instanceof FormControl && control.value !== undefined && control.value !== null) {
+ if (typeof control.value === 'string') {
+ control.setValue(control.value.trim());
}
} else if (key === 'config' && formName === 'vim') {
- const newFormGroup: FormGroup = formGroup.get(key) as FormGroup;
- this.cleanForm(newFormGroup);
+ this.cleanForm(control as FormGroup);
}
});
}