@hedhog/admin 0.48.10 → 0.48.12

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 (134) hide show
  1. package/dist/admin.module.d.ts.map +1 -1
  2. package/dist/admin.module.js +4 -1
  3. package/dist/admin.module.js.map +1 -1
  4. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +29 -0
  5. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -0
  6. package/dist/dashboard/dashboard-core/dashboard-core.controller.js +38 -0
  7. package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -0
  8. package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts +3 -0
  9. package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts.map +1 -0
  10. package/dist/dashboard/dashboard-core/dashboard-core.module.js +26 -0
  11. package/dist/dashboard/dashboard-core/dashboard-core.module.js.map +1 -0
  12. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +29 -0
  13. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -0
  14. package/dist/dashboard/dashboard-core/dashboard-core.service.js +33 -0
  15. package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -0
  16. package/dist/dashboard/dashboard.module.d.ts.map +1 -1
  17. package/dist/dashboard/dashboard.module.js +5 -3
  18. package/dist/dashboard/dashboard.module.js.map +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/setting/dto/create.dto.d.ts +9 -0
  24. package/dist/setting/dto/create.dto.d.ts.map +1 -0
  25. package/dist/setting/dto/create.dto.js +40 -0
  26. package/dist/setting/dto/create.dto.js.map +1 -0
  27. package/dist/setting/dto/delete.dto.d.ts +4 -0
  28. package/dist/setting/dto/delete.dto.d.ts.map +1 -0
  29. package/dist/setting/dto/delete.dto.js +23 -0
  30. package/dist/setting/dto/delete.dto.js.map +1 -0
  31. package/dist/setting/dto/setting-user.dto.d.ts +4 -0
  32. package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
  33. package/dist/setting/dto/setting-user.dto.js +21 -0
  34. package/dist/setting/dto/setting-user.dto.js.map +1 -0
  35. package/dist/setting/dto/setting.dto.d.ts +9 -0
  36. package/dist/setting/dto/setting.dto.d.ts.map +1 -0
  37. package/dist/setting/dto/setting.dto.js +34 -0
  38. package/dist/setting/dto/setting.dto.js.map +1 -0
  39. package/dist/setting/dto/update.dto.d.ts +6 -0
  40. package/dist/setting/dto/update.dto.d.ts.map +1 -0
  41. package/dist/setting/dto/update.dto.js +9 -0
  42. package/dist/setting/dto/update.dto.js.map +1 -0
  43. package/dist/setting/setting.controller.d.ts +102 -0
  44. package/dist/setting/setting.controller.d.ts.map +1 -0
  45. package/dist/setting/setting.controller.js +160 -0
  46. package/dist/setting/setting.controller.js.map +1 -0
  47. package/dist/setting/setting.module.d.ts +3 -0
  48. package/dist/setting/setting.module.d.ts.map +1 -0
  49. package/dist/setting/setting.module.js +31 -0
  50. package/dist/setting/setting.module.js.map +1 -0
  51. package/dist/setting/setting.service.d.ts +103 -0
  52. package/dist/setting/setting.service.d.ts.map +1 -0
  53. package/dist/setting/setting.service.js +333 -0
  54. package/dist/setting/setting.service.js.map +1 -0
  55. package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
  56. package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
  57. package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
  58. package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
  59. package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
  60. package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
  61. package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
  62. package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
  63. package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
  64. package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
  65. package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
  66. package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
  67. package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
  68. package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
  69. package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
  70. package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
  71. package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
  72. package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
  73. package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
  74. package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
  75. package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
  76. package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
  77. package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
  78. package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
  79. package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
  80. package/hedhog/tables/dashboard.yaml +9 -0
  81. package/hedhog/tables/dashboard_component.yaml +34 -0
  82. package/hedhog/tables/dashboard_component_locale.yaml +24 -0
  83. package/hedhog/tables/dashboard_item.yaml +25 -0
  84. package/hedhog/tables/dashboard_locale.yaml +24 -0
  85. package/hedhog/tables/dashboard_user.yaml +25 -0
  86. package/hedhog/tables/menu.yaml +18 -0
  87. package/hedhog/tables/menu_locale.yaml +19 -0
  88. package/hedhog/tables/menu_screen.yaml +16 -0
  89. package/hedhog/tables/multifactor.yaml +6 -0
  90. package/hedhog/tables/multifactor_locale.yaml +19 -0
  91. package/hedhog/tables/role.yaml +6 -0
  92. package/hedhog/tables/role_locale.yaml +20 -0
  93. package/hedhog/tables/role_menu.yaml +18 -0
  94. package/hedhog/tables/role_route.yaml +18 -0
  95. package/hedhog/tables/role_screen.yaml +18 -0
  96. package/hedhog/tables/role_user.yaml +18 -0
  97. package/hedhog/tables/route.yaml +23 -0
  98. package/hedhog/tables/route_screen.yaml +18 -0
  99. package/hedhog/tables/screen.yaml +8 -0
  100. package/hedhog/tables/screen_locale.yaml +20 -0
  101. package/hedhog/tables/setting.yaml +27 -0
  102. package/hedhog/tables/setting_group.yaml +8 -0
  103. package/hedhog/tables/setting_group_locale.yaml +23 -0
  104. package/hedhog/tables/setting_locale.yaml +24 -0
  105. package/hedhog/tables/setting_user.yaml +21 -0
  106. package/hedhog/tables/translation.yaml +25 -0
  107. package/hedhog/tables/translation_namespace.yaml +6 -0
  108. package/hedhog/tables/user.yaml +18 -0
  109. package/hedhog/tables/user_activity.yaml +14 -0
  110. package/hedhog.yaml +142 -473
  111. package/isabelli.json +0 -0
  112. package/isabelli.xml +0 -0
  113. package/isabelli.yaml +0 -0
  114. package/package.json +1 -1
  115. package/src/admin.module.ts +4 -1
  116. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
  117. package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
  118. package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
  119. package/src/dashboard/dashboard-core/dashboard-core.controller.ts +12 -0
  120. package/src/dashboard/dashboard-core/dashboard-core.module.ts +14 -0
  121. package/src/dashboard/dashboard-core/dashboard-core.service.ts +16 -0
  122. package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
  123. package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
  124. package/src/dashboard/dashboard.module.ts +5 -3
  125. package/src/dashboard/index.ts +1 -1
  126. package/src/index.ts +2 -0
  127. package/src/setting/dto/create.dto.ts +21 -0
  128. package/src/setting/dto/delete.dto.ts +8 -0
  129. package/src/setting/dto/setting-user.dto.ts +6 -0
  130. package/src/setting/dto/setting.dto.ts +17 -0
  131. package/src/setting/dto/update.dto.ts +4 -0
  132. package/src/setting/setting.controller.ts +105 -0
  133. package/src/setting/setting.module.ts +18 -0
  134. package/src/setting/setting.service.ts +400 -0
