data-primals-engine 1.5.2 → 1.6.1
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/README.md +938 -915
- package/client/README.md +136 -136
- package/client/index.js +0 -1
- package/client/public/doc/API.postman_collection.json +213 -213
- package/client/public/react.svg +9 -9
- package/client/src/AddWidgetTypeModal.jsx +47 -47
- package/client/src/App.css +42 -42
- package/client/src/App.jsx +92 -150
- package/client/src/App.scss +6 -0
- package/client/src/AssistantChat.jsx +362 -363
- package/client/src/Button.jsx +12 -12
- package/client/src/Dashboard.jsx +480 -480
- package/client/src/DashboardHtmlViewItem.jsx +146 -146
- package/client/src/DashboardView.jsx +654 -654
- package/client/src/DataEditor.jsx +383 -383
- package/client/src/DataLayout.jsx +779 -808
- package/client/src/DataTable.jsx +782 -822
- package/client/src/DataTable.scss +186 -186
- package/client/src/GeolocationField.jsx +93 -93
- package/client/src/HistoryDialog.jsx +307 -307
- package/client/src/HistoryDialog.scss +319 -319
- package/client/src/HtmlViewBuilderModal.jsx +90 -90
- package/client/src/HtmlViewBuilderModal.scss +17 -17
- package/client/src/HtmlViewCard.jsx +43 -43
- package/client/src/ModelCreator.jsx +683 -686
- package/client/src/ModelCreator.scss +1 -1
- package/client/src/ModelCreatorField.jsx +950 -950
- package/client/src/ModelImporter.jsx +3 -0
- package/client/src/ModelList.jsx +280 -280
- package/client/src/Notification.jsx +136 -136
- package/client/src/PackGallery.jsx +391 -391
- package/client/src/PackGallery.scss +231 -231
- package/client/src/Pagination.jsx +143 -143
- package/client/src/RelationField.jsx +354 -354
- package/client/src/RelationSelectorWidget.jsx +172 -172
- package/client/src/RelationValue.jsx +2 -1
- package/client/src/contexts/CommandContext.jsx +260 -0
- package/client/src/contexts/ModelContext.jsx +4 -1
- package/client/src/contexts/UIContext.jsx +72 -72
- package/client/src/filter.js +263 -263
- package/client/src/index.css +90 -90
- package/package.json +6 -5
- package/perf/artillery-hooks.js +37 -37
- package/perf/setup.yml +25 -25
- package/src/constants.js +4 -0
- package/src/defaultModels.js +7 -0
- package/src/engine.js +335 -335
- package/src/events.js +232 -137
- package/src/filter.js +274 -274
- package/src/index.js +1 -0
- package/src/modules/assistant/assistant.js +225 -83
- package/src/modules/auth-google/index.js +50 -50
- package/src/modules/auth-microsoft/index.js +81 -81
- package/src/modules/data/data.core.js +118 -118
- package/src/modules/data/data.history.js +555 -555
- package/src/modules/data/data.operations.js +112 -9
- package/src/modules/data/data.relations.js +686 -686
- package/src/modules/data/data.routes.js +1879 -1879
- package/src/modules/data/data.validation.js +2 -2
- package/src/modules/file.js +247 -247
- package/src/modules/user.js +14 -9
- package/src/packs.js +2 -2
- package/src/providers.js +2 -2
- package/src/services/stripe.js +196 -196
- package/src/sso.js +193 -193
- package/test/data.history.integration.test.js +264 -264
- package/test/data.integration.test.js +1281 -1206
- package/test/events.test.js +108 -10
- package/test/model.integration.test.js +377 -377
- package/test/user.test.js +106 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { Dialog } from './Dialog.jsx';
|
|
4
|
-
import {TextField, SelectField, NumberField, CodeField, ModelField} from './Field.jsx';
|
|
5
|
-
import Button from './Button.jsx';
|
|
6
|
-
import { FaSave, FaTimes } from 'react-icons/fa';
|
|
7
|
-
import './HtmlViewBuilderModal.scss';
|
|
8
|
-
|
|
9
|
-
const HtmlViewBuilderModal = ({ isOpen, onClose, onSave, models, initialConfig }) => {
|
|
10
|
-
const { t } = useTranslation();
|
|
11
|
-
const [config, setConfig] = useState({});
|
|
12
|
-
const [jsonError, setJsonError] = useState('');
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (isOpen) {
|
|
16
|
-
setConfig(initialConfig || {
|
|
17
|
-
title: '',
|
|
18
|
-
model: '',
|
|
19
|
-
limit: 10,
|
|
20
|
-
filter: {},
|
|
21
|
-
template: '',
|
|
22
|
-
css: '',
|
|
23
|
-
...initialConfig
|
|
24
|
-
});
|
|
25
|
-
setJsonError('');
|
|
26
|
-
}
|
|
27
|
-
}, [isOpen, initialConfig]);
|
|
28
|
-
|
|
29
|
-
const modelOptions = useMemo(() => {
|
|
30
|
-
return (models || []).map(m => ({ label: m.name, value: m.name }));
|
|
31
|
-
}, [models]);
|
|
32
|
-
|
|
33
|
-
const handleChange = (e) => {
|
|
34
|
-
const { name, value } = e.target || e;
|
|
35
|
-
setConfig(prev => ({ ...prev, [name]: value }));
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const handleCodeChange = (name, value) => {
|
|
39
|
-
setConfig(prev => ({ ...prev, [name]: value }));
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const handleFilterChange = (codeValue) => {
|
|
43
|
-
try {
|
|
44
|
-
const parsed = JSON.parse(codeValue);
|
|
45
|
-
setConfig(prev => ({ ...prev, filter: parsed }));
|
|
46
|
-
setJsonError('');
|
|
47
|
-
} catch (e) {
|
|
48
|
-
setJsonError(t('dashboards.invalidJson', 'JSON invalide'));
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const handleSave = () => {
|
|
53
|
-
if (!config.model || !config.template) {
|
|
54
|
-
console.error("Model and template are required.");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (jsonError) return;
|
|
58
|
-
onSave(config);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
if (!isOpen) return null;
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Dialog
|
|
65
|
-
isModal={true}
|
|
66
|
-
isClosable={true}
|
|
67
|
-
onClose={onClose}
|
|
68
|
-
title={initialConfig?.id ? t('dashboards.editHtmlViewTitle', 'Modifier la Vue HTML') : t('dashboards.addHtmlViewTitle', 'Ajouter une Vue HTML')}
|
|
69
|
-
className="html-view-builder-modal"
|
|
70
|
-
>
|
|
71
|
-
<div className="form-grid">
|
|
72
|
-
<TextField name="title" label={t('dashboards.widgetTitle', 'Titre du widget')} value={config.title || ''} onChange={handleChange} />
|
|
73
|
-
<ModelField name="model" label={t('model', 'Modèle')} value={config.model || ''} onChange={(option) => handleChange({ name: 'model', value: option?.value })} required />
|
|
74
|
-
<NumberField name="limit" label={t('dashboards.dataLimit', 'Limite de données')} value={config.limit ?? 10} onChange={handleChange} min={1} max={100} />
|
|
75
|
-
<CodeField name="filter" label={t('filter', 'Filtre (JSON)')} value={typeof config.filter === 'string' ? config.filter : JSON.stringify(config.filter || {}, null, 2)} language="json" onChange={(e) => handleFilterChange(e.value)} error={jsonError} />
|
|
76
|
-
<CodeField name="template" label={t('dashboards.htmlTemplate', 'Template HTML')} value={config.template || ''} language="html" onChange={(e) => handleCodeChange('template', e.value)} required height="200px" />
|
|
77
|
-
<CodeField name="css" label={t('dashboards.cssStyles', 'Styles CSS')} value={config.css || ''} language="css" onChange={(e) => handleCodeChange('css', e.value)} height="150px" />
|
|
78
|
-
</div>
|
|
79
|
-
<div className="flex actions right">
|
|
80
|
-
<Button onClick={onClose} className="btn-secondary">
|
|
81
|
-
<FaTimes /> {t('btns.cancel', 'Annuler')}
|
|
82
|
-
</Button>
|
|
83
|
-
<Button onClick={handleSave} className="btn-primary" disabled={!!jsonError}>
|
|
84
|
-
<FaSave /> {t('btns.save', 'Enregistrer')}
|
|
85
|
-
</Button>
|
|
86
|
-
</div>
|
|
87
|
-
</Dialog>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Dialog } from './Dialog.jsx';
|
|
4
|
+
import {TextField, SelectField, NumberField, CodeField, ModelField} from './Field.jsx';
|
|
5
|
+
import Button from './Button.jsx';
|
|
6
|
+
import { FaSave, FaTimes } from 'react-icons/fa';
|
|
7
|
+
import './HtmlViewBuilderModal.scss';
|
|
8
|
+
|
|
9
|
+
const HtmlViewBuilderModal = ({ isOpen, onClose, onSave, models, initialConfig }) => {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const [config, setConfig] = useState({});
|
|
12
|
+
const [jsonError, setJsonError] = useState('');
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (isOpen) {
|
|
16
|
+
setConfig(initialConfig || {
|
|
17
|
+
title: '',
|
|
18
|
+
model: '',
|
|
19
|
+
limit: 10,
|
|
20
|
+
filter: {},
|
|
21
|
+
template: '',
|
|
22
|
+
css: '',
|
|
23
|
+
...initialConfig
|
|
24
|
+
});
|
|
25
|
+
setJsonError('');
|
|
26
|
+
}
|
|
27
|
+
}, [isOpen, initialConfig]);
|
|
28
|
+
|
|
29
|
+
const modelOptions = useMemo(() => {
|
|
30
|
+
return (models || []).map(m => ({ label: m.name, value: m.name }));
|
|
31
|
+
}, [models]);
|
|
32
|
+
|
|
33
|
+
const handleChange = (e) => {
|
|
34
|
+
const { name, value } = e.target || e;
|
|
35
|
+
setConfig(prev => ({ ...prev, [name]: value }));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const handleCodeChange = (name, value) => {
|
|
39
|
+
setConfig(prev => ({ ...prev, [name]: value }));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleFilterChange = (codeValue) => {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(codeValue);
|
|
45
|
+
setConfig(prev => ({ ...prev, filter: parsed }));
|
|
46
|
+
setJsonError('');
|
|
47
|
+
} catch (e) {
|
|
48
|
+
setJsonError(t('dashboards.invalidJson', 'JSON invalide'));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleSave = () => {
|
|
53
|
+
if (!config.model || !config.template) {
|
|
54
|
+
console.error("Model and template are required.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (jsonError) return;
|
|
58
|
+
onSave(config);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
if (!isOpen) return null;
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Dialog
|
|
65
|
+
isModal={true}
|
|
66
|
+
isClosable={true}
|
|
67
|
+
onClose={onClose}
|
|
68
|
+
title={initialConfig?.id ? t('dashboards.editHtmlViewTitle', 'Modifier la Vue HTML') : t('dashboards.addHtmlViewTitle', 'Ajouter une Vue HTML')}
|
|
69
|
+
className="html-view-builder-modal"
|
|
70
|
+
>
|
|
71
|
+
<div className="form-grid">
|
|
72
|
+
<TextField name="title" label={t('dashboards.widgetTitle', 'Titre du widget')} value={config.title || ''} onChange={handleChange} />
|
|
73
|
+
<ModelField name="model" label={t('model', 'Modèle')} value={config.model || ''} onChange={(option) => handleChange({ name: 'model', value: option?.value })} required />
|
|
74
|
+
<NumberField name="limit" label={t('dashboards.dataLimit', 'Limite de données')} value={config.limit ?? 10} onChange={handleChange} min={1} max={100} />
|
|
75
|
+
<CodeField name="filter" label={t('filter', 'Filtre (JSON)')} value={typeof config.filter === 'string' ? config.filter : JSON.stringify(config.filter || {}, null, 2)} language="json" onChange={(e) => handleFilterChange(e.value)} error={jsonError} />
|
|
76
|
+
<CodeField name="template" label={t('dashboards.htmlTemplate', 'Template HTML')} value={config.template || ''} language="html" onChange={(e) => handleCodeChange('template', e.value)} required height="200px" />
|
|
77
|
+
<CodeField name="css" label={t('dashboards.cssStyles', 'Styles CSS')} value={config.css || ''} language="css" onChange={(e) => handleCodeChange('css', e.value)} height="150px" />
|
|
78
|
+
</div>
|
|
79
|
+
<div className="flex actions right">
|
|
80
|
+
<Button onClick={onClose} className="btn-secondary">
|
|
81
|
+
<FaTimes /> {t('btns.cancel', 'Annuler')}
|
|
82
|
+
</Button>
|
|
83
|
+
<Button onClick={handleSave} className="btn-primary" disabled={!!jsonError}>
|
|
84
|
+
<FaSave /> {t('btns.save', 'Enregistrer')}
|
|
85
|
+
</Button>
|
|
86
|
+
</div>
|
|
87
|
+
</Dialog>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
91
|
export default HtmlViewBuilderModal;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
.html-view-builder-modal {
|
|
2
|
-
.form-grid {
|
|
3
|
-
display: grid;
|
|
4
|
-
grid-template-columns: 1fr;
|
|
5
|
-
gap: 1rem;
|
|
6
|
-
padding-bottom: 1rem;
|
|
7
|
-
|
|
8
|
-
.code-editor-container {
|
|
9
|
-
grid-column: 1 / -1;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.actions {
|
|
14
|
-
margin-top: 1rem;
|
|
15
|
-
padding-top: 1rem;
|
|
16
|
-
border-top: 1px solid var(--border-color);
|
|
17
|
-
}
|
|
1
|
+
.html-view-builder-modal {
|
|
2
|
+
.form-grid {
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-columns: 1fr;
|
|
5
|
+
gap: 1rem;
|
|
6
|
+
padding-bottom: 1rem;
|
|
7
|
+
|
|
8
|
+
.code-editor-container {
|
|
9
|
+
grid-column: 1 / -1;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.actions {
|
|
14
|
+
margin-top: 1rem;
|
|
15
|
+
padding-top: 1rem;
|
|
16
|
+
border-top: 1px solid var(--border-color);
|
|
17
|
+
}
|
|
18
18
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import React, {useEffect, useMemo} from 'react';
|
|
2
|
-
import './HtmlViewCard.scss';
|
|
3
|
-
import {renderHtmlTemplate} from "./DashboardHtmlViewItem.jsx";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Affiche une vue HTML personnalisée, généralement générée par l'assistant IA.
|
|
7
|
-
* @param {object} props
|
|
8
|
-
* @param {object} props.config - La configuration de la vue.
|
|
9
|
-
* @param {string} props.config.title - Le titre de la carte.
|
|
10
|
-
* @param {string} props.config.template - La chaîne de template HTML Handlebars.
|
|
11
|
-
* @param {Array<object>} props.config.data - Le tableau d'enregistrements de données à afficher.
|
|
12
|
-
*/
|
|
13
|
-
const HtmlViewCard = ({ config }) => {
|
|
14
|
-
const { title, template, data, css } = config;
|
|
15
|
-
|
|
16
|
-
// Génère un ID unique et stable pour ce composant
|
|
17
|
-
const containerId = useMemo(() => `html-view-${Math.random().toString(36).substring(2, 9)}`, []);
|
|
18
|
-
|
|
19
|
-
// Effet pour injecter et nettoyer le CSS
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!css) return;
|
|
22
|
-
|
|
23
|
-
const styleElement = document.createElement('style');
|
|
24
|
-
// Remplace le placeholder par notre ID unique pour scoper le CSS
|
|
25
|
-
styleElement.innerHTML = css.replace(/\{\{containerId\}\}/g, containerId);
|
|
26
|
-
document.head.appendChild(styleElement);
|
|
27
|
-
|
|
28
|
-
// Fonction de nettoyage : retire le style quand le composant est démonté
|
|
29
|
-
return () => {
|
|
30
|
-
document.head.removeChild(styleElement);
|
|
31
|
-
};
|
|
32
|
-
}, [css, containerId]);
|
|
33
|
-
|
|
34
|
-
const renderedHtml = renderHtmlTemplate(template, data);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div id={containerId} className="html-view-card">
|
|
38
|
-
{title && <h4>{title}</h4>}
|
|
39
|
-
<div className="html-view-content" dangerouslySetInnerHTML={{ __html: renderedHtml }} />
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
|
|
1
|
+
import React, {useEffect, useMemo} from 'react';
|
|
2
|
+
import './HtmlViewCard.scss';
|
|
3
|
+
import {renderHtmlTemplate} from "./DashboardHtmlViewItem.jsx";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Affiche une vue HTML personnalisée, généralement générée par l'assistant IA.
|
|
7
|
+
* @param {object} props
|
|
8
|
+
* @param {object} props.config - La configuration de la vue.
|
|
9
|
+
* @param {string} props.config.title - Le titre de la carte.
|
|
10
|
+
* @param {string} props.config.template - La chaîne de template HTML Handlebars.
|
|
11
|
+
* @param {Array<object>} props.config.data - Le tableau d'enregistrements de données à afficher.
|
|
12
|
+
*/
|
|
13
|
+
const HtmlViewCard = ({ config }) => {
|
|
14
|
+
const { title, template, data, css } = config;
|
|
15
|
+
|
|
16
|
+
// Génère un ID unique et stable pour ce composant
|
|
17
|
+
const containerId = useMemo(() => `html-view-${Math.random().toString(36).substring(2, 9)}`, []);
|
|
18
|
+
|
|
19
|
+
// Effet pour injecter et nettoyer le CSS
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!css) return;
|
|
22
|
+
|
|
23
|
+
const styleElement = document.createElement('style');
|
|
24
|
+
// Remplace le placeholder par notre ID unique pour scoper le CSS
|
|
25
|
+
styleElement.innerHTML = css.replace(/\{\{containerId\}\}/g, containerId);
|
|
26
|
+
document.head.appendChild(styleElement);
|
|
27
|
+
|
|
28
|
+
// Fonction de nettoyage : retire le style quand le composant est démonté
|
|
29
|
+
return () => {
|
|
30
|
+
document.head.removeChild(styleElement);
|
|
31
|
+
};
|
|
32
|
+
}, [css, containerId]);
|
|
33
|
+
|
|
34
|
+
const renderedHtml = renderHtmlTemplate(template, data);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div id={containerId} className="html-view-card">
|
|
38
|
+
{title && <h4>{title}</h4>}
|
|
39
|
+
<div className="html-view-content" dangerouslySetInnerHTML={{ __html: renderedHtml }} />
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
44
|
export default HtmlViewCard;
|