@hed-hog/core 0.0.151 → 0.0.153
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/dashboard/dashboard/dashboard.controller.d.ts +214 -9
- package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dashboard.controller.js +35 -35
- package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -1
- package/dist/dashboard/dashboard/dashboard.module.d.ts +1 -1
- package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dashboard.module.js +11 -6
- package/dist/dashboard/dashboard/dashboard.module.js.map +1 -1
- package/dist/dashboard/dashboard/dashboard.service.d.ts +217 -16
- package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dashboard.service.js +115 -28
- package/dist/dashboard/dashboard/dashboard.service.js.map +1 -1
- package/dist/dashboard/dashboard/dto/create.dto.d.ts +4 -2
- package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dto/create.dto.js +10 -1
- package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -1
- package/dist/dashboard/dashboard/dto/index.d.ts +5 -0
- package/dist/dashboard/dashboard/dto/index.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dto/index.js +25 -0
- package/dist/dashboard/dashboard/dto/index.js.map +1 -0
- package/dist/dashboard/dashboard/dto/update.dto.d.ts +5 -4
- package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dto/update.dto.js +27 -3
- package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +114 -9
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js +35 -36
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.module.js +4 -3
- package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +116 -15
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.js +109 -22
- package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -1
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +4 -2
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dto/create.dto.js +10 -1
- package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -1
- package/dist/dashboard/dashboard-component/dto/index.d.ts +5 -0
- package/dist/dashboard/dashboard-component/dto/index.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dto/index.js +25 -0
- package/dist/dashboard/dashboard-component/dto/index.js.map +1 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +13 -4
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dto/update.dto.js +67 -3
- package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +56 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js +65 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +52 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-core/dashboard-core.service.js +221 -0
- package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +26 -29
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js +24 -43
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +30 -34
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-item/dashboard-item.service.js +51 -35
- package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -1
- package/dist/dashboard/dashboard-item/dto/index.d.ts +5 -0
- package/dist/dashboard/dashboard-item/dto/index.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dto/index.js +25 -0
- package/dist/dashboard/dashboard-item/dto/index.js.map +1 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +7 -4
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -1
- package/dist/dashboard/dashboard-item/dto/update.dto.js +42 -3
- package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -1
- package/dist/dashboard/dashboard.module.js +1 -1
- package/dist/dashboard/dashboard.module.js.map +1 -1
- package/dist/oauth/oauth.controller.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.js.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.js +7 -4
- package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +1 -0
- package/dist/setting/setting.service.js.map +1 -1
- package/hedhog/data/route.yaml +44 -14
- package/hedhog/data/setting_group.yaml +10 -0
- package/hedhog/query/dashboard-seed.sql +131 -0
- package/package.json +1 -1
- package/src/dashboard/dashboard/dashboard.controller.ts +26 -23
- package/src/dashboard/dashboard/dashboard.module.ts +7 -2
- package/src/dashboard/dashboard/dashboard.service.ts +125 -44
- package/src/dashboard/dashboard/dto/create.dto.ts +12 -3
- package/src/dashboard/dashboard/dto/index.ts +7 -0
- package/src/dashboard/dashboard/dto/update.dto.ts +17 -3
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +22 -19
- package/src/dashboard/dashboard-component/dashboard-component.module.ts +3 -3
- package/src/dashboard/dashboard-component/dashboard-component.service.ts +128 -39
- package/src/dashboard/dashboard-component/dto/create.dto.ts +12 -3
- package/src/dashboard/dashboard-component/dto/index.ts +7 -0
- package/src/dashboard/dashboard-component/dto/update.dto.ts +49 -3
- package/src/dashboard/dashboard-core/dashboard-core.controller.ts +53 -2
- package/src/dashboard/dashboard-core/dashboard-core.service.ts +271 -0
- package/src/dashboard/dashboard-item/dashboard-item.controller.ts +17 -26
- package/src/dashboard/dashboard-item/dashboard-item.service.ts +55 -47
- package/src/dashboard/dashboard-item/dto/index.ts +7 -0
- package/src/dashboard/dashboard-item/dto/update.dto.ts +27 -3
- package/src/dashboard/dashboard.module.ts +2 -2
- package/src/language/en.json +4 -1
- package/src/language/pt.json +4 -1
- package/src/oauth/oauth.controller.ts +1 -2
- package/src/oauth/providers/microsoft-entra-id.provider.ts +9 -4
- package/src/setting/setting.service.ts +1 -0
package/hedhog/data/route.yaml
CHANGED
|
@@ -614,6 +614,48 @@
|
|
|
614
614
|
role:
|
|
615
615
|
- where:
|
|
616
616
|
slug: admin
|
|
617
|
+
- url: /dashboard-core/:slug
|
|
618
|
+
method: GET
|
|
619
|
+
relations:
|
|
620
|
+
role:
|
|
621
|
+
- where:
|
|
622
|
+
slug: admin
|
|
623
|
+
- url: /dashboard-core/stats/overview
|
|
624
|
+
method: GET
|
|
625
|
+
relations:
|
|
626
|
+
role:
|
|
627
|
+
- where:
|
|
628
|
+
slug: admin
|
|
629
|
+
- url: /dashboard-core/stats/user-growth
|
|
630
|
+
method: GET
|
|
631
|
+
relations:
|
|
632
|
+
role:
|
|
633
|
+
- where:
|
|
634
|
+
slug: admin
|
|
635
|
+
- url: /dashboard-core/layout/:slug
|
|
636
|
+
method: GET
|
|
637
|
+
relations:
|
|
638
|
+
role:
|
|
639
|
+
- where:
|
|
640
|
+
slug: admin
|
|
641
|
+
- url: /dashboard-core/layout/:slug
|
|
642
|
+
method: POST
|
|
643
|
+
relations:
|
|
644
|
+
role:
|
|
645
|
+
- where:
|
|
646
|
+
slug: admin
|
|
647
|
+
- url: /dashboard-core/widget/:slug
|
|
648
|
+
method: POST
|
|
649
|
+
relations:
|
|
650
|
+
role:
|
|
651
|
+
- where:
|
|
652
|
+
slug: admin
|
|
653
|
+
- url: /dashboard-core/widget/:slug/:widgetId
|
|
654
|
+
method: DELETE
|
|
655
|
+
relations:
|
|
656
|
+
role:
|
|
657
|
+
- where:
|
|
658
|
+
slug: admin
|
|
617
659
|
- url: /dashboard
|
|
618
660
|
method: GET
|
|
619
661
|
relations:
|
|
@@ -638,7 +680,7 @@
|
|
|
638
680
|
role:
|
|
639
681
|
- where:
|
|
640
682
|
slug: admin
|
|
641
|
-
- url: /dashboard
|
|
683
|
+
- url: /dashboard/:id
|
|
642
684
|
method: DELETE
|
|
643
685
|
relations:
|
|
644
686
|
role:
|
|
@@ -668,7 +710,7 @@
|
|
|
668
710
|
role:
|
|
669
711
|
- where:
|
|
670
712
|
slug: admin
|
|
671
|
-
- url: /dashboard-component
|
|
713
|
+
- url: /dashboard-component/:id
|
|
672
714
|
method: DELETE
|
|
673
715
|
relations:
|
|
674
716
|
role:
|
|
@@ -687,18 +729,6 @@
|
|
|
687
729
|
- where:
|
|
688
730
|
slug: admin
|
|
689
731
|
- url: /dashboard-item/:id
|
|
690
|
-
method: GET
|
|
691
|
-
relations:
|
|
692
|
-
role:
|
|
693
|
-
- where:
|
|
694
|
-
slug: admin
|
|
695
|
-
- url: /dashboard-item/:id
|
|
696
|
-
method: PATCH
|
|
697
|
-
relations:
|
|
698
|
-
role:
|
|
699
|
-
- where:
|
|
700
|
-
slug: admin
|
|
701
|
-
- url: /dashboard-item
|
|
702
732
|
method: DELETE
|
|
703
733
|
relations:
|
|
704
734
|
role:
|
|
@@ -419,6 +419,16 @@
|
|
|
419
419
|
order: 1
|
|
420
420
|
- value: email
|
|
421
421
|
order: 2
|
|
422
|
+
- slug: microsoft_entra_id_tenant_id
|
|
423
|
+
type: string
|
|
424
|
+
name:
|
|
425
|
+
en: Microsoft Entra ID Tenant ID
|
|
426
|
+
pt: ID do Tenant Microsoft Entra ID
|
|
427
|
+
description:
|
|
428
|
+
en: The Azure AD tenant ID for corporate Microsoft Entra ID (Azure AD) authentication. Leave empty to use common endpoint for personal Microsoft accounts.
|
|
429
|
+
pt: O ID do tenant do Azure AD para autenticação corporativa Microsoft Entra ID (Azure AD). Deixe vazio para usar o endpoint comum para contas pessoais da Microsoft.
|
|
430
|
+
value: ""
|
|
431
|
+
user_override: false
|
|
422
432
|
- slug: google_client_id
|
|
423
433
|
type: string
|
|
424
434
|
name:
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
-- Dashboard Seed Script (Versão Simplificada)
|
|
2
|
+
-- Este script cria os dados iniciais para o sistema de dashboard
|
|
3
|
+
|
|
4
|
+
-- Primeiro, criar o dashboard principal
|
|
5
|
+
INSERT INTO dashboard (slug, created_at, updated_at)
|
|
6
|
+
VALUES ('admin-dashboard', NOW(), NOW())
|
|
7
|
+
ON CONFLICT (slug) DO NOTHING;
|
|
8
|
+
|
|
9
|
+
-- Criar locales do dashboard
|
|
10
|
+
DO $$
|
|
11
|
+
DECLARE
|
|
12
|
+
v_dashboard_id INT;
|
|
13
|
+
v_locale_en_id INT;
|
|
14
|
+
v_locale_pt_id INT;
|
|
15
|
+
BEGIN
|
|
16
|
+
SELECT id INTO v_dashboard_id FROM dashboard WHERE slug = 'admin-dashboard';
|
|
17
|
+
SELECT id INTO v_locale_en_id FROM locale WHERE code = 'en' LIMIT 1;
|
|
18
|
+
SELECT id INTO v_locale_pt_id FROM locale WHERE code = 'pt' LIMIT 1;
|
|
19
|
+
|
|
20
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_locale WHERE dashboard_id = v_dashboard_id AND locale_id = v_locale_en_id) THEN
|
|
21
|
+
INSERT INTO dashboard_locale (locale_id, dashboard_id, name, created_at, updated_at)
|
|
22
|
+
VALUES (v_locale_en_id, v_dashboard_id, 'Admin Dashboard', NOW(), NOW());
|
|
23
|
+
END IF;
|
|
24
|
+
|
|
25
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_locale WHERE dashboard_id = v_dashboard_id AND locale_id = v_locale_pt_id) THEN
|
|
26
|
+
INSERT INTO dashboard_locale (locale_id, dashboard_id, name, created_at, updated_at)
|
|
27
|
+
VALUES (v_locale_pt_id, v_dashboard_id, 'Dashboard Admin', NOW(), NOW());
|
|
28
|
+
END IF;
|
|
29
|
+
END $$;
|
|
30
|
+
|
|
31
|
+
-- Criar componentes de dashboard
|
|
32
|
+
DO $$
|
|
33
|
+
DECLARE
|
|
34
|
+
v_locale_en_id INT;
|
|
35
|
+
v_locale_pt_id INT;
|
|
36
|
+
v_component_id INT;
|
|
37
|
+
BEGIN
|
|
38
|
+
SELECT id INTO v_locale_en_id FROM locale WHERE code = 'en' LIMIT 1;
|
|
39
|
+
SELECT id INTO v_locale_pt_id FROM locale WHERE code = 'pt' LIMIT 1;
|
|
40
|
+
|
|
41
|
+
-- Componente: Total de Usuários
|
|
42
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
43
|
+
VALUES ('total-users', '/widgets/total-users', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
44
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
45
|
+
RETURNING id INTO v_component_id;
|
|
46
|
+
|
|
47
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
48
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
49
|
+
VALUES (v_locale_en_id, v_component_id, 'Total Users', NOW(), NOW());
|
|
50
|
+
END IF;
|
|
51
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
52
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
53
|
+
VALUES (v_locale_pt_id, v_component_id, 'Total de Usuários', NOW(), NOW());
|
|
54
|
+
END IF;
|
|
55
|
+
|
|
56
|
+
-- Componente: Usuários Recentes
|
|
57
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
58
|
+
VALUES ('recent-users', '/widgets/recent-users', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
59
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
60
|
+
RETURNING id INTO v_component_id;
|
|
61
|
+
|
|
62
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
63
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
64
|
+
VALUES (v_locale_en_id, v_component_id, 'Recent Users', NOW(), NOW());
|
|
65
|
+
END IF;
|
|
66
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
67
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
68
|
+
VALUES (v_locale_pt_id, v_component_id, 'Usuários Recentes', NOW(), NOW());
|
|
69
|
+
END IF;
|
|
70
|
+
|
|
71
|
+
-- Componente: Usuários Ativos
|
|
72
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
73
|
+
VALUES ('active-users', '/widgets/active-users', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
74
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
75
|
+
RETURNING id INTO v_component_id;
|
|
76
|
+
|
|
77
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
78
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
79
|
+
VALUES (v_locale_en_id, v_component_id, 'Active Users', NOW(), NOW());
|
|
80
|
+
END IF;
|
|
81
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
82
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
83
|
+
VALUES (v_locale_pt_id, v_component_id, 'Usuários Ativos', NOW(), NOW());
|
|
84
|
+
END IF;
|
|
85
|
+
|
|
86
|
+
-- Componente: Total de Roles
|
|
87
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
88
|
+
VALUES ('total-roles', '/widgets/total-roles', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
89
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
90
|
+
RETURNING id INTO v_component_id;
|
|
91
|
+
|
|
92
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
93
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
94
|
+
VALUES (v_locale_en_id, v_component_id, 'Total Roles', NOW(), NOW());
|
|
95
|
+
END IF;
|
|
96
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
97
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
98
|
+
VALUES (v_locale_pt_id, v_component_id, 'Total de Perfis', NOW(), NOW());
|
|
99
|
+
END IF;
|
|
100
|
+
|
|
101
|
+
-- Componente: Total de Menus
|
|
102
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
103
|
+
VALUES ('total-menus', '/widgets/total-menus', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
104
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
105
|
+
RETURNING id INTO v_component_id;
|
|
106
|
+
|
|
107
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
108
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
109
|
+
VALUES (v_locale_en_id, v_component_id, 'Total Menus', NOW(), NOW());
|
|
110
|
+
END IF;
|
|
111
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
112
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
113
|
+
VALUES (v_locale_pt_id, v_component_id, 'Total de Menus', NOW(), NOW());
|
|
114
|
+
END IF;
|
|
115
|
+
|
|
116
|
+
-- Componente: Total de Rotas
|
|
117
|
+
INSERT INTO dashboard_component (slug, path, min_width, max_width, min_height, max_height, width, height, is_resizable, created_at, updated_at)
|
|
118
|
+
VALUES ('total-routes', '/widgets/total-routes', 2, 6, 1, 2, 3, 2, true, NOW(), NOW())
|
|
119
|
+
ON CONFLICT (slug) DO UPDATE SET updated_at = NOW()
|
|
120
|
+
RETURNING id INTO v_component_id;
|
|
121
|
+
|
|
122
|
+
IF NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_en_id AND dashboard_component_id = v_component_id) THEN
|
|
123
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
124
|
+
VALUES (v_locale_en_id, v_component_id, 'Total Routes', NOW(), NOW());
|
|
125
|
+
END IF;
|
|
126
|
+
IF v_locale_pt_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM dashboard_component_locale WHERE locale_id = v_locale_pt_id AND dashboard_component_id = v_component_id) THEN
|
|
127
|
+
INSERT INTO dashboard_component_locale (locale_id, dashboard_component_id, name, created_at, updated_at)
|
|
128
|
+
VALUES (v_locale_pt_id, v_component_id, 'Total de Rotas', NOW(), NOW());
|
|
129
|
+
END IF;
|
|
130
|
+
|
|
131
|
+
END $$;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
3
|
import { Pagination } from '@hed-hog/api-pagination';
|
|
4
4
|
import {
|
|
@@ -9,41 +9,44 @@ import {
|
|
|
9
9
|
Param,
|
|
10
10
|
ParseIntPipe,
|
|
11
11
|
Patch,
|
|
12
|
-
Post
|
|
12
|
+
Post
|
|
13
13
|
} from '@nestjs/common';
|
|
14
14
|
import { DashboardService } from './dashboard.service';
|
|
15
|
-
import {
|
|
16
|
-
|
|
15
|
+
import {
|
|
16
|
+
CreateDashboardDTO,
|
|
17
|
+
UpdateDashboardDTO,
|
|
18
|
+
} from './dto';
|
|
17
19
|
@Role()
|
|
18
|
-
@Controller('
|
|
20
|
+
@Controller('dashboard')
|
|
19
21
|
export class DashboardController {
|
|
20
22
|
constructor(private readonly dashboardService: DashboardService) {}
|
|
21
23
|
|
|
22
24
|
@Get()
|
|
23
|
-
|
|
24
|
-
return this.dashboardService.
|
|
25
|
+
getAllDashboards(@Pagination() paginationParams, @Locale() locale: string) {
|
|
26
|
+
return this.dashboardService.getAllDashboards(paginationParams, locale);
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
@Get(':id')
|
|
28
|
-
|
|
29
|
-
return this.dashboardService.
|
|
30
|
+
getDashboard(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
|
|
31
|
+
return this.dashboardService.getDashboard(id, locale);
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
|
|
32
34
|
@Post()
|
|
33
|
-
|
|
34
|
-
return this.dashboardService.
|
|
35
|
+
createDashboard(@Body() data: CreateDashboardDTO, @Locale() locale: string) {
|
|
36
|
+
return this.dashboardService.createDashboard(data, locale);
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
|
|
37
39
|
@Patch(':id')
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
updateDashboard(
|
|
41
|
+
@Param('id', ParseIntPipe) id: number,
|
|
42
|
+
@Body() data: UpdateDashboardDTO,
|
|
43
|
+
@Locale() locale: string,
|
|
44
|
+
) {
|
|
45
|
+
return this.dashboardService.updateDashboard(id, data, locale);
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
@Delete()
|
|
46
|
-
|
|
47
|
-
return this.dashboardService.
|
|
47
|
+
|
|
48
|
+
@Delete(':id')
|
|
49
|
+
deleteDashboard(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
|
|
50
|
+
return this.dashboardService.deleteDashboard(id, locale);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { LocaleModule } from '@hed-hog/api-locale';
|
|
2
|
+
import { PaginationModule } from '@hed-hog/api-pagination';
|
|
2
3
|
import { PrismaModule } from '@hed-hog/api-prisma';
|
|
3
4
|
import { forwardRef, Module } from '@nestjs/common';
|
|
4
5
|
import { DashboardController } from './dashboard.controller';
|
|
5
6
|
import { DashboardService } from './dashboard.service';
|
|
6
7
|
|
|
7
8
|
@Module({
|
|
8
|
-
imports: [
|
|
9
|
+
imports: [
|
|
10
|
+
forwardRef(() => LocaleModule),
|
|
11
|
+
forwardRef(() => PrismaModule),
|
|
12
|
+
forwardRef(() => PaginationModule),
|
|
13
|
+
],
|
|
9
14
|
controllers: [DashboardController],
|
|
10
15
|
providers: [DashboardService],
|
|
11
16
|
exports: [forwardRef(() => DashboardService)],
|
|
12
17
|
})
|
|
13
|
-
export class
|
|
18
|
+
export class DashboardCrudModule {}
|
|
@@ -1,71 +1,152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { PaginationDTO } from '@hed-hog/api-pagination';
|
|
1
|
+
import { getLocaleText, LocaleService } from '@hed-hog/api-locale';
|
|
2
|
+
import { PaginationService } from '@hed-hog/api-pagination';
|
|
4
3
|
import { PrismaService } from '@hed-hog/api-prisma';
|
|
5
|
-
import { Injectable } from '@nestjs/common';
|
|
6
|
-
import {
|
|
7
|
-
import { CreateDTO } from './dto/create.dto';
|
|
8
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
4
|
+
import { forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
|
|
5
|
+
import { CreateDashboardDTO, UpdateDashboardDTO } from './dto';
|
|
9
6
|
|
|
10
7
|
@Injectable()
|
|
11
8
|
export class DashboardService {
|
|
12
9
|
constructor(
|
|
13
|
-
|
|
10
|
+
@Inject(forwardRef(() => PrismaService))
|
|
14
11
|
private readonly prismaService: PrismaService,
|
|
12
|
+
@Inject(forwardRef(() => PaginationService))
|
|
13
|
+
private readonly paginationService: PaginationService,
|
|
14
|
+
@Inject(forwardRef(() => LocaleService))
|
|
15
|
+
private readonly localeService: LocaleService,
|
|
15
16
|
) {}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
async list(locale: string, paginationParams: PaginationDTO) {
|
|
20
|
-
return this.localeService.listModelWithLocale(
|
|
21
|
-
locale,
|
|
22
|
-
'dashboard',
|
|
17
|
+
async getAllDashboards(paginationParams, locale: string) {
|
|
18
|
+
return this.paginationService.paginate(
|
|
19
|
+
this.prismaService.dashboard,
|
|
23
20
|
paginationParams,
|
|
24
|
-
{},
|
|
25
21
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
include: {
|
|
23
|
+
dashboard_locale: {
|
|
24
|
+
include: {
|
|
25
|
+
locale: true,
|
|
26
|
+
},
|
|
29
27
|
},
|
|
30
28
|
},
|
|
29
|
+
orderBy: {
|
|
30
|
+
id: 'desc',
|
|
31
|
+
},
|
|
31
32
|
},
|
|
33
|
+
'dashboard',
|
|
32
34
|
);
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
async getDashboard(id: number, locale: string) {
|
|
38
|
+
const dashboard = await this.prismaService.dashboard.findUnique({
|
|
39
|
+
where: { id },
|
|
40
|
+
include: {
|
|
41
|
+
dashboard_locale: {
|
|
42
|
+
include: {
|
|
43
|
+
locale: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
dashboard_item: {
|
|
47
|
+
include: {
|
|
48
|
+
dashboard_component: {
|
|
49
|
+
include: {
|
|
50
|
+
dashboard_component_locale: {
|
|
51
|
+
include: {
|
|
52
|
+
locale: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (!dashboard) {
|
|
63
|
+
throw new NotFoundException(
|
|
64
|
+
getLocaleText('dashboardNotFound', locale, 'Dashboard not found'),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
34
67
|
|
|
35
|
-
|
|
36
|
-
return this.localeService.getModelWithLocale(this.modelName, id);
|
|
68
|
+
return dashboard;
|
|
37
69
|
}
|
|
70
|
+
|
|
71
|
+
async createDashboard(data: CreateDashboardDTO, locale: string) {
|
|
72
|
+
const dashboard = await this.prismaService.dashboard.create({
|
|
73
|
+
data: {
|
|
74
|
+
slug: data.slug,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
38
77
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
78
|
+
// Criar locales se fornecidos
|
|
79
|
+
if (data.locale) {
|
|
80
|
+
for (const [localeCode, localeData] of Object.entries(data.locale)) {
|
|
81
|
+
const localeRecord = await this.prismaService.locale.findFirst({
|
|
82
|
+
where: { code: localeCode },
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (localeRecord) {
|
|
86
|
+
await this.prismaService.dashboard_locale.create({
|
|
87
|
+
data: {
|
|
88
|
+
dashboard_id: dashboard.id,
|
|
89
|
+
locale_id: localeRecord.id,
|
|
90
|
+
name: localeData.name,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return this.getDashboard(dashboard.id, locale);
|
|
45
98
|
}
|
|
99
|
+
|
|
100
|
+
async updateDashboard(id: number, data: UpdateDashboardDTO, locale: string) {
|
|
101
|
+
await this.prismaService.dashboard.update({
|
|
102
|
+
where: { id },
|
|
103
|
+
data: {
|
|
104
|
+
slug: data.slug,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
46
107
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
108
|
+
// Atualizar locales se fornecidos
|
|
109
|
+
if (data.locale) {
|
|
110
|
+
// Remove locales existentes
|
|
111
|
+
await this.prismaService.dashboard_locale.deleteMany({
|
|
112
|
+
where: { dashboard_id: id },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Criar novos locales
|
|
116
|
+
for (const [localeCode, localeData] of Object.entries(data.locale)) {
|
|
117
|
+
const localeRecord = await this.prismaService.locale.findFirst({
|
|
118
|
+
where: { code: localeCode },
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (localeRecord) {
|
|
122
|
+
await this.prismaService.dashboard_locale.create({
|
|
123
|
+
data: {
|
|
124
|
+
dashboard_id: id,
|
|
125
|
+
locale_id: localeRecord.id,
|
|
126
|
+
name: localeData.name,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return this.getDashboard(id, locale);
|
|
54
134
|
}
|
|
135
|
+
|
|
136
|
+
async deleteDashboard(id: number, locale: string) {
|
|
137
|
+
const dashboard = await this.prismaService.dashboard.findUnique({
|
|
138
|
+
where: { id },
|
|
139
|
+
});
|
|
55
140
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'You must select at least one item to delete.',
|
|
141
|
+
if (!dashboard) {
|
|
142
|
+
throw new NotFoundException(
|
|
143
|
+
getLocaleText('dashboardNotFound', locale, 'Dashboard not found'),
|
|
60
144
|
);
|
|
61
145
|
}
|
|
62
146
|
|
|
63
|
-
|
|
64
|
-
where: {
|
|
65
|
-
id: {
|
|
66
|
-
in: ids,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
147
|
+
await this.prismaService.dashboard.delete({
|
|
148
|
+
where: { id },
|
|
69
149
|
});
|
|
150
|
+
return { success: true };
|
|
70
151
|
}
|
|
71
152
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { getLocaleText
|
|
2
|
-
import { IsNotEmpty, IsString } from 'class-validator';
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsNotEmpty, IsObject, IsString } from 'class-validator';
|
|
3
3
|
|
|
4
|
-
export class CreateDTO
|
|
4
|
+
export class CreateDTO {
|
|
5
5
|
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
6
6
|
@IsNotEmpty({ message: (args) => getLocaleText('validation.fieldRequired', args.value) })
|
|
7
7
|
slug: string;
|
|
8
|
+
|
|
9
|
+
@IsObject({
|
|
10
|
+
message: (args) =>
|
|
11
|
+
getLocaleText('validation.localeMustBeObject', args.value),
|
|
12
|
+
})
|
|
13
|
+
@IsNotEmpty({
|
|
14
|
+
message: (args) => getLocaleText('validation.localeRequired', args.value),
|
|
15
|
+
})
|
|
16
|
+
locale: Record<string, { name: string }>;
|
|
8
17
|
}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';
|
|
3
3
|
|
|
4
|
-
export class UpdateDTO
|
|
4
|
+
export class UpdateDTO {
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
7
|
+
slug?: string;
|
|
8
|
+
|
|
9
|
+
@IsOptional()
|
|
10
|
+
@IsObject({
|
|
11
|
+
message: (args) =>
|
|
12
|
+
getLocaleText('validation.localeMustBeObject', args.value),
|
|
13
|
+
})
|
|
14
|
+
@IsNotEmpty({
|
|
15
|
+
message: (args) => getLocaleText('validation.localeRequired', args.value),
|
|
16
|
+
})
|
|
17
|
+
locale?: Record<string, { name: string }>;
|
|
18
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
2
|
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
+
import { Pagination } from '@hed-hog/api-pagination';
|
|
3
4
|
import {
|
|
4
5
|
Body,
|
|
5
6
|
Controller,
|
|
@@ -10,12 +11,13 @@ import {
|
|
|
10
11
|
ParseIntPipe,
|
|
11
12
|
Patch,
|
|
12
13
|
Post,
|
|
13
|
-
forwardRef
|
|
14
|
+
forwardRef
|
|
14
15
|
} from '@nestjs/common';
|
|
15
|
-
import { CreateDTO } from './dto/create.dto';
|
|
16
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
17
16
|
import { DashboardComponentService } from './dashboard-component.service';
|
|
18
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
CreateDashboardComponentDTO,
|
|
19
|
+
UpdateDashboardComponentDTO,
|
|
20
|
+
} from './dto';
|
|
19
21
|
|
|
20
22
|
@Role()
|
|
21
23
|
@Controller('dashboard-component')
|
|
@@ -26,30 +28,31 @@ export class DashboardComponentController {
|
|
|
26
28
|
) {}
|
|
27
29
|
|
|
28
30
|
@Get()
|
|
29
|
-
|
|
30
|
-
return this.dashboardComponentService.
|
|
31
|
+
getAllComponents(@Pagination() paginationParams) {
|
|
32
|
+
return this.dashboardComponentService.getAllComponents(paginationParams);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
@Get(':id')
|
|
34
|
-
|
|
35
|
-
return this.dashboardComponentService.
|
|
36
|
+
getComponent(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
|
|
37
|
+
return this.dashboardComponentService.getComponent(id, locale);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
@Post()
|
|
39
|
-
|
|
40
|
-
return this.dashboardComponentService.
|
|
41
|
+
createComponent(@Body() data: CreateDashboardComponentDTO, @Locale() locale: string) {
|
|
42
|
+
return this.dashboardComponentService.createComponent(data, locale);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
@Patch(':id')
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
updateComponent(
|
|
47
|
+
@Param('id', ParseIntPipe) id: number,
|
|
48
|
+
@Body() data: UpdateDashboardComponentDTO,
|
|
49
|
+
@Locale() locale: string,
|
|
50
|
+
) {
|
|
51
|
+
return this.dashboardComponentService.updateComponent(id, data, locale);
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
@Delete()
|
|
52
|
-
|
|
53
|
-
return this.dashboardComponentService.
|
|
54
|
+
@Delete(':id')
|
|
55
|
+
deleteComponent(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
|
|
56
|
+
return this.dashboardComponentService.deleteComponent(id, locale);
|
|
54
57
|
}
|
|
55
58
|
}
|