From 39b900cc3868cbdea1585d9c76f7a36e7aec3a38 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 May 2024 07:39:37 -0500 Subject: [PATCH 1/6] update filter row --- src/app/adf-roles/df-roles-access/df-roles-access.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/adf-roles/df-roles-access/df-roles-access.component.ts b/src/app/adf-roles/df-roles-access/df-roles-access.component.ts index 02422d7e..928fb3dc 100644 --- a/src/app/adf-roles/df-roles-access/df-roles-access.component.ts +++ b/src/app/adf-roles/df-roles-access/df-roles-access.component.ts @@ -52,7 +52,7 @@ import { CommonModule } from '@angular/common'; ], animations: [ trigger('detailExpand', [ - state('collapsed,void', style({ height: '0px', minHeight: '0' })), + state('collapsed,void', style({ height: '*', minHeight: '0' })), state('expanded', style({ height: '*' })), transition( 'expanded <=> collapsed', From 908b5af547299e40561625bc0c3dfb6f3fbba870 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 May 2024 13:28:27 -0500 Subject: [PATCH 2/6] #245 - SAML Configuration --- .../df-service-details.component.ts | 45 ++++++++++++++++--- src/app/shared/utilities/case.ts | 15 ++++--- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/app/adf-services/df-service-details/df-service-details.component.ts b/src/app/adf-services/df-service-details/df-service-details.component.ts index 980a07d9..d85cc9ad 100644 --- a/src/app/adf-services/df-service-details/df-service-details.component.ts +++ b/src/app/adf-services/df-service-details/df-service-details.component.ts @@ -267,9 +267,11 @@ export class DfServiceDetailsComponent implements OnInit { } get viewSchema() { - return this.configSchema?.filter( + const result = this.configSchema?.filter( control => !['storageServiceId', 'storagePath'].includes(control.name) ); + console.log(result, '====== view schema'); + return result; } getConfigControl(name: string) { @@ -287,8 +289,8 @@ export class DfServiceDetailsComponent implements OnInit { const data = this.serviceForm.getRawValue(); type Params = { - snackbarError: string; - snackbarSuccess: string; + snackbarError?: string; + snackbarSuccess?: string; fields?: string; related?: string; }; @@ -320,9 +322,42 @@ export class DfServiceDetailsComponent implements OnInit { delete data.service_doc_by_service_id; } + if (!data.config.default_role) { + data.config.default_role = 1; + } + + console.log(data.config, '====== params'); + let payload; + if (data.type === 'okta_saml') { + params = { + ...params, + fields: '*', + related: 'service_doc_by_service_id', + }; + data.service_doc_by_service_id = null; + payload = { + ...data, + is_active: data.isActive, + id: null, + config: { + sp_nameIDFormat: data.config.spNameIDFormat, + default_role: data.config.defaultRole, + sp_x509cert: data.config.spX509cert, + sp_privateKey: data.config.spPrivateKey, + idp_entityId: data.config.idpEntityId, + idp_singleSignOnService_url: data.config.idpSingleSignOnServiceUrl, + idp_x509cert: data.config.idpX509cert, + relay_state: data.config.relayState, + }, + }; + delete payload.isActive; + console.log(data, '===== payload'); + } else { + payload = { ...data }; + } if (this.edit) { this.servicesService - .update(this.serviceData.id, data, { + .update(this.serviceData.id, payload, { snackbarError: 'server', snackbarSuccess: 'services.updateSuccessMsg', }) @@ -333,7 +368,7 @@ export class DfServiceDetailsComponent implements OnInit { this.servicesService .create( { - resource: [data], + resource: [payload], }, params ) diff --git a/src/app/shared/utilities/case.ts b/src/app/shared/utilities/case.ts index f6cbb4f4..2f878f6b 100644 --- a/src/app/shared/utilities/case.ts +++ b/src/app/shared/utilities/case.ts @@ -50,13 +50,14 @@ export function mapCamelToSnake(obj: T): T { const newObj: Record = {}; for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { - if (key === 'requestBody') { - newObj[key] = (obj as Record)[key]; - } else { - newObj[camelToSnakeString(key)] = mapCamelToSnake( - (obj as Record)[key] - ); - } + newObj[key] = (obj as Record)[key]; + // if (key === 'requestBody') { + // newObj[key] = (obj as Record)[key]; + // } else { + // newObj[camelToSnakeString(key)] = mapCamelToSnake( + // (obj as Record)[key] + // ); + // } } } return newObj as unknown as T; From a62f71d7a712d454d8cdbe39471bf398e0b8496d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 May 2024 16:35:34 -0500 Subject: [PATCH 3/6] updated function --- .../df-service-details.component.ts | 44 ++++++++++++++----- .../df-array-field.component.ts | 1 + src/app/shared/utilities/case.ts | 27 +++++++----- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/app/adf-services/df-service-details/df-service-details.component.ts b/src/app/adf-services/df-service-details/df-service-details.component.ts index d85cc9ad..2773365a 100644 --- a/src/app/adf-services/df-service-details/df-service-details.component.ts +++ b/src/app/adf-services/df-service-details/df-service-details.component.ts @@ -27,7 +27,10 @@ import { TranslocoPipe } from '@ngneat/transloco'; import { DfArrayFieldComponent } from 'src/app/shared/components/df-field-array/df-array-field.component'; import { DfDynamicFieldComponent } from 'src/app/shared/components/df-dynamic-field/df-dynamic-field.component'; import { ConfigSchema, ServiceType } from 'src/app/shared/types/service'; -import { snakeToCamelString } from 'src/app/shared/utilities/case'; +import { + camelToSnakeString, + snakeToCamelString, +} from 'src/app/shared/utilities/case'; import { faCircleInfo } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { MatTooltipModule } from '@angular/material/tooltip'; @@ -262,6 +265,17 @@ export class DfServiceDetailsComponent implements OnInit { ?.configSchema.map(control => ({ ...control, name: snakeToCamelString(control.name), + items: + control.type === 'array' + ? [ + ...((control.items as ConfigSchema[]) || []).map( + (each: ConfigSchema) => ({ + ...each, + name: snakeToCamelString(each.name), + }) + ), + ] + : control.items, })) ?? [] ); } @@ -270,7 +284,6 @@ export class DfServiceDetailsComponent implements OnInit { const result = this.configSchema?.filter( control => !['storageServiceId', 'storagePath'].includes(control.name) ); - console.log(result, '====== view schema'); return result; } @@ -322,13 +335,8 @@ export class DfServiceDetailsComponent implements OnInit { delete data.service_doc_by_service_id; } - if (!data.config.default_role) { - data.config.default_role = 1; - } - - console.log(data.config, '====== params'); let payload; - if (data.type === 'okta_saml') { + if (data.type.toLowerCase().includes('saml')) { params = { ...params, fields: '*', @@ -338,7 +346,7 @@ export class DfServiceDetailsComponent implements OnInit { payload = { ...data, is_active: data.isActive, - id: null, + id: this.edit ? this.serviceData.id : null, config: { sp_nameIDFormat: data.config.spNameIDFormat, default_role: data.config.defaultRole, @@ -350,8 +358,21 @@ export class DfServiceDetailsComponent implements OnInit { relay_state: data.config.relayState, }, }; + if (data.config.appRoleMap) { + payload.config.app_role_map = data.config.appRoleMap.map( + (item: any) => { + return Object.keys(item).reduce( + (acc, cur) => + (acc = { ...acc, [camelToSnakeString(cur)]: item[cur] }), + {} + ); + } + ); + } + if (data.config.iconClass) { + payload.config.icon_class = data.config.iconClass; + } delete payload.isActive; - console.log(data, '===== payload'); } else { payload = { ...data }; } @@ -373,7 +394,8 @@ export class DfServiceDetailsComponent implements OnInit { params ) .subscribe(() => { - this.router.navigate([`/api-connections/api-docs/${data.name}`]); + this.router.navigate(['../'], { relativeTo: this.activatedRoute }); + // this.router.navigate([`/api-connections/api-docs/${data.name}`]); }); } } diff --git a/src/app/shared/components/df-field-array/df-array-field.component.ts b/src/app/shared/components/df-field-array/df-array-field.component.ts index 0506ca93..d8a84ff6 100644 --- a/src/app/shared/components/df-field-array/df-array-field.component.ts +++ b/src/app/shared/components/df-field-array/df-array-field.component.ts @@ -73,6 +73,7 @@ export class DfArrayFieldComponent implements OnInit, ControlValueAccessor { updateDataSource() { this.dataSource = new MatTableDataSource(this.fieldArray.controls); + console.log(this.fieldArray.controls, '===== controls'); } constructor( diff --git a/src/app/shared/utilities/case.ts b/src/app/shared/utilities/case.ts index 2f878f6b..d579b22b 100644 --- a/src/app/shared/utilities/case.ts +++ b/src/app/shared/utilities/case.ts @@ -48,16 +48,23 @@ export function mapCamelToSnake(obj: T): T { return obj.map(item => mapCamelToSnake(item)) as unknown as T; } else if (typeof obj === 'object' && obj !== null) { const newObj: Record = {}; - for (const key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - newObj[key] = (obj as Record)[key]; - // if (key === 'requestBody') { - // newObj[key] = (obj as Record)[key]; - // } else { - // newObj[camelToSnakeString(key)] = mapCamelToSnake( - // (obj as Record)[key] - // ); - // } + if ('type' in obj && obj['type'] === 'okta_saml') { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + newObj[key] = (obj as Record)[key]; + } + } + } else { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (key === 'requestBody') { + newObj[key] = (obj as Record)[key]; + } else { + newObj[camelToSnakeString(key)] = mapCamelToSnake( + (obj as Record)[key] + ); + } + } } } return newObj as unknown as T; From fa00eeceb412e85fad14a9f3856e0cdb22d9c7b0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 May 2024 21:06:37 -0500 Subject: [PATCH 4/6] updated service definition --- .../df-service-details.component.html | 12 ++++- .../df-service-details.component.ts | 47 +++++++++++++++++-- src/app/shared/types/files.ts | 2 + 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/app/adf-services/df-service-details/df-service-details.component.html b/src/app/adf-services/df-service-details/df-service-details.component.html index 24ddb5d6..114c940d 100644 --- a/src/app/adf-services/df-service-details/df-service-details.component.html +++ b/src/app/adf-services/df-service-details/df-service-details.component.html @@ -364,14 +364,22 @@

JSON YAML - + Service Definition + +