@applica-software-guru/react-admin 1.0.57 → 1.0.59

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 (79) hide show
  1. package/.eslintrc.json +3 -0
  2. package/README.md +14 -0
  3. package/dist/ApplicaAdmin.d.ts +68 -2
  4. package/dist/ApplicaAdmin.d.ts.map +1 -1
  5. package/dist/components/MainIcon.d.ts.map +1 -1
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/index.d.ts.map +1 -1
  8. package/dist/components/ra-pages/LoginPage/AuthCard.d.ts +12 -0
  9. package/dist/components/ra-pages/LoginPage/AuthCard.d.ts.map +1 -0
  10. package/dist/components/ra-pages/LoginPage/AuthLogin.d.ts +6 -0
  11. package/dist/components/ra-pages/LoginPage/AuthLogin.d.ts.map +1 -0
  12. package/dist/components/ra-pages/LoginPage/AuthWrapper.d.ts +15 -0
  13. package/dist/components/ra-pages/LoginPage/AuthWrapper.d.ts.map +1 -0
  14. package/dist/components/ra-pages/LoginPage/Login.d.ts +34 -0
  15. package/dist/components/ra-pages/LoginPage/Login.d.ts.map +1 -0
  16. package/dist/components/ra-pages/LoginPage/index.d.ts +3 -0
  17. package/dist/components/ra-pages/LoginPage/index.d.ts.map +1 -0
  18. package/dist/components/ra-pages/index.d.ts +3 -0
  19. package/dist/components/ra-pages/index.d.ts.map +1 -0
  20. package/dist/react-admin.cjs.js +48 -48
  21. package/dist/react-admin.cjs.js.map +1 -1
  22. package/dist/react-admin.es.js +7158 -7078
  23. package/dist/react-admin.es.js.map +1 -1
  24. package/dist/react-admin.umd.js +50 -50
  25. package/dist/react-admin.umd.js.map +1 -1
  26. package/index.html +13 -0
  27. package/package.json +5 -6
  28. package/src/ApplicaAdmin.tsx +83 -60
  29. package/src/components/MainIcon.jsx +4 -3
  30. package/src/components/index.jsx +1 -0
  31. package/src/components/ra-pages/LoginPage/AuthCard.jsx +33 -0
  32. package/src/components/ra-pages/LoginPage/AuthLogin.jsx +79 -0
  33. package/src/components/ra-pages/LoginPage/AuthWrapper.jsx +46 -0
  34. package/src/components/ra-pages/LoginPage/Login.tsx +61 -0
  35. package/src/components/ra-pages/LoginPage/index.jsx +3 -0
  36. package/src/components/ra-pages/index.ts +3 -0
  37. package/src/main.tsx +10 -0
  38. package/{playground/src/App.js → src/playground/App.jsx} +4 -2
  39. package/{playground/src/components/index.js → src/playground/components/index.jsx} +1 -0
  40. package/{playground/src/components/ra-lists/DeviceList.js → src/playground/components/ra-lists/DeviceList.jsx} +1 -1
  41. package/{playground/src/config.js → src/playground/config.jsx} +1 -1
  42. package/{playground/src/entities/device.js → src/playground/entities/device.jsx} +1 -1
  43. package/{playground/src/entities/i18n-message.js → src/playground/entities/i18n-message.jsx} +1 -1
  44. package/{playground/src/entities/user.js → src/playground/entities/user.jsx} +2 -2
  45. package/src/playground/hooks/index.jsx +1 -0
  46. package/{playground/src/theme.js → src/playground/theme.jsx} +1 -1
  47. package/vite.config.js +5 -0
  48. package/playground/config-overrides.js +0 -31
  49. package/playground/jsconfig.json +0 -9
  50. package/playground/package-lock.json +0 -17777
  51. package/playground/package.json +0 -69
  52. package/playground/public/favicon-dark.png +0 -0
  53. package/playground/public/favicon-light.png +0 -0
  54. package/playground/public/index.html +0 -46
  55. package/playground/src/hooks/index.js +0 -1
  56. package/playground/src/react-app-env.d.js +0 -1
  57. /package/{playground/src → src/playground}/.prettierrc +0 -0
  58. /package/{playground/src → src/playground}/build.json +0 -0
  59. /package/{playground/src → src/playground}/components/pages/CustomPage.jsx +0 -0
  60. /package/{playground/src → src/playground}/components/pages/index.jsx +0 -0
  61. /package/{playground/src/components/ra-buttons/index.js → src/playground/components/ra-buttons/index.jsx} +0 -0
  62. /package/{playground/src/components/ra-fields/UserPictureField.js → src/playground/components/ra-fields/UserPictureField.jsx} +0 -0
  63. /package/{playground/src/components/ra-fields/index.js → src/playground/components/ra-fields/index.jsx} +0 -0
  64. /package/{playground/src/components/ra-forms/DeviceForm.js → src/playground/components/ra-forms/DeviceForm.jsx} +0 -0
  65. /package/{playground/src/components/ra-forms/I18nMessageForm.js → src/playground/components/ra-forms/I18nMessageForm.jsx} +0 -0
  66. /package/{playground/src/components/ra-forms/UserForm.js → src/playground/components/ra-forms/UserForm.jsx} +0 -0
  67. /package/{playground/src/components/ra-forms/index.js → src/playground/components/ra-forms/index.jsx} +0 -0
  68. /package/{playground/src/components/ra-inputs/LangSelectInput.js → src/playground/components/ra-inputs/LangSelectInput.jsx} +0 -0
  69. /package/{playground/src/components/ra-inputs/YesOrNoSelectInput.js → src/playground/components/ra-inputs/YesOrNoSelectInput.jsx} +0 -0
  70. /package/{playground/src/components/ra-inputs/index.js → src/playground/components/ra-inputs/index.jsx} +0 -0
  71. /package/{playground/src/components/ra-lists/I18nMessageList.js → src/playground/components/ra-lists/I18nMessageList.jsx} +0 -0
  72. /package/{playground/src/components/ra-lists/UserList.js → src/playground/components/ra-lists/UserList.jsx} +0 -0
  73. /package/{playground/src/components/ra-lists/index.js → src/playground/components/ra-lists/index.jsx} +0 -0
  74. /package/{playground/src/contexts/index.js → src/playground/contexts/index.jsx} +0 -0
  75. /package/{playground/src/entities/index.js → src/playground/entities/index.jsx} +0 -0
  76. /package/{playground/src/entities/notification.js → src/playground/entities/notification.jsx} +0 -0
  77. /package/{playground/src/index.js → src/playground/index.jsx} +0 -0
  78. /package/{playground/src/menu.js → src/playground/menu.jsx} +0 -0
  79. /package/{playground/src/reportWebVitals.js → src/playground/reportWebVitals.jsx} +0 -0
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>React-Admin Demo Application</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  "license": "MIT",
16
16
  "type": "module",
