@hedhog/admin 0.48.6 → 0.48.7

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.
Files changed (170) hide show
  1. package/dist/admin.module.d.ts.map +1 -1
  2. package/dist/admin.module.js +2 -0
  3. package/dist/admin.module.js.map +1 -1
  4. package/dist/auth/consts/body.d.ts.map +1 -1
  5. package/dist/dashboard/dashboard/dashboard.controller.d.ts +22 -0
  6. package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -0
  7. package/dist/dashboard/dashboard/dashboard.controller.js +88 -0
  8. package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -0
  9. package/dist/dashboard/dashboard/dashboard.module.d.ts +3 -0
  10. package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -0
  11. package/dist/dashboard/dashboard/dashboard.module.js +26 -0
  12. package/dist/dashboard/dashboard/dashboard.module.js.map +1 -0
  13. package/dist/dashboard/dashboard/dashboard.service.d.ts +30 -0
  14. package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -0
  15. package/dist/dashboard/dashboard/dashboard.service.js +61 -0
  16. package/dist/dashboard/dashboard/dashboard.service.js.map +1 -0
  17. package/dist/dashboard/dashboard/dto/create.dto.d.ts +5 -0
  18. package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -0
  19. package/dist/dashboard/dashboard/dto/create.dto.js +23 -0
  20. package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -0
  21. package/dist/dashboard/dashboard/dto/update.dto.d.ts +6 -0
  22. package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -0
  23. package/dist/dashboard/dashboard/dto/update.dto.js +9 -0
  24. package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -0
  25. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +22 -0
  26. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -0
  27. package/dist/dashboard/dashboard-component/dashboard-component.controller.js +90 -0
  28. package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -0
  29. package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts +3 -0
  30. package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts.map +1 -0
  31. package/dist/dashboard/dashboard-component/dashboard-component.module.js +26 -0
  32. package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -0
  33. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +30 -0
  34. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -0
  35. package/dist/dashboard/dashboard-component/dashboard-component.service.js +59 -0
  36. package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -0
  37. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +13 -0
  38. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -0
  39. package/dist/dashboard/dashboard-component/dto/create.dto.js +59 -0
  40. package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -0
  41. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +6 -0
  42. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -0
  43. package/dist/dashboard/dashboard-component/dto/update.dto.js +9 -0
  44. package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -0
  45. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +52 -0
  46. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -0
  47. package/dist/dashboard/dashboard-item/dashboard-item.controller.js +88 -0
  48. package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -0
  49. package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts +3 -0
  50. package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts.map +1 -0
  51. package/dist/dashboard/dashboard-item/dashboard-item.module.js +26 -0
  52. package/dist/dashboard/dashboard-item/dashboard-item.module.js.map +1 -0
  53. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +57 -0
  54. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -0
  55. package/dist/dashboard/dashboard-item/dashboard-item.service.js +77 -0
  56. package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -0
  57. package/dist/dashboard/dashboard-item/dto/create.dto.d.ts +9 -0
  58. package/dist/dashboard/dashboard-item/dto/create.dto.d.ts.map +1 -0
  59. package/dist/dashboard/dashboard-item/dto/create.dto.js +41 -0
  60. package/dist/dashboard/dashboard-item/dto/create.dto.js.map +1 -0
  61. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +6 -0
  62. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -0
  63. package/dist/dashboard/dashboard-item/dto/update.dto.js +9 -0
  64. package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -0
  65. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +52 -0
  66. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts.map +1 -0
  67. package/dist/dashboard/dashboard-user/dashboard-user.controller.js +88 -0
  68. package/dist/dashboard/dashboard-user/dashboard-user.controller.js.map +1 -0
  69. package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts +3 -0
  70. package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts.map +1 -0
  71. package/dist/dashboard/dashboard-user/dashboard-user.module.js +26 -0
  72. package/dist/dashboard/dashboard-user/dashboard-user.module.js.map +1 -0
  73. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +59 -0
  74. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts.map +1 -0
  75. package/dist/dashboard/dashboard-user/dashboard-user.service.js +83 -0
  76. package/dist/dashboard/dashboard-user/dashboard-user.service.js.map +1 -0
  77. package/dist/dashboard/dashboard-user/dto/create.dto.d.ts +10 -0
  78. package/dist/dashboard/dashboard-user/dto/create.dto.d.ts.map +1 -0
  79. package/dist/dashboard/dashboard-user/dto/create.dto.js +42 -0
  80. package/dist/dashboard/dashboard-user/dto/create.dto.js.map +1 -0
  81. package/dist/dashboard/dashboard-user/dto/update.dto.d.ts +6 -0
  82. package/dist/dashboard/dashboard-user/dto/update.dto.d.ts.map +1 -0
  83. package/dist/dashboard/dashboard-user/dto/update.dto.js +9 -0
  84. package/dist/dashboard/dashboard-user/dto/update.dto.js.map +1 -0
  85. package/dist/dashboard/dashboard.module.d.ts +3 -0
  86. package/dist/dashboard/dashboard.module.d.ts.map +1 -0
  87. package/dist/dashboard/dashboard.module.js +35 -0
  88. package/dist/dashboard/dashboard.module.js.map +1 -0
  89. package/dist/dashboard/index.d.ts +2 -0
  90. package/dist/dashboard/index.d.ts.map +1 -0
  91. package/dist/dashboard/index.js +18 -0
  92. package/dist/dashboard/index.js.map +1 -0
  93. package/dist/emails/lib.d.ts.map +1 -1
  94. package/frontend/dashboard/components/create-panel.tsx.ejs +63 -0
  95. package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -0
  96. package/frontend/dashboard/components/update-panel.tsx.ejs +80 -0
  97. package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -0
  98. package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -0
  99. package/frontend/dashboard/react-query/handlers.ts.ejs +28 -0
  100. package/frontend/dashboard/react-query/requests.ts.ejs +56 -0
  101. package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -0
  102. package/frontend/dashboard-component/components/dashboard-component.screen.tsx.ejs +135 -0
  103. package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -0
  104. package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -0
  105. package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -0
  106. package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -0
  107. package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -0
  108. package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -0
  109. package/frontend/dashboard-item/components/dashboard-item.screen.tsx.ejs +133 -0
  110. package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -0
  111. package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -0
  112. package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -0
  113. package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -0
  114. package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -0
  115. package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -0
  116. package/frontend/dashboard-user/components/dashboard-user.screen.tsx.ejs +131 -0
  117. package/frontend/dashboard-user/components/update-panel.tsx.ejs +138 -0
  118. package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -0
  119. package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -0
  120. package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -0
  121. package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -0
  122. package/frontend/translation/fields/en.json +23 -1
  123. package/frontend/translation/fields/pt.json +27 -1
  124. package/frontend/translation/modules/en.json +6 -1
  125. package/frontend/translation/modules/pt.json +6 -1
  126. package/hedhog.yaml +439 -0
  127. package/package.json +2 -2
  128. package/src/admin.module.ts +2 -0
  129. package/src/dashboard/dashboard/dashboard.controller.ts +49 -0
  130. package/src/dashboard/dashboard/dashboard.module.ts +13 -0
  131. package/src/dashboard/dashboard/dashboard.service.ts +71 -0
  132. package/src/dashboard/dashboard/dto/create.dto.ts +8 -0
  133. package/src/dashboard/dashboard/dto/update.dto.ts +4 -0
  134. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -0
  135. package/src/dashboard/dashboard-component/dashboard-component.module.ts +14 -0
  136. package/src/dashboard/dashboard-component/dashboard-component.service.ts +70 -0
  137. package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -0
  138. package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -0
  139. package/src/dashboard/dashboard-item/dashboard-item.controller.ts +55 -0
  140. package/src/dashboard/dashboard-item/dashboard-item.module.ts +13 -0
  141. package/src/dashboard/dashboard-item/dashboard-item.service.ts +82 -0
  142. package/src/dashboard/dashboard-item/dto/create.dto.ts +22 -0
  143. package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -0
  144. package/src/dashboard/dashboard-user/dashboard-user.controller.ts +55 -0
  145. package/src/dashboard/dashboard-user/dashboard-user.module.ts +13 -0
  146. package/src/dashboard/dashboard-user/dashboard-user.service.ts +89 -0
  147. package/src/dashboard/dashboard-user/dto/create.dto.ts +22 -0
  148. package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -0
  149. package/src/dashboard/dashboard.module.ts +22 -0
  150. package/src/dashboard/index.ts +1 -0
  151. package/frontend/menu-locale/locales/en/admin.menu-locale.json +0 -11
  152. package/frontend/menu-locale/locales/pt/admin.menu-locale.json +0 -11
  153. package/frontend/menu-screen/locales/en/admin.menu-screen.json +0 -11
  154. package/frontend/menu-screen/locales/pt/admin.menu-screen.json +0 -11
  155. package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +0 -11
  156. package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +0 -11
  157. package/frontend/screen-locale/locales/en/admin.screen-locale.json +0 -11
  158. package/frontend/screen-locale/locales/pt/admin.screen-locale.json +0 -11
  159. package/frontend/translation/components/create-panel.tsx.ejs +0 -52
  160. package/frontend/translation/components/update-panel.tsx.ejs +0 -67
  161. package/frontend/translation/locales/en/admin.translation.json +0 -11
  162. package/frontend/translation/locales/pt/admin.translation.json +0 -11
  163. package/frontend/translation/react-query/handlers.ts.ejs +0 -28
  164. package/frontend/translation/react-query/requests.ts.ejs +0 -58
  165. package/frontend/translation-namespace/components/create-panel.tsx.ejs +0 -53
  166. package/frontend/translation-namespace/components/update-panel.tsx.ejs +0 -70
  167. package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +0 -11
  168. package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +0 -11
  169. package/frontend/translation-namespace/react-query/handlers.ts.ejs +0 -28
  170. package/frontend/translation-namespace/react-query/requests.ts.ejs +0 -60
