Skip to content

Commit 4f72f2c

Browse files
authored
Merge pull request #1521 from rocket-admin/backend_charts
feat: add chart_type to DashboardWidgetEntity and related DTOs for enhanced widget configuration
2 parents e46655c + 9d5073c commit 4f72f2c

11 files changed

Lines changed: 40 additions & 0 deletions

backend/src/entities/visualizations/dashboard-widget/dashboard-widget.entity.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export class DashboardWidgetEntity {
2222
@Column({ type: 'varchar' })
2323
widget_type: DashboardWidgetTypeEnum;
2424

25+
@Column({ type: 'varchar', default: null, nullable: true })
26+
chart_type: string | null;
27+
2528
@Column({ default: null, nullable: true })
2629
name: string | null;
2730

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class DashboardWidgetController {
6969
masterPassword: masterPwd,
7070
userId,
7171
widget_type: createDto.widget_type,
72+
chart_type: createDto.chart_type,
7273
name: createDto.name,
7374
description: createDto.description,
7475
position_x: createDto.position_x,
@@ -108,6 +109,7 @@ export class DashboardWidgetController {
108109
masterPassword: masterPwd,
109110
userId,
110111
widget_type: updateDto.widget_type,
112+
chart_type: updateDto.chart_type,
111113
name: updateDto.name,
112114
description: updateDto.description,
113115
position_x: updateDto.position_x,

backend/src/entities/visualizations/dashboard-widget/data-structures/create-dashboard-widget.ds.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class CreateDashboardWidgetDs {
66
masterPassword: string;
77
userId: string;
88
widget_type: DashboardWidgetTypeEnum;
9+
chart_type?: string;
910
name?: string;
1011
description?: string;
1112
position_x?: number;

backend/src/entities/visualizations/dashboard-widget/data-structures/update-dashboard-widget.ds.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class UpdateDashboardWidgetDs {
77
masterPassword: string;
88
userId: string;
99
widget_type?: DashboardWidgetTypeEnum;
10+
chart_type?: string;
1011
name?: string;
1112
description?: string;
1213
position_x?: number;

backend/src/entities/visualizations/dashboard-widget/dto/create-dashboard-widget.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export class CreateDashboardWidgetDto {
88
@IsEnum(DashboardWidgetTypeEnum)
99
widget_type: DashboardWidgetTypeEnum;
1010

11+
@ApiPropertyOptional({ description: 'Chart type for chart widgets' })
12+
@IsOptional()
13+
@IsString()
14+
chart_type?: string;
15+
1116
@ApiPropertyOptional({ description: 'Widget name' })
1217
@IsOptional()
1318
@IsString()

backend/src/entities/visualizations/dashboard-widget/dto/found-dashboard-widget.dto.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export class FoundDashboardWidgetDto {
88
@ApiProperty({ description: 'Widget type', enum: DashboardWidgetTypeEnum })
99
widget_type: DashboardWidgetTypeEnum;
1010

11+
@ApiPropertyOptional({ description: 'Chart type for chart widgets' })
12+
chart_type: string | null;
13+
1114
@ApiPropertyOptional({ description: 'Widget name' })
1215
name: string | null;
1316

backend/src/entities/visualizations/dashboard-widget/dto/update-dashboard-widget.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export class UpdateDashboardWidgetDto {
88
@IsEnum(DashboardWidgetTypeEnum)
99
widget_type?: DashboardWidgetTypeEnum;
1010

11+
@ApiPropertyOptional({ description: 'Chart type for chart widgets' })
12+
@IsOptional()
13+
@IsString()
14+
chart_type?: string;
15+
1116
@ApiPropertyOptional({ description: 'Widget name' })
1217
@IsOptional()
1318
@IsString()

backend/src/entities/visualizations/dashboard-widget/use-cases/create-dashboard-widget.use.case.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class CreateDashboardWidgetUseCase
2727
connectionId,
2828
masterPassword,
2929
widget_type,
30+
chart_type,
3031
name,
3132
description,
3233
position_x,
@@ -68,6 +69,7 @@ export class CreateDashboardWidgetUseCase
6869

6970
const newWidget = new DashboardWidgetEntity();
7071
newWidget.widget_type = widget_type;
72+
newWidget.chart_type = chart_type || null;
7173
newWidget.name = name || null;
7274
newWidget.description = description || null;
7375
newWidget.position_x = position_x ?? 0;

backend/src/entities/visualizations/dashboard-widget/use-cases/update-dashboard-widget.use.case.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class UpdateDashboardWidgetUseCase
2727
connectionId,
2828
masterPassword,
2929
widget_type,
30+
chart_type,
3031
name,
3132
description,
3233
position_x,
@@ -78,6 +79,9 @@ export class UpdateDashboardWidgetUseCase
7879
if (widget_type !== undefined) {
7980
foundWidget.widget_type = widget_type;
8081
}
82+
if (chart_type !== undefined) {
83+
foundWidget.chart_type = chart_type;
84+
}
8185
if (name !== undefined) {
8286
foundWidget.name = name;
8387
}

backend/src/entities/visualizations/dashboard-widget/utils/build-found-dashboard-widget-dto.util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function buildFoundDashboardWidgetDto(widget: DashboardWidgetEntity): Fou
55
return {
66
id: widget.id,
77
widget_type: widget.widget_type,
8+
chart_type: widget.chart_type,
89
name: widget.name,
910
description: widget.description,
1011
position_x: widget.position_x,

0 commit comments

Comments
 (0)