package/isabelli.yaml ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedhog/admin",
3
- "version": "0.48.10",
3
+ "version": "0.48.12",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -5,12 +5,13 @@ import { PrismaModule } from '@hedhog/prisma';
5
5
  import { forwardRef, Module } from '@nestjs/common';
6
6
  import { ConfigModule } from '@nestjs/config';
7
7
  import { AuthModule } from './auth/auth.module';
8
- import { DashboardModule } from './dashboard/dashboard.module';
9
8
  import { CoreModule } from './core/core.module';
9
+ import { DashboardModule } from './dashboard/dashboard.module';
10
10
  import { MenuModule } from './menu/menu.module';
11
11
  import { RoleModule } from './role/role.module';
12
12
  import { RouteModule } from './route/route.module';
13
13
  import { ScreenModule } from './screen/screen.module';
14
+ import { SettingModule } from './setting/setting.module';
14
15
  import { UserModule } from './user/user.module';
15
16
 
16
17
  @Module({
@@ -28,6 +29,7 @@ import { UserModule } from './user/user.module';
28
29
  forwardRef(() => LocaleModule),
29
30
  forwardRef(() => UserModule),
30
31
  forwardRef(() => CoreModule),
32
+ forwardRef(() => SettingModule),
31
33
  ],
32
34
  exports: [
33
35
  UserModule,
@@ -38,6 +40,7 @@ import { UserModule } from './user/user.module';
38
40
  MenuModule,
39
41
  ScreenModule,
40
42
  LocaleModule,
43
+ SettingModule,
41
44
  ],
42
45
  })
