Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class DfServiceDetailsComponent implements OnInit {
isNetworkService = false;
isScriptService = false;
isFile = false;
isAuth = false;
serviceTypes: Array<ServiceType>;
notIncludedServices: Array<ServiceType>;
serviceForm: FormGroup;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
46 changes: 25 additions & 21 deletions src/app/shared/utilities/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,38 @@ export function mapSnakeToCamel<T>(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<T>(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<string, unknown> = {};
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<string, unknown>)[key];
}
}
} else {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (key === 'requestBody') {
newObj[key] = (obj as Record<string, unknown>)[key];
} else {
newObj[camelToSnakeString(key)] = mapCamelToSnake(
(obj as Record<string, unknown>)[key]
);
}
} else {
newObj[camelToSnakeString(key)] = mapCamelToSnake(
(obj as Record<string, unknown>)[key]
);
}
}
}
Expand Down