@hedhog/admin 0.51.4 → 0.51.6

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 (57) hide show
  1. package/dist/core/core.service.d.ts +1 -0
  2. package/dist/core/core.service.d.ts.map +1 -1
  3. package/dist/core/core.service.js +21 -5
  4. package/dist/core/core.service.js.map +1 -1
  5. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +11 -11
  6. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +11 -11
  7. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
  8. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
  9. package/dist/menu/menu.controller.d.ts +3 -3
  10. package/dist/menu/menu.service.d.ts +3 -3
  11. package/dist/user/user.controller.d.ts +0 -10
  12. package/dist/user/user.controller.d.ts.map +1 -1
  13. package/dist/user/user.controller.js +0 -10
  14. package/dist/user/user.controller.js.map +1 -1
  15. package/dist/user/user.service.d.ts +0 -10
  16. package/dist/user/user.service.d.ts.map +1 -1
  17. package/dist/user/user.service.js +0 -7
  18. package/dist/user/user.service.js.map +1 -1
  19. package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
  20. package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
  21. package/frontend/dashboard/components/database-stats.tsx.ejs +2 -2
  22. package/frontend/dashboard/components/module-installed.tsx.ejs +2 -2
  23. package/frontend/dashboard/components/system-info.tsx.ejs +3 -3
  24. package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
  25. package/frontend/dashboard/components/user-summary.tsx.ejs +2 -2
  26. package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
  27. package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
  28. package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
  29. package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
  30. package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
  31. package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
  32. package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
  33. package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
  34. package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
  35. package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
  36. package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
  37. package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
  38. package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
  39. package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
  40. package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
  41. package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
  42. package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
  43. package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
  44. package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
  45. package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
  46. package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
  47. package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
  48. package/package.json +1 -1
  49. package/src/core/core.service.ts +24 -5
  50. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
  51. package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
  52. package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
  53. package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
  54. package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
  55. package/src/dashboard/index.ts +1 -1
  56. package/src/user/user.controller.ts +0 -5
  57. package/src/user/user.service.ts +1 -9
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedhog/admin",
3
- "version": "0.51.4",
3
+ "version": "0.51.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -220,7 +220,8 @@ export class CoreService {
220
220
  os.platform() === 'win32'
221
221
  ? this.parseWindowsDiskInfo(stdout)
222
222
  : this.parseUnixDiskInfo(stdout);
223
- resolve(diskInfo);
223
+
224
+ resolve(diskInfo.filter((disk) => disk.filesystem !== undefined));
224
225
  });
225
226
  });
226
227
  }
@@ -257,18 +258,36 @@ export class CoreService {
257
258
  return result;
258
259
  }
259
260
 
261
+ private parsedSizeFormated(size: string): number {
262
+ const unit = size.slice(-1).toUpperCase();
263
+ const value = parseFloat(size.slice(0, -1));
264
+
265
+ switch (unit) {
266
+ case 'T':
267
+ return value * 1024 ** 4;
268
+ case 'G':
269
+ return value * 1024 ** 3;
270
+ case 'M':
271
+ return value * 1024 ** 2;
272
+ case 'K':
273
+ return value * 1024;
274
+ default:
275
+ return value; // Assume bytes if no unit is provided
276
+ }
277
+ }
278
+
260
279
  private parseUnixDiskInfo(output: string) {
261
280
  const lines = output.trim().split('\n');
262
281
  const result = [];
263
282
  for (let i = 1; i < lines.length; i++) {
264
283
  const parts = lines[i].split(/\s+/);
265
284
  if (parts.length >= 6) {
285
+ const size = this.parsedSizeFormated(parts[1]);
286
+ const free = this.parsedSizeFormated(parts[3]);
266
287
  result.push({
267
288
  filesystem: parts[0],
268
- size: parts[1],
269
- used: parts[2],
270
- available: parts[3],
271
- capacity: parts[4],
289
+ free,
290
+ size,
272
291
  mountpoint: parts[5],
273
292
  });
274
293
  }
@@ -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) {}
@@ -1 +1 @@
1
- export * from './dashboard.module';
1
+ export * from './dashboard.module';
@@ -52,11 +52,6 @@ export class UserController {
52
52
  return this.userService.get(userId);
53
53
  }
54
54
 
55
- @Get('email/:email')
56
- async getByEmail(@Param('email') email: string) {
57
- return this.userService.getByEmail(email);
58
- }
59
-
60
55
  @Post()
61
56
  create(@Body() data: CreateDTO) {
62
57
  return this.userService.create(data);
@@ -20,7 +20,7 @@ export class UserService {
20
20
  private readonly prismaService: PrismaService,
21
21
  @Inject(forwardRef(() => PaginationService))
22
22
  private readonly paginationService: PaginationService,
23
- ) {}
23
+ ) { }
24
24
 
25
25
  async listRoles(userId: number, paginationParams: PaginationDTO) {
26
26
  return this.paginationService.paginate(
@@ -99,14 +99,6 @@ export class UserService {
99
99
  });
100
100
  }
101
101
 
102
- async getByEmail(email: string) {
103
- return this.prismaService.user.findFirst({
104
- where: {
105
- email,
106
- },
107
- });
108
- }
109
-
110
102
  async update({ id, data }: { id: number; data: UpdateDTO }) {
111
103
  return this.prismaService.user.update({
112
104
  where: { id },