17
17
  "scripts": {
18
- "dev-vite": "vite",
18
+ "dev": "vite",
19
19
  "build": "vite build",
20
20
  "watch": "vite build --watch",
21
21
  "preview": "vite preview",
@@ -23,10 +23,7 @@
23
23
  "lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx}'",
24
24
  "format": "prettier --write 'src//**/*.{js,jsx,ts,tsx}' --config ./.prettierrc",
25
25
  "test": "vitest",
26
- "clear": "rm -rf node_modules && rm -rf playground/node_modules && rm package-lock.json && rm playground/package-lock.json",
27
- "setup": "npm install && cd playground && npm i && husky install",
28
- "playground": "cd playground && sleep 10 && npm run start",
29
- "dev": "npm-run-all --parallel watch playground"
26
+ "clear": "rm -rf node_modules && rm -rf playground/node_modules && rm package-lock.json && rm playground/package-lock.json"
30
27
  },
31
28
  "husky": {
32
29
  "hooks": {
@@ -75,6 +72,8 @@
75
72
  "simplebar-react": "^3.2.4"
76
73
  },
77
74
  "devDependencies": {
75
+ "@applica-software-guru/crud-client": "^1.0.20",
76
+ "@applica-software-guru/iam-client": "^1.0.53",
78
77
  "@testing-library/jest-dom": "^5.16.5",
79
78
  "@testing-library/react": "^14.0.0",
80
79
  "@types/node": "^18.7.6",
@@ -1,6 +1,7 @@
1
1
  import { AppConfigProvider, MenuConfigProvider, MenuPropTypes, ThemeConfigProvider } from './contexts';
2
2
  import { CatchResult, useCliErrorCatcher } from './dev';
3
- import { Layout, MainIcon, Notification, SmallIcon } from './components';
3
+ import { Layout, LoginPage, MainIcon, Notification, SmallIcon } from './components';
4
+ import React, { useMemo } from 'react';
4
5
  import { createI18nProvider, useI18nCatcher, useI18nLanguages } from './i18n';
5
6
 
6
7
  import Admin from './Admin';
@@ -9,7 +10,6 @@ import { I18nCatcherBodyBuilderResultProps } from './i18n/useI18nCatcher';
9
10
  import { MenuProps } from 'src/types';
10
11
  import PropTypes from 'prop-types';
11
12
  import { QueryClient } from 'react-query';
12
- import { useMemo } from 'react';
13
13
 
14
14
  const languageResponseMapper = (response: any) =>
15
15
  response.reduce(
@@ -38,19 +38,82 @@ const queryClient = new QueryClient({
38
38
  });
39
39
 
40
40
  export type ApplicaAdminProps = AdminProps & {
41
+ /**
42
+ * Eventuali configurazioni aggiuntive da passare al tema.
43
+ * @remarks Questo tema è basato su Mantis Theme (https://mantisdashboard.io/)
44
+ *
45
+ * @see https://marmelab.com/react-admin/Theming.html
46
+ * @see https://material-ui.com/customization/theming/
47
+ */
41
48
  theme: any;
49
+ /**
50
+ * URL dell'API da utilizzare nell'applicazione.
51
+ * Sebbene venga già definito un dataProvider ed authProvider di default, è possibile che l'app
52
+ * utilizzi l'apiUrl specificato per ulteriori operazioni (es. getstione delle notifiche).
53
+ */
42
54
  apiUrl: string;
55
+ /**
56
+ * La lingua di default da utilizzare nell'applicazione.
57
+ */
43
58
  defaultLocale: string;
59
+ /**
60
+ * Se impostato a true, l'applicazione lavora in modalità sviluppo.
61
+ * La modalità sviluppo è utile per effettuare test e debug ed esegue attività che non sono
62
+ * consigliate in produzione (es. cattura e inoltro dei messaggi non localizzati).
63
+ */
44
64
  development: boolean;
65
+ /**
66
+ * Il logo da visualizzare nella barra laterale quando il menu è espanso lateralmente.
67
+ */
45
68
  logoMain: any;
69
+ /**
70
+ * Eventuale logo da visualizzare nella barra laterale quando il menu è ridotto lateralmente.
71
+ */
46
72
  logoIcon: any;
73
+ /**
74
+ * Configurazione del menu da visualizzare nell'applicazione.
75
+ */
47
76
  menu: MenuProps;
77
+ /**
78
+ * Nome dell'applicazione da mostrare nell'header.
79
+ */
48
80
  name: string;
81
+ /**
82
+ * Versione dell'applicazione da mostrare nel footer.
83
+ */
49
84
  version: string;
85
+ /**
86
+ * Il provider di autenticazione da utilizzare nell'applicazione.
87
+ */
50
88
  dataProvider: any;
89
+ /**
90
+ * Il provider di dati da utilizzare nell'applicazione.
91
+ */
51
92
  authProvider: any;
93
+ /**
94
+ * Indica il nome della risorsa REST da utilizzare per la gestione delle notifiche.
95
+ * @example
96
+ * // In questo caso, le notifiche verranno gestite tramite la risorsa "entities/notification"
97
+ * <ApplicaAdmin notification="entities/notification" />
98
+ */
52
99
  notification: string;
100
+ /**
101
+ * Indica se le notifiche devono essere disabilitate.
102
+ * Se le notifiche sono abilitate comparirà automaticamente un'icona in alto a destra nell'header.
103
+ *
104
+ * @example
105
+ * // In questo caso, le notifiche verranno disabilitate
106
+ * <ApplicaAdmin disableNotification />
107
+ */
53
108
  disableNotification: boolean;
109
+ /**
110
+ * Indica se la schermata di registrazione deve essere disabilitata.
111
+ */
112
+ disableSignup: boolean;
113
+ /**
114
+ * Indica se la schermata di recupero password deve essere disabilitata.
115
+ */
116
+ disableForgotPassword: boolean;
54
117
  };
55
118
 
56
119
  /**
@@ -86,74 +149,22 @@ export type ApplicaAdminProps = AdminProps & {
86
149
  * @returns {React.ReactElement}
87
150
  */
88
151
  const ApplicaAdmin = ({
89
- /**
90
- * Eventuali configurazioni aggiuntive da passare al tema.
91
- * @remarks Questo tema è basato su Mantis Theme (https://mantisdashboard.io/)
92
- *
93
- * @see https://marmelab.com/react-admin/Theming.html
94
- * @see https://material-ui.com/customization/theming/
95
- */
96
152
  theme,
97
- /**
98
- * URL dell'API da utilizzare nell'applicazione.
99
- * Sebbene venga già definito un dataProvider ed authProvider di default, è possibile che l'app
100
- * utilizzi l'apiUrl specificato per ulteriori operazioni (es. getstione delle notifiche).
101
- */
102
153
  apiUrl,
103
- /**
104
- * La lingua di default da utilizzare nell'applicazione.
105
- */
106
154
  defaultLocale,
107
- /**
108
- * Se impostato a true, l'applicazione lavora in modalità sviluppo.
109
- * La modalità sviluppo è utile per effettuare test e debug ed esegue attività che non sono
110
- * consigliate in produzione (es. cattura e inoltro dei messaggi non localizzati).
111
- */
112
155
  development,
113
- /**
114
- * Il logo da visualizzare nella barra laterale quando il menu è espanso lateralmente.
115
- */
116
156
  logoMain,
117
- /**
118
- * Eventuale logo da visualizzare nella barra laterale quando il menu è ridotto lateralmente.
119
- */
120
157
  logoIcon,
121
- /**
122
- * Configurazione del menu da visualizzare nell'applicazione.
123
- */
158
+ loginPage,
124
159
  menu,
125
- /**
126
- * Nome dell'applicazione da mostrare nell'header.
127
- */
128
160
  name,
129
- /**
130
- * Versione dell'applicazione da mostrare nel footer.
131
- */
132
161
  version,
133
- /**
134
- * Il provider di autenticazione da utilizzare nell'applicazione.
135
- */
136
162
  dataProvider,
137
- /**
138
- * Il provider di dati da utilizzare nell'applicazione.
139
- */
140
163
  authProvider,
141
- /**
142
- * Indica il nome della risorsa REST da utilizzare per la gestione delle notifiche.
143
- * @example
144
- * // In questo caso, le notifiche verranno gestite tramite la risorsa "entities/notification"
145
- * <ApplicaAdmin notification="entities/notification" />
146
- */
147
164
  notification,
148
- /**
149
- * Indica se le notifiche devono essere disabilitate.
150
- * Se le notifiche sono abilitate comparirà automaticamente un'icona in alto a destra nell'header.
151
- *
152
- * @example
153
- * // In questo caso, le notifiche verranno disabilitate
154
- * <ApplicaAdmin disableNotification />
155
- */
156
165
  disableNotification,
166
+ disableSignup,
167
+ disableForgotPassword,
157
168
  ...props
158
169
  }: ApplicaAdminProps) => {
159
170
  const languages = useI18nLanguages({
@@ -191,7 +202,13 @@ const ApplicaAdmin = ({
191
202
  return result;
192
203
  }
193
204
  });
194
-
205
+ const login = useMemo(() => {
206
+ if (React.isValidElement(loginPage)) {
207
+ // @ts-ignore
208
+ return React.cloneElement(loginPage, { name, version, enableSignup: !disableSignup, enablePasswordForgot: !disableForgotPassword });
209
+ }
210
+ return loginPage;
211
+ }, [loginPage, name, version, disableSignup, disableForgotPassword]);
195
212
  const layout = useMemo(
196
213
  () => (props: any) => {
197
214
  const _logoMain = name ? <MainIcon title={name} /> : logoMain;
@@ -232,6 +249,7 @@ const ApplicaAdmin = ({
232
249
  dataProvider={dataProvider}
233
250
  authProvider={authProvider}
234
251
  i18nProvider={i18nProivder}
252
+ loginPage={login}
235
253
  {...props}
236
254
  />
237
255
  </ThemeConfigProvider>
@@ -247,7 +265,10 @@ ApplicaAdmin.defaultProps = {
247
265
  development: false,
248
266
  version: '0.0.0',
249
267
  notification: 'entities/notification',
250
- disableNotification: false
268
+ disableNotification: false,
269
+ disableSignup: false,
270
+ disableForgotPassword: false,
271
+ loginPage: <LoginPage version="0.0.0" name="Applica" />
251
272
  };
252
273
 
253
274
  ApplicaAdmin.propTypes = {
@@ -264,7 +285,9 @@ ApplicaAdmin.propTypes = {
264
285
  authProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
265
286
  dataProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
266
287
  notification: PropTypes.string,
267
- disableNotification: PropTypes.bool
288
+ disableNotification: PropTypes.bool,
289
+ disableSignup: PropTypes.bool,
290
+ disableForgotPassword: PropTypes.bool
268
291
  };
269
292
 
270
293
  export default ApplicaAdmin;
@@ -1,8 +1,9 @@
1
+ import { Stack, Typography } from '@mui/material';
2
+
1
3
  import PropTypes from 'prop-types';
2
- import { Typography } from '@mui/material';
3
4
 
4
5
  const MainIcon = ({ title }) => (
5
- <>
6
+ <Stack direction="row">
6
7
  <Typography variant="h2" sx={{ fontWeight: 'regular', letterSpacing: -2.5 }}>
7
8
  a.
8
9
  </Typography>
@@ -10,7 +11,7 @@ const MainIcon = ({ title }) => (
10
11
  <Typography variant="h2" sx={{ fontWeight: 'bold' }}>
11
12
  {title}
12
13
  </Typography>
13
- </>
14
+ </Stack>
14
15
  );
15
16
 
16
17
  MainIcon.propTypes = {
@@ -22,3 +22,4 @@ export * from './ra-inputs';
22
22
  export * from './ra-lists';
23
23
  export * from './ra-forms';
24
24
  export * from './ra-custom';
25
+ export * from './ra-pages';
@@ -0,0 +1,33 @@
1
+ import { Box } from '@mui/material';
2
+ import MainCard from '../../MainCard';
3
+ import PropTypes from 'prop-types';
4
+ import { useTheme } from '@mui/material/styles';
5
+
6
+ const AuthCard = ({ children, ...other }) => {
7
+ const theme = useTheme();
8
+ return (
9
+ <MainCard
10
+ sx={{
11
+ maxWidth: { xs: 400, lg: 475 },
12
+ margin: { xs: 2.5, md: 3 },
13
+ '& > *': {
14
+ flexGrow: 1,
15
+ flexBasis: '50%'
16
+ }
17
+ }}
18
+ content={false}
19
+ {...other}
20
+ border={false}
21
+ boxShadow
22
+ shadow={theme.customShadows.z1}
23
+ >
24
+ <Box sx={{ p: { xs: 2, sm: 3, md: 4, xl: 5 } }}>{children}</Box>
25
+ </MainCard>
26
+ );
27
+ };
28
+
29
+ AuthCard.propTypes = {
30
+ children: PropTypes.node
31
+ };
32
+
33
+ export default AuthCard;
@@ -0,0 +1,79 @@
1
+ import { AnimateButton, TextInput } from '../../../components';
2
+ import { Button, CircularProgress, Grid, Link, Stack } from '@mui/material';
3
+ import { Form, required, useLogin, useNotify, useSafeSetState, useTranslate } from 'react-admin';
4
+
5
+ import { Link as RouterLink } from 'react-router-dom';
6
+
7
+ const AuthLogin = ({ enablePasswordForgot, ...props }) => {
8
+ const { redirectTo } = props;
9
+ const [loading, setLoading] = useSafeSetState(false);
10
+ const login = useLogin();
11
+ const translate = useTranslate();
12
+ const notify = useNotify();
13
+
14
+ const handleSubmit = (values) => {
15
+ setLoading(true);
16
+ login(values, redirectTo)
17
+ .then(() => {
18
+ setLoading(false);
19
+ })
20
+ .catch((error) => {
21
+ setLoading(false);
22
+ notify(
23
+ typeof error === 'string' ? error : typeof error === 'undefined' || !error.message ? 'ra.auth.sign_in_error' : error.message,
24
+ {
25
+ type: 'error',
26
+ messageArgs: {
27
+ _: typeof error === 'string' ? error : error && error.message ? error.message : undefined
28
+ }
29
+ }
30
+ );
31
+ });
32
+ };
33
+ return (
34
+ <Form onSubmit={handleSubmit}>
35
+ <Grid container>
36
+ <Grid item xs={12} sx={{ mb: 2 }}>
37
+ <TextInput
38
+ autoFocus
39
+ source="username"
40
+ label={translate('ra.auth.username')}
41
+ autoComplete="username"
42
+ validate={required()}
43
+ placeholder="user@company.name"
44
+ fullWidth
45
+ />
46
+ </Grid>
47
+ <Grid item xs={12} sx={{ mb: 2 }}>
48
+ <TextInput
49
+ source="password"
50
+ label={translate('ra.auth.password')}
51
+ type="password"
52
+ autoComplete="current-password"
53
+ validate={required()}
54
+ placeholder={translate('ra.auth.password_placeholder')}
55
+ fullWidth
56
+ />
57
+ </Grid>
58
+ </Grid>
59
+ {enablePasswordForgot && (
60
+ <Grid item xs={12} sx={{ mt: 1 }}>
61
+ <Stack direction="row" justifyContent="flex-end" alignItems="flex-end" spacing={2}>
62
+ <Link variant="h6" component={RouterLink} to={'/forgot-password'} color="text.primary">
63
+ {translate('ra.auth.forgot_password')}
64
+ </Link>
65
+ </Stack>
66
+ </Grid>
67
+ )}
68
+ <Grid item xs={12} sx={{ mt: 1 }}>
69
+ <AnimateButton>
70
+ <Button variant="contained" type="submit" color="primary" disabled={loading} fullWidth>
71
+ {loading ? <CircularProgress size={19} thickness={3} /> : translate('ra.auth.sign_in')}
72
+ </Button>
73
+ </AnimateButton>
74
+ </Grid>
75
+ </Form>
76
+ );
77
+ };
78
+
79
+ export default AuthLogin;
@@ -0,0 +1,46 @@
1
+ import { Box, Grid } from '@mui/material';
2
+
3
+ import AuthCard from './AuthCard';
4
+ import Footer from '../../Layout/Footer';
5
+ import MainIcon from '../../MainIcon';
6
+ import PropTypes from 'prop-types';
7
+
8
+ const AuthWrapper = ({ version, name, children }) => (
9
+ <Box sx={{ minHeight: '100vh' }}>
10
+ <Grid
11
+ container
12
+ direction="column"
13
+ justifyContent="flex-end"
14
+ sx={{
15
+ minHeight: '100vh'
16
+ }}
17
+ >
18
+ <Grid item xs={12} sx={{ ml: 3, mt: 3 }}>
19
+ <MainIcon title={name} />
20
+ </Grid>
21
+ <Grid item xs={12}>
22
+ <Grid
23
+ item
24
+ xs={12}
25
+ container
26
+ justifyContent="center"
27
+ alignItems="center"
28
+ sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
29
+ >
30
+ <Grid item>
31
+ <AuthCard>{children}</AuthCard>
32
+ </Grid>
33
+ </Grid>
34
+ <Footer name={name} version={version} />
35
+ </Grid>
36
+ </Grid>
37
+ </Box>
38
+ );
39
+
40
+ AuthWrapper.propTypes = {
41
+ children: PropTypes.node,
42
+ version: PropTypes.string,
43
+ name: PropTypes.string
44
+ };
45
+
46
+ export default AuthWrapper;
@@ -0,0 +1,61 @@
1
+ import { Grid, Stack, Typography } from '@mui/material';
2
+
3
+ import AuthLogin from './AuthLogin';
4
+ import AuthWrapper from './AuthWrapper';
5
+ import { Link } from 'react-router-dom';
6
+ import PropTypes from 'prop-types';
7
+ import { useTranslate } from 'ra-core';
8
+
9
+ export type LoginProps = {
10
+ /**
11
+ * Versione dell'applicazione.
12
+ */
13
+ version: string;
14
+ /**
15
+ * Nome dell'applicazione.
16
+ */
17
+ name: string;
18
+ /**
19
+ * Indica se abilitare o meno la schermata di recupero password.
20
+ */
21
+ enablePasswordForgot?: boolean;
22
+ /**
23
+ * Indica se abilitare o meno la schermata di registrazione.
24
+ */
25
+ enableSignup?: boolean;
26
+ };
27
+ const Login = ({ version, name, enablePasswordForgot, enableSignup }: LoginProps) => {
28
+ const translate = useTranslate();
29
+ return (
30
+ <AuthWrapper name={name} version={version}>
31
+ <Grid container spacing={3}>
32
+ <Grid item xs={12}>
33
+ <Stack direction="row" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
34
+ <Typography variant="h3">Login</Typography>
35
+ {enableSignup && (
36
+ <Typography component={Link} to={'/signup'} variant="body1" sx={{ textDecoration: 'none' }} color="primary">
37
+ {translate('ra.auth.signup')}
38
+ </Typography>
39
+ )}
40
+ </Stack>
41
+ </Grid>
42
+ <Grid item xs={12}>
43
+ <AuthLogin enablePasswordForgot={enablePasswordForgot} />
44
+ </Grid>
45
+ </Grid>
46
+ </AuthWrapper>
47
+ );
48
+ };
49
+
50
+ Login.propTypes = {
51
+ version: PropTypes.string.isRequired,
52
+ name: PropTypes.string.isRequired,
53
+ enablePasswordForgot: PropTypes.bool,
54
+ enableSignup: PropTypes.bool
55
+ };
56
+ Login.defaultProps = {
57
+ enablePasswordForgot: true,
58
+ enableSignup: true
59
+ };
60
+
61
+ export default Login;
@@ -0,0 +1,3 @@
1
+ import Login from './Login';
2
+
3
+ export default Login;
@@ -0,0 +1,3 @@
1
+ import LoginPage from './LoginPage';
2
+
3
+ export { LoginPage };
package/src/main.tsx ADDED
@@ -0,0 +1,10 @@
1
+ import App from './playground/App';
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom/client';
4
+
5
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6
+ ReactDOM.createRoot(document.getElementById('root')!).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -1,4 +1,4 @@
1
- import '@applica-software-guru/react-admin/style.css';
1
+ // import '@applica-software-guru/react-admin/style.css';
2
2
 
3
3
  import * as entities from './entities';
4
4
 
@@ -6,7 +6,7 @@ import { API_URL, FILE_FIELDS } from './config';
6
6
  import { ApplicaAdmin, HttpError, Resource } from '@applica-software-guru/react-admin';
7
7
  import { createAttachmentsParser, createDataProvider } from '@applica-software-guru/crud-client';
8
8
 
9
- import { CustomPage } from 'components/pages';
9
+ import { CustomPage } from './components/pages';
10
10
  import { CustomRoutes } from 'ra-core';
11
11
  import { Route } from 'react-router-dom';
12
12
  import build from './build.json';
@@ -34,6 +34,8 @@ const App = () => {
34
34
  menu={menu}
35
35
  name="RA"
36
36
  version={build.version}
37
+ disableSignup
38
+ disableForgotPassword
37
39
  >
38
40
  <Resource name="entities/notification" {...entities.notification} />
39
41
  <Resource name="entities/user" {...entities.user} />
@@ -3,3 +3,4 @@ export * from './ra-inputs';
3
3
  export * from './ra-fields';
4
4
  export * from './ra-forms';
5
5
  export * from './ra-buttons';
6
+ export * from './pages';
@@ -12,7 +12,7 @@ const AlertBox = () => {
12
12
  );
13
13
  };
14
14
  const DeviceList = () => (
15
- <List perPage={25} filters={[<SearchInput source="keyword" alwaysOn />]}>
15
+ <List perPage={25} filters={[<SearchInput key="keyword" source="keyword" alwaysOn />]}>
16
16
  <AlertBox />
17
17
  <Datagrid rowClick="edit">
18
18
  <TextField source="id" />
@@ -1,6 +1,6 @@
1
1
  let environment = 'PRODUCTION';
2
2
  let appUrl = `//${document.location.host}/`;
3
- if (appUrl.endsWith(':3000/')) {
3
+ if (appUrl.endsWith(':3000/') || appUrl.indexOf(':51') !== -1) {
4
4
  appUrl = 'http://localhost:8080/';
5
5
  environment = 'DEVELOPER';
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import { Create, Edit } from '@applica-software-guru/react-admin';
2
- import { DeviceForm, DeviceList } from 'components';
2
+ import { DeviceForm, DeviceList } from '../components';
3
3
  const DeviceCreate = () => (
4
4
  <Create>
5
5
  <DeviceForm />
@@ -1,5 +1,5 @@
1
1
  import { Create, Edit } from '@applica-software-guru/react-admin';
2
- import { I18nMessageForm, I18nMessageList } from 'components';
2
+ import { I18nMessageForm, I18nMessageList } from '../components';
3
3
 
4
4
  import { FlagOutlined } from '@ant-design/icons';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { Create, Edit } from '@applica-software-guru/react-admin';
2
- import { UserForm, UserList } from 'components';
2
+ import { UserForm, UserList } from '../components';
3
3
 
4
- import { CONFIGURED_ROLES } from 'config';
4
+ import { CONFIGURED_ROLES } from '../config';
5
5
  import { UserOutlined } from '@ant-design/icons';
6
6
 
7
7
  const UserCreate = () => (
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- const theme = (theme) => ({
1
+ const theme = () => ({
2
2
  components: {
3
3
  MuiPaper: {
4
4
  styleOverrides: {}
package/vite.config.js CHANGED
@@ -8,6 +8,11 @@ import { resolve } from 'node:path';
8
8
 
9
9
  const { EsLinter, linterPlugin } = EsLint;
10
10
  export default defineConfig((configEnv) => ({
11
+ resolve: {
12
+ alias: {
13
+ '@applica-software-guru/react-admin': resolve(__dirname, 'src')
14
+ }
15
+ },
11
16
  plugins: [
12
17
  dts({
13
18
  include: ['./src/**/*.{js,jsx,ts,tsx}']
@@ -1,31 +0,0 @@
1
- const webpack = require('webpack');
2
- const WorkBoxPlugin = require('workbox-webpack-plugin');
3
-
4
- module.exports = function override(config) {
5
- config.resolve.fallback = {
6
- process: require.resolve('process/browser'),
7
- // zlib: require.resolve('browserify-zlib'),
8
- stream: require.resolve('stream-browserify'),
9
- crypto: require.resolve('crypto-browserify'),
10
- util: require.resolve('util'),
11
- buffer: require.resolve('buffer')
12
- // asset: require.resolve('assert')
13
- };
14
-
15
- // https://stackoverflow.com/questions/69135310/workaround-for-cache-size-limit-in-create-react-app-pwa-service-worker
16
- config.plugins.forEach((plugin) => {
17
- if (plugin instanceof WorkBoxPlugin.InjectManifest) {
18
- plugin.config.maximumFileSizeToCacheInBytes = 50 * 1024 * 1024;
19
- }
20
- });
21
-
22
- config.plugins = [
23
- ...config.plugins,
24
- new webpack.ProvidePlugin({
25
- process: 'process/browser.js',
26
- Buffer: ['buffer', 'Buffer']
27
- })
28
- ];
29
-
30
- return config;
31
- };