@fluxo-dev/shell 0.0.8 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/index.esm.css +115 -0
  2. package/index.esm.d.ts +1 -0
  3. package/index.esm.js +68195 -0
  4. package/package.json +13 -2
  5. package/src/index.d.ts +1 -0
  6. package/src/lib/app.d.ts +16 -0
  7. package/src/lib/components/error-page/404.d.ts +1 -0
  8. package/src/lib/components/routes/main-routes.d.ts +6 -0
  9. package/src/lib/layouts/blank/blank-layout.d.ts +2 -0
  10. package/src/lib/layouts/main/app-bar.d.ts +9 -0
  11. package/src/lib/layouts/main/app-layout.d.ts +5 -0
  12. package/src/lib/layouts/main/content.d.ts +2 -0
  13. package/src/lib/layouts/main/footer-bar.d.ts +5 -0
  14. package/src/lib/layouts/main/navbar-item.d.ts +12 -0
  15. package/src/lib/layouts/main/navbar.d.ts +1 -0
  16. package/src/lib/layouts/main/search-bar.d.ts +5 -0
  17. package/src/lib/layouts/main/shell-spotlight.d.ts +2 -0
  18. package/src/lib/models/app-jit.d.ts +5 -0
  19. package/src/lib/pages/general/fluxo-plugin-loader.d.ts +7 -0
  20. package/src/lib/pages/login/account-confirmation.d.ts +2 -0
  21. package/src/lib/pages/login/change-password.d.ts +2 -0
  22. package/src/lib/pages/login/forgot-password.d.ts +2 -0
  23. package/src/lib/pages/login/login-page.d.ts +2 -0
  24. package/src/lib/pages/login/reset-password.d.ts +2 -0
  25. package/src/lib/pages/settings/apps/add-jit-app.d.ts +5 -0
  26. package/src/lib/pages/settings/apps/app-item.d.ts +10 -0
  27. package/src/lib/pages/settings/apps/app-jit-item.d.ts +8 -0
  28. package/src/lib/pages/settings/apps/apps-list.d.ts +6 -0
  29. package/src/lib/pages/settings/apps/embedded-module-item.d.ts +10 -0
  30. package/src/lib/pages/settings/apps/install-or-upgrade-app.d.ts +6 -0
  31. package/src/lib/pages/settings/menu-designer/custom-node.d.ts +14 -0
  32. package/src/lib/pages/settings/menu-designer/menu-create-form.d.ts +5 -0
  33. package/src/lib/pages/settings/menu-designer/menu-designer.d.ts +1 -0
  34. package/src/lib/pages/settings/menu-designer/menu-item-edit.d.ts +8 -0
  35. package/src/lib/pages/settings/menu-designer/placeholder.d.ts +8 -0
  36. package/src/lib/pages/settings/security/components/domani-role/domain-role-form.d.ts +6 -0
  37. package/src/lib/pages/settings/security/components/domani-role/domain-role-grid.d.ts +1 -0
  38. package/src/lib/pages/settings/security/components/permission/create-custom-permission-form.d.ts +7 -0
  39. package/src/lib/pages/settings/security/components/permission/create-scope-form.d.ts +7 -0
  40. package/src/lib/pages/settings/security/components/permission/permission-grid.d.ts +1 -0
  41. package/src/lib/pages/settings/security/components/permission/permission-navigator.d.ts +8 -0
  42. package/src/lib/pages/settings/security/components/permission/update-permission.d.ts +5 -0
  43. package/src/lib/pages/settings/security/components/route-rule/route-rule-create-form.d.ts +7 -0
  44. package/src/lib/pages/settings/security/components/route-rule/route-rule-grid.d.ts +1 -0
  45. package/src/lib/pages/settings/security/components/user/user-form.d.ts +7 -0
  46. package/src/lib/pages/settings/security/components/user/users-grid.d.ts +1 -0
  47. package/src/lib/pages/settings/settings.d.ts +6 -0
  48. package/src/lib/pages/settings/token/token-row.d.ts +7 -0
  49. package/src/lib/pages/settings/token/tokens.d.ts +2 -0
  50. package/src/lib/pages/settings/ui/ui.d.ts +1 -0
  51. package/src/lib/services/app-jit-manager.d.ts +10 -0
  52. package/src/lib/services/app-menu.service.d.ts +5 -0
  53. package/src/lib/utils/icon-factory.d.ts +9 -0
  54. package/src/lib/utils/security/only-not-logged-route.d.ts +2 -0
  55. package/src/lib/utils/security/protected-route.d.ts +2 -0
  56. package/.babelrc +0 -12
  57. package/.eslintrc.json +0 -18
  58. package/jest.config.ts +0 -11
  59. package/project.json +0 -43
  60. package/src/index.ts +0 -1
  61. package/src/lib/app.module.css +0 -1
  62. package/src/lib/app.spec.tsx +0 -17
  63. package/src/lib/app.tsx +0 -374
  64. package/src/lib/components/error-page/404.tsx +0 -16
  65. package/src/lib/components/routes/main-routes.tsx +0 -26
  66. package/src/lib/layouts/blank/blank-layout.tsx +0 -10
  67. package/src/lib/layouts/main/app-bar.tsx +0 -192
  68. package/src/lib/layouts/main/app-layout.tsx +0 -52
  69. package/src/lib/layouts/main/content.tsx +0 -10
  70. package/src/lib/layouts/main/footer-bar.tsx +0 -76
  71. package/src/lib/layouts/main/navbar-item.module.css +0 -49
  72. package/src/lib/layouts/main/navbar-item.tsx +0 -129
  73. package/src/lib/layouts/main/navbar.tsx +0 -38
  74. package/src/lib/layouts/main/search-bar.tsx +0 -44
  75. package/src/lib/layouts/main/shell-spotlight.tsx +0 -58
  76. package/src/lib/models/app-jit.ts +0 -6
  77. package/src/lib/pages/general/fluxo-plugin-loader.tsx +0 -22
  78. package/src/lib/pages/login/account-confirmation.tsx +0 -86
  79. package/src/lib/pages/login/change-password.tsx +0 -58
  80. package/src/lib/pages/login/forgot-password.tsx +0 -53
  81. package/src/lib/pages/login/login-page.tsx +0 -70
  82. package/src/lib/pages/login/reset-password.tsx +0 -91
  83. package/src/lib/pages/settings/apps/add-jit-app.tsx +0 -79
  84. package/src/lib/pages/settings/apps/app-item.tsx +0 -157
  85. package/src/lib/pages/settings/apps/app-jit-item.tsx +0 -105
  86. package/src/lib/pages/settings/apps/apps-list.tsx +0 -171
  87. package/src/lib/pages/settings/apps/embedded-module-item.tsx +0 -66
  88. package/src/lib/pages/settings/apps/install-or-upgrade-app.tsx +0 -105
  89. package/src/lib/pages/settings/menu-designer/custom-node.module.css +0 -34
  90. package/src/lib/pages/settings/menu-designer/custom-node.tsx +0 -160
  91. package/src/lib/pages/settings/menu-designer/menu-create-form.tsx +0 -109
  92. package/src/lib/pages/settings/menu-designer/menu-designer.module.css +0 -19
  93. package/src/lib/pages/settings/menu-designer/menu-designer.tsx +0 -463
  94. package/src/lib/pages/settings/menu-designer/menu-item-edit.tsx +0 -115
  95. package/src/lib/pages/settings/menu-designer/placeholder.module.css +0 -8
  96. package/src/lib/pages/settings/menu-designer/placeholder.tsx +0 -13
  97. package/src/lib/pages/settings/security/components/domani-role/domain-role-form.tsx +0 -67
  98. package/src/lib/pages/settings/security/components/domani-role/domain-role-grid.tsx +0 -139
  99. package/src/lib/pages/settings/security/components/permission/create-custom-permission-form.tsx +0 -64
  100. package/src/lib/pages/settings/security/components/permission/create-scope-form.tsx +0 -158
  101. package/src/lib/pages/settings/security/components/permission/permission-grid.tsx +0 -304
  102. package/src/lib/pages/settings/security/components/permission/permission-navigator.tsx +0 -320
  103. package/src/lib/pages/settings/security/components/permission/update-permission.tsx +0 -54
  104. package/src/lib/pages/settings/security/components/route-rule/route-rule-create-form.tsx +0 -59
  105. package/src/lib/pages/settings/security/components/route-rule/route-rule-grid.tsx +0 -229
  106. package/src/lib/pages/settings/security/components/user/user-form.tsx +0 -123
  107. package/src/lib/pages/settings/security/components/user/users-grid.tsx +0 -127
  108. package/src/lib/pages/settings/settings.tsx +0 -298
  109. package/src/lib/pages/settings/token/token-row.tsx +0 -69
  110. package/src/lib/pages/settings/token/tokens.tsx +0 -73
  111. package/src/lib/pages/settings/ui/ui.tsx +0 -149
  112. package/src/lib/services/app-jit-manager.ts +0 -92
  113. package/src/lib/services/app-menu.service.ts +0 -35
  114. package/src/lib/utils/icon-factory.tsx +0 -25
  115. package/src/lib/utils/security/only-not-logged-route.tsx +0 -17
  116. package/src/lib/utils/security/protected-route.tsx +0 -47
  117. package/tsconfig.json +0 -20
  118. package/tsconfig.lib.json +0 -24
  119. package/tsconfig.spec.json +0 -20
