From 13b3f3dd584e35aa1db30f6248ba13a563319c3c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Sep 2024 04:35:33 -0400 Subject: [PATCH] #340 - Fix updating auth connectors issue --- .../df-service-details.component.ts | 13 ++++-- src/app/shared/utilities/case.ts | 46 ++++++++++--------- 2 files changed, 35 insertions(+), 24 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 c225aab4..8c8ab29a 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 @@ -104,6 +104,7 @@ export class DfServiceDetailsComponent implements OnInit { isNetworkService = false; isScriptService = false; isFile = false; + isAuth = false; serviceTypes: Array; notIncludedServices: Array; serviceForm: FormGroup; @@ -158,6 +159,7 @@ export class DfServiceDetailsComponent implements OnInit { ) ) .subscribe(({ env, route }) => { + console.log(route['groups'][0]); if (route['groups'] && route['groups'][0] === 'Database') { this.isDatabase = true; } @@ -170,6 +172,9 @@ export class DfServiceDetailsComponent implements OnInit { if (route['groups'] && route['groups'][0] === 'File') { this.isFile = true; } + if (route['groups'] && route['groups'][0] === 'LDAP') { + this.isAuth = true; + } const { data, serviceTypes, groups } = route; const licenseType = env.platform?.license; this.serviceTypes = serviceTypes.filter( @@ -237,9 +242,11 @@ export class DfServiceDetailsComponent implements OnInit { ...data, config: data.config, }); - this.getConfigControl('serviceDefinition').setValue( - data.config.content - ); + if (!this.isAuth) { + this.getConfigControl('serviceDefinition').setValue( + data.config.content + ); + } if (data?.serviceDocByServiceId) { this.serviceDefinitionType = '' + data?.serviceDocByServiceId.format; diff --git a/src/app/shared/utilities/case.ts b/src/app/shared/utilities/case.ts index f418dafa..6ff9d58c 100644 --- a/src/app/shared/utilities/case.ts +++ b/src/app/shared/utilities/case.ts @@ -40,34 +40,38 @@ export function mapSnakeToCamel(obj: T): T { // } // } -export const camelToSnakeString = (str: string) => - str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1_$2').toLowerCase(); +export const camelToSnakeString = (str: string) => { + if ( + str === 'idpSingleSignOnServiceUrl' || + str === 'idp_singleSignOnService_url' + ) { + return 'idp_singleSignOnService_url'; + } + if (str === 'idpEntityId' || str === 'idp_entityId') { + return 'idp_entityId'; + } + if (str === 'spNameIDFormat' || str === 'sp_nameIDFormat') { + return 'sp_nameIDFormat'; + } + if (str === 'spPrivateKey' || str === 'sp_privateKey') { + return 'sp_privateKey'; + } + return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1_$2').toLowerCase(); +}; export function mapCamelToSnake(obj: T): T { if (Array.isArray(obj)) { return obj.map(item => mapCamelToSnake(item)) as unknown as T; } else if (typeof obj === 'object' && obj !== null) { const newObj: Record = {}; - if ( - 'type' in obj && - (obj['type'] === 'okta_saml' || obj['type'] === 'saml') - ) { - console.log('okta_saml'); - for (const key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (key === 'requestBody') { 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] - ); - } + } else { + newObj[camelToSnakeString(key)] = mapCamelToSnake( + (obj as Record)[key] + ); } } }