43
46
  export class AdminModule {}
@@ -1,55 +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 { DashboardComponentService } from './dashboard-component.service';
18
- import { Role, DeleteDTO } from '@hedhog/core';
19
-
20
- @Role()
21
- @Controller('dashboard-component')
22
- export class DashboardComponentController {
23
- constructor(
24
- @Inject(forwardRef(() => DashboardComponentService))
25
- private readonly dashboardComponentService: DashboardComponentService
26
- ) {}
27
-
28
- @Get()
29
- async list(@Locale() locale, @Pagination() paginationParams) {
30
- return this.dashboardComponentService.list(locale, paginationParams);
31
- }
32
-
33
- @Get(':id')
34
- async get(@Param('id', ParseIntPipe) id: number) {
35
- return this.dashboardComponentService.get(id);
36
- }
37
-
38
- @Post()
39
- async create(@Body() data: CreateDTO) {
40
- return this.dashboardComponentService.create(data);
41
- }
42
-
43
- @Patch(':id')
44
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
- return this.dashboardComponentService.update({
46
- id,
47
- data
48
- });
49
- }
50
-
51
- @Delete()
52
- async delete(@Body() data: DeleteDTO) {
53
- return this.dashboardComponentService.delete(data);
54
- }
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 { DashboardComponentService } from './dashboard-component.service';
18
+ import { Role, DeleteDTO } from '@hedhog/core';
19
+
20
+ @Role()
21
+ @Controller('dashboard-component')
22
+ export class DashboardComponentController {
23
+ constructor(
24
+ @Inject(forwardRef(() => DashboardComponentService))
25
+ private readonly dashboardComponentService: DashboardComponentService
26
+ ) {}
27
+
28
+ @Get()
29
+ async list(@Locale() locale, @Pagination() paginationParams) {
30
+ return this.dashboardComponentService.list(locale, paginationParams);
31
+ }
32
+
33
+ @Get(':id')
34
+ async get(@Param('id', ParseIntPipe) id: number) {
35
+ return this.dashboardComponentService.get(id);
36
+ }
37
+
38
+ @Post()
39
+ async create(@Body() data: CreateDTO) {
40
+ return this.dashboardComponentService.create(data);
41
+ }
42
+
43
+ @Patch(':id')
44
+ async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
+ return this.dashboardComponentService.update({
46
+ id,
47
+ data
48
+ });
49
+ }
50
+
51
+ @Delete()
52
+ async delete(@Body() data: DeleteDTO) {
53
+ return this.dashboardComponentService.delete(data);
54
+ }
55
+ }
@@ -1,36 +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
- }
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
+ }
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -0,0 +1,12 @@
1
+ import { Controller, Get, Param } from '@nestjs/common';
2
+ import { DashboardCoreService } from './dashboard-core.service';
3
+
4
+ @Controller('dashboard-core')
5
+ export class DashboardCoreController {
6
+ constructor(private readonly dashboardCoreService: DashboardCoreService) {}
7
+
8
+ @Get(':slug')
9
+ fromSlug(@Param('slug') slug: string) {
10
+ return this.dashboardCoreService.fromSlug(slug);
11
+ }
12
+ }
@@ -0,0 +1,14 @@
1
+ import { forwardRef, Module } from '@nestjs/common';
2
+
3
+ import { LocaleModule } from '@hedhog/locale';
4
+ import { PrismaModule } from '@hedhog/prisma';
5
+ import { DashboardCoreController } from './dashboard-core.controller';
6
+ import { DashboardCoreService } from './dashboard-core.service';
7
+
8
+ @Module({
9
+ imports: [forwardRef(() => LocaleModule), forwardRef(() => PrismaModule)],
10
+ controllers: [DashboardCoreController],
11
+ providers: [DashboardCoreService],
12
+ exports: [DashboardCoreService],
13
+ })
14
+ export class DashboardCoreModule {}
@@ -0,0 +1,16 @@
1
+ import { PrismaService } from '@hedhog/prisma';
2
+ import { Injectable } from '@nestjs/common';
3
+
4
+ @Injectable()
5
+ export class DashboardCoreService {
6
+ constructor(private readonly prismaService: PrismaService) {}
7
+
8
+ async fromSlug(slug: string) {
9
+ return this.prismaService.dashboard_item.findMany({
10
+ where: { dashboard: { slug } },
11
+ include: {
12
+ dashboard_user: true,
13
+ },
14
+ });
15
+ }
16
+ }
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
3
-
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateDTO } from './create.dto';
3
+
4
+ export class UpdateDTO extends PartialType(CreateDTO) {}
@@ -1,9 +1,10 @@
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
1
  import { LocaleModule } from '@hedhog/locale';
