@hedhog/admin 0.48.6 → 0.48.7
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 +2 -0
- package/dist/admin.module.js.map +1 -1
- package/dist/auth/consts/body.d.ts.map +1 -1
- package/dist/dashboard/dashboard/dashboard.controller.d.ts +22 -0
- package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.controller.js +88 -0
- package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -0
- package/dist/dashboard/dashboard/dashboard.module.d.ts +3 -0
- package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.module.js +26 -0
- package/dist/dashboard/dashboard/dashboard.module.js.map +1 -0
- package/dist/dashboard/dashboard/dashboard.service.d.ts +30 -0
- package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dashboard.service.js +61 -0
- package/dist/dashboard/dashboard/dashboard.service.js.map +1 -0
- package/dist/dashboard/dashboard/dto/create.dto.d.ts +5 -0
- package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dto/create.dto.js +23 -0
- package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +22 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js +90 -0
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts +3 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.js +26 -0
- package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +30 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.js +59 -0
- package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +13 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.js +59 -0
- package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +52 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js +88 -0
- package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts +3 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.js +26 -0
- package/dist/dashboard/dashboard-item/dashboard-item.module.js.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +57 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.js +77 -0
- package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.d.ts +9 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.js +41 -0
- package/dist/dashboard/dashboard-item/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +52 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.js +88 -0
- package/dist/dashboard/dashboard-user/dashboard-user.controller.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts +3 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.js +26 -0
- package/dist/dashboard/dashboard-user/dashboard-user.module.js.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +59 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.js +83 -0
- package/dist/dashboard/dashboard-user/dashboard-user.service.js.map +1 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.d.ts +10 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.js +42 -0
- package/dist/dashboard/dashboard-user/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.d.ts +6 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.js +9 -0
- package/dist/dashboard/dashboard-user/dto/update.dto.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts +3 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard.module.js +35 -0
- package/dist/dashboard/dashboard.module.js.map +1 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +18 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/emails/lib.d.ts.map +1 -1
- package/frontend/dashboard/components/create-panel.tsx.ejs +63 -0
- package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -0
- package/frontend/dashboard/components/update-panel.tsx.ejs +80 -0
- package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -0
- package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -0
- package/frontend/dashboard/react-query/handlers.ts.ejs +28 -0
- package/frontend/dashboard/react-query/requests.ts.ejs +56 -0
- package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -0
- package/frontend/dashboard-component/components/dashboard-component.screen.tsx.ejs +135 -0
- package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -0
- package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -0
- package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -0
- package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -0
- package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -0
- package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -0
- package/frontend/dashboard-item/components/dashboard-item.screen.tsx.ejs +133 -0
- package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -0
- package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -0
- package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -0
- package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -0
- package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -0
- package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -0
- package/frontend/dashboard-user/components/dashboard-user.screen.tsx.ejs +131 -0
- package/frontend/dashboard-user/components/update-panel.tsx.ejs +138 -0
- package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -0
- package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -0
- package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -0
- package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -0
- package/frontend/translation/fields/en.json +23 -1
- package/frontend/translation/fields/pt.json +27 -1
- package/frontend/translation/modules/en.json +6 -1
- package/frontend/translation/modules/pt.json +6 -1
- package/hedhog.yaml +439 -0
- package/package.json +2 -2
- package/src/admin.module.ts +2 -0
- package/src/dashboard/dashboard/dashboard.controller.ts +49 -0
- package/src/dashboard/dashboard/dashboard.module.ts +13 -0
- package/src/dashboard/dashboard/dashboard.service.ts +71 -0
- package/src/dashboard/dashboard/dto/create.dto.ts +8 -0
- package/src/dashboard/dashboard/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -0
- package/src/dashboard/dashboard-component/dashboard-component.module.ts +14 -0
- package/src/dashboard/dashboard-component/dashboard-component.service.ts +70 -0
- package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -0
- package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-item/dashboard-item.controller.ts +55 -0
- package/src/dashboard/dashboard-item/dashboard-item.module.ts +13 -0
- package/src/dashboard/dashboard-item/dashboard-item.service.ts +82 -0
- package/src/dashboard/dashboard-item/dto/create.dto.ts +22 -0
- package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard-user/dashboard-user.controller.ts +55 -0
- package/src/dashboard/dashboard-user/dashboard-user.module.ts +13 -0
- package/src/dashboard/dashboard-user/dashboard-user.service.ts +89 -0
- package/src/dashboard/dashboard-user/dto/create.dto.ts +22 -0
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -0
- package/src/dashboard/dashboard.module.ts +22 -0
- package/src/dashboard/index.ts +1 -0
- package/frontend/menu-locale/locales/en/admin.menu-locale.json +0 -11
- package/frontend/menu-locale/locales/pt/admin.menu-locale.json +0 -11
- package/frontend/menu-screen/locales/en/admin.menu-screen.json +0 -11
- package/frontend/menu-screen/locales/pt/admin.menu-screen.json +0 -11
- package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +0 -11
- package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +0 -11
- package/frontend/screen-locale/locales/en/admin.screen-locale.json +0 -11
- package/frontend/screen-locale/locales/pt/admin.screen-locale.json +0 -11
- package/frontend/translation/components/create-panel.tsx.ejs +0 -52
- package/frontend/translation/components/update-panel.tsx.ejs +0 -67
- package/frontend/translation/locales/en/admin.translation.json +0 -11
- package/frontend/translation/locales/pt/admin.translation.json +0 -11
- package/frontend/translation/react-query/handlers.ts.ejs +0 -28
- package/frontend/translation/react-query/requests.ts.ejs +0 -58
- package/frontend/translation-namespace/components/create-panel.tsx.ejs +0 -53
- package/frontend/translation-namespace/components/update-panel.tsx.ejs +0 -70
- package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +0 -11
- package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +0 -11
- package/frontend/translation-namespace/react-query/handlers.ts.ejs +0 -28
- package/frontend/translation-namespace/react-query/requests.ts.ejs +0 -60
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import FormPanel, {
|
|
2
|
+
FormPanelRef,
|
|
3
|
+
getFieldsLocale,
|
|
4
|
+
} from '@/components/panels/form-panel'
|
|
5
|
+
import { Overlay } from '@/components/custom/overlay'
|
|
6
|
+
import { TabPanel } from '@/components/panels/tab-panel'
|
|
7
|
+
import {
|
|
8
|
+
useDashboardGet,
|
|
9
|
+
useDashboardUpdate,
|
|
10
|
+
} from '@/features/dashboard/dashboard'
|
|
11
|
+
import useEffectAfterFirstUpdate from '@/hooks/use-effect-after-first-update'
|
|
12
|
+
import { Dashboard } from '@/types/models'
|
|
13
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
|
14
|
+
import { useTranslation } from 'react-i18next'
|
|
15
|
+
import { EnumFieldType } from '@/enums/EnumFieldType'
|
|
16
|
+
|
|
17
|
+
export type DashboardUpdatePanelProps = {
|
|
18
|
+
data: Dashboard
|
|
19
|
+
onUpdated?: (data: Dashboard) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DashboardUpdatePanel = forwardRef(
|
|
23
|
+
({ data, onUpdated }: DashboardUpdatePanelProps, ref) => {
|
|
24
|
+
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
|
25
|
+
const { data: item, isLoading } = useDashboardGet(
|
|
26
|
+
(data as any).dashboard_id as number
|
|
27
|
+
)
|
|
28
|
+
const { mutate: dashboardUpdate } = useDashboardUpdate()
|
|
29
|
+
const formRef = useRef<FormPanelRef>(null)
|
|
30
|
+
|
|
31
|
+
useEffectAfterFirstUpdate(() => {
|
|
32
|
+
if (item && formRef.current) {
|
|
33
|
+
formRef.current.setValuesFromItem(item)
|
|
34
|
+
}
|
|
35
|
+
}, [item])
|
|
36
|
+
|
|
37
|
+
useImperativeHandle(ref, () => ({}))
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TabPanel
|
|
41
|
+
activeTabIndex={0}
|
|
42
|
+
tabs={[
|
|
43
|
+
{
|
|
44
|
+
title: t('details', { ns: 'actions' }),
|
|
45
|
+
children: (
|
|
46
|
+
<Overlay loading={isLoading}>
|
|
47
|
+
<FormPanel
|
|
48
|
+
ref={formRef}
|
|
49
|
+
fields={[
|
|
50
|
+
{
|
|
51
|
+
name: 'slug',
|
|
52
|
+
label: { text: t('dashboard.slug', { ns: 'fields' }) },
|
|
53
|
+
type: EnumFieldType.TEXT,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
...getFieldsLocale([{ name: 'name' }], item),
|
|
57
|
+
]}
|
|
58
|
+
button={{ text: t('save', { ns: 'actions' }) }}
|
|
59
|
+
onSubmit={(data) => {
|
|
60
|
+
dashboardUpdate({
|
|
61
|
+
id: data.id,
|
|
62
|
+
data,
|
|
63
|
+
})
|
|
64
|
+
if (typeof onUpdated === 'function') {
|
|
65
|
+
onUpdated(data)
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
</Overlay>
|
|
70
|
+
),
|
|
71
|
+
},
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
DashboardUpdatePanel.displayName = 'DashboardUpdatePanel'
|
|
79
|
+
|
|
80
|
+
export default DashboardUpdatePanel
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"create": "Create dashboard",
|
|
3
|
+
"createText": "Fill the dashboard informations.",
|
|
4
|
+
"createTooltip": "Create new dashboard",
|
|
5
|
+
"delete": "Delete dashboard",
|
|
6
|
+
"deleteText": "Are you sure to delete these dashboard?",
|
|
7
|
+
"deleteTooltip": "Delete the selected dashboard",
|
|
8
|
+
"edit": "Edit dashboard",
|
|
9
|
+
"editText": "View and edit dashboard information.",
|
|
10
|
+
"editTooltip": "Edit the selected dashboard"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"create": "Criar dashboard",
|
|
3
|
+
"createText": "Preencha as informações do dashboard.",
|
|
4
|
+
"createTooltip": "Criar novo dashboard",
|
|
5
|
+
"delete": "Excluir dashboard",
|
|
6
|
+
"deleteText": "Você tem certeza de que deseja excluir estes dashboards?",
|
|
7
|
+
"deleteTooltip": "Excluir o dashboard selecionado",
|
|
8
|
+
"edit": "Editar dashboard",
|
|
9
|
+
"editText": "Visualizar e editar informações do dashboard.",
|
|
10
|
+
"editTooltip": "Editar o dashboard selecionado"
|
|
11
|
+
}
|
|
@@ -0,0 +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";
|
|
6
|
+
|
|
7
|
+
export function useDashboardCreate() {
|
|
8
|
+
const { dashboardCreate } = requests();
|
|
9
|
+
return useDefaultMutation(scope, "create", dashboardCreate);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useDashboardDelete() {
|
|
13
|
+
const { dashboardDelete } = requests();
|
|
14
|
+
return useDefaultMutation(scope, "delete", dashboardDelete);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useDashboardUpdate() {
|
|
18
|
+
const { dashboardUpdate } = requests();
|
|
19
|
+
return useDefaultMutation(scope, "update", dashboardUpdate);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useDashboardGet(id: number) {
|
|
23
|
+
const { dashboardGet } = requests();
|
|
24
|
+
return useQuery({
|
|
25
|
+
queryKey: [scope, "get"],
|
|
26
|
+
queryFn: () => dashboardGet(id),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useApp } from "@/hooks/use-app";
|
|
2
|
+
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
|
3
|
+
import { Dashboard } from "@/types/models";
|
|
4
|
+
import { HttpMethod } from "@/types/http-method";
|
|
5
|
+
import { formatDataWithLocale } from '@hedhog/utils'
|
|
6
|
+
|
|
7
|
+
export function requests() {
|
|
8
|
+
const { request } = useApp();
|
|
9
|
+
|
|
10
|
+
const dashboardList = async (params: PaginationParams) => {
|
|
11
|
+
return request<PaginationResult<Dashboard>>({
|
|
12
|
+
url: "/dashboard",
|
|
13
|
+
params,
|
|
14
|
+
}).then((res) => res.data);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const dashboardGet = async (id: number) => {
|
|
18
|
+
return request<Dashboard>({
|
|
19
|
+
url: `/dashboard/${id}`,
|
|
20
|
+
}).then((res) => res.data);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const dashboardCreate = async (params: { data: Dashboard }) => {
|
|
24
|
+
const { data } = params;
|
|
25
|
+
return request<Dashboard>({
|
|
26
|
+
url: "/dashboard",
|
|
27
|
+
method: HttpMethod.POST,
|
|
28
|
+
data: formatDataWithLocale(data),
|
|
29
|
+
}).then((res) => res.data);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const dashboardDelete = async (ids: number[]) => {
|
|
33
|
+
return request<Delete>({
|
|
34
|
+
url: "/dashboard",
|
|
35
|
+
data: { ids },
|
|
36
|
+
method: HttpMethod.DELETE,
|
|
37
|
+
}).then((res) => res.data);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const dashboardUpdate = async (params: { id: number; data: Dashboard }) => {
|
|
41
|
+
const { id, data } = params;
|
|
42
|
+
return request<Dashboard>({
|
|
43
|
+
url: `/dashboard/${id}`,
|
|
44
|
+
method: HttpMethod.PATCH,
|
|
45
|
+
data: formatDataWithLocale(data),
|
|
46
|
+
}).then((res) => res.data);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
dashboardCreate,
|
|
51
|
+
dashboardUpdate,
|
|
52
|
+
dashboardDelete,
|
|
53
|
+
dashboardList,
|
|
54
|
+
dashboardGet,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import FormPanel, {
|
|
2
|
+
FormPanelRef,
|
|
3
|
+
getFieldsLocale,
|
|
4
|
+
} from '@/components/panels/form-panel'
|
|
5
|
+
import { EnumFieldType } from '@/enums/EnumFieldType'
|
|
6
|
+
import { useDashboardComponentCreate } from '@/features/dashboard/dashboard-component'
|
|
7
|
+
import { DashboardComponent } from '@/types/models'
|
|
8
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
|
9
|
+
import { useTranslation } from 'react-i18next'
|
|
10
|
+
|
|
11
|
+
export type DashboardComponentCreatePanelRef = {
|
|
12
|
+
submit: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type DashboardComponentCreatePanelProps = {
|
|
16
|
+
onCreated?: (data: DashboardComponent) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DashboardComponentCreatePanel = forwardRef(
|
|
20
|
+
({ onCreated }: DashboardComponentCreatePanelProps, ref) => {
|
|
21
|
+
const formRef = useRef<FormPanelRef>(null)
|
|
22
|
+
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
|
23
|
+
const { mutateAsync: createDashboardComponent } =
|
|
24
|
+
useDashboardComponentCreate()
|
|
25
|
+
|
|
26
|
+
useImperativeHandle(
|
|
27
|
+
ref,
|
|
28
|
+
() => ({
|
|
29
|
+
submit: () => {
|
|
30
|
+
formRef.current?.submit()
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
[formRef]
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<FormPanel
|
|
38
|
+
ref={formRef}
|
|
39
|
+
fields={[
|
|
40
|
+
...getFieldsLocale([{ name: 'name' }]),
|
|
41
|
+
{
|
|
42
|
+
name: 'slug',
|
|
43
|
+
label: { text: t('dashboard-component.slug', { ns: 'fields' }) },
|
|
44
|
+
type: EnumFieldType.TEXT,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'path',
|
|
49
|
+
label: { text: t('dashboard-component.path', { ns: 'fields' }) },
|
|
50
|
+
type: EnumFieldType.TEXT,
|
|
51
|
+
required: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'min_width',
|
|
55
|
+
label: {
|
|
56
|
+
text: t('dashboard-component.min_width', { ns: 'fields' }),
|
|
57
|
+
},
|
|
58
|
+
type: EnumFieldType.NUMBER,
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'width',
|
|
63
|
+
label: { text: t('dashboard-component.width', { ns: 'fields' }) },
|
|
64
|
+
type: EnumFieldType.NUMBER,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'max_width',
|
|
69
|
+
label: {
|
|
70
|
+
text: t('dashboard-component.max_width', { ns: 'fields' }),
|
|
71
|
+
},
|
|
72
|
+
type: EnumFieldType.NUMBER,
|
|
73
|
+
required: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'min_height',
|
|
77
|
+
label: {
|
|
78
|
+
text: t('dashboard-component.min_height', { ns: 'fields' }),
|
|
79
|
+
},
|
|
80
|
+
type: EnumFieldType.NUMBER,
|
|
81
|
+
required: true,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'height',
|
|
85
|
+
label: { text: t('dashboard-component.height', { ns: 'fields' }) },
|
|
86
|
+
type: EnumFieldType.NUMBER,
|
|
87
|
+
required: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'max_height',
|
|
91
|
+
label: {
|
|
92
|
+
text: t('dashboard-component.max_height', { ns: 'fields' }),
|
|
93
|
+
},
|
|
94
|
+
type: EnumFieldType.NUMBER,
|
|
95
|
+
required: true,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'is_resizable',
|
|
99
|
+
label: {
|
|
100
|
+
text: t('dashboard-component.is_resizable', { ns: 'fields' }),
|
|
101
|
+
},
|
|
102
|
+
type: EnumFieldType.SWITCH,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
]}
|
|
106
|
+
button={{ text: t('create', { ns: 'actions' }) }}
|
|
107
|
+
onSubmit={async (data) => {
|
|
108
|
+
const createdData = await createDashboardComponent({
|
|
109
|
+
data: {
|
|
110
|
+
...data,
|
|
111
|
+
min_width: Number(data.min_width),
|
|
112
|
+
width: Number(data.width),
|
|
113
|
+
max_width: Number(data.max_width),
|
|
114
|
+
min_height: Number(data.min_height),
|
|
115
|
+
height: Number(data.height),
|
|
116
|
+
max_height: Number(data.max_height),
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
if (typeof onCreated === 'function') {
|
|
120
|
+
onCreated(createdData as any)
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
DashboardComponentCreatePanel.displayName = 'DashboardComponentCreatePanel'
|
|
129
|
+
|
|
130
|
+
export default DashboardComponentCreatePanel
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { PageTitle } from '@/components/custom/page-title'
|
|
2
|
+
import DataPanel from '@/components/panels/data-panel'
|
|
3
|
+
import { useDashboardComponentDelete } from '@/features/dashboard/dashboard-component'
|
|
4
|
+
import { useApp } from '@/hooks/use-app'
|
|
5
|
+
import { isPlural } from '@/lib/utils'
|
|
6
|
+
import { DashboardComponent } from '@/types/models'
|
|
7
|
+
import { IconEdit, IconPlus, IconTrash } from '@tabler/icons-react'
|
|
8
|
+
import { useState } from 'react'
|
|
9
|
+
import { useTranslation } from 'react-i18next'
|
|
10
|
+
import DashboardComponentCreatePanel from './components/dashboard-component-create-panel'
|
|
11
|
+
import DashboardComponentUpdatePanel from './components/dashboard-component-update-panel'
|
|
12
|
+
import DashboardComponentCard from '@/components/cards/dashboard-component-card'
|
|
13
|
+
|
|
14
|
+
export default function Page() {
|
|
15
|
+
const [selectedItems, setSelectedItems] = useState<DashboardComponent[]>([])
|
|
16
|
+
const { mutate: deleteDashboardComponent } = useDashboardComponentDelete()
|
|
17
|
+
const { openSheet, confirm, closeSheet } = useApp()
|
|
18
|
+
const { t } = useTranslation([
|
|
19
|
+
'dashboard.dashboard-component',
|
|
20
|
+
'modules',
|
|
21
|
+
'actions',
|
|
22
|
+
'fields',
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
const openCreate = () => {
|
|
26
|
+
const id = openSheet({
|
|
27
|
+
title: t('create', { ns: 'dashboard.dashboard-component' }),
|
|
28
|
+
description: t('createText', {
|
|
29
|
+
ns: 'dashboard.dashboard-component',
|
|
30
|
+
}),
|
|
31
|
+
children: () => (
|
|
32
|
+
<DashboardComponentCreatePanel onCreated={() => closeSheet(id)} />
|
|
33
|
+
),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return id
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const openDelete = (items: DashboardComponent[]) => {
|
|
40
|
+
return confirm({
|
|
41
|
+
title: `${t('delete', { ns: 'dashboard.dashboard-component' })} ${items.length} ${isPlural(items.length) ? t('items', { ns: 'actions' }) : t('item', { ns: 'actions' })}`,
|
|
42
|
+
description: t('deleteText', {
|
|
43
|
+
ns: 'dashboard.dashboard-component',
|
|
44
|
+
}),
|
|
45
|
+
})
|
|
46
|
+
.then(() =>
|
|
47
|
+
deleteDashboardComponent(
|
|
48
|
+
items
|
|
49
|
+
.map((item) => (item as any).component_id)
|
|
50
|
+
.filter((id) => id !== undefined)
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
.catch(() => setSelectedItems(items))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const openUpdate = (item: DashboardComponent) => {
|
|
57
|
+
const id = openSheet({
|
|
58
|
+
children: () => (
|
|
59
|
+
<DashboardComponentUpdatePanel
|
|
60
|
+
data={item}
|
|
61
|
+
onUpdated={() => closeSheet(id)}
|
|
62
|
+
/>
|
|
63
|
+
),
|
|
64
|
+
title: t('edit', { ns: 'dashboard.dashboard-component' }),
|
|
65
|
+
description: t('editText', {
|
|
66
|
+
ns: 'dashboard.dashboard-component',
|
|
67
|
+
}),
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return id
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<PageTitle title={t('dashboard_component', { ns: 'modules' })} />
|
|
76
|
+
<DataPanel
|
|
77
|
+
url='/dashboard-component'
|
|
78
|
+
layout='grid'
|
|
79
|
+
id='dashboard-component'
|
|
80
|
+
selectable
|
|
81
|
+
render={(item: DashboardComponent) => (
|
|
82
|
+
<DashboardComponentCard item={item} />
|
|
83
|
+
)}
|
|
84
|
+
responsiveColumns={{
|
|
85
|
+
default: 1,
|
|
86
|
+
sm: 2,
|
|
87
|
+
md: 1,
|
|
88
|
+
lg: 2,
|
|
89
|
+
xl: 3,
|
|
90
|
+
}}
|
|
91
|
+
selected={selectedItems as DashboardComponent[]}
|
|
92
|
+
multiple
|
|
93
|
+
hasSearch
|
|
94
|
+
onItemDoubleClick={(item) => openUpdate(item)}
|
|
95
|
+
menuActions={[
|
|
96
|
+
{
|
|
97
|
+
icon: <IconEdit className='mr-1 w-8 cursor-pointer' />,
|
|
98
|
+
label: t('edit', { ns: 'actions' }),
|
|
99
|
+
tooltip: t('editTooltip', {
|
|
100
|
+
ns: 'dashboard.dashboard-component',
|
|
101
|
+
}),
|
|
102
|
+
handler: (items: DashboardComponent[]) => {
|
|
103
|
+
if (items.length === 1) openUpdate(items[0])
|
|
104
|
+
},
|
|
105
|
+
show: 'once',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
icon: <IconTrash className='mr-1 w-8 cursor-pointer' />,
|
|
109
|
+
label: t('delete', { ns: 'actions' }),
|
|
110
|
+
tooltip: t('deleteTooltip', {
|
|
111
|
+
ns: 'dashboard.dashboard-component',
|
|
112
|
+
}),
|
|
113
|
+
variant: 'destructive',
|
|
114
|
+
handler: (items: DashboardComponent[]) => {
|
|
115
|
+
openDelete(items)
|
|
116
|
+
},
|
|
117
|
+
show: 'some',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
icon: <IconPlus className='mr-1 w-8 cursor-pointer' />,
|
|
121
|
+
label: t('create', { ns: 'actions' }),
|
|
122
|
+
tooltip: t('createTooltip', {
|
|
123
|
+
ns: 'dashboard.dashboard-component',
|
|
124
|
+
}),
|
|
125
|
+
variant: 'default',
|
|
126
|
+
handler: () => {
|
|
127
|
+
openCreate()
|
|
128
|
+
},
|
|
129
|
+
show: 'none',
|
|
130
|
+
},
|
|
131
|
+
]}
|
|
132
|
+
/>
|
|
133
|
+
</>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import FormPanel, {
|
|
2
|
+
FormPanelRef,
|
|
3
|
+
getFieldsLocale,
|
|
4
|
+
} from '@/components/panels/form-panel'
|
|
5
|
+
import { Overlay } from '@/components/custom/overlay'
|
|
6
|
+
import { TabPanel } from '@/components/panels/tab-panel'
|
|
7
|
+
import {
|
|
8
|
+
useDashboardComponentGet,
|
|
9
|
+
useDashboardComponentUpdate,
|
|
10
|
+
} from '@/features/dashboard/dashboard-component'
|
|
11
|
+
import useEffectAfterFirstUpdate from '@/hooks/use-effect-after-first-update'
|
|
12
|
+
import { DashboardComponent } from '@/types/models'
|
|
13
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
|
14
|
+
import { useTranslation } from 'react-i18next'
|
|
15
|
+
import { EnumFieldType } from '@/enums/EnumFieldType'
|
|
16
|
+
|
|
17
|
+
export type DashboardComponentUpdatePanelProps = {
|
|
18
|
+
data: DashboardComponent
|
|
19
|
+
onUpdated?: (data: DashboardComponent) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DashboardComponentUpdatePanel = forwardRef(
|
|
23
|
+
({ data, onUpdated }: DashboardComponentUpdatePanelProps, ref) => {
|
|
24
|
+
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
|
25
|
+
const { data: item, isLoading } = useDashboardComponentGet(
|
|
26
|
+
(data as any).component_id as number
|
|
27
|
+
)
|
|
28
|
+
const { mutate: dashboardComponentUpdate } = useDashboardComponentUpdate()
|
|
29
|
+
const formRef = useRef<FormPanelRef>(null)
|
|
30
|
+
|
|
31
|
+
useEffectAfterFirstUpdate(() => {
|
|
32
|
+
if (item && formRef.current) {
|
|
33
|
+
formRef.current.setValuesFromItem(item)
|
|
34
|
+
}
|
|
35
|
+
}, [item])
|
|
36
|
+
|
|
37
|
+
useImperativeHandle(ref, () => ({}))
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TabPanel
|
|
41
|
+
activeTabIndex={0}
|
|
42
|
+
tabs={[
|
|
43
|
+
{
|
|
44
|
+
title: t('details', { ns: 'actions' }),
|
|
45
|
+
children: (
|
|
46
|
+
<Overlay loading={isLoading}>
|
|
47
|
+
<FormPanel
|
|
48
|
+
ref={formRef}
|
|
49
|
+
fields={[
|
|
50
|
+
...getFieldsLocale([{ name: 'name' }], item),
|
|
51
|
+
{
|
|
52
|
+
name: 'slug',
|
|
53
|
+
label: {
|
|
54
|
+
text: t('dashboard-component.slug', { ns: 'fields' }),
|
|
55
|
+
},
|
|
56
|
+
type: EnumFieldType.TEXT,
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'path',
|
|
61
|
+
label: {
|
|
62
|
+
text: t('dashboard-component.path', { ns: 'fields' }),
|
|
63
|
+
},
|
|
64
|
+
type: EnumFieldType.TEXT,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'min_width',
|
|
69
|
+
label: {
|
|
70
|
+
text: t('dashboard-component.min_width', {
|
|
71
|
+
ns: 'fields',
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
type: EnumFieldType.NUMBER,
|
|
75
|
+
required: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'width',
|
|
79
|
+
label: {
|
|
80
|
+
text: t('dashboard-component.width', { ns: 'fields' }),
|
|
81
|
+
},
|
|
82
|
+
type: EnumFieldType.NUMBER,
|
|
83
|
+
required: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'max_width',
|
|
87
|
+
label: {
|
|
88
|
+
text: t('dashboard-component.max_width', {
|
|
89
|
+
ns: 'fields',
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
type: EnumFieldType.NUMBER,
|
|
93
|
+
required: true,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'min_height',
|
|
97
|
+
label: {
|
|
98
|
+
text: t('dashboard-component.min_height', {
|
|
99
|
+
ns: 'fields',
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
type: EnumFieldType.NUMBER,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'height',
|
|
107
|
+
label: {
|
|
108
|
+
text: t('dashboard-component.height', { ns: 'fields' }),
|
|
109
|
+
},
|
|
110
|
+
type: EnumFieldType.NUMBER,
|
|
111
|
+
required: true,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'max_height',
|
|
115
|
+
label: {
|
|
116
|
+
text: t('dashboard-component.max_height', {
|
|
117
|
+
ns: 'fields',
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
type: EnumFieldType.NUMBER,
|
|
121
|
+
required: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'is_resizable',
|
|
125
|
+
label: {
|
|
126
|
+
text: t('dashboard-component.is_resizable', {
|
|
127
|
+
ns: 'fields',
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
type: EnumFieldType.SWITCH,
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
133
|
+
]}
|
|
134
|
+
button={{ text: t('save', { ns: 'actions' }) }}
|
|
135
|
+
onSubmit={(data) => {
|
|
136
|
+
dashboardComponentUpdate({
|
|
137
|
+
id: data.id,
|
|
138
|
+
data: {
|
|
139
|
+
...data,
|
|
140
|
+
min_width: Number(data.min_width),
|
|
141
|
+
width: Number(data.width),
|
|
142
|
+
max_width: Number(data.max_width),
|
|
143
|
+
min_height: Number(data.min_height),
|
|
144
|
+
height: Number(data.height),
|
|
145
|
+
max_height: Number(data.max_height),
|
|
146
|
+
},
|
|
147
|
+
})
|
|
148
|
+
if (typeof onUpdated === 'function') {
|
|
149
|
+
onUpdated(data)
|
|
150
|
+
}
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
</Overlay>
|
|
154
|
+
),
|
|
155
|
+
},
|
|
156
|
+
]}
|
|
157
|
+
/>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
DashboardComponentUpdatePanel.displayName = 'DashboardComponentUpdatePanel'
|
|
163
|
+
|
|
164
|
+
export default DashboardComponentUpdatePanel
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"create": "Create dashboard component",
|
|
3
|
+
"createText": "Fill the dashboard component informations.",
|
|
4
|
+
"createTooltip": "Create new dashboard component",
|
|
5
|
+
"delete": "Delete dashboard component",
|
|
6
|
+
"deleteText": "Are you sure to delete these dashboard components?",
|
|
7
|
+
"deleteTooltip": "Delete the selected dashboard component",
|
|
8
|
+
"edit": "Edit dashboard component",
|
|
9
|
+
"editText": "View and edit dashboard component information.",
|
|
10
|
+
"editTooltip": "Edit the selected dashboard component"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"create": "Criar componente do dashboard",
|
|
3
|
+
"createText": "Preencha as informações do componente do dashboard.",
|
|
4
|
+
"createTooltip": "Criar novo componente do dashboard",
|
|
5
|
+
"delete": "Excluir componente do dashboard",
|
|
6
|
+
"deleteText": "Você tem certeza de que deseja excluir esses componentes do dashboard?",
|
|
7
|
+
"deleteTooltip": "Excluir o componente do dashboard selecionado",
|
|
8
|
+
"edit": "Editar componente do dashboard",
|
|
9
|
+
"editText": "Ver e editar as informações do componente do dashboard.",
|
|
10
|
+
"editTooltip": "Editar o componente do dashboard selecionado"
|
|
11
|
+
}
|
|
@@ -0,0 +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-component";
|
|
6
|
+
|
|
7
|
+
export function useDashboardComponentCreate() {
|
|
8
|
+
const { dashboardComponentCreate } = requests();
|
|
9
|
+
return useDefaultMutation(scope, "create", dashboardComponentCreate);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useDashboardComponentDelete() {
|
|
13
|
+
const { dashboardComponentDelete } = requests();
|
|
14
|
+
return useDefaultMutation(scope, "delete", dashboardComponentDelete);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useDashboardComponentUpdate() {
|
|
18
|
+
const { dashboardComponentUpdate } = requests();
|
|
19
|
+
return useDefaultMutation(scope, "update", dashboardComponentUpdate);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useDashboardComponentGet(id: number) {
|
|
23
|
+
const { dashboardComponentGet } = requests();
|
|
24
|
+
return useQuery({
|
|
25
|
+
queryKey: [scope, "get"],
|
|
26
|
+
queryFn: () => dashboardComponentGet(id),
|
|
27
|
+
});
|
|
28
|
+
}
|