[feat][Remote objects] Edit a connection (for pg) (#5210)
## Context #4774 ## How was it tested Locally ## In further PRs - Update connection status upon page change - Adapt Info banner to dark mode - placeholders for form
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
|
||||
import { isDefined } from 'class-validator';
|
||||
|
||||
import {
|
||||
RemoteServerEntity,
|
||||
RemoteServerType,
|
||||
UserMappingOptions,
|
||||
} from 'src/engine/metadata-modules/remote-server/remote-server.entity';
|
||||
import { UserMappingOptionsInput } from 'src/engine/metadata-modules/remote-server/utils/user-mapping-options.utils';
|
||||
|
||||
export type DeepPartial<T> = {
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
@ -13,7 +15,7 @@ export type DeepPartial<T> = {
|
||||
const buildUserMappingOptionsQuery = (
|
||||
parameters: any[],
|
||||
parametersPositions: object,
|
||||
userMappingOptions: DeepPartial<UserMappingOptions>,
|
||||
userMappingOptions: DeepPartial<UserMappingOptionsInput>,
|
||||
): string | null => {
|
||||
const shouldUpdateUserMappingOptionsPassword = isDefined(
|
||||
userMappingOptions?.password,
|
||||
@ -130,6 +132,10 @@ export const updateRemoteServerRawQuery = (
|
||||
options.push(fwdOptionsQuery);
|
||||
}
|
||||
|
||||
if (options.length < 1) {
|
||||
throw new BadRequestException('No fields to update');
|
||||
}
|
||||
|
||||
const rawQuery = `UPDATE metadata."remoteServer" SET ${options.join(
|
||||
', ',
|
||||
)} WHERE "id"= $1 RETURNING *`;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { InputType, Field } from '@nestjs/graphql';
|
||||
import { InputType, Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import { IsOptional } from 'class-validator';
|
||||
|
||||
@ -12,3 +12,10 @@ export class UserMappingOptionsInput {
|
||||
@Field(() => String, { nullable: true })
|
||||
password: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class GetUserMappingOptions {
|
||||
@IsOptional()
|
||||
@Field(() => String, { nullable: true })
|
||||
username: string;
|
||||
}
|
||||
Reference in New Issue
Block a user