@@ -1,123 +0,0 @@
1
- import {DomainRole, FluxoClientSys, User, UserService} from "@fluxo-dev/api-client-base";
2
- import { Button, MultiSelect, Stack, TextInput } from "@mantine/core";
3
- import { useForm } from "@mantine/form";
4
- import { showNotification } from "@mantine/notifications";
5
- import { IconFilePlus } from '@tabler/icons-react';
6
- import {useEffect, useState} from "react";
7
-
8
- export interface UserFormProps {
9
- user?: User,
10
- onCreate: () => void
11
- }
12
- function UserForm(props: UserFormProps) {
13
- const userService = new UserService();
14
- const roles = [
15
- { value: 'administrator', label: 'Amministratore' },
16
- { value: 'user', label: 'Utente' }
17
- ];
18
-
19
- const [domainRoles, setDomainRoles] = useState<DomainRole[]>([]);
20
-
21
- useEffect(() => {
22
-
23
- FluxoClientSys.Instance.security.domainRole.find(999,0)
24
- .then((res) => {
25
- setDomainRoles(res.results);
26
- });
27
-
28
- }, []);
29
-
30
- const generalForm = useForm({
31
- initialValues: {
32
- user: {
33
- firstName: props.user?.userData?.FirstName ?? '',
34
- lastName: props.user?.userData?.LastName ?? '',
35
- email: props.user?.email ?? '',
36
- userName: ''
37
- },
38
- assignToRoles: props.user?.roles ?? [],
39
- assignToDomainRoles: props.user?.domainRoles.map(a => a.id!.toString()) ?? []
40
- },
41
- clearInputErrorOnChange: true,
42
- validateInputOnChange: true,
43
- validate: {
44
- user: {
45
- firstName: (value) => (!value ? 'Il nome è obbligatorio' : null),
46
- lastName: (value) => (!value ? 'Il cognome è obbligatorio' : null),
47
- email: (value) => (!value ? 'L\'email è obbligatoria' : null),
48
- },
49
- }
50
- });
51
-
52
- const create = (value: any) => {
53
- value.user.userName = value.user.email;
54
-
55
- const newUser = {
56
- user: value.user,
57
- assignToRoles: value.assignToRoles,
58
- assignToDomainRoles: value.assignToDomainRoles.map((a: string) => parseInt(a))
59
- };
60
-
61
-
62
- (props.user ? userService.updateUser(props.user.id, newUser) : userService.createUser(newUser))
63
- .then((res) => {
64
- if (res.success) {
65
- showNotification({
66
- title: 'Operazione completata',
67
- message: 'Aggiornamento completato',
68
- color: 'green',
69
- })
70
- generalForm.reset();
71
- generalForm.resetDirty();
72
- if (props.onCreate)
73
- props.onCreate();
74
- } else {
75
- showNotification({
76
- title: 'Errore',
77
- message: `Errore durante l'aggiornamento: ${res.errors.map(x => x.description).join(', ')}`,
78
- color: 'red',
79
- });
80
- }
81
- })
82
- .catch((err) => {
83
- showNotification({
84
- title: 'Errore',
85
- message: `Errore durante l'aggiornamento: ${err.message}`,
86
- color: 'red',
87
- });
88
- })
89
- }
90
-
91
- return (
92
- <form
93
- onKeyDown={event => { if (event.which === 13) event.preventDefault() }}
94
- onSubmit={generalForm.onSubmit(
95
- (values, event) => {
96
- event?.preventDefault();
97
- create(values);
98
- })}>
99
- <Stack gap="xs">
100
- <TextInput label={'Nome'} {...generalForm.getInputProps('user.firstName')} />
101
- <TextInput label={'Cognome'} {...generalForm.getInputProps('user.lastName')} />
102
- <TextInput label={'Email'} disabled={!!props.user} {...generalForm.getInputProps('user.email')} />
103
- <MultiSelect
104
- data={roles}
105
- label="Tipo di accesso"
106
- placeholder="Seleziona uno o più tipi di accesso"
107
- {...generalForm.getInputProps('assignToRoles')}
108
- />
109
- <MultiSelect
110
- data={domainRoles.map(x => ({value: x.id!.toString(), label: x.name}))}
111
- label="Ruolo"
112
- placeholder="Seleziona uno o più ruoli"
113
- {...generalForm.getInputProps('assignToDomainRoles')}
114
- />
115
- </Stack >
116
- <Stack align="flex-end" mt="md">
117
- <Button type="submit" leftSection={<IconFilePlus />} ml='auto' disabled={!generalForm.isDirty()}>Salva</Button>
118
- </Stack >
119
- </form>
120
- );
121
- }
122
-
123
- export default UserForm;
@@ -1,127 +0,0 @@
1
- import React, {useEffect, useState} from "react";
2
- import {FluxoClientSys, User} from "@fluxo-dev/api-client-base";
3
- import {showNotification} from "@mantine/notifications";
4
- import {ActionIcon, Badge, Menu, Modal, Stack, Table} from "@mantine/core";
5
- import {DataCard} from "@fluxo-dev/ui-components";
6
- import {IconDotsVertical, IconEdit, IconPlus, IconTrash} from "@tabler/icons-react";
7
- import UserForm from "./user-form";
8
-
9
- export function UsersGrid() {
10
- const [users, setUsers] = useState<User[]>([]);
11
-
12
- const [currentUser, setCurrentUser] = useState<User>();
13
-
14
- const [newUserModalOpen, setNewUserModalOpen] = useState<boolean>(false);
15
-
16
- useEffect(() => {
17
- getAllUsers();
18
- }, [])
19
-
20
- const getAllUsers = () => {
21
- FluxoClientSys.Instance.security.user.getAllUsers().then(res => {
22
- setUsers(res);
23
- })
24
- }
25
-
26
- const deletion = (id: string) => {
27
- FluxoClientSys.Instance.security.user.deleteUser(id)
28
- .then((res) => {
29
- if (res.success) {
30
- showNotification({
31
- title: 'Cancellazione completata',
32
- message: `L'utente è stato cancellato con successo`,
33
- color: 'green',
34
- });
35
- } else {
36
- showNotification({
37
- title: 'Errore',
38
- message: `Errore durante la cancellazione: ${res.errors.map(x => x.description).join(', ')}`,
39
- color: 'red',
40
- });
41
- }
42
- getAllUsers();
43
- })
44
- }
45
-
46
- return (
47
- <Stack>
48
- <DataCard
49
- title={'Utenti'}
50
- actions={[
51
- {icon: <IconPlus size={18}/>, label: 'Nuovo utente', onClick: () => setNewUserModalOpen(true)},
52
- ]}>
53
-
54
- <Table highlightOnHover>
55
- <Table.Thead>
56
- <Table.Tr>
57
- <Table.Th>Nome</Table.Th>
58
- <Table.Th>Cognome</Table.Th>
59
- <Table.Th>Email</Table.Th>
60
- <Table.Th>Tipo di accesso</Table.Th>
61
- <Table.Th>Ruoli</Table.Th>
62
- <Table.Th></Table.Th>
63
- </Table.Tr>
64
- </Table.Thead>
65
- <Table.Tbody>
66
- {
67
- users.map((element, i) =>
68
- <Table.Tr key={i}>
69
- <Table.Td>{element.userData.FirstName}</Table.Td>
70
- <Table.Td>{element.userData.LastName}</Table.Td>
71
- <Table.Td>{element.email}</Table.Td>
72
- <Table.Td>
73
- <Stack gap={8}>
74
- {element.roles.map((d) => {
75
- return (
76
- <Badge key={d} color={'orange'}>{d}</Badge>
77
- )
78
- })}
79
- </Stack>
80
- </Table.Td>
81
- <Table.Td>
82
- <Stack gap={8}>
83
- {element.domainRoles.map((d) => {
84
- return (
85
- <Badge key={d.id}>{d.name}</Badge>
86
- )
87
- })}
88
- </Stack>
89
- </Table.Td>
90
- <Table.Td align="right">
91
- <Menu shadow="md" width={200}>
92
- <Menu.Target>
93
- <ActionIcon><IconDotsVertical size={18} /></ActionIcon>
94
- </Menu.Target>
95
-
96
- <Menu.Dropdown>
97
- <Menu.Item onClick={() => {
98
- setCurrentUser(element);
99
- setNewUserModalOpen(true);
100
- }} leftSection={<IconEdit size={14} />}>Modifica</Menu.Item>
101
- <Menu.Item color={'red'} onClick={() => deletion(element.id)} leftSection={<IconTrash color={'red'} size={14} />}>Elimina</Menu.Item>
102
- </Menu.Dropdown>
103
- </Menu>
104
- </Table.Td>
105
- </Table.Tr>
106
- )
107
- }
108
- </Table.Tbody>
109
- </Table>
110
- </DataCard>
111
-
112
-
113
- <Modal centered opened={newUserModalOpen} onClose={() => {
114
- setNewUserModalOpen(false);
115
- setCurrentUser(undefined);
116
- }} title={`${currentUser ? 'Modifica utente' : 'Crea utente'}`}>
117
- <UserForm onCreate={() => {
118
- setNewUserModalOpen(false);
119
- getAllUsers();
120
- setCurrentUser(undefined);
121
- }} user={currentUser}/>
122
- </Modal>
123
-
124
-
125
- </Stack>
126
- );
127
- }
@@ -1,298 +0,0 @@
1
- import {
2
- DataCard,
3
- ShellPage,
4
- SideMenuGroup,
5
- WaitData,
6
- } from "@fluxo-dev/ui-components";
7
- import { Text } from '@mantine/core';
8
- import {
9
- IconApi, IconApps, IconCode,
10
- IconDashboard,
11
- IconKey,
12
- IconLockAccess,
13
- IconMenu, IconPrinter, IconRoute, IconUsers, IconUsersGroup,
14
- IconVariable,
15
- } from '@tabler/icons-react';
16
- import React, { useEffect, useState } from 'react';
17
- import { Ui } from './ui/ui';
18
- import { MenuDesigner } from './menu-designer/menu-designer';
19
- import { RestApiDocumentation } from '@fluxo-fe/shell/korebi';
20
- import {Documentation, EmbeddedModule, FluxoClientSys} from "@fluxo-dev/api-client-base";
21
- import { ErrorPage } from "@fluxo-dev/ui-components";
22
- import Tokens from './token/tokens';
23
- import {useNavigate} from "react-router-dom";
24
- import {AppsList} from "./apps/apps-list";
25
- import {PermissionGrid} from "./security/components/permission/permission-grid";
26
- import {DomainRoleGrid} from "./security/components/domani-role/domain-role-grid";
27
- import {UsersGrid} from "./security/components/user/users-grid";
28
- import {RouteRuleGrid} from "./security/components/route-rule/route-rule-grid";
29
- import {PrintServerList} from "@fluxo-fe/shell/printing";
30
-
31
- export interface SettingsProps {
32
- pluginEndpoint: string;
33
- modules: EmbeddedModule[];
34
- }
35
-
36
- export function Settings(props: SettingsProps) {
37
- const [currentTab, setCurrentTab] = useState('ui');
38
- const [apiRestDoc, setApiRestDoc] = useState<Documentation>();
39
- const navigate = useNavigate();
40
-
41
-
42
- useEffect(() => {
43
- const hash = window.location.hash.slice(1);
44
- if (hash) {
45
- setCurrentTab(hash);
46
- }
47
- }, []);
48
-
49
- useEffect(() => {
50
- FluxoClientSys.Instance.korebi.documentation.getRestApiDocumentation().then((res) => {
51
- setApiRestDoc(res);
52
- });
53
- }, []);
54
-
55
- const getSideMenuGroups = (): SideMenuGroup[] => {
56
- return [
57
- {
58
- name: "Interfaccia",
59
- items: [
60
- {
61
- key: 'ui',
62
- title: (
63
- <Text>
64
- Brand
65
- </Text>
66
- ),
67
- onClick: () => {
68
- window.location.hash = 'ui';
69
- setCurrentTab('ui')
70
- },
71
- disabled: false,
72
- icon: <IconDashboard size={18} />,
73
- description:
74
- 'Gestisci colori logo e altri impostazioni di interfaccia',
75
- },
76
- {
77
- key: 'menu',
78
- title: (
79
- <Text>
80
- Menu e ricerca
81
- </Text>
82
- ),
83
- onClick: () => {
84
- window.location.hash = 'menu';
85
- setCurrentTab('menu')
86
- },
87
- disabled: false,
88
- icon: <IconMenu size={18} />,
89
- description: 'Gestione del menu laterale e delle azioni veloci',
90
- },
91
- ],
92
- },
93
- {
94
- name: 'Sicurezza',
95
- items: [
96
- {
97
- key: 'users',
98
- title: (
99
- <Text>
100
- Utenti
101
- </Text>
102
- ),
103
- onClick: () => {
104
- window.location.hash = 'users';
105
- setCurrentTab('users');
106
- },
107
- disabled: false,
108
- icon: <IconUsers size={18} />,
109
- description: 'Crea, modifica, elimina utenti',
110
- },
111
- {
112
- key: 'roles',
113
- title: (
114
- <Text>
115
- Ruoli
116
- </Text>
117
- ),
118
- onClick: () => {
119
- window.location.hash = 'roles';
120
- setCurrentTab('roles')
121
- },
122
- disabled: false,
123
- icon: <IconUsersGroup size={18} />,
124
- description: 'Crea, modifica, elimina ruoli',
125
- },
126
- {
127
- key: 'permissions',
128
- title: (
129
- <Text>
130
- Permessi
131
- </Text>
132
- ),
133
- onClick: () => {
134
- window.location.hash = 'permissions';
135
- setCurrentTab('permissions')
136
- },
137
- disabled: false,
138
- icon: <IconKey size={18} />,
139
- description: 'Gestisci i permessi utente',
140
- },
141
- {
142
- key: 'routes',
143
- title: (
144
- <Text>
145
- Regole sulle rotte <small><b>(Avanzato)</b></small>
146
- </Text>
147
- ),
148
- onClick: () => {
149
- window.location.hash = 'routes';
150
- setCurrentTab('routes')
151
- },
152
- disabled: false,
153
- icon: <IconRoute size={18} />,
154
- description: 'Gestisci le regole sulle rotte',
155
- },
156
- ]
157
- },
158
- {
159
- name: 'Stampe',
160
- items: [
161
- {
162
- key: 'print-server',
163
- title: (
164
- <Text>
165
- Print server
166
- </Text>
167
- ),
168
- onClick: () => {
169
- window.location.hash = 'print-server';
170
- setCurrentTab('print-server')
171
- },
172
- disabled: false,
173
- icon: <IconPrinter size={18} />,
174
- description: 'Gestisci i print server',
175
- }
176
- ]
177
- },
178
- {
179
- name: 'Sviluppatori',
180
- items: [
181
- {
182
- key: 'tokens',
183
- title: (
184
- <Text>
185
- Access tokens <small>(account)</small>
186
- </Text>
187
- ),
188
- onClick: () => {
189
- window.location.hash = 'tokens';
190
- setCurrentTab('tokens')
191
- },
192
- disabled: false,
193
- icon: <IconLockAccess size={18} />,
194
- description: 'Gestisci i tuoi access tokens',
195
- },
196
- {
197
- key: 'environment',
198
- title: (
199
- <Text>
200
- Variabili d'ambiente <small>(Globale)</small>
201
- </Text>
202
- ),
203
- onClick: () => {
204
- window.location.hash = 'environment';
205
- setCurrentTab('environment')
206
- },
207
- disabled: false,
208
- icon: <IconVariable size={18} />,
209
- description: "Crea, modifica o elimina le variabili d'ambiente",
210
- },
211
- {
212
- key: 'plugin',
213
- title: (
214
- <Text>
215
- Apps <small>(Globale)</small>
216
- </Text>
217
- ),
218
- onClick: () => {
219
- window.location.hash = 'plugin';
220
- setCurrentTab('plugin')
221
- },
222
- disabled: false,
223
- icon: <IconApps size={18} />,
224
- description: 'Installa o gestisci le apps',
225
- },
226
- {
227
- key: 'apidoc',
228
- title: (
229
- <Text>
230
- API <small>REST</small>
231
- </Text>
232
- ),
233
- onClick: () => {
234
- window.location.hash = 'apidoc';
235
- setCurrentTab('apidoc')
236
- },
237
- disabled: false,
238
- icon: <IconApi size={18} />,
239
- description: 'Documentazione delle API REST',
240
- },
241
- {
242
- key: 'ide',
243
- title: (
244
- <Text>
245
- Ambiente di sviluppo <small>KOREBI</small>
246
- </Text>
247
- ),
248
- onClick: () => navigate('/korebi-ide'),
249
- disabled: false,
250
- icon: <IconCode size={18} />,
251
- description: 'Accedi all\'ambiente di sviluppo',
252
- },
253
- ],
254
- },
255
- ];
256
- };
257
-
258
- const renderCurrentSection = (tab: string) => {
259
- switch (tab) {
260
- case 'ui':
261
- return <Ui />;
262
- case 'menu':
263
- return <MenuDesigner />;
264
- case 'tokens':
265
- return <Tokens />;
266
- case 'users':
267
- return <UsersGrid />;
268
- case 'roles':
269
- return <DomainRoleGrid />;
270
- case 'permissions':
271
- return <PermissionGrid />;
272
- case 'routes':
273
- return <RouteRuleGrid />;
274
- case 'print-server':
275
- return <PrintServerList />;
276
- case 'apidoc':
277
- return apiRestDoc ? (
278
- <DataCard title={'Documentazione API REST'}>
279
- <RestApiDocumentation documentation={apiRestDoc} />
280
- </DataCard>
281
- ) : (
282
- <WaitData />
283
- );
284
- case 'plugin':
285
- return <AppsList pluginEndpoint={props.pluginEndpoint} modules={props.modules} />;
286
- default:
287
- return <ErrorPage />;
288
- }
289
- };
290
-
291
- return (
292
- <ShellPage
293
- headerProps={{ title: 'Impostazioni', subtitle: '' }}
294
- contextSidebarProps={{ groups: getSideMenuGroups(), activeKey: currentTab }}>
295
- {renderCurrentSection(currentTab)}
296
- </ShellPage>
297
- );
298
- }
@@ -1,69 +0,0 @@
1
- import { ApiKey, ApiKeyService } from "@fluxo-dev/api-client-base";
2
- import { Badge, Button, Group, Stack } from "@mantine/core";
3
- import { showNotification } from "@mantine/notifications";
4
- import dayjs from 'dayjs';
5
-
6
- interface TokenRowProps {
7
- token: ApiKey;
8
- onChange: () => void
9
- }
10
-
11
- function TokenRow(props: TokenRowProps) {
12
- const apiKeyService = new ApiKeyService();
13
-
14
- const enable = () => {
15
- apiKeyService.enable(props.token.id)
16
- .then((res) => {
17
- showNotification({
18
- title: '',
19
- message: `Token abilitato`,
20
- color: 'green',
21
- });
22
- props.onChange();
23
- })
24
- }
25
-
26
- const disable = () => {
27
- apiKeyService.disable(props.token.id)
28
- .then((res) => {
29
- showNotification({
30
- title: '',
31
- message: `Token disabilitato`,
32
- color: 'green',
33
- });
34
- props.onChange();
35
- })
36
- }
37
-
38
- const deletion = () => {
39
- apiKeyService.delete(props.token.id)
40
- .then((res) => {
41
- showNotification({
42
- title: 'Cancellazione completata',
43
- message: `Il token è stato cancellato con successo`,
44
- color: 'green',
45
- });
46
- props.onChange();
47
- })
48
- }
49
-
50
- return (
51
- <Group justify='space-between' style={{ border: '1px solid #dedede', padding: 15 }}>
52
- <Stack gap={0}>
53
- <span>{props.token.description}</span>
54
- <small>{dayjs(props.token.expirationDate).format('DD/MM/YYYY')}</small>
55
- </Stack>
56
- <Group>
57
- {props.token.isActive ? <Badge color="green">Attivo</Badge> : <Badge color="red">Disattivo</Badge>}
58
- <Button variant="light" size="xs" onClick={props.token.isActive ? disable : enable}>
59
- {props.token.isActive ? 'Disabilita' : 'Abilita'}
60
- </Button>
61
- <Button variant="light" color="red" size="xs" onClick={deletion}>
62
- Cancella
63
- </Button>
64
- </Group>
65
- </Group>
66
- );
67
- }
68
-
69
- export default TokenRow;
@@ -1,73 +0,0 @@
1
- import { DataCard } from "@fluxo-dev/ui-components";
2
- import { ApiKey, ApiKeyService } from "@fluxo-dev/api-client-base";
3
- import { Button, Modal, Stack, TextInput } from "@mantine/core";
4
- import {DatePickerInput} from '@mantine/dates';
5
- import { showNotification } from "@mantine/notifications";
6
- import { IconFilePlus, IconPlus } from '@tabler/icons-react';
7
- import { useEffect, useState } from "react";
8
- import TokenRow from "./token-row";
9
-
10
- function Tokens() {
11
- const [tokens, setTokens] = useState<ApiKey[]>([]);
12
- const [newTokenDescr, setNewTokenDescr] = useState<string>('');
13
- const [newTokenDate, setNewTokenDate] = useState<Date | null>();
14
- const [newTokenModalOpen, setNewTokenModalOpen] = useState<boolean>(false);
15
- const apiKeyService = new ApiKeyService();
16
-
17
- useEffect(() => {
18
- getApiKeys();
19
- }, [])
20
-
21
- const getApiKeys = () => {
22
- apiKeyService.getApiKeys().then(res => {
23
- setTokens(res);
24
- })
25
- }
26
-
27
- const create = () => {
28
- apiKeyService.create({ description: newTokenDescr, expirationDate: newTokenDate! })
29
- .then((res) => {
30
- showNotification({
31
- title: 'Salvataggio completato',
32
- message: `Il menu è stato salvato con successo`,
33
- color: 'green',
34
- });
35
- getApiKeys();
36
- setNewTokenModalOpen(false);
37
- setNewTokenDescr('');
38
- setNewTokenDate(undefined);
39
- }).catch((err) => {
40
- showNotification({
41
- title: 'Errore',
42
- message: `Errore durante il salvataggio del token. ${err.message}`,
43
- color: 'red',
44
- })
45
- })
46
- }
47
-
48
- return (
49
- <>
50
- <DataCard
51
- title={'Access token'}
52
- actions={[
53
- { icon: <IconPlus size={18} />, label: 'Genera un nuovo token', onClick: () => setNewTokenModalOpen(true) },
54
- ]}>
55
- <Stack gap={16}>
56
- {
57
- tokens.map((v, i) => <TokenRow key={i} token={v} onChange={getApiKeys} />)
58
- }
59
- </Stack>
60
- </DataCard>
61
-
62
- <Modal centered opened={newTokenModalOpen} onClose={() => setNewTokenModalOpen(false)} title="Nuovo token">
63
- <Stack align="flex-start" justify="flex-start">
64
- <DatePickerInput w='100%' label="Data scadenza" onChange={(v) => setNewTokenDate(v)} />
65
- <TextInput w='100%' label='Descrizione' onChange={(v) => setNewTokenDescr(v.currentTarget.value)} />
66
- <Button onClick={create} leftSection={<IconFilePlus />} ml='auto'>Salva</Button>
67
- </Stack>
68
- </Modal>
69
- </>
70
- );
71
- }
72
-
73
- export default Tokens;