@@ -0,0 +1,70 @@
1
+ import { PaginationDTO } from '@hedhog/pagination';
2
+ import { PrismaService } from '@hedhog/prisma';
3
+ import {
4
+ BadRequestException,
5
+ Inject,
6
+ Injectable,
7
+ forwardRef,
8
+ } from '@nestjs/common';
9
+ import { CreateDTO } from './dto/create.dto';
10
+ import { DeleteDTO } from '@hedhog/core';
11
+ import { UpdateDTO } from './dto/update.dto';
12
+ import { LocaleService } from '@hedhog/locale';
13
+
14
+ @Injectable()
15
+ export class DashboardComponentService {
16
+ private readonly modelName = 'dashboard_component';
17
+ private readonly foreignKey = 'component_id';
18
+
19
+ constructor(
20
+ @Inject(forwardRef(() => PrismaService))
21
+ private readonly prismaService: PrismaService,
22
+ @Inject(forwardRef(() => LocaleService))
23
+ private readonly localeService: LocaleService,
24
+ ) {}
25
+
26
+ async list(locale: string, paginationParams: PaginationDTO) {
27
+ return this.localeService.listModelWithLocale(
28
+ locale,
29
+ this.modelName,
30
+ paginationParams,
31
+ );
32
+ }
33
+
34
+ async get(id: number) {
35
+ return this.localeService.getModelWithLocale(this.modelName, id);
36
+ }
37
+
38
+ async create(data: CreateDTO) {
39
+ return this.localeService.createModelWithLocale(
40
+ this.modelName,
41
+ this.foreignKey,
42
+ data,
43
+ );
44
+ }
45
+
46
+ async update({ id, data }: { id: number; data: UpdateDTO }) {
47
+ return this.localeService.updateModelWithLocale(
48
+ this.modelName,
49
+ this.foreignKey,
50
+ id,
51
+ data,
52
+ );
53
+ }
54
+
55
+ async delete({ ids }: DeleteDTO) {
56
+ if (ids == undefined || ids == null) {
57
+ throw new BadRequestException(
58
+ 'You must select at least one item to delete.',
59
+ );
60
+ }
61
+
62
+ return this.prismaService.dashboard_component.deleteMany({
63
+ where: {
64
+ id: {
65
+ in: ids,
66
+ },
67
+ },
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,36 @@
1
+ import { IsString, IsNumber, IsBoolean, IsOptional } from 'class-validator';
2
+ import { WithLocaleDTO } from '@hedhog/locale';
3
+
4
+ export class CreateDTO extends WithLocaleDTO {
5
+ @IsString()
6
+ slug: string;
7
+
8
+ @IsString()
9
+ path: string;
10
+
11
+ @IsOptional()
12
+ @IsNumber()
13
+ min_width?: number;
14
+
15
+ @IsOptional()
16
+ @IsNumber()
17
+ max_width?: number;
18
+
19
+ @IsOptional()
20
+ @IsNumber()
21
+ min_height?: number;
22
+
23
+ @IsOptional()
24
+ @IsNumber()
25
+ max_height?: number;
26
+
27
+ @IsNumber()
28
+ width: number;
29
+
30
+ @IsNumber()
31
+ height: number;
32
+
33
+ @IsOptional()
34
+ @IsBoolean()
35
+ is_resizable?: boolean;
36
+ }
@@ -0,0 +1,4 @@
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -0,0 +1,55 @@
1
+ import { Pagination } from '@hedhog/pagination';
2
+ import { Locale } from '@hedhog/locale';
3
+ import {
4
+ Body,
5
+ Controller,
6
+ Delete,
7
+ Get,
8
+ Inject,
9
+ Param,
10
+ ParseIntPipe,
11
+ Patch,
12
+ Post,
13
+ forwardRef,
14
+ } from '@nestjs/common';
15
+ import { CreateDTO } from './dto/create.dto';
16
+ import { UpdateDTO } from './dto/update.dto';
17
+ import { DashboardItemService } from './dashboard-item.service';
18
+ import { Role, DeleteDTO } from '@hedhog/core';
19
+
20
+ @Role()
21
+ @Controller('dashboard-item')
22
+ export class DashboardItemController {
23
+ constructor(
24
+ @Inject(forwardRef(() => DashboardItemService))
25
+ private readonly dashboardItemService: DashboardItemService,
26
+ ) {}
27
+
28
+ @Get()
29
+ async list(@Pagination() paginationParams) {
30
+ return this.dashboardItemService.list(paginationParams);
31
+ }
32
+
33
+ @Get(':id')
34
+ async get(@Param('id', ParseIntPipe) id: number) {
35
+ return this.dashboardItemService.get(id);
36
+ }
37
+
38
+ @Post()
39
+ async create(@Body() data: CreateDTO) {
40
+ return this.dashboardItemService.create(data);
41
+ }
42
+
43
+ @Patch(':id')
44
+ async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
+ return this.dashboardItemService.update({
46
+ id,
47
+ data,
48
+ });
49
+ }
50
+
51
+ @Delete()
52
+ async delete(@Body() data: DeleteDTO) {
53
+ return this.dashboardItemService.delete(data);
54
+ }
55
+ }
@@ -0,0 +1,13 @@
1
+ import { PaginationModule } from '@hedhog/pagination';
2
+ import { PrismaModule } from '@hedhog/prisma';
3
+ import { forwardRef, Module } from '@nestjs/common';
4
+ import { DashboardItemService } from './dashboard-item.service';
5
+ import { DashboardItemController } from './dashboard-item.controller';
6
+
7
+ @Module({
8
+ imports: [forwardRef(() => PrismaModule), forwardRef(() => PaginationModule)],
9
+ controllers: [DashboardItemController],
10
+ providers: [DashboardItemService],
11
+ exports: [DashboardItemService],
12
+ })
13
+ export class DashboardItemModule {}
@@ -0,0 +1,82 @@
1
+ import { DeleteDTO } from '@hedhog/core';
2
+ import { PaginationDTO, PaginationService } from '@hedhog/pagination';
3
+ import { PrismaService } from '@hedhog/prisma';
4
+ import {
5
+ BadRequestException,
6
+ Inject,
7
+ Injectable,
8
+ forwardRef,
9
+ } from '@nestjs/common';
10
+ import { CreateDTO } from './dto/create.dto';
11
+ import { UpdateDTO } from './dto/update.dto';
12
+
13
+ @Injectable()
14
+ export class DashboardItemService {
15
+ constructor(
16
+ @Inject(forwardRef(() => PrismaService))
17
+ private readonly prismaService: PrismaService,
18
+ @Inject(forwardRef(() => PaginationService))
19
+ private readonly paginationService: PaginationService,
20
+ ) {}
21
+
22
+ async list(paginationParams: PaginationDTO) {
23
+ const fields = [];
24
+ const OR: any[] = this.prismaService.createInsensitiveSearch(
25
+ fields,
26
+ paginationParams,
27
+ );
28
+
29
+ if (paginationParams.search && !isNaN(+paginationParams.search)) {
30
+ OR.push({ id: { equals: +paginationParams.search } });
31
+ }
32
+
33
+ return this.paginationService.paginate(
34
+ this.prismaService.dashboard_item,
35
+ paginationParams,
36
+ {
37
+ where: {
38
+ OR,
39
+ },
40
+ include: {
41
+ dashboard_component: true,
42
+ dashboard: true,
43
+ },
44
+ },
45
+ );
46
+ }
47
+
48
+ async get(id: number) {
49
+ return this.prismaService.dashboard_item.findUnique({
50
+ where: { id: id },
51
+ });
52
+ }
53
+
54
+ async create(data: CreateDTO) {
55
+ return this.prismaService.dashboard_item.create({
56
+ data,
57
+ });
58
+ }
59
+
60
+ async update({ id, data }: { id: number; data: UpdateDTO }) {
61
+ return this.prismaService.dashboard_item.update({
62
+ where: { id: id },
63
+ data,
64
+ });
65
+ }
66
+
67
+ async delete({ ids }: DeleteDTO) {
68
+ if (ids == undefined || ids == null) {
69
+ throw new BadRequestException(
70
+ 'You must select at least one item to delete.',
71
+ );
72
+ }
73
+
74
+ return this.prismaService.dashboard_item.deleteMany({
75
+ where: {
76
+ id: {
77
+ in: ids,
78
+ },
79
+ },
80
+ });
81
+ }
82
+ }
@@ -0,0 +1,22 @@
1
+ import { IsString, IsNumber, IsBoolean, IsOptional } from 'class-validator';
2
+ import { WithLocaleDTO } from '@hedhog/locale';
3
+
4
+ export class CreateDTO {
5
+ @IsNumber()
6
+ component_id: number;
7
+
8
+ @IsNumber()
9
+ dashboard_id: number;
10
+
11
+ @IsNumber()
12
+ width: number;
13
+
14
+ @IsNumber()
15
+ height: number;
16
+
17
+ @IsNumber()
18
+ x_axis: number;
19
+
20
+ @IsNumber()
21
+ y_axis: number;
22
+ }
@@ -0,0 +1,4 @@
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -0,0 +1,55 @@
1
+ import { Pagination } from '@hedhog/pagination';
2
+ import { Locale } from '@hedhog/locale';
3
+ import {
4
+ Body,
5
+ Controller,
6
+ Delete,
7
+ Get,
8
+ Inject,
9
+ Param,
10
+ ParseIntPipe,
11
+ Patch,
12
+ Post,
13
+ forwardRef,
14
+ } from '@nestjs/common';
15
+ import { CreateDTO } from './dto/create.dto';
16
+ import { UpdateDTO } from './dto/update.dto';
17
+ import { DashboardUserService } from './dashboard-user.service';
18
+ import { Role, DeleteDTO } from '@hedhog/core';
19
+
20
+ @Role()
21
+ @Controller('dashboard-user')
22
+ export class DashboardUserController {
23
+ constructor(
24
+ @Inject(forwardRef(() => DashboardUserService))
25
+ private readonly dashboardUserService: DashboardUserService,
26
+ ) {}
27
+
28
+ @Get()
29
+ async list(@Pagination() paginationParams) {
30
+ return this.dashboardUserService.list(paginationParams);
31
+ }
32
+
33
+ @Get(':id')
34
+ async get(@Param('id', ParseIntPipe) id: number) {
35
+ return this.dashboardUserService.get(id);
36
+ }
37
+
38
+ @Post()
39
+ async create(@Body() data: CreateDTO) {
40
+ return this.dashboardUserService.create(data);
41
+ }
42
+
43
+ @Patch(':id')
44
+ async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
+ return this.dashboardUserService.update({
46
+ id,
47
+ data,
48
+ });
49
+ }
50
+
51
+ @Delete()
52
+ async delete(@Body() data: DeleteDTO) {
53
+ return this.dashboardUserService.delete(data);
54
+ }
55
+ }
@@ -0,0 +1,13 @@
1
+ import { PaginationModule } from '@hedhog/pagination';
2
+ import { PrismaModule } from '@hedhog/prisma';
3
+ import { forwardRef, Module } from '@nestjs/common';
4
+ import { DashboardUserService } from './dashboard-user.service';
5
+ import { DashboardUserController } from './dashboard-user.controller';
6
+
7
+ @Module({
8
+ imports: [forwardRef(() => PrismaModule), forwardRef(() => PaginationModule)],
9
+ controllers: [DashboardUserController],
10
+ providers: [DashboardUserService],
11
+ exports: [DashboardUserService],
12
+ })
13
+ export class DashboardUserModule {}
@@ -0,0 +1,89 @@
1
+ import { DeleteDTO } from '@hedhog/core';
2
+ import { PaginationDTO, PaginationService } from '@hedhog/pagination';
3
+ import { PrismaService } from '@hedhog/prisma';
4
+ import {
5
+ BadRequestException,
6
+ Inject,
7
+ Injectable,
8
+ forwardRef,
9
+ } from '@nestjs/common';
10
+ import { CreateDTO } from './dto/create.dto';
11
+ import { UpdateDTO } from './dto/update.dto';
12
+
13
+ @Injectable()
14
+ export class DashboardUserService {
15
+ private readonly modelName = 'dashboard_user';
16
+ private readonly foreignKey = 'user_id';
17
+
18
+ constructor(
19
+ @Inject(forwardRef(() => PrismaService))
20
+ private readonly prismaService: PrismaService,
21
+ @Inject(forwardRef(() => PaginationService))
22
+ private readonly paginationService: PaginationService,
23
+ ) {}
24
+
25
+ async list(paginationParams: PaginationDTO) {
26
+ const fields = [];
27
+ const OR: any[] = this.prismaService.createInsensitiveSearch(
28
+ fields,
29
+ paginationParams,
30
+ );
31
+
32
+ if (paginationParams.search && !isNaN(+paginationParams.search)) {
33
+ OR.push({ id: { equals: +paginationParams.search } });
34
+ }
35
+
36
+ return this.paginationService.paginate(
37
+ this.prismaService.dashboard_user,
38
+ paginationParams,
39
+ {
40
+ where: {
41
+ OR,
42
+ },
43
+ include: {
44
+ dashboard_item: {
45
+ include: {
46
+ dashboard_component: true,
47
+ },
48
+ },
49
+ user: true,
50
+ },
51
+ },
52
+ );
53
+ }
54
+
55
+ async get(id: number) {
56
+ return this.prismaService.dashboard_user.findUnique({
57
+ where: { id: id },
58
+ });
59
+ }
60
+
61
+ async create(data: CreateDTO) {
62
+ return this.prismaService.dashboard_user.create({
63
+ data,
64
+ });
65
+ }
66
+
67
+ async update({ id, data }: { id: number; data: UpdateDTO }) {
68
+ return this.prismaService.dashboard_user.update({
69
+ where: { id: id },
70
+ data,
71
+ });
72
+ }
73
+
74
+ async delete({ ids }: DeleteDTO) {
75
+ if (ids == undefined || ids == null) {
76
+ throw new BadRequestException(
77
+ 'You must select at least one item to delete.',
78
+ );
79
+ }
80
+
81
+ return this.prismaService.dashboard_user.deleteMany({
82
+ where: {
83
+ id: {
84
+ in: ids,
85
+ },
86
+ },
87
+ });
88
+ }
89
+ }
@@ -0,0 +1,22 @@
1
+ import { IsString, IsNumber, IsBoolean, IsOptional } from 'class-validator';
2
+ import { WithLocaleDTO } from '@hedhog/locale';
3
+
4
+ export class CreateDTO extends WithLocaleDTO {
5
+ @IsNumber()
6
+ item_id: number;
7
+
8
+ @IsNumber()
9
+ user_id: number;
10
+
11
+ @IsNumber()
12
+ width: number;
13
+
14
+ @IsNumber()
15
+ height: number;
16
+
17
+ @IsNumber()
18
+ x_axis: number;
19
+
20
+ @IsNumber()
21
+ y_axis: number;
22
+ }
@@ -0,0 +1,4 @@
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -0,0 +1,22 @@
1
+ import { DashboardComponentModule } from './dashboard-component/dashboard-component.module';
2
+ import { DashboardUserModule } from './dashboard-user/dashboard-user.module';
3
+ import { DashboardItemModule } from './dashboard-item/dashboard-item.module';
4
+ import { LocaleModule } from '@hedhog/locale';
5
+ import { PrismaModule } from '@hedhog/prisma';
6
+ import { forwardRef, Module } from '@nestjs/common';
7
+ import { DashboardModule2 } from './dashboard/dashboard.module';
8
+
9
+ @Module({
10
+ imports: [
11
+ forwardRef(() => LocaleModule),
12
+ forwardRef(() => PrismaModule),
13
+ forwardRef(() => DashboardModule2),
14
+ forwardRef(() => DashboardComponentModule),
15
+ forwardRef(() => DashboardItemModule),
16
+ forwardRef(() => DashboardUserModule),
17
+ ],
18
+ controllers: [],
19
+ providers: [],
20
+ exports: [],
21
+ })
22
+ export class DashboardModule {}
@@ -0,0 +1 @@
1
+ export * from './dashboard.module';
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Create menu locale",
3
- "createText": "Fill the menu locale informations.",
4
- "createTooltip": "Create new menu locale",
5
- "delete": "Delete menu locale",
6
- "deleteText": "Are you sure to delete these menu locale?",
7
- "deleteTooltip": "Delete the selected menu locale",
8
- "edit": "Edit menu locale",
9
- "editText": "View and edit menu locale information.",
10
- "editTooltip": "Edit the selected menu locale"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Criar menu locale",
3
- "createText": "Preencha as informações do menu locale.",
4
- "createTooltip": "Criar novo menu locale",
5
- "delete": "Excluir menu locale",
6
- "deleteText": "Você tem certeza de que deseja excluir esses menu locale?",
7
- "deleteTooltip": "Excluir o menu locale selecionado",
8
- "edit": "Editar menu locale",
9
- "editText": "Visualizar e editar informações do menu locale.",
10
- "editTooltip": "Editar o menu locale selecionado"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Create menu screen",
3
- "createText": "Fill the menu screen informations.",
4
- "createTooltip": "Create new menu screen",
5
- "delete": "Delete menu screen",
6
- "deleteText": "Are you sure to delete these menu screen?",
7
- "deleteTooltip": "Delete the selected menu screen",
8
- "edit": "Edit menu screen",
9
- "editText": "View and edit menu screen information.",
10
- "editTooltip": "Edit the selected menu screen"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Criar menu screen",
3
- "createText": "Preencha as informações do menu screen.",
4
- "createTooltip": "Criar novo menu screen",
5
- "delete": "Excluir menu screen",
6
- "deleteText": "Você tem certeza de que deseja excluir estes menu screen?",
7
- "deleteTooltip": "Excluir o menu screen selecionado",
8
- "edit": "Editar menu screen",
9
- "editText": "Visualizar e editar as informações do menu screen.",
10
- "editTooltip": "Editar o menu screen selecionado"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Create multifactor locale",
3
- "createText": "Fill the multifactor locale informations.",
4
- "createTooltip": "Create new multifactor locale",
5
- "delete": "Delete multifactor locale",
6
- "deleteText": "Are you sure to delete these multifactor locale?",
7
- "deleteTooltip": "Delete the selected multifactor locale",
8
- "edit": "Edit multifactor locale",
9
- "editText": "View and edit multifactor locale information.",
10
- "editTooltip": "Edit the selected multifactor locale"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Criar multifator local",
3
- "createText": "Preencha as informações do multifator local.",
4
- "createTooltip": "Criar novo multifator local",
5
- "delete": "Excluir multifator local",
6
- "deleteText": "Você tem certeza de que deseja excluir este multifator local?",
7
- "deleteTooltip": "Excluir o multifator local selecionado",
8
- "edit": "Editar multifator local",
9
- "editText": "Ver e editar as informações do multifator local.",
10
- "editTooltip": "Editar o multifator local selecionado"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Create screen locale",
3
- "createText": "Fill the screen locale informations.",
4
- "createTooltip": "Create new screen locale",
5
- "delete": "Delete screen locale",
6
- "deleteText": "Are you sure to delete these screen locale?",
7
- "deleteTooltip": "Delete the selected screen locale",
8
- "edit": "Edit screen locale",
9
- "editText": "View and edit screen locale information.",
10
- "editTooltip": "Edit the selected screen locale"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Criar tela locale",
3
- "createText": "Preencha as informações da tela locale.",
4
- "createTooltip": "Criar nova tela locale",
5
- "delete": "Excluir tela locale",
6
- "deleteText": "Você tem certeza de que deseja excluir estas telas locale?",
7
- "deleteTooltip": "Excluir a tela locale selecionada",
8
- "edit": "Editar tela locale",
9
- "editText": "Visualizar e editar as informações da tela locale.",
10
- "editTooltip": "Editar a tela locale selecionada"
11
- }
@@ -1,52 +0,0 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
-
3
- import { useTranslationCreate } from "@/features/admin/translation";
4
- import { Translation } from "@/types/models";
5
- import { forwardRef, useImperativeHandle, useRef } from "react";
6
- import { useTranslation } from "react-i18next";
7
-
8
- export type TranslationCreatePanelRef = {
9
- submit: () => void;
10
- };
11
-
12
- export type TranslationCreatePanelProps = {
13
- onCreated?: (data: Translation) => void;
14
- };
15
-
16
- const TranslationCreatePanel = forwardRef(
17
- ({ onCreated }: TranslationCreatePanelProps, ref) => {
18
- const formRef = useRef<FormPanelRef>(null);
19
- const { t } = useTranslation(["actions", "fields", "translations"]);
20
- const { mutateAsync: createTranslation } = useTranslationCreate();
21
-
22
- useImperativeHandle(
23
- ref,
24
- () => ({
25
- submit: () => {
26
- formRef.current?.submit();
27
- },
28
- }),
29
- [formRef],
30
- );
31
-
32
- return (
33
- <FormPanel
34
- ref={formRef}
35
- fields={[]}
36
- button={{ text: t("create", { ns: "actions" }) }}
37
- onSubmit={async (data) => {
38
- const createdData = await createTranslation({
39
- data,
40
- });
41
- if (typeof onCreated === "function") {
42
- onCreated(createdData as any);
43
- }
44
- }}
45
- />
46
- );
47
- },
48
- );
49
-
50
- TranslationCreatePanel.displayName = "TranslationCreatePanel";
51
-
52
- export default TranslationCreatePanel;