Skip to content

Commit 4fa7f24

Browse files
authored
Merge branch 'main' into feat/dashboards-feature
2 parents 240cb92 + da3a51d commit 4fa7f24

49 files changed

Lines changed: 1325 additions & 321 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { PersonalTableSettingsModule } from './entities/table-settings/personal-
4747
import { SavedDbQueryModule } from './entities/visualizations/saved-db-query/saved-db-query.module.js';
4848
import { DashboardModule } from './entities/visualizations/dashboard/dashboards.module.js';
4949
import { DashboardWidgetModule } from './entities/visualizations/dashboard-widget/dashboard-widget.module.js';
50+
import { SelfHostedOperationsModule } from './selfhosted-operations/selhosted-operations.module.js';
5051

5152
@Module({
5253
imports: [
@@ -98,6 +99,7 @@ import { DashboardWidgetModule } from './entities/visualizations/dashboard-widge
9899
SavedDbQueryModule,
99100
DashboardModule,
100101
DashboardWidgetModule,
102+
SelfHostedOperationsModule.register(),
101103
],
102104
controllers: [AppController],
103105
providers: [

backend/src/common/data-injection.tokens.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,7 @@ export enum UseCaseType {
202202
CREATE_DASHBOARD_WIDGET = 'CREATE_DASHBOARD_WIDGET',
203203
UPDATE_DASHBOARD_WIDGET = 'UPDATE_DASHBOARD_WIDGET',
204204
DELETE_DASHBOARD_WIDGET = 'DELETE_DASHBOARD_WIDGET',
205+
206+
IS_CONFIGURED = 'IS_CONFIGURED',
207+
CREATE_INITIAL_USER = 'CREATE_INITIAL_USER',
205208
}

backend/src/entities/ai/ai-conversation-history/ai-chat-messages/ai-chat-message.entity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class AiChatMessageEntity {
3434
@ManyToOne(
3535
() => UserAiChatEntity,
3636
(ai_chat) => ai_chat.messages,
37+
{ onDelete: 'CASCADE' },
3738
)
3839
@JoinColumn({ name: 'ai_chat_id' })
3940
ai_chat: Relation<UserAiChatEntity>;

backend/src/entities/ai/ai-conversation-history/user-ai-chat/user-ai-chat.entity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class UserAiChatEntity {
2929
@ManyToOne(
3030
() => UserEntity,
3131
(user) => user.ai_chats,
32+
{ onDelete: 'CASCADE' },
3233
)
3334
@JoinColumn({ name: 'user_id' })
3435
user: Relation<UserEntity>;

backend/src/entities/connection/connection.entity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ export class ConnectionEntity {
272272
@ManyToOne(
273273
(_) => CompanyInfoEntity,
274274
(company) => company.connections,
275+
{ onDelete: 'CASCADE' },
275276
)
276277
@JoinTable()
277278
company: Relation<CompanyInfoEntity>;
Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
import sjson from 'secure-json-parse';
2-
import {
3-
AfterLoad,
4-
BeforeInsert,
5-
BeforeUpdate,
6-
Column,
7-
Entity,
8-
JoinColumn,
9-
ManyToOne,
10-
PrimaryGeneratedColumn,
11-
Relation,
12-
} from 'typeorm';
13-
import { DashboardWidgetTypeEnum } from '../../../enums/dashboard-widget-type.enum.js';
1+
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Relation } from 'typeorm';
142
import { DashboardEntity } from '../dashboard/dashboard.entity.js';
153
import { SavedDbQueryEntity } from '../saved-db-query/saved-db-query.entity.js';
164

@@ -19,18 +7,6 @@ export class DashboardWidgetEntity {
197
@PrimaryGeneratedColumn('uuid')
208
id: string;
219

22-
@Column({ type: 'varchar' })
23-
widget_type: DashboardWidgetTypeEnum;
24-
25-
@Column({ type: 'varchar', default: null, nullable: true })
26-
chart_type: string | null;
27-
28-
@Column({ default: null, nullable: true })
29-
name: string | null;
30-
31-
@Column({ type: 'text', default: null, nullable: true })
32-
description: string | null;
33-
3410
@Column({ type: 'int', default: 0 })
3511
position_x: number;
3612

@@ -43,9 +19,6 @@ export class DashboardWidgetEntity {
4319
@Column({ type: 'int', default: 3 })
4420
height: number;
4521

46-
@Column('json', { default: null, nullable: true })
47-
widget_options: string | null;
48-
4922
@Column({ type: 'uuid' })
5023
dashboard_id: string;
5124

@@ -63,40 +36,4 @@ export class DashboardWidgetEntity {
6336
@ManyToOne(() => SavedDbQueryEntity, { onDelete: 'SET NULL', nullable: true })
6437
@JoinColumn({ name: 'query_id' })
6538
query: Relation<SavedDbQueryEntity> | null;
66-
67-
@BeforeUpdate()
68-
stringifyOptionsOnUpdate(): void {
69-
try {
70-
if (this.widget_options && typeof this.widget_options === 'object') {
71-
this.widget_options = JSON.stringify(this.widget_options);
72-
}
73-
} catch (e) {
74-
console.error('-> Error widget options stringify ' + e.message);
75-
}
76-
}
77-
78-
@BeforeInsert()
79-
stringifyOptions(): void {
80-
try {
81-
if (this.widget_options && typeof this.widget_options === 'object') {
82-
this.widget_options = JSON.stringify(this.widget_options);
83-
}
84-
} catch (e) {
85-
console.error('-> Error widget options stringify ' + e.message);
86-
}
87-
}
88-
89-
@AfterLoad()
90-
parseOptions(): void {
91-
try {
92-
if (this.widget_options && typeof this.widget_options === 'string') {
93-
this.widget_options = sjson.parse(this.widget_options, null, {
94-
protoAction: 'remove',
95-
constructorAction: 'remove',
96-
});
97-
}
98-
} catch (e) {
99-
console.error('-> Error widget options parse ' + e.message);
100-
}
101-
}
10239
}

backend/src/entities/visualizations/dashboard-widget/dashboard-widgets.controller.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,11 @@ export class DashboardWidgetController {
7070
connectionId,
7171
masterPassword: masterPwd,
7272
userId,
73-
widget_type: createDto.widget_type,
74-
chart_type: createDto.chart_type,
75-
name: createDto.name,
76-
description: createDto.description,
73+
query_id: createDto.query_id,
7774
position_x: createDto.position_x,
7875
position_y: createDto.position_y,
7976
width: createDto.width,
8077
height: createDto.height,
81-
widget_options: createDto.widget_options,
82-
query_id: createDto.query_id,
8378
};
8479
return await this.createDashboardWidgetUseCase.execute(inputData, InTransactionEnum.ON);
8580
}
@@ -110,16 +105,11 @@ export class DashboardWidgetController {
110105
connectionId,
111106
masterPassword: masterPwd,
112107
userId,
113-
widget_type: updateDto.widget_type,
114-
chart_type: updateDto.chart_type,
115-
name: updateDto.name,
116-
description: updateDto.description,
108+
query_id: updateDto.query_id,
117109
position_x: updateDto.position_x,
118110
position_y: updateDto.position_y,
119111
width: updateDto.width,
120112
height: updateDto.height,
121-
widget_options: updateDto.widget_options,
122-
query_id: updateDto.query_id,
123113
};
124114
return await this.updateDashboardWidgetUseCase.execute(inputData, InTransactionEnum.ON);
125115
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import { DashboardWidgetTypeEnum } from '../../../../enums/dashboard-widget-type.enum.js';
2-
31
export class CreateDashboardWidgetDs {
42
dashboardId: string;
53
connectionId: string;
64
masterPassword: string;
75
userId: string;
8-
widget_type: DashboardWidgetTypeEnum;
9-
chart_type?: string;
10-
name?: string;
11-
description?: string;
6+
query_id?: string;
127
position_x?: number;
138
position_y?: number;
149
width?: number;
1510
height?: number;
16-
widget_options?: Record<string, unknown>;
17-
query_id?: string;
1811
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import { DashboardWidgetTypeEnum } from '../../../../enums/dashboard-widget-type.enum.js';
2-
31
export class UpdateDashboardWidgetDs {
42
widgetId: string;
53
dashboardId: string;
64
connectionId: string;
75
masterPassword: string;
86
userId: string;
9-
widget_type?: DashboardWidgetTypeEnum;
10-
chart_type?: string;
11-
name?: string;
12-
description?: string;
7+
query_id?: string;
138
position_x?: number;
149
position_y?: number;
1510
width?: number;
1611
height?: number;
17-
widget_options?: Record<string, unknown>;
18-
query_id?: string;
1912
}
Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2-
import { IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, Max, Min } from 'class-validator';
3-
import { DashboardWidgetTypeEnum } from '../../../../enums/dashboard-widget-type.enum.js';
1+
import { ApiPropertyOptional } from '@nestjs/swagger';
2+
import { IsInt, IsOptional, IsUUID, Max, Min } from 'class-validator';
43

54
export class CreateDashboardWidgetDto {
6-
@ApiProperty({ description: 'Widget type', enum: DashboardWidgetTypeEnum })
7-
@IsNotEmpty()
8-
@IsEnum(DashboardWidgetTypeEnum)
9-
widget_type: DashboardWidgetTypeEnum;
10-
11-
@ApiPropertyOptional({ description: 'Chart type for chart widgets' })
12-
@IsOptional()
13-
@IsString()
14-
chart_type?: string;
15-
16-
@ApiPropertyOptional({ description: 'Widget name' })
17-
@IsOptional()
18-
@IsString()
19-
name?: string;
20-
21-
@ApiPropertyOptional({ description: 'Widget description' })
5+
@ApiPropertyOptional({ description: 'Associated saved query ID' })
226
@IsOptional()
23-
@IsString()
24-
description?: string;
7+
@IsUUID()
8+
query_id?: string;
259

2610
@ApiPropertyOptional({ description: 'Position X in grid', default: 0 })
2711
@IsOptional()
@@ -48,13 +32,4 @@ export class CreateDashboardWidgetDto {
4832
@Min(1)
4933
@Max(12)
5034
height?: number;
51-
52-
@ApiPropertyOptional({ description: 'Visualization options as JSON' })
53-
@IsOptional()
54-
widget_options?: Record<string, unknown>;
55-
56-
@ApiPropertyOptional({ description: 'Associated saved query ID' })
57-
@IsOptional()
58-
@IsUUID()
59-
query_id?: string;
6035
}

0 commit comments

Comments
 (0)