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/app/k8s/k8s-ksu/ksu-add/KSUAddComponent.ts b/src/app/k8s/k8s-ksu/ksu-add/KSUAddComponent.ts
index 26f86f1..db13e4a 100644
--- a/src/app/k8s/k8s-ksu/ksu-add/KSUAddComponent.ts
+++ b/src/app/k8s/k8s-ksu/ksu-add/KSUAddComponent.ts
@@ -167,6 +167,8 @@
         } else if (this.profileType === 'edit') {
             this.isKsu = true;
             this.getksuDetails();
+        } else if (this.profileType === 'card-add') {
+            this.isKsu = true;
         } else {
             this.isKsu = true;
         }
@@ -272,7 +274,7 @@
                     profile_type: this.KsuForm.value.profile_type
                 }
             };
-        } else if (this.profileType === 'edit' || this.profileType === 'add') {
+        } else if (this.profileType === 'edit' || this.profileType === 'add' || this.profileType === 'card-add') {
             this.addEditKSU();
         }
         this.submitted = true;
@@ -290,22 +292,24 @@
     /** Add/Edit KSU @public */
     public addEditKSU(): void {
         this.okaArray = this.KsuForm.get('oka') as FormArray;
-        const transValue = this.okaArray.at(0).get('transformation').value;
-        const validJSON: boolean = this.sharedService.checkJson(transValue);
-        if (validJSON) {
-            for (let i = 0; i < this.okaArray.length; i++) {
-                const formGroup = this.okaArray.at(i) as FormGroup;
-                formGroup.patchValue({
-                    transformation: JSON.parse(transValue)
-                });
-            }
-        } else {
-            const getConfigJson: string = jsyaml.load(transValue, { json: true });
-            for (let i = 0; i < this.okaArray.length; i++) {
-                const formGroup = this.okaArray.at(i) as FormGroup;
-                formGroup.patchValue({
-                    transformation: JSON.parse(getConfigJson)
-                });
+        const transValue = this.okaArray?.at(0)?.get('transformation').value;
+        if (!isNullOrUndefined(transValue)) {
+            const validJSON: boolean = this.sharedService.checkJson(transValue);
+            if (validJSON) {
+                for (let i = 0; i < this.okaArray.length; i++) {
+                    const formGroup = this.okaArray.at(i) as FormGroup;
+                    formGroup.patchValue({
+                        transformation: JSON.parse(transValue)
+                    });
+                }
+            } else {
+                const getConfigJson: string = jsyaml.load(transValue, { json: true });
+                for (let i = 0; i < this.okaArray.length; i++) {
+                    const formGroup = this.okaArray.at(i) as FormGroup;
+                    formGroup.patchValue({
+                        transformation: JSON.parse(getConfigJson)
+                    });
+                }
             }
         }
         if (this.profileType === 'edit') {
@@ -450,14 +454,27 @@
     /** Get profile details @public */
     public getprofileDetails(event: string, name?: string): void {
         this.profileData = [];
-        if (event === 'infra_config_profiles') {
-            this.profileUrl = environment.K8SINFRACONFIGPROFILE_URL;
-        } else if (event === 'infra_controller_profiles') {
-            this.profileUrl = environment.K8SINFRACONTROLLERPROFILE_URL;
-        } else if (event === 'app_profiles') {
-            this.profileUrl = environment.K8SAPPPROFILE_URL;
-        } else if (event === 'resource_profiles') {
-            this.profileUrl = environment.K8SRESOURCEPROFILE_URL;
+        if (this.profileType === 'card-add') {
+            if (event === 'infra_config_profiles') {
+                this.profileUrl = environment.K8SCREATECLUSTER_URL + '/' + this.profileID + '/' + event;
+            } else if (event === 'infra_controller_profiles') {
+                this.profileUrl = environment.K8SCREATECLUSTER_URL + '/' + this.profileID + '/' + event;
+            } else if (event === 'app_profiles') {
+                this.profileUrl = environment.K8SCREATECLUSTER_URL + '/' + this.profileID + '/' + event;
+            } else if (event === 'resource_profiles') {
+                this.profileUrl = environment.K8SCREATECLUSTER_URL + '/' + this.profileID + '/' + event;
+            }
+        }
+        else {
+            if (event === 'infra_config_profiles') {
+                this.profileUrl = environment.K8SINFRACONFIGPROFILE_URL;
+            } else if (event === 'infra_controller_profiles') {
+                this.profileUrl = environment.K8SINFRACONTROLLERPROFILE_URL;
+            } else if (event === 'app_profiles') {
+                this.profileUrl = environment.K8SAPPPROFILE_URL;
+            } else if (event === 'resource_profiles') {
+                this.profileUrl = environment.K8SRESOURCEPROFILE_URL;
+            }
         }
         this.restService.getResource(this.profileUrl)
             .subscribe((profileData: []): void => {