Skip to content

Commit bf62d63

Browse files
authored
Merge branch 'main' into backend_dashboards
2 parents a23e875 + 1e610d4 commit bf62d63

File tree

4 files changed

+590
-580
lines changed

4 files changed

+590
-580
lines changed

backend/src/entities/table-settings/personal-table-settings/dto/create-personal-table-settings.dto.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ import { QueryOrderingEnum } from '../../../../enums/query-ordering.enum.js';
33
import { IsBoolean, IsEnum, IsOptional } from 'class-validator';
44

55
export class CreatePersonalTableSettingsDto {
6-
@ApiProperty({ enumName: 'QueryOrderingEnum', enum: QueryOrderingEnum, description: 'The ordering direction' })
7-
@IsOptional()
8-
@IsEnum(QueryOrderingEnum)
9-
ordering: QueryOrderingEnum;
6+
@ApiProperty({ enumName: 'QueryOrderingEnum', enum: QueryOrderingEnum, description: 'The ordering direction' })
7+
@IsOptional()
8+
@IsEnum(QueryOrderingEnum)
9+
ordering: QueryOrderingEnum;
1010

11-
@ApiProperty({ type: String, description: 'The ordering field' })
12-
@IsOptional()
13-
ordering_field: string;
11+
@ApiProperty({ type: String, description: 'The ordering field' })
12+
@IsOptional()
13+
ordering_field: string;
1414

15-
@ApiProperty({ type: Number, description: 'The number of items per page' })
16-
@IsOptional()
17-
list_per_page: number;
15+
@ApiProperty({ type: Number, description: 'The number of items per page' })
16+
@IsOptional()
17+
list_per_page: number;
1818

19-
@ApiProperty({ isArray: true, type: String, description: 'The columns view' })
20-
@IsOptional()
21-
columns_view: Array<string>;
19+
@ApiProperty({ isArray: true, type: String, description: 'The columns view' })
20+
@IsOptional()
21+
columns_view: Array<string>;
2222

23-
@ApiProperty({ type: [String], description: 'The order of columns' })
24-
@IsOptional()
25-
list_fields: Array<string>;
23+
@ApiProperty({ type: [String], description: 'The order of columns' })
24+
@IsOptional()
25+
list_fields: Array<string>;
2626

27-
@ApiProperty({ type: Boolean, description: 'Whether to use original column names' })
28-
@IsOptional()
29-
@IsBoolean()
30-
original_names: boolean;
27+
@ApiProperty({ type: Boolean, description: 'Whether to use original column names' })
28+
@IsOptional()
29+
@IsBoolean()
30+
original_names: boolean;
3131
}
Lines changed: 130 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import {
2-
Body,
3-
Controller,
4-
Delete,
5-
Get,
6-
HttpException,
7-
HttpStatus,
8-
Inject,
9-
Injectable,
10-
Put,
11-
UseGuards,
12-
UseInterceptors,
2+
Body,
3+
Controller,
4+
Delete,
5+
Get,
6+
HttpException,
7+
HttpStatus,
8+
Inject,
9+
Injectable,
10+
Put,
11+
UseGuards,
12+
UseInterceptors,
1313
} from '@nestjs/common';
1414
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
1515
import { SentryInterceptor } from '../../../interceptors/sentry.interceptor.js';
1616
import { UseCaseType } from '../../../common/data-injection.tokens.js';
1717
import {
18-
ICreateUpdatePersonalTableSettings,
19-
IDeletePersonalTableSettings,
20-
IFindPersonalTableSettings,
18+
ICreateUpdatePersonalTableSettings,
19+
IDeletePersonalTableSettings,
20+
IFindPersonalTableSettings,
2121
} from './use-cases/personal-table-settings.use-cases.interface.js';
2222
import { TableReadGuard } from '../../../guards/table-read.guard.js';
2323
import { UserId } from '../../../decorators/user-id.decorator.js';
@@ -37,123 +37,123 @@ import { CreatePersonalTableSettingsDto } from './dto/create-personal-table-sett
3737
@ApiTags('Personal table settings')
3838
@Injectable()
3939
export class PersonalTableSettingsController {
40-
constructor(
41-
@Inject(UseCaseType.FIND_PERSONAL_TABLE_SETTINGS)
42-
private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings,
43-
@Inject(UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS)
44-
private readonly createUpdatePersonalTableSettingsUseCase: ICreateUpdatePersonalTableSettings,
45-
@Inject(UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS)
46-
private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings,
47-
) {}
40+
constructor(
41+
@Inject(UseCaseType.FIND_PERSONAL_TABLE_SETTINGS)
42+
private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings,
43+
@Inject(UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS)
44+
private readonly createUpdatePersonalTableSettingsUseCase: ICreateUpdatePersonalTableSettings,
45+
@Inject(UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS)
46+
private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings,
47+
) {}
4848

49-
@ApiOperation({ summary: 'Find user personal table settings' })
50-
@ApiResponse({
51-
status: 200,
52-
description: 'Table settings found.',
53-
type: FoundPersonalTableSettingsDto,
54-
})
55-
@ApiParam({ name: 'connectionId', required: true })
56-
@ApiQuery({ name: 'tableName', required: true })
57-
@UseGuards(TableReadGuard)
58-
@Get('/settings/personal/:connectionId')
59-
async findAll(
60-
@SlugUuid('connectionId') connectionId: string,
61-
@QueryTableName() tableName: string,
62-
@MasterPassword() masterPwd: string,
63-
@UserId() userId: string,
64-
): Promise<FoundPersonalTableSettingsDto> {
65-
if (!connectionId) {
66-
throw new HttpException(
67-
{
68-
message: Messages.CONNECTION_ID_MISSING,
69-
},
70-
HttpStatus.BAD_REQUEST,
71-
);
72-
}
73-
const inputData: FindPersonalTableSettingsDs = {
74-
connectionId,
75-
tableName,
76-
userId,
77-
masterPassword: masterPwd,
78-
};
79-
return await this.findPersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
80-
}
49+
@ApiOperation({ summary: 'Find user personal table settings' })
50+
@ApiResponse({
51+
status: 200,
52+
description: 'Table settings found.',
53+
type: FoundPersonalTableSettingsDto,
54+
})
55+
@ApiParam({ name: 'connectionId', required: true })
56+
@ApiQuery({ name: 'tableName', required: true })
57+
@UseGuards(TableReadGuard)
58+
@Get('/settings/personal/:connectionId')
59+
async findAll(
60+
@SlugUuid('connectionId') connectionId: string,
61+
@QueryTableName() tableName: string,
62+
@MasterPassword() masterPwd: string,
63+
@UserId() userId: string,
64+
): Promise<FoundPersonalTableSettingsDto> {
65+
if (!connectionId) {
66+
throw new HttpException(
67+
{
68+
message: Messages.CONNECTION_ID_MISSING,
69+
},
70+
HttpStatus.BAD_REQUEST,
71+
);
72+
}
73+
const inputData: FindPersonalTableSettingsDs = {
74+
connectionId,
75+
tableName,
76+
userId,
77+
masterPassword: masterPwd,
78+
};
79+
return await this.findPersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
80+
}
8181

82-
@ApiOperation({ summary: 'Create or update user personal table settings' })
83-
@ApiResponse({
84-
status: 200,
85-
description: 'Table settings crated/updated.',
86-
type: FoundPersonalTableSettingsDto,
87-
})
88-
@ApiBody({ type: CreatePersonalTableSettingsDto })
89-
@ApiParam({ name: 'connectionId', required: true })
90-
@ApiQuery({ name: 'tableName', required: true })
91-
@UseGuards(TableReadGuard)
92-
@Put('/settings/personal/:connectionId')
93-
async createOrUpdate(
94-
@SlugUuid('connectionId') connectionId: string,
95-
@QueryTableName() tableName: string,
96-
@MasterPassword() masterPwd: string,
97-
@UserId() userId: string,
98-
@Body() personalSettingsData: CreatePersonalTableSettingsDto,
99-
): Promise<FoundPersonalTableSettingsDto> {
100-
if (!connectionId) {
101-
throw new HttpException(
102-
{
103-
message: Messages.CONNECTION_ID_MISSING,
104-
},
105-
HttpStatus.BAD_REQUEST,
106-
);
107-
}
108-
const inputData: CreatePersonalTableSettingsDs = {
109-
table_settings_metadata: {
110-
connection_id: connectionId,
111-
table_name: tableName,
112-
user_id: userId,
113-
master_password: masterPwd,
114-
},
115-
table_settings_data: {
116-
columns_view: personalSettingsData.columns_view || null,
117-
list_fields: personalSettingsData.list_fields || null,
118-
list_per_page: personalSettingsData.list_per_page || null,
119-
ordering: personalSettingsData.ordering || null,
120-
ordering_field: personalSettingsData.ordering_field || null,
121-
original_names: personalSettingsData.original_names || null,
122-
},
123-
};
124-
return await this.createUpdatePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
125-
}
82+
@ApiOperation({ summary: 'Create or update user personal table settings' })
83+
@ApiResponse({
84+
status: 200,
85+
description: 'Table settings crated/updated.',
86+
type: FoundPersonalTableSettingsDto,
87+
})
88+
@ApiBody({ type: CreatePersonalTableSettingsDto })
89+
@ApiParam({ name: 'connectionId', required: true })
90+
@ApiQuery({ name: 'tableName', required: true })
91+
@UseGuards(TableReadGuard)
92+
@Put('/settings/personal/:connectionId')
93+
async createOrUpdate(
94+
@SlugUuid('connectionId') connectionId: string,
95+
@QueryTableName() tableName: string,
96+
@MasterPassword() masterPwd: string,
97+
@UserId() userId: string,
98+
@Body() personalSettingsData: CreatePersonalTableSettingsDto,
99+
): Promise<FoundPersonalTableSettingsDto> {
100+
if (!connectionId) {
101+
throw new HttpException(
102+
{
103+
message: Messages.CONNECTION_ID_MISSING,
104+
},
105+
HttpStatus.BAD_REQUEST,
106+
);
107+
}
108+
const inputData: CreatePersonalTableSettingsDs = {
109+
table_settings_metadata: {
110+
connection_id: connectionId,
111+
table_name: tableName,
112+
user_id: userId,
113+
master_password: masterPwd,
114+
},
115+
table_settings_data: {
116+
columns_view: personalSettingsData.columns_view || null,
117+
list_fields: personalSettingsData.list_fields || null,
118+
list_per_page: personalSettingsData.list_per_page || null,
119+
ordering: personalSettingsData.ordering || null,
120+
ordering_field: personalSettingsData.ordering_field || null,
121+
original_names: personalSettingsData.original_names || null,
122+
},
123+
};
124+
return await this.createUpdatePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
125+
}
126126

127-
@ApiOperation({ summary: 'Clear user personal table settings' })
128-
@ApiResponse({
129-
status: 200,
130-
description: 'Table settings removed.',
131-
type: FoundPersonalTableSettingsDto,
132-
})
133-
@ApiParam({ name: 'connectionId', required: true })
134-
@ApiQuery({ name: 'tableName', required: true })
135-
@UseGuards(TableReadGuard)
136-
@Delete('/settings/personal/:connectionId')
137-
async clearTableSettings(
138-
@SlugUuid('connectionId') connectionId: string,
139-
@QueryTableName() tableName: string,
140-
@MasterPassword() masterPwd: string,
141-
@UserId() userId: string,
142-
): Promise<FoundPersonalTableSettingsDto> {
143-
if (!connectionId) {
144-
throw new HttpException(
145-
{
146-
message: Messages.CONNECTION_ID_MISSING,
147-
},
148-
HttpStatus.BAD_REQUEST,
149-
);
150-
}
151-
const inputData: FindPersonalTableSettingsDs = {
152-
connectionId,
153-
tableName,
154-
userId,
155-
masterPassword: masterPwd,
156-
};
157-
return await this.deletePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
158-
}
127+
@ApiOperation({ summary: 'Clear user personal table settings' })
128+
@ApiResponse({
129+
status: 200,
130+
description: 'Table settings removed.',
131+
type: FoundPersonalTableSettingsDto,
132+
})
133+
@ApiParam({ name: 'connectionId', required: true })
134+
@ApiQuery({ name: 'tableName', required: true })
135+
@UseGuards(TableReadGuard)
136+
@Delete('/settings/personal/:connectionId')
137+
async clearTableSettings(
138+
@SlugUuid('connectionId') connectionId: string,
139+
@QueryTableName() tableName: string,
140+
@MasterPassword() masterPwd: string,
141+
@UserId() userId: string,
142+
): Promise<FoundPersonalTableSettingsDto> {
143+
if (!connectionId) {
144+
throw new HttpException(
145+
{
146+
message: Messages.CONNECTION_ID_MISSING,
147+
},
148+
HttpStatus.BAD_REQUEST,
149+
);
150+
}
151+
const inputData: FindPersonalTableSettingsDs = {
152+
connectionId,
153+
tableName,
154+
userId,
155+
masterPassword: masterPwd,
156+
};
157+
return await this.deletePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
158+
}
159159
}

0 commit comments

Comments
 (0)