@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.
- package/dist/admin.module.d.ts.map +1 -1
- package/dist/admin.module.js +4 -1
- package/dist/admin.module.js.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +29 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js +38 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts +3 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.js +26 -0
- package/dist/dashboard/dashboard-core/dashboard-core.module.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +29 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.js +33 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -1
- package/dist/dashboard/dashboard.module.js +5 -3
- package/dist/dashboard/dashboard.module.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/setting/dto/create.dto.d.ts +9 -0
- package/dist/setting/dto/create.dto.d.ts.map +1 -0
- package/dist/setting/dto/create.dto.js +40 -0
- package/dist/setting/dto/create.dto.js.map +1 -0
- package/dist/setting/dto/delete.dto.d.ts +4 -0
- package/dist/setting/dto/delete.dto.d.ts.map +1 -0
- package/dist/setting/dto/delete.dto.js +23 -0
- package/dist/setting/dto/delete.dto.js.map +1 -0
- package/dist/setting/dto/setting-user.dto.d.ts +4 -0
- package/dist/setting/dto/setting-user.dto.d.ts.map +1 -0
- package/dist/setting/dto/setting-user.dto.js +21 -0
- package/dist/setting/dto/setting-user.dto.js.map +1 -0
- package/dist/setting/dto/setting.dto.d.ts +9 -0
- package/dist/setting/dto/setting.dto.d.ts.map +1 -0
- package/dist/setting/dto/setting.dto.js +34 -0
- package/dist/setting/dto/setting.dto.js.map +1 -0
- package/dist/setting/dto/update.dto.d.ts +6 -0
- package/dist/setting/dto/update.dto.d.ts.map +1 -0
- package/dist/setting/dto/update.dto.js +9 -0
- package/dist/setting/dto/update.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +102 -0
- package/dist/setting/setting.controller.d.ts.map +1 -0
- package/dist/setting/setting.controller.js +160 -0
- package/dist/setting/setting.controller.js.map +1 -0
- package/dist/setting/setting.module.d.ts +3 -0
- package/dist/setting/setting.module.d.ts.map +1 -0
- package/dist/setting/setting.module.js +31 -0
- package/dist/setting/setting.module.js.map +1 -0
- package/dist/setting/setting.service.d.ts +103 -0
- package/dist/setting/setting.service.d.ts.map +1 -0
- package/dist/setting/setting.service.js +333 -0
- package/dist/setting/setting.service.js.map +1 -0
- package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
- package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
- package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
- package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
- package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
- package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
- package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
- package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
- package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
- package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
- package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
- package/hedhog/tables/dashboard.yaml +9 -0
- package/hedhog/tables/dashboard_component.yaml +34 -0
- package/hedhog/tables/dashboard_component_locale.yaml +24 -0
- package/hedhog/tables/dashboard_item.yaml +25 -0
- package/hedhog/tables/dashboard_locale.yaml +24 -0
- package/hedhog/tables/dashboard_user.yaml +25 -0
- package/hedhog/tables/menu.yaml +18 -0
- package/hedhog/tables/menu_locale.yaml +19 -0
- package/hedhog/tables/menu_screen.yaml +16 -0
- package/hedhog/tables/multifactor.yaml +6 -0
- package/hedhog/tables/multifactor_locale.yaml +19 -0
- package/hedhog/tables/role.yaml +6 -0
- package/hedhog/tables/role_locale.yaml +20 -0
- package/hedhog/tables/role_menu.yaml +18 -0
- package/hedhog/tables/role_route.yaml +18 -0
- package/hedhog/tables/role_screen.yaml +18 -0
- package/hedhog/tables/role_user.yaml +18 -0
- package/hedhog/tables/route.yaml +23 -0
- package/hedhog/tables/route_screen.yaml +18 -0
- package/hedhog/tables/screen.yaml +8 -0
- package/hedhog/tables/screen_locale.yaml +20 -0
- package/hedhog/tables/setting.yaml +27 -0
- package/hedhog/tables/setting_group.yaml +8 -0
- package/hedhog/tables/setting_group_locale.yaml +23 -0
- package/hedhog/tables/setting_locale.yaml +24 -0
- package/hedhog/tables/setting_user.yaml +21 -0
- package/hedhog/tables/translation.yaml +25 -0
- package/hedhog/tables/translation_namespace.yaml +6 -0
- package/hedhog/tables/user.yaml +18 -0
- package/hedhog/tables/user_activity.yaml +14 -0
- package/hedhog.yaml +142 -473
- package/isabelli.json +0 -0
- package/isabelli.xml +0 -0
- package/isabelli.yaml +0 -0
- package/package.json +1 -1
- package/src/admin.module.ts +4 -1
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
- package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
- package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-core/dashboard-core.controller.ts +12 -0
- package/src/dashboard/dashboard-core/dashboard-core.module.ts +14 -0
- package/src/dashboard/dashboard-core/dashboard-core.service.ts +16 -0
- package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard.module.ts +5 -3
- package/src/dashboard/index.ts +1 -1
- package/src/index.ts +2 -0
- package/src/setting/dto/create.dto.ts +21 -0
- package/src/setting/dto/delete.dto.ts +8 -0
- package/src/setting/dto/setting-user.dto.ts +6 -0
- package/src/setting/dto/setting.dto.ts +17 -0
- package/src/setting/dto/update.dto.ts +4 -0
- package/src/setting/setting.controller.ts +105 -0
- package/src/setting/setting.module.ts +18 -0
- package/src/setting/setting.service.ts +400 -0
package/isabelli.yaml
ADDED
File without changes
|
package/package.json
CHANGED
package/src/admin.module.ts
CHANGED
@@ -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: [],
|
package/src/dashboard/index.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from './dashboard.module';
|
1
|
+
export * from './dashboard.module';
|
package/src/index.ts
CHANGED
@@ -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,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,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 {}
|