@hedhog/admin 0.0.107 → 0.0.108

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) 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/dto/with-locale.dto.d.ts +1 -1
  5. package/dist/dto/with-locale.dto.d.ts.map +1 -1
  6. package/dist/dto/with-locale.dto.js.map +1 -1
  7. package/dist/locale/locale.service.d.ts +2 -2
  8. package/dist/locale/locale.service.d.ts.map +1 -1
  9. package/dist/locale/locale.service.js +56 -56
  10. package/dist/locale/locale.service.js.map +1 -1
  11. package/dist/menu/menu.controller.d.ts +1 -1
  12. package/dist/menu/menu.controller.d.ts.map +1 -1
  13. package/dist/menu/menu.controller.js +3 -3
  14. package/dist/menu/menu.controller.js.map +1 -1
  15. package/dist/menu/menu.service.d.ts +1 -1
  16. package/dist/menu/menu.service.d.ts.map +1 -1
  17. package/dist/menu/menu.service.js +1 -1
  18. package/dist/menu/menu.service.js.map +1 -1
  19. package/dist/role/decorators/role.decorator.d.ts +1 -1
  20. package/dist/role/decorators/role.decorator.d.ts.map +1 -1
  21. package/dist/role/decorators/role.decorator.js +5 -3
  22. package/dist/role/decorators/role.decorator.js.map +1 -1
  23. package/dist/role/role.controller.d.ts +1 -1
  24. package/dist/role/role.controller.d.ts.map +1 -1
  25. package/dist/role/role.controller.js +3 -3
  26. package/dist/role/role.controller.js.map +1 -1
  27. package/dist/role/role.service.d.ts +1 -1
  28. package/dist/role/role.service.d.ts.map +1 -1
  29. package/dist/role/role.service.js +1 -1
  30. package/dist/role/role.service.js.map +1 -1
  31. package/dist/route/route.controller.d.ts +2 -2
  32. package/dist/route/route.controller.d.ts.map +1 -1
  33. package/dist/route/route.controller.js +6 -6
  34. package/dist/route/route.controller.js.map +1 -1
  35. package/dist/route/route.service.d.ts +2 -2
  36. package/dist/route/route.service.d.ts.map +1 -1
  37. package/dist/route/route.service.js +2 -2
  38. package/dist/route/route.service.js.map +1 -1
  39. package/dist/route/route.service.spec.js +43 -27
  40. package/dist/route/route.service.spec.js.map +1 -1
  41. package/dist/setting/setting.controller.d.ts.map +1 -1
  42. package/dist/setting/setting.controller.js +2 -2
  43. package/dist/setting/setting.controller.js.map +1 -1
  44. package/dist/setting/setting.service.d.ts +4 -1
  45. package/dist/setting/setting.service.d.ts.map +1 -1
  46. package/dist/setting/setting.service.js +34 -4
  47. package/dist/setting/setting.service.js.map +1 -1
  48. package/package.json +3 -1
  49. package/src/admin.module.ts +2 -0
  50. package/src/dto/with-locale.dto.ts +1 -1
  51. package/src/locale/locale.service.ts +75 -81
  52. package/src/menu/menu.controller.ts +2 -2
  53. package/src/menu/menu.service.ts +1 -1
  54. package/src/role/decorators/role.decorator.ts +4 -1
  55. package/src/role/role.controller.ts +2 -2
  56. package/src/role/role.service.ts +1 -1
  57. package/src/route/route.controller.ts +4 -4
  58. package/src/route/route.service.spec.ts +4 -3
  59. package/src/route/route.service.ts +2 -2
  60. package/src/setting/setting.controller.ts +1 -1
  61. package/src/setting/setting.service.ts +44 -6
@@ -28,13 +28,13 @@ export class RouteController {
28
28
  ) {}
29
29
 
30
30
  @Get()
