@hed-hog/core 0.0.170 → 0.0.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +70 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js +13 -3
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +70 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.js +33 -4
- package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -1
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts +122 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.js +83 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.d.ts +3 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.js +26 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts +125 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js +143 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.d.ts +5 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.js +25 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/index.d.ts +2 -0
- package/dist/dashboard/dashboard-component-role/dto/index.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/index.js +18 -0
- package/dist/dashboard/dashboard-component-role/dto/index.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -1
- package/dist/dashboard/dashboard.module.js +2 -0
- package/dist/dashboard/dashboard.module.js.map +1 -1
- package/hedhog/data/route.yaml +30 -0
- package/package.json +3 -3
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +7 -2
- package/src/dashboard/dashboard-component/dashboard-component.service.ts +44 -4
- package/src/dashboard/dashboard-component-role/dashboard-component-role.controller.ts +57 -0
- package/src/dashboard/dashboard-component-role/dashboard-component-role.module.ts +13 -0
- package/src/dashboard/dashboard-component-role/dashboard-component-role.service.ts +170 -0
- package/src/dashboard/dashboard-component-role/dto/create.dto.ts +9 -0
- package/src/dashboard/dashboard-component-role/dto/index.ts +1 -0
- package/src/dashboard/dashboard.module.ts +2 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { PaginationService } from '@hed-hog/api-pagination';
|
|
2
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
3
|
+
import { CreateDashboardComponentRoleDTO } from './dto';
|
|
4
|
+
export declare class DashboardComponentRoleService {
|
|
5
|
+
private readonly prismaService;
|
|
6
|
+
private readonly paginationService;
|
|
7
|
+
constructor(prismaService: PrismaService, paginationService: PaginationService);
|
|
8
|
+
getAll(paginationParams: any, locale: string): Promise<{
|
|
9
|
+
total: any;
|
|
10
|
+
lastPage: number;
|
|
11
|
+
page: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
prev: number;
|
|
14
|
+
next: number;
|
|
15
|
+
data: any[];
|
|
16
|
+
}>;
|
|
17
|
+
getAllByComponent(componentId: number, locale: string): Promise<({
|
|
18
|
+
role: {
|
|
19
|
+
role_locale: ({
|
|
20
|
+
locale: {
|
|
21
|
+
code: string;
|
|
22
|
+
name: string;
|
|
23
|
+
region: string;
|
|
24
|
+
id: number;
|
|
25
|
+
created_at: Date;
|
|
26
|
+
updated_at: Date;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
30
|
+
name: string;
|
|
31
|
+
id: number;
|
|
32
|
+
description: string | null;
|
|
33
|
+
created_at: Date;
|
|
34
|
+
updated_at: Date;
|
|
35
|
+
locale_id: number;
|
|
36
|
+
role_id: number;
|
|
37
|
+
})[];
|
|
38
|
+
} & {
|
|
39
|
+
id: number;
|
|
40
|
+
created_at: Date;
|
|
41
|
+
updated_at: Date;
|
|
42
|
+
slug: string;
|
|
43
|
+
};
|
|
44
|
+
} & {
|
|
45
|
+
id: number;
|
|
46
|
+
created_at: Date;
|
|
47
|
+
updated_at: Date;
|
|
48
|
+
component_id: number;
|
|
49
|
+
role_id: number;
|
|
50
|
+
})[]>;
|
|
51
|
+
create(data: CreateDashboardComponentRoleDTO, locale: string): Promise<{
|
|
52
|
+
dashboard_component: {
|
|
53
|
+
dashboard_component_locale: ({
|
|
54
|
+
locale: {
|
|
55
|
+
code: string;
|
|
56
|
+
name: string;
|
|
57
|
+
region: string;
|
|
58
|
+
id: number;
|
|
59
|
+
created_at: Date;
|
|
60
|
+
updated_at: Date;
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
};
|
|
63
|
+
} & {
|
|
64
|
+
name: string;
|
|
65
|
+
id: number;
|
|
66
|
+
description: string;
|
|
67
|
+
created_at: Date;
|
|
68
|
+
updated_at: Date;
|
|
69
|
+
locale_id: number;
|
|
70
|
+
dashboard_component_id: number;
|
|
71
|
+
})[];
|
|
72
|
+
} & {
|
|
73
|
+
width: number;
|
|
74
|
+
id: number;
|
|
75
|
+
created_at: Date;
|
|
76
|
+
updated_at: Date;
|
|
77
|
+
slug: string;
|
|
78
|
+
min_width: number;
|
|
79
|
+
max_width: number | null;
|
|
80
|
+
min_height: number;
|
|
81
|
+
max_height: number | null;
|
|
82
|
+
height: number;
|
|
83
|
+
is_resizable: boolean;
|
|
84
|
+
};
|
|
85
|
+
role: {
|
|
86
|
+
role_locale: ({
|
|
87
|
+
locale: {
|
|
88
|
+
code: string;
|
|
89
|
+
name: string;
|
|
90
|
+
region: string;
|
|
91
|
+
id: number;
|
|
92
|
+
created_at: Date;
|
|
93
|
+
updated_at: Date;
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
};
|
|
96
|
+
} & {
|
|
97
|
+
name: string;
|
|
98
|
+
id: number;
|
|
99
|
+
description: string | null;
|
|
100
|
+
created_at: Date;
|
|
101
|
+
updated_at: Date;
|
|
102
|
+
locale_id: number;
|
|
103
|
+
role_id: number;
|
|
104
|
+
})[];
|
|
105
|
+
} & {
|
|
106
|
+
id: number;
|
|
107
|
+
created_at: Date;
|
|
108
|
+
updated_at: Date;
|
|
109
|
+
slug: string;
|
|
110
|
+
};
|
|
111
|
+
} & {
|
|
112
|
+
id: number;
|
|
113
|
+
created_at: Date;
|
|
114
|
+
updated_at: Date;
|
|
115
|
+
component_id: number;
|
|
116
|
+
role_id: number;
|
|
117
|
+
}>;
|
|
118
|
+
delete(id: number, locale: string): Promise<{
|
|
119
|
+
success: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
deleteByComponentAndRole(componentId: number, roleId: number, locale: string): Promise<{
|
|
122
|
+
success: boolean;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=dashboard-component-role.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-component-role.service.d.ts","sourceRoot":"","sources":["../../../src/dashboard/dashboard-component-role/dashboard-component-role.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,OAAO,CAAC;AAExD,qBACa,6BAA6B;IAGtC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,MAAM,CAAC,gBAAgB,KAAA,EAAE,MAAM,EAAE,MAAM;;;;;;;;;IAiCvC,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmBrD,MAAM,CAAC,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+C5D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;IAsBjC,wBAAwB,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;;;CAyBjB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DashboardComponentRoleService = void 0;
|
|
16
|
+
const api_locale_1 = require("@hed-hog/api-locale");
|
|
17
|
+
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
18
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
let DashboardComponentRoleService = class DashboardComponentRoleService {
|
|
21
|
+
constructor(prismaService, paginationService) {
|
|
22
|
+
this.prismaService = prismaService;
|
|
23
|
+
this.paginationService = paginationService;
|
|
24
|
+
}
|
|
25
|
+
async getAll(paginationParams, locale) {
|
|
26
|
+
return this.paginationService.paginate(this.prismaService.dashboard_component_role, paginationParams, {
|
|
27
|
+
include: {
|
|
28
|
+
dashboard_component: {
|
|
29
|
+
include: {
|
|
30
|
+
dashboard_component_locale: {
|
|
31
|
+
include: {
|
|
32
|
+
locale: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
role: {
|
|
38
|
+
include: {
|
|
39
|
+
role_locale: {
|
|
40
|
+
include: {
|
|
41
|
+
locale: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
orderBy: {
|
|
48
|
+
id: 'desc',
|
|
49
|
+
},
|
|
50
|
+
}, 'dashboardComponentRole');
|
|
51
|
+
}
|
|
52
|
+
async getAllByComponent(componentId, locale) {
|
|
53
|
+
const relations = await this.prismaService.dashboard_component_role.findMany({
|
|
54
|
+
where: { component_id: componentId },
|
|
55
|
+
include: {
|
|
56
|
+
role: {
|
|
57
|
+
include: {
|
|
58
|
+
role_locale: {
|
|
59
|
+
include: {
|
|
60
|
+
locale: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return relations;
|
|
68
|
+
}
|
|
69
|
+
async create(data, locale) {
|
|
70
|
+
// Verificar se a relação já existe
|
|
71
|
+
const existing = await this.prismaService.dashboard_component_role.findFirst({
|
|
72
|
+
where: {
|
|
73
|
+
component_id: data.component_id,
|
|
74
|
+
role_id: data.role_id,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
if (existing) {
|
|
78
|
+
throw new Error((0, api_locale_1.getLocaleText)('dashboardComponentRoleAlreadyExists', locale, 'Dashboard component role already exists'));
|
|
79
|
+
}
|
|
80
|
+
return this.prismaService.dashboard_component_role.create({
|
|
81
|
+
data: {
|
|
82
|
+
component_id: data.component_id,
|
|
83
|
+
role_id: data.role_id,
|
|
84
|
+
},
|
|
85
|
+
include: {
|
|
86
|
+
dashboard_component: {
|
|
87
|
+
include: {
|
|
88
|
+
dashboard_component_locale: {
|
|
89
|
+
include: {
|
|
90
|
+
locale: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
role: {
|
|
96
|
+
include: {
|
|
97
|
+
role_locale: {
|
|
98
|
+
include: {
|
|
99
|
+
locale: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async delete(id, locale) {
|
|
108
|
+
const relation = await this.prismaService.dashboard_component_role.findUnique({
|
|
109
|
+
where: { id },
|
|
110
|
+
});
|
|
111
|
+
if (!relation) {
|
|
112
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('dashboardComponentRoleNotFound', locale, 'Dashboard component role not found'));
|
|
113
|
+
}
|
|
114
|
+
await this.prismaService.dashboard_component_role.delete({
|
|
115
|
+
where: { id },
|
|
116
|
+
});
|
|
117
|
+
return { success: true };
|
|
118
|
+
}
|
|
119
|
+
async deleteByComponentAndRole(componentId, roleId, locale) {
|
|
120
|
+
const relation = await this.prismaService.dashboard_component_role.findFirst({
|
|
121
|
+
where: {
|
|
122
|
+
component_id: componentId,
|
|
123
|
+
role_id: roleId,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
if (!relation) {
|
|
127
|
+
throw new common_1.NotFoundException((0, api_locale_1.getLocaleText)('dashboardComponentRoleNotFound', locale, 'Dashboard component role not found'));
|
|
128
|
+
}
|
|
129
|
+
await this.prismaService.dashboard_component_role.delete({
|
|
130
|
+
where: { id: relation.id },
|
|
131
|
+
});
|
|
132
|
+
return { success: true };
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.DashboardComponentRoleService = DashboardComponentRoleService;
|
|
136
|
+
exports.DashboardComponentRoleService = DashboardComponentRoleService = __decorate([
|
|
137
|
+
(0, common_1.Injectable)(),
|
|
138
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => api_prisma_1.PrismaService))),
|
|
139
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => api_pagination_1.PaginationService))),
|
|
140
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService,
|
|
141
|
+
api_pagination_1.PaginationService])
|
|
142
|
+
], DashboardComponentRoleService);
|
|
143
|
+
//# sourceMappingURL=dashboard-component-role.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-component-role.service.js","sourceRoot":"","sources":["../../../src/dashboard/dashboard-component-role/dashboard-component-role.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoD;AACpD,4DAA4D;AAC5D,oDAAoD;AACpD,2CAKwB;AAIjB,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACxC,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAc;QAC3C,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CACpC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ACzB,IAAA,0BAAa,EACX,gCAAgC,EAChC,MAAM,EACN,oCAAoC,CACrC,CACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,MAAM,CAAC;YACvD,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE;SAC3B,CAAC,CAAC;QAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AA7JY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAiB,CAAC,CAAC,CAAA;qCADZ,0BAAa;QAET,kCAAiB;GAL5C,6BAA6B,CA6JzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../../src/dashboard/dashboard-component-role/dto/create.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,+BAA+B;IAE1C,YAAY,EAAE,MAAM,CAAC;IAGrB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateDashboardComponentRoleDTO = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateDashboardComponentRoleDTO {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateDashboardComponentRoleDTO = CreateDashboardComponentRoleDTO;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsInt)(),
|
|
19
|
+
__metadata("design:type", Number)
|
|
20
|
+
], CreateDashboardComponentRoleDTO.prototype, "component_id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsInt)(),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], CreateDashboardComponentRoleDTO.prototype, "role_id", void 0);
|
|
25
|
+
//# sourceMappingURL=create.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../../src/dashboard/dashboard-component-role/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAwC;AAExC,MAAa,+BAA+B;CAM3C;AAND,0EAMC;AAJC;IADC,IAAA,uBAAK,GAAE;;qEACa;AAGrB;IADC,IAAA,uBAAK,GAAE;;gEACQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/dashboard/dashboard-component-role/dto/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create.dto"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dashboard/dashboard-component-role/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.module.d.ts","sourceRoot":"","sources":["../../src/dashboard/dashboard.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dashboard.module.d.ts","sourceRoot":"","sources":["../../src/dashboard/dashboard.module.ts"],"names":[],"mappings":"AAUA,qBAea,eAAe;CAAG"}
|
|
@@ -10,6 +10,7 @@ exports.DashboardModule = void 0;
|
|
|
10
10
|
const api_locale_1 = require("@hed-hog/api-locale");
|
|
11
11
|
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
12
12
|
const common_1 = require("@nestjs/common");
|
|
13
|
+
const dashboard_component_role_module_1 = require("./dashboard-component-role/dashboard-component-role.module");
|
|
13
14
|
const dashboard_component_module_1 = require("./dashboard-component/dashboard-component.module");
|
|
14
15
|
const dashboard_core_module_1 = require("./dashboard-core/dashboard-core.module");
|
|
15
16
|
const dashboard_item_module_1 = require("./dashboard-item/dashboard-item.module");
|
|
@@ -25,6 +26,7 @@ exports.DashboardModule = DashboardModule = __decorate([
|
|
|
25
26
|
(0, common_1.forwardRef)(() => api_prisma_1.PrismaModule),
|
|
26
27
|
(0, common_1.forwardRef)(() => dashboard_module_1.DashboardCrudModule),
|
|
27
28
|
(0, common_1.forwardRef)(() => dashboard_component_module_1.DashboardComponentModule),
|
|
29
|
+
(0, common_1.forwardRef)(() => dashboard_component_role_module_1.DashboardComponentRoleModule),
|
|
28
30
|
(0, common_1.forwardRef)(() => dashboard_item_module_1.DashboardItemModule),
|
|
29
31
|
(0, common_1.forwardRef)(() => dashboard_user_module_1.DashboardUserModule),
|
|
30
32
|
(0, common_1.forwardRef)(() => dashboard_core_module_1.DashboardCoreModule),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.module.js","sourceRoot":"","sources":["../../src/dashboard/dashboard.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAmD;AACnD,oDAAmD;AACnD,2CAAoD;AACpD,iGAA4F;AAC5F,kFAA6E;AAC7E,kFAA6E;AAC7E,kFAA6E;AAC7E,mEAAmE;
|
|
1
|
+
{"version":3,"file":"dashboard.module.js","sourceRoot":"","sources":["../../src/dashboard/dashboard.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAmD;AACnD,oDAAmD;AACnD,2CAAoD;AACpD,gHAA0G;AAC1G,iGAA4F;AAC5F,kFAA6E;AAC7E,kFAA6E;AAC7E,kFAA6E;AAC7E,mEAAmE;AAiB5D,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAf3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,yBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,yBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sCAAmB,CAAC;YACrC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qDAAwB,CAAC;YAC1C,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8DAA4B,CAAC;YAC9C,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;SACtC;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,eAAe,CAAG"}
|
package/hedhog/data/route.yaml
CHANGED
|
@@ -692,6 +692,12 @@
|
|
|
692
692
|
role:
|
|
693
693
|
- where:
|
|
694
694
|
slug: admin
|
|
695
|
+
- url: /dashboard-component/user
|
|
696
|
+
method: GET
|
|
697
|
+
relations:
|
|
698
|
+
role:
|
|
699
|
+
- where:
|
|
700
|
+
slug: admin
|
|
695
701
|
- url: /dashboard-component
|
|
696
702
|
method: POST
|
|
697
703
|
relations:
|
|
@@ -716,6 +722,30 @@
|
|
|
716
722
|
role:
|
|
717
723
|
- where:
|
|
718
724
|
slug: admin
|
|
725
|
+
- url: /dashboard-component-role
|
|
726
|
+
method: GET
|
|
727
|
+
relations:
|
|
728
|
+
role:
|
|
729
|
+
- where:
|
|
730
|
+
slug: admin
|
|
731
|
+
- url: /dashboard-component-role
|
|
732
|
+
method: POST
|
|
733
|
+
relations:
|
|
734
|
+
role:
|
|
735
|
+
- where:
|
|
736
|
+
slug: admin
|
|
737
|
+
- url: /dashboard-component-role/:id
|
|
738
|
+
method: DELETE
|
|
739
|
+
relations:
|
|
740
|
+
role:
|
|
741
|
+
- where:
|
|
742
|
+
slug: admin
|
|
743
|
+
- url: /dashboard-component-role/component/:componentId/role/:roleId
|
|
744
|
+
method: DELETE
|
|
745
|
+
relations:
|
|
746
|
+
role:
|
|
747
|
+
- where:
|
|
748
|
+
slug: admin
|
|
719
749
|
- url: /dashboard-item
|
|
720
750
|
method: GET
|
|
721
751
|
relations:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.171",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"sharp": "^0.34.2",
|
|
30
30
|
"speakeasy": "^2.0.0",
|
|
31
31
|
"uuid": "^11.1.0",
|
|
32
|
-
"@hed-hog/api-prisma": "0.0.4",
|
|
33
32
|
"@hed-hog/api-locale": "0.0.11",
|
|
34
|
-
"@hed-hog/api": "0.0.
|
|
33
|
+
"@hed-hog/api-prisma": "0.0.4",
|
|
35
34
|
"@hed-hog/api-mail": "0.0.7",
|
|
35
|
+
"@hed-hog/api": "0.0.3",
|
|
36
36
|
"@hed-hog/types": "0.0.1",
|
|
37
37
|
"@hed-hog/api-pagination": "0.0.5"
|
|
38
38
|
},
|
|
@@ -28,8 +28,13 @@ export class DashboardComponentController {
|
|
|
28
28
|
) {}
|
|
29
29
|
|
|
30
30
|
@Get()
|
|
31
|
-
getAllComponents(@Pagination() paginationParams
|
|
32
|
-
return this.dashboardComponentService.getAllComponents(paginationParams
|
|
31
|
+
getAllComponents(@Pagination() paginationParams) {
|
|
32
|
+
return this.dashboardComponentService.getAllComponents(paginationParams);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Get('user')
|
|
36
|
+
getAllComponentsByUserRole(@Pagination() paginationParams, @User() { id }) {
|
|
37
|
+
return this.dashboardComponentService.getAllComponentsByUserRole(paginationParams, id);
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
@Get(':id')
|
|
@@ -20,8 +20,50 @@ export class DashboardComponentService {
|
|
|
20
20
|
private readonly paginationService: PaginationService,
|
|
21
21
|
) {}
|
|
22
22
|
|
|
23
|
-
async getAllComponents(paginationParams: PaginationDTO
|
|
24
|
-
const
|
|
23
|
+
async getAllComponents(paginationParams: PaginationDTO) {
|
|
24
|
+
const fields = ['slug']
|
|
25
|
+
const OR = this.prismaService.createInsensitiveSearch(
|
|
26
|
+
fields,
|
|
27
|
+
paginationParams,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (paginationParams.search) {
|
|
31
|
+
OR.push({
|
|
32
|
+
dashboard_component_locale: {
|
|
33
|
+
some: {
|
|
34
|
+
name: {
|
|
35
|
+
contains: paginationParams.search,
|
|
36
|
+
mode: 'insensitive',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return this.paginationService.paginate(
|
|
44
|
+
this.prismaService.dashboard_component,
|
|
45
|
+
paginationParams,
|
|
46
|
+
{
|
|
47
|
+
include: {
|
|
48
|
+
dashboard_component_locale: {
|
|
49
|
+
include: {
|
|
50
|
+
locale: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
where: {
|
|
55
|
+
OR,
|
|
56
|
+
},
|
|
57
|
+
orderBy: {
|
|
58
|
+
created_at: 'desc',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
'dashboardComponent',
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getAllComponentsByUserRole(paginationParams: PaginationDTO, userId: number) {
|
|
66
|
+
const userRoles = await this.prismaService.role_user.findMany({
|
|
25
67
|
where: { user_id: userId },
|
|
26
68
|
select: { role_id: true },
|
|
27
69
|
});
|
|
@@ -61,7 +103,6 @@ export class DashboardComponentService {
|
|
|
61
103
|
where: {
|
|
62
104
|
AND: [
|
|
63
105
|
{
|
|
64
|
-
// @ts-ignore
|
|
65
106
|
dashboard_component_role: {
|
|
66
107
|
some: {
|
|
67
108
|
role_id: {
|
|
@@ -94,7 +135,6 @@ export class DashboardComponentService {
|
|
|
94
135
|
const component = await this.prismaService.dashboard_component.findFirst({
|
|
95
136
|
where: {
|
|
96
137
|
id,
|
|
97
|
-
// @ts-ignore
|
|
98
138
|
dashboard_component_role: {
|
|
99
139
|
some: {
|
|
100
140
|
role_id: {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
|
+
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
+
import { Pagination } from '@hed-hog/api-pagination';
|
|
4
|
+
import {
|
|
5
|
+
Body,
|
|
6
|
+
Controller,
|
|
7
|
+
Delete,
|
|
8
|
+
Get,
|
|
9
|
+
Inject,
|
|
10
|
+
Param,
|
|
11
|
+
ParseIntPipe,
|
|
12
|
+
Post,
|
|
13
|
+
Query,
|
|
14
|
+
forwardRef,
|
|
15
|
+
} from '@nestjs/common';
|
|
16
|
+
import { DashboardComponentRoleService } from './dashboard-component-role.service';
|
|
17
|
+
import { CreateDashboardComponentRoleDTO } from './dto';
|
|
18
|
+
|
|
19
|
+
@Role()
|
|
20
|
+
@Controller('dashboard-component-role')
|
|
21
|
+
export class DashboardComponentRoleController {
|
|
22
|
+
constructor(
|
|
23
|
+
@Inject(forwardRef(() => DashboardComponentRoleService))
|
|
24
|
+
private readonly service: DashboardComponentRoleService,
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
@Get()
|
|
28
|
+
getAll(
|
|
29
|
+
@Pagination() paginationParams,
|
|
30
|
+
@Locale() locale: string,
|
|
31
|
+
@Query('componentId') componentId?: string,
|
|
32
|
+
) {
|
|
33
|
+
if (componentId) {
|
|
34
|
+
return this.service.getAllByComponent(parseInt(componentId), locale);
|
|
35
|
+
}
|
|
36
|
+
return this.service.getAll(paginationParams, locale);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Post()
|
|
40
|
+
create(@Body() data: CreateDashboardComponentRoleDTO, @Locale() locale: string) {
|
|
41
|
+
return this.service.create(data, locale);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Delete(':id')
|
|
45
|
+
delete(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
|
|
46
|
+
return this.service.delete(id, locale);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Delete('component/:componentId/role/:roleId')
|
|
50
|
+
deleteByComponentAndRole(
|
|
51
|
+
@Param('componentId', ParseIntPipe) componentId: number,
|
|
52
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
|
53
|
+
@Locale() locale: string,
|
|
54
|
+
) {
|
|
55
|
+
return this.service.deleteByComponentAndRole(componentId, roleId, locale);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PaginationModule } from '@hed-hog/api-pagination';
|
|
2
|
+
import { PrismaModule } from '@hed-hog/api-prisma';
|
|
3
|
+
import { forwardRef, Module } from '@nestjs/common';
|
|
4
|
+
import { DashboardComponentRoleController } from './dashboard-component-role.controller';
|
|
5
|
+
import { DashboardComponentRoleService } from './dashboard-component-role.service';
|
|
6
|
+
|
|
7
|
+
@Module({
|
|
8
|
+
imports: [forwardRef(() => PrismaModule), forwardRef(() => PaginationModule)],
|
|
9
|
+
controllers: [DashboardComponentRoleController],
|
|
10
|
+
providers: [DashboardComponentRoleService],
|
|
11
|
+
exports: [DashboardComponentRoleService],
|
|
12
|
+
})
|
|
13
|
+
export class DashboardComponentRoleModule {}
|