@hedhog/admin 0.51.44 → 0.51.46
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/auth/auth.controller.d.ts +1 -19
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +0 -44
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.service.d.ts +9 -24
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +13 -99
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +11 -11
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +11 -11
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
- package/dist/menu/menu.controller.d.ts +3 -3
- package/dist/menu/menu.service.d.ts +3 -3
- 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/package.json +1 -1
- package/src/auth/auth.controller.ts +1 -26
- package/src/auth/auth.service.ts +10 -116
- 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-item/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
- package/src/dashboard/index.ts +1 -1
@@ -1,28 +1,28 @@
|
|
1
|
-
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { requests } from "./requests";
|
4
|
-
|
5
|
-
const scope = "dashboard-user";
|
6
|
-
|
7
|
-
export function useDashboardUserCreate() {
|
8
|
-
const { dashboardUserCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", dashboardUserCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function useDashboardUserDelete() {
|
13
|
-
const { dashboardUserDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", dashboardUserDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function useDashboardUserUpdate() {
|
18
|
-
const { dashboardUserUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", dashboardUserUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function useDashboardUserGet(id: number) {
|
23
|
-
const { dashboardUserGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => dashboardUserGet(id),
|
27
|
-
});
|
28
|
-
}
|
1
|
+
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
3
|
+
import { requests } from "./requests";
|
4
|
+
|
5
|
+
const scope = "dashboard-user";
|
6
|
+
|
7
|
+
export function useDashboardUserCreate() {
|
8
|
+
const { dashboardUserCreate } = requests();
|
9
|
+
return useDefaultMutation(scope, "create", dashboardUserCreate);
|
10
|
+
}
|
11
|
+
|
12
|
+
export function useDashboardUserDelete() {
|
13
|
+
const { dashboardUserDelete } = requests();
|
14
|
+
return useDefaultMutation(scope, "delete", dashboardUserDelete);
|
15
|
+
}
|
16
|
+
|
17
|
+
export function useDashboardUserUpdate() {
|
18
|
+
const { dashboardUserUpdate } = requests();
|
19
|
+
return useDefaultMutation(scope, "update", dashboardUserUpdate);
|
20
|
+
}
|
21
|
+
|
22
|
+
export function useDashboardUserGet(id: number) {
|
23
|
+
const { dashboardUserGet } = requests();
|
24
|
+
return useQuery({
|
25
|
+
queryKey: [scope, "get"],
|
26
|
+
queryFn: () => dashboardUserGet(id),
|
27
|
+
});
|
28
|
+
}
|
@@ -1,58 +1,58 @@
|
|
1
|
-
import { useApp } from "@/hooks/use-app";
|
2
|
-
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
-
import { DashboardUser } from "@/types/models";
|
4
|
-
import { HttpMethod } from "@/types/http-method";
|
5
|
-
|
6
|
-
export function requests() {
|
7
|
-
const { request } = useApp();
|
8
|
-
|
9
|
-
const dashboardUserList = async (params: PaginationParams) => {
|
10
|
-
return request<PaginationResult<DashboardUser>>({
|
11
|
-
url: "/dashboard-user",
|
12
|
-
params,
|
13
|
-
}).then((res) => res.data);
|
14
|
-
};
|
15
|
-
|
16
|
-
const dashboardUserGet = async (id: number) => {
|
17
|
-
return request<DashboardUser>({
|
18
|
-
url: `/dashboard-user/${id}`,
|
19
|
-
}).then((res) => res.data);
|
20
|
-
};
|
21
|
-
|
22
|
-
const dashboardUserCreate = async (params: { data: DashboardUser }) => {
|
23
|
-
const { data } = params;
|
24
|
-
return request<DashboardUser>({
|
25
|
-
url: "/dashboard-user",
|
26
|
-
method: HttpMethod.POST,
|
27
|
-
data: data,
|
28
|
-
}).then((res) => res.data);
|
29
|
-
};
|
30
|
-
|
31
|
-
const dashboardUserDelete = async (ids: number[]) => {
|
32
|
-
return request<Delete>({
|
33
|
-
url: "/dashboard-user",
|
34
|
-
data: { ids },
|
35
|
-
method: HttpMethod.DELETE,
|
36
|
-
}).then((res) => res.data);
|
37
|
-
};
|
38
|
-
|
39
|
-
const dashboardUserUpdate = async (params: {
|
40
|
-
id: number;
|
41
|
-
data: DashboardUser;
|
42
|
-
}) => {
|
43
|
-
const { id, data } = params;
|
44
|
-
return request<DashboardUser>({
|
45
|
-
url: `/dashboard-user/${id}`,
|
46
|
-
method: HttpMethod.PATCH,
|
47
|
-
data: data,
|
48
|
-
}).then((res) => res.data);
|
49
|
-
};
|
50
|
-
|
51
|
-
return {
|
52
|
-
dashboardUserCreate,
|
53
|
-
dashboardUserUpdate,
|
54
|
-
dashboardUserDelete,
|
55
|
-
dashboardUserList,
|
56
|
-
dashboardUserGet,
|
57
|
-
};
|
58
|
-
}
|
1
|
+
import { useApp } from "@/hooks/use-app";
|
2
|
+
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
+
import { DashboardUser } from "@/types/models";
|
4
|
+
import { HttpMethod } from "@/types/http-method";
|
5
|
+
|
6
|
+
export function requests() {
|
7
|
+
const { request } = useApp();
|
8
|
+
|
9
|
+
const dashboardUserList = async (params: PaginationParams) => {
|
10
|
+
return request<PaginationResult<DashboardUser>>({
|
11
|
+
url: "/dashboard-user",
|
12
|
+
params,
|
13
|
+
}).then((res) => res.data);
|
14
|
+
};
|
15
|
+
|
16
|
+
const dashboardUserGet = async (id: number) => {
|
17
|
+
return request<DashboardUser>({
|
18
|
+
url: `/dashboard-user/${id}`,
|
19
|
+
}).then((res) => res.data);
|
20
|
+
};
|
21
|
+
|
22
|
+
const dashboardUserCreate = async (params: { data: DashboardUser }) => {
|
23
|
+
const { data } = params;
|
24
|
+
return request<DashboardUser>({
|
25
|
+
url: "/dashboard-user",
|
26
|
+
method: HttpMethod.POST,
|
27
|
+
data: data,
|
28
|
+
}).then((res) => res.data);
|
29
|
+
};
|
30
|
+
|
31
|
+
const dashboardUserDelete = async (ids: number[]) => {
|
32
|
+
return request<Delete>({
|
33
|
+
url: "/dashboard-user",
|
34
|
+
data: { ids },
|
35
|
+
method: HttpMethod.DELETE,
|
36
|
+
}).then((res) => res.data);
|
37
|
+
};
|
38
|
+
|
39
|
+
const dashboardUserUpdate = async (params: {
|
40
|
+
id: number;
|
41
|
+
data: DashboardUser;
|
42
|
+
}) => {
|
43
|
+
const { id, data } = params;
|
44
|
+
return request<DashboardUser>({
|
45
|
+
url: `/dashboard-user/${id}`,
|
46
|
+
method: HttpMethod.PATCH,
|
47
|
+
data: data,
|
48
|
+
}).then((res) => res.data);
|
49
|
+
};
|
50
|
+
|
51
|
+
return {
|
52
|
+
dashboardUserCreate,
|
53
|
+
dashboardUserUpdate,
|
54
|
+
dashboardUserDelete,
|
55
|
+
dashboardUserList,
|
56
|
+
dashboardUserGet,
|
57
|
+
};
|
58
|
+
}
|
package/package.json
CHANGED
@@ -9,7 +9,6 @@ import {
|
|
9
9
|
Inject,
|
10
10
|
Post,
|
11
11
|
Query,
|
12
|
-
Res,
|
13
12
|
} from '@nestjs/common';
|
14
13
|
import { AuthService } from './auth.service';
|
15
14
|
import { ChangeDTO } from './dto/change.dto';
|
@@ -27,7 +26,7 @@ export class AuthController {
|
|
27
26
|
constructor(
|
28
27
|
@Inject(forwardRef(() => AuthService))
|
29
28
|
private readonly service: AuthService,
|
30
|
-
) {
|
29
|
+
) {}
|
31
30
|
|
32
31
|
@Public()
|
33
32
|
@Get('create-user')
|
@@ -151,28 +150,4 @@ export class AuthController {
|
|
151
150
|
async verifyMfa(@Body() { token, email }: { token: string; email: string }) {
|
152
151
|
return this.service.verifyMfa(email, token, false);
|
153
152
|
}
|
154
|
-
|
155
|
-
@Public()
|
156
|
-
@Get('google/login')
|
157
|
-
async loginGoogle(@Res() res) {
|
158
|
-
return this.service.loginGoogle(res);
|
159
|
-
}
|
160
|
-
|
161
|
-
@Public()
|
162
|
-
@Get('google/callback')
|
163
|
-
async callbackGoogle(@Query() { code }: { code: string }) {
|
164
|
-
return this.service.callbackGoogle(code);
|
165
|
-
}
|
166
|
-
|
167
|
-
@Public()
|
168
|
-
@Get('facebook/login')
|
169
|
-
async loginFacebook(@Res() res) {
|
170
|
-
return this.service.loginFacebook(res);
|
171
|
-
}
|
172
|
-
|
173
|
-
@Public()
|
174
|
-
@Get('facebook/callback')
|
175
|
-
async callbackFacebook(@Query() { code }: { code: string }) {
|
176
|
-
return this.service.callbackFacebook(code);
|
177
|
-
}
|
178
153
|
}
|
package/src/auth/auth.service.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { MailService as MailManagerService } from '@hedhog/mail-manager';
|
2
2
|
import { PrismaService } from '@hedhog/prisma';
|
3
|
-
import { HttpService } from '@nestjs/axios';
|
4
3
|
import {
|
5
4
|
BadRequestException,
|
6
5
|
ConflictException,
|
@@ -13,8 +12,8 @@ import {
|
|
13
12
|
import { ConfigService } from '@nestjs/config';
|
14
13
|
import { JwtService } from '@nestjs/jwt';
|
15
14
|
import { compare, genSalt, hash } from 'bcrypt';
|
15
|
+
import { randomBytes } from 'crypto';
|
16
16
|
import * as qrcode from 'qrcode';
|
17
|
-
import { lastValueFrom } from 'rxjs';
|
18
17
|
import * as speakeasy from 'speakeasy';
|
19
18
|
import { SettingService } from '../setting/setting.service';
|
20
19
|
import { ChangeDTO } from './dto/change.dto';
|
@@ -32,7 +31,6 @@ export class AuthService implements OnModuleInit {
|
|
32
31
|
public settings: Record<string, any> = {};
|
33
32
|
|
34
33
|
constructor(
|
35
|
-
private readonly httpService: HttpService,
|
36
34
|
private readonly configService: ConfigService,
|
37
35
|
@Inject(forwardRef(() => PrismaService))
|
38
36
|
private readonly prisma: PrismaService,
|
@@ -42,7 +40,7 @@ export class AuthService implements OnModuleInit {
|
|
42
40
|
private readonly mail: MailManagerService,
|
43
41
|
@Inject(forwardRef(() => SettingService))
|
44
42
|
private readonly setting: SettingService,
|
45
|
-
) {
|
43
|
+
) {}
|
46
44
|
|
47
45
|
async onModuleInit() {
|
48
46
|
this.settings = await this.setting.getSettingValues([
|
@@ -222,6 +220,10 @@ export class AuthService implements OnModuleInit {
|
|
222
220
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
223
221
|
}
|
224
222
|
|
223
|
+
generateRandomPassword(length = 12) {
|
224
|
+
return randomBytes(length).toString('base64').slice(0, length);
|
225
|
+
}
|
226
|
+
|
225
227
|
async loginWithEmailAndPassword(
|
226
228
|
locale: string,
|
227
229
|
email: string,
|
@@ -242,6 +244,10 @@ export class AuthService implements OnModuleInit {
|
|
242
244
|
throw new BadRequestException('Acesso negado');
|
243
245
|
}
|
244
246
|
|
247
|
+
return this.userMfaSteps(user, locale);
|
248
|
+
}
|
249
|
+
|
250
|
+
async userMfaSteps(user, locale = 'pt') {
|
245
251
|
if (!user.multifactor_id) {
|
246
252
|
return this.getToken(user);
|
247
253
|
} else {
|
@@ -783,116 +789,4 @@ export class AuthService implements OnModuleInit {
|
|
783
789
|
|
784
790
|
return { ...newToken, codes };
|
785
791
|
}
|
786
|
-
|
787
|
-
async loginGoogle(res: any) {
|
788
|
-
const redirectURI = new URL('/callback/google', this.settings['url']).toString();
|
789
|
-
const params = new URLSearchParams({
|
790
|
-
client_id: this.settings['google_client_id'],
|
791
|
-
redirect_uri: redirectURI,
|
792
|
-
response_type: 'code',
|
793
|
-
scope: Array.isArray(this.settings['google_scopes'])
|
794
|
-
? this.settings['google_scopes'].join(' ')
|
795
|
-
: String(this.settings['google_scopes']),
|
796
|
-
});
|
797
|
-
return res.redirect(`https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`);
|
798
|
-
}
|
799
|
-
|
800
|
-
async callbackGoogle(code: string) {
|
801
|
-
const tokenUrl = 'https://oauth2.googleapis.com/token';
|
802
|
-
const profileUrl = 'https://www.googleapis.com/oauth2/v2/userinfo';
|
803
|
-
const tokenResponse = await this.fetchOAuthToken({
|
804
|
-
code,
|
805
|
-
url: tokenUrl,
|
806
|
-
clientId: this.settings['google_client_id'],
|
807
|
-
clientSecret: this.settings['google_client_secret'],
|
808
|
-
redirectUri: `${this.settings['url']}/google/callback`,
|
809
|
-
});
|
810
|
-
const profile = await this.fetchOAuthProfile(tokenResponse.access_token, profileUrl);
|
811
|
-
const user = await this.findOrCreateUser(profile);
|
812
|
-
return this.getToken(user);
|
813
|
-
}
|
814
|
-
|
815
|
-
async loginFacebook(res: any) {
|
816
|
-
const redirectURI = new URL('/callback/facebook', this.settings['url']).toString();
|
817
|
-
const params = new URLSearchParams({
|
818
|
-
client_id: this.settings['facebook_client_id'],
|
819
|
-
redirect_uri: redirectURI,
|
820
|
-
response_type: 'code',
|
821
|
-
scope: Array.isArray(this.settings['facebook_scopes'])
|
822
|
-
? this.settings['facebook_scopes'].join(',')
|
823
|
-
: String(this.settings['facebook_scopes'] ?? 'email'),
|
824
|
-
auth_type: 'rerequest',
|
825
|
-
});
|
826
|
-
return res.redirect(`https://www.facebook.com/v17.0/dialog/oauth?${params.toString()}`);
|
827
|
-
}
|
828
|
-
|
829
|
-
async callbackFacebook(code: string) {
|
830
|
-
const tokenUrl = 'https://graph.facebook.com/v17.0/oauth/access_token';
|
831
|
-
const profileUrl = 'https://graph.facebook.com/me?fields=id,name,email';
|
832
|
-
const tokenResponse = await this.fetchOAuthToken({
|
833
|
-
code,
|
834
|
-
url: tokenUrl,
|
835
|
-
clientId: this.settings['facebook_client_id'],
|
836
|
-
clientSecret: this.settings['facebook_client_secret'],
|
837
|
-
redirectUri: `${this.settings['url']}/facebook/callback`,
|
838
|
-
});
|
839
|
-
const profile = await this.fetchOAuthProfile(tokenResponse.access_token, profileUrl);
|
840
|
-
const user = await this.findOrCreateUser(profile);
|
841
|
-
return this.getToken(user);
|
842
|
-
}
|
843
|
-
|
844
|
-
private async fetchOAuthToken({
|
845
|
-
code,
|
846
|
-
url,
|
847
|
-
clientId,
|
848
|
-
clientSecret,
|
849
|
-
redirectUri,
|
850
|
-
}: {
|
851
|
-
code: string;
|
852
|
-
url: string;
|
853
|
-
clientId: string;
|
854
|
-
clientSecret: string;
|
855
|
-
redirectUri: string;
|
856
|
-
}) {
|
857
|
-
const body = new URLSearchParams({
|
858
|
-
client_id: clientId,
|
859
|
-
client_secret: clientSecret,
|
860
|
-
redirect_uri: redirectUri,
|
861
|
-
grant_type: 'authorization_code',
|
862
|
-
code,
|
863
|
-
}).toString();
|
864
|
-
|
865
|
-
const response = await lastValueFrom(
|
866
|
-
this.httpService.post(url, body, {
|
867
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
868
|
-
}),
|
869
|
-
);
|
870
|
-
return response.data;
|
871
|
-
}
|
872
|
-
|
873
|
-
private async fetchOAuthProfile(accessToken: string, url: string) {
|
874
|
-
const response = await lastValueFrom(
|
875
|
-
this.httpService.get(url, {
|
876
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
877
|
-
}),
|
878
|
-
);
|
879
|
-
return response.data;
|
880
|
-
}
|
881
|
-
|
882
|
-
private async findOrCreateUser(profile: any) {
|
883
|
-
let user = await this.prisma.user.findFirst({
|
884
|
-
where: { email: profile.email },
|
885
|
-
});
|
886
|
-
if (!user) {
|
887
|
-
user = await this.prisma.user.create({
|
888
|
-
data: {
|
889
|
-
email: profile.email,
|
890
|
-
name: profile.name,
|
891
|
-
password: '',
|
892
|
-
code: profile.id,
|
893
|
-
},
|
894
|
-
});
|
895
|
-
}
|
896
|
-
return user;
|
897
|
-
}
|
898
792
|
}
|
@@ -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) {}
|
@@ -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) {}
|
package/src/dashboard/index.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from './dashboard.module';
|
1
|
+
export * from './dashboard.module';
|