5
2
  import { PrismaModule } from '@hedhog/prisma';
6
3
  import { forwardRef, Module } from '@nestjs/common';
4
+ import { DashboardComponentModule } from './dashboard-component/dashboard-component.module';
5
+ import { DashboardCoreModule } from './dashboard-core/dashboard-core.module';
6
+ import { DashboardItemModule } from './dashboard-item/dashboard-item.module';
7
+ import { DashboardUserModule } from './dashboard-user/dashboard-user.module';
7
8
  import { DashboardModule2 } from './dashboard/dashboard.module';
8
9
 
9
10
  @Module({
@@ -14,6 +15,7 @@ import { DashboardModule2 } from './dashboard/dashboard.module';
14
15
  forwardRef(() => DashboardComponentModule),
15
16
  forwardRef(() => DashboardItemModule),
16
17
  forwardRef(() => DashboardUserModule),
18
+ forwardRef(() => DashboardCoreModule),
17
19
  ],
18
20
  controllers: [],
19
21
  providers: [],
@@ -1 +1 @@
1
- export * from './dashboard.module';
1
+ export * from './dashboard.module';
package/src/index.ts CHANGED
@@ -18,3 +18,5 @@ export * from './screen/screen.service';
18
18
  // User Module
19
19
  export * from './user/constants/user.constants';
20
20
  export * from './user/user.service';
21
+
22
+ export * from './setting/setting.service';
@@ -0,0 +1,21 @@
1
+ import { IsString, IsInt, Length, IsBoolean } from 'class-validator';
2
+ import { WithLocaleDTO } from '@hedhog/locale';
3
+
4
+ export class CreateDTO extends WithLocaleDTO {
5
+ @IsString()
6
+ @Length(0, 255)
7
+ slug: string;
8
+
9
+ @IsString()
10
+ type: string;
11
+
12
+ @IsString()
13
+ @Length(0, 1023)
14
+ value: string;
15
+
16
+ @IsBoolean()
17
+ user_override: boolean;
18
+
19
+ @IsInt()
20
+ group_id: number;
21
+ }
@@ -0,0 +1,8 @@
1
+ import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
2
+
3
+ export class DeleteDTO {
4
+ @IsArray()
5
+ @ArrayMinSize(1)
6
+ @IsInt({ each: true })
7
+ ids: number[];
8
+ }
@@ -0,0 +1,6 @@
1
+ import { IsString } from 'class-validator';
2
+
3
+ export class SettingUserDTO {
4
+ @IsString()
5
+ value: string;
6
+ }
@@ -0,0 +1,17 @@
1
+ import { Type } from 'class-transformer';
2
+ import { IsArray, IsString, ValidateNested } from 'class-validator';
3
+
4
+ class Setting {
5
+ @IsString()
6
+ slug: string;
7
+
8
+ @IsString()
9
+ value: string;
10
+ }
11
+
12
+ export class SettingDTO {
13
+ @IsArray()
14
+ @ValidateNested({ each: true })
15
+ @Type(() => Setting)
16
+ setting: Setting[];
17
+ }
@@ -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,105 @@
1
+ import { Public, Role, User } from '@hedhog/core';
2
+ import { Locale } from '@hedhog/locale';
3
+ import { Pagination } from '@hedhog/pagination';
4
+ import {
5
+ Body,
6
+ Controller,
7
+ Delete,
8
+ forwardRef,
9
+ Get,
10
+ Inject,
11
+ Param,
12
+ ParseIntPipe,
13
+ Patch,
14
+ Post,
15
+ Put,
16
+ } from '@nestjs/common';
17
+ import { CreateDTO } from './dto/create.dto';
18
+ import { DeleteDTO } from './dto/delete.dto';
19
+ import { SettingUserDTO } from './dto/setting-user.dto';
20
+ import { SettingDTO } from './dto/setting.dto';
21
+ import { UpdateDTO } from './dto/update.dto';
22
+ import { SettingService } from './setting.service';
23
+
24
+ @Role()
25
+ @Controller('setting')
26
+ export class SettingsController {
27
+ constructor(
28
+ @Inject(forwardRef(() => SettingService))
29
+ private readonly settingService: SettingService,
30
+ ) {}
31
+
32
+ @Get('group/:slug')
33
+ async getSettingFromGroup(
34
+ @Pagination() paginationParams,
35
+ @Locale() locale,
36
+ @Param('slug') slug: string,
37
+ ) {
38
+ return this.settingService.getSettingFromGroup(
39
+ locale,
40
+ paginationParams,
41
+ slug,
42
+ );
43
+ }
44
+
45
+ @Public()
46
+ @Get('group')
47
+ async listSettingGroups(@Pagination() paginationParams, @Locale() locale) {
48
+ return this.settingService.listSettingGroups(locale, paginationParams);
49
+ }
50
+
51
+ @Get('/user')
52
+ async getUserSettings(@User() { id }) {
53
+ return this.settingService.getUserSettings(id);
54
+ }
55
+
56
+ @Get()
57
+ async listSettings(@Pagination() paginationParams, @Locale() locale) {
58
+ return this.settingService.listSettings(locale, paginationParams);
59
+ }
60
+
61
+ @Get(':settingId')
62
+ async get(@Param('settingId', ParseIntPipe) settingId: number) {
63
+ return this.settingService.get(settingId);
64
+ }
65
+
66
+ @Post()
67
+ async create(@Body() data: CreateDTO) {
68
+ return this.settingService.create(data);
69
+ }
70
+
71
+ @Put('user/:slug')
72
+ async updateUserFromSlug(
73
+ @Param('slug') slug: string,
74
+ @Body() { value }: SettingUserDTO,
75
+ @User() { id },
76
+ ) {
77
+ return this.settingService.setSettingUserValue(id, slug, value);
78
+ }
79
+
80
+ @Put(':slug')
81
+ async updateFromSlug(@Param('slug') slug: string, @Body() data: UpdateDTO) {
82
+ return this.settingService.updateFromSlug(slug, data);
83
+ }
84
+
85
+ @Put()
86
+ async setManySettings(@Body() data: SettingDTO) {
87
+ return this.settingService.setManySettings(data);
88
+ }
89
+
90
+ @Patch(':settingId')
91
+ async update(
92
+ @Param('settingId', ParseIntPipe) settingId: number,
93
+ @Body() data: UpdateDTO,
94
+ ) {
95
+ return this.settingService.update({
96
+ id: settingId,
97
+ data,
98
+ });
99
+ }
100
+
101
+ @Delete()
102
+ async delete(@Body() data: DeleteDTO) {
103
+ return this.settingService.delete(data);
104
+ }
105
+ }
@@ -0,0 +1,18 @@
1
+ import { PaginationModule } from '@hedhog/pagination';
2
+ import { PrismaModule } from '@hedhog/prisma';
3
+ import { Module, forwardRef } from '@nestjs/common';
4
+ import { AuthModule } from '../auth/auth.module';
5
+ import { SettingsController } from './setting.controller';
6
+ import { SettingService } from './setting.service';
7
+
8
+ @Module({
9
+ imports: [
10
+ forwardRef(() => AuthModule),
11
+ forwardRef(() => PrismaModule),
12
+ forwardRef(() => PaginationModule),
13
+ ],
14
+ controllers: [SettingsController],
15
+ providers: [SettingService],
16
+ exports: [SettingService],
17
+ })
18
+ export class SettingModule {}