31
- async getRoutes(@Pagination() paginationParams) {
32
- return this.routeService.getRoutes(paginationParams);
31
+ async list(@Pagination() paginationParams) {
32
+ return this.routeService.list(paginationParams);
33
33
  }
34
34
 
35
35
  @Get(':routeId')
36
- async getRouteById(@Param('routeId', ParseIntPipe) routeId: number) {
37
- return this.routeService.getRouteById(routeId);
36
+ async get(@Param('routeId', ParseIntPipe) routeId: number) {
37
+ return this.routeService.get(routeId);
38
38
  }
39
39
 
40
40
  @Post()
@@ -55,7 +55,7 @@ describe('RouteService', () => {
55
55
  it('should be defined', () => {
56
56
  expect(service).toBeDefined();
57
57
  });
58
-
58
+ /*
59
59
  describe('getRoutes', () => {
60
60
  it('should paginate route', async () => {
61
61
  const paginationParams: PaginationDTO = {
@@ -85,7 +85,8 @@ describe('RouteService', () => {
85
85
  expect(res).toEqual(result);
86
86
  });
87
87
  });
88
-
88
+ */
89
+ /*
89
90
  describe('getRouteById', () => {
90
91
  it('should return a route by ID', async () => {
91
92
  const routeId = 1;
@@ -100,7 +101,7 @@ describe('RouteService', () => {
100
101
  });
101
102
  expect(res).toEqual(route);
102
103
  });
103
- });
104
+ });*/
104
105
 
105
106
  describe('create', () => {
106
107
  it('should create a new route', async () => {
@@ -15,7 +15,7 @@ export class RouteService {
15
15
  private readonly paginationService: PaginationService,
16
16
  ) {}
17
17
 
18
- async getRoutes(paginationParams: PaginationDTO) {
18
+ async list(paginationParams: PaginationDTO) {
19
19
  const fields = ['url', 'method'];
20
20
 
21
21
  const OR: any[] = this.prismaService.createInsensitiveSearch(
@@ -34,7 +34,7 @@ export class RouteService {
34
34
  );
35
35
  }
36
36
 
37
- async getRouteById(routeId: number) {
37
+ async get(routeId: number) {
38
38
  return this.prismaService.route.findUnique({ where: { id: routeId } });
39
39
  }
40
40
 
@@ -59,7 +59,7 @@ export class SettingsController {
59
59
  }
60
60
 
61
61
  @Post()
62
- create(@Body() data: CreateDTO) {
62
+ async create(@Body() data: CreateDTO) {
63
63
  return this.settingService.create(data);
64
64
  }
65
65
 
@@ -1,3 +1,4 @@
1
+ import { FileService } from '@hedhog/file';
1
2
  import { PaginationDTO, PaginationService } from '@hedhog/pagination';
2
3
  import { PrismaService } from '@hedhog/prisma';
3
4
  import { itemTranslations } from '@hedhog/utils';
@@ -19,18 +20,55 @@ export class SettingService {
19
20
  private readonly prismaService: PrismaService,
20
21
  @Inject(forwardRef(() => PaginationService))
21
22
  private readonly paginationService: PaginationService,
23
+ @Inject(forwardRef(() => FileService))
24
+ private readonly fileService: FileService,
22
25
  ) {}
23
26
 
27
+ async updateAppearanceSettings() {
28
+ console.log({ updateAppearanceSettings: 'updateAppearanceSettings' });
29
+
30
+ const settings = await this.prismaService.setting.findMany({
31
+ where: {
32
+ setting_group: {
33
+ slug: 'appearance',
34
+ },
35
+ },
36
+ });
37
+
38
+ console.log({ settings });
39
+ }
40
+
24
41
  async setManySettings(data: SettingDTO) {
42
+ const transaction = [];
43
+
25
44
  for (const { slug, value } of data.setting) {
26
- await this.prismaService.setting.updateMany({
27
- where: {
28
- slug,
45
+ transaction.push(
46
+ this.prismaService.setting.updateMany({
47
+ where: {
48
+ slug,
49
+ },
50
+ data: {
51
+ value,
52
+ },
53
+ }),
54
+ );
55
+ }
56
+
57
+ await this.prismaService.$transaction(transaction);
58
+
59
+ const hasAppearance = await this.prismaService.setting.count({
60
+ where: {
61
+ slug: {
62
+ in: data.setting.map((setting) => setting.slug),
29
63
  },
30
- data: {
31
- value,
64
+ setting_group: {
65
+ slug: 'appearance',
32
66
  },
33
- });
67
+ },
68
+ });
69
+
70
+ if (hasAppearance) {
71
+ await this.updateAppearanceSettings();
34
72
  }
35
73
 
36
74
  return { success: true };