data-primals-engine 1.5.0 → 1.5.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.
Files changed (52) hide show
  1. package/README.md +35 -0
  2. package/client/src/AddWidgetTypeModal.jsx +47 -43
  3. package/client/src/App.jsx +2 -6
  4. package/client/src/App.scss +12 -0
  5. package/client/src/AssistantChat.jsx +363 -323
  6. package/client/src/AssistantChat.scss +27 -10
  7. package/client/src/Dashboard.jsx +480 -396
  8. package/client/src/Dashboard.scss +1 -1
  9. package/client/src/DashboardHtmlViewItem.jsx +147 -0
  10. package/client/src/DashboardView.jsx +654 -569
  11. package/client/src/DataEditor.jsx +10 -3
  12. package/client/src/DataLayout.jsx +805 -755
  13. package/client/src/DataLayout.scss +14 -0
  14. package/client/src/DataTable.jsx +39 -75
  15. package/client/src/Dialog.scss +1 -1
  16. package/client/src/Field.jsx +2057 -1825
  17. package/client/src/FlexViewCard.jsx +44 -0
  18. package/client/src/HistoryDialog.jsx +47 -14
  19. package/client/src/HtmlViewBuilderModal.jsx +91 -0
  20. package/client/src/HtmlViewBuilderModal.scss +18 -0
  21. package/client/src/HtmlViewCard.jsx +44 -0
  22. package/client/src/HtmlViewCard.scss +35 -0
  23. package/client/src/KanbanCard.jsx +1 -2
  24. package/client/src/ModelCreator.jsx +5 -4
  25. package/client/src/ModelCreatorField.jsx +51 -4
  26. package/client/src/ModelList.jsx +92 -53
  27. package/client/src/Notification.jsx +136 -136
  28. package/client/src/Notification.scss +0 -18
  29. package/client/src/Pagination.jsx +5 -3
  30. package/client/src/RelationField.jsx +354 -258
  31. package/client/src/RelationSelectorWidget.jsx +173 -0
  32. package/client/src/contexts/ModelContext.jsx +10 -1
  33. package/client/src/contexts/UIContext.jsx +72 -63
  34. package/client/src/filter.js +262 -212
  35. package/client/src/hooks/useValidation.js +75 -0
  36. package/client/src/translations.js +24 -24
  37. package/package.json +2 -1
  38. package/src/constants.js +1 -1
  39. package/src/defaultModels.js +1596 -1544
  40. package/src/i18n.js +710 -10
  41. package/src/modules/assistant/assistant.js +148 -18
  42. package/src/modules/bucket.js +2 -1
  43. package/src/modules/data/data.core.js +118 -92
  44. package/src/modules/data/data.history.js +531 -492
  45. package/src/modules/data/data.js +3 -53
  46. package/src/modules/data/data.operations.js +77 -26
  47. package/src/modules/data/data.relations.js +686 -686
  48. package/src/modules/data/data.routes.js +1879 -1821
  49. package/src/modules/data/data.validation.js +81 -2
  50. package/src/modules/file.js +247 -238
  51. package/src/packs.js +5482 -5478
  52. package/test/data.integration.test.js +1115 -1060
package/README.md CHANGED
@@ -111,6 +111,26 @@ MONGO_DB_URL=mongodb://127.0.0.1:27017
111
111
  | CERT | Path to cert file. | certs/cert.pem |
112
112
  | CERT_KEY | Path to the key file for your certificate. | certs/key.pem |
113
113
 
114
+ ### Programmatic Configuration
115
+
116
+ In addition to environment variables, you can programmatically override most of the application's internal constants at runtime. This is useful for fine-tuning performance, limits, or behavior without restarting the server.
117
+
118
+ The engine exposes a `Config` object for this purpose. You can modify any constant defined in `src/constants.js`.
119
+
120
+ To override a constant, use the `Config.Set()` method **before** initializing the engine:
121
+
122
+ ```javascript
123
+ import express from "express";
124
+ import { Engine, Config } from 'data-primals-engine';
125
+
126
+ // Override default constants before engine initialization
127
+ Config.Set("maxRequestData", 1000); // Increase max data per request
128
+ Config.Set("maxFileSize", 50 * 1024 * 1024); // Allow larger file uploads (50MB)
129
+
130
+ const app = express();
131
+ const engine = await Engine.Create({ app });
132
+ ```
133
+
114
134
  ### Start the server
115
135
  ```bash
116
136
  # Development mode
@@ -410,6 +430,21 @@ await editData(
410
430
  );
411
431
  ```
412
432
 
433
+ ```javascript
434
+ await editData(
435
+ "resource",
436
+ { source: "507f1f77bcf86cd799439011" },
437
+ { "file[]": {
438
+ "path": "C:/Users/.../test-upload-on-insert.txt",
439
+ "name": 'test-upload-on-insert.txt',
440
+ "type": 'text/plain',
441
+ "size": 1524,
442
+ "lastModifiedDate": new Date(),
443
+ }}, // No files
444
+ currentUser
445
+ );
446
+ ```
447
+
413
448
  ### patchData(modelName, filter, data, files, user)
414
449
 
415
450
  > Partially updates data (only modifies specified fields).
@@ -1,44 +1,48 @@
1
- // src/components/AddWidgetTypeModal.jsx
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import { useTranslation } from 'react-i18next';
5
- import { FaChartBar, FaTachometerAlt, FaThLarge } from 'react-icons/fa';
6
- import './AddWidgetTypeModal.scss';
7
- import {Dialog} from "./Dialog.jsx"; // Créez ce fichier SCSS
8
-
9
- const AddWidgetTypeModal = ({ onClose, onSelectType }) => {
10
- const { t } = useTranslation();
11
-
12
- return (
13
- <Dialog className={"add-widget-type-modal-content"} isModal={true} isClosable={true} onClose={onClose} title={t('dashboard.addWidgetTitle', 'Ajouter un élément au tableau de bord')}>
14
- <>
15
- <div className="flex widget-type-options">
16
- <button onClick={() => onSelectType('KPI')} className="widget-type-button">
17
- <FaTachometerAlt size={40} />
18
- <span>{t('dashboard.addKPI', 'Ajouter un KPI')}</span>
19
- </button>
20
- <button onClick={() => onSelectType('Chart')} className="widget-type-button">
21
- <FaChartBar size={40} />
22
- <span>{t('dashboard.addChart', 'Ajouter un Graphique')}</span>
23
- </button>
24
- <button disabled={false} onClick={() => onSelectType('FlexView')} className="widget-type-button">
25
- <FaThLarge size={40} />
26
- <span>{t('dashboard.addFlexView', 'Ajouter une Vue Flex')}</span>
27
- </button>
28
- </div>
29
- <div className={"flex actions center"}>
30
- <button onClick={onClose} className="btn-close-modal">
31
- {t('btns.cancel', 'Annuler')}
32
- </button>
33
- </div>
34
- </>
35
- </Dialog>
36
- );
37
- };
38
-
39
- AddWidgetTypeModal.propTypes = {
40
- onClose: PropTypes.func.isRequired,
41
- onSelectType: PropTypes.func.isRequired,
42
- };
43
-
1
+ // src/components/AddWidgetTypeModal.jsx
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { FaChartBar, FaTachometerAlt, FaThLarge, FaFileCode } from 'react-icons/fa';
6
+ import './AddWidgetTypeModal.scss';
7
+ import {Dialog} from "./Dialog.jsx"; // Créez ce fichier SCSS
8
+
9
+ const AddWidgetTypeModal = ({ onClose, onSelectType }) => {
10
+ const { t } = useTranslation();
11
+
12
+ return (
13
+ <Dialog className={"add-widget-type-modal-content"} isModal={true} isClosable={true} onClose={onClose} title={t('dashboard.addWidgetTitle', 'Ajouter un élément au tableau de bord')}>
14
+ <>
15
+ <div className="flex widget-type-options">
16
+ <button onClick={() => onSelectType('KPI')} className="widget-type-button">
17
+ <FaTachometerAlt size={40} />
18
+ <span>{t('dashboard.addKPI', 'Ajouter un KPI')}</span>
19
+ </button>
20
+ <button onClick={() => onSelectType('Chart')} className="widget-type-button">
21
+ <FaChartBar size={40} />
22
+ <span>{t('dashboard.addChart', 'Ajouter un Graphique')}</span>
23
+ </button>
24
+ <button disabled={false} onClick={() => onSelectType('FlexView')} className="widget-type-button">
25
+ <FaThLarge size={40} />
26
+ <span>{t('dashboard.addFlexView', 'Ajouter une Vue Flex')}</span>
27
+ </button>
28
+ <button onClick={() => onSelectType('HtmlView')} className="widget-type-button">
29
+ <FaFileCode size={40} />
30
+ <span>{t('dashboard.addHtmlView', 'Ajouter une Vue HTML')}</span>
31
+ </button>
32
+ </div>
33
+ <div className={"flex actions center"}>
34
+ <button onClick={onClose} className="btn-close-modal">
35
+ {t('btns.cancel', 'Annuler')}
36
+ </button>
37
+ </div>
38
+ </>
39
+ </Dialog>
40
+ );
41
+ };
42
+
43
+ AddWidgetTypeModal.propTypes = {
44
+ onClose: PropTypes.func.isRequired,
45
+ onSelectType: PropTypes.func.isRequired,
46
+ };
47
+
44
48
  export default AddWidgetTypeModal;
@@ -90,9 +90,7 @@ function Layout ({header, routes, body, footer,refreshUI}) {
90
90
  const lang = (i18n.resolvedLanguage || i18n.language).split(/[-_]/)?.[0];
91
91
  const {models= [], setGeneratedModels } = useModelContext();
92
92
  const { me, setMe } = useAuthContext();
93
- // 2. NOUVEAU : État pour stocker la configuration de l'assistant
94
- const [assistantConfig, setAssistantConfig] = useState(null);
95
-
93
+ const { assistantConfig, setAssistantConfig} = useUI();
96
94
  const promotionalMessages = [
97
95
  { text: t('promo.rotation.6') },
98
96
  { text: t('promo.rotation.1') },
@@ -312,7 +310,6 @@ function Layout ({header, routes, body, footer,refreshUI}) {
312
310
  const myInputRef = useRef(null);
313
311
 
314
312
  return <div className={['ar', 'fa'].includes(lang)? 'rtl' : 'ltr'}>
315
- <NotificationList />
316
313
  <><Helmet><title>
317
314
  {t('seo.title', seoTitle)}</title></Helmet></>
318
315
  <Routes>
@@ -408,7 +405,6 @@ function Layout ({header, routes, body, footer,refreshUI}) {
408
405
  <footer className="flex flex-centered">
409
406
  {footer}
410
407
  </footer>
411
- {me && <AssistantChat config={assistantConfig} />}
412
408
  </div>;
413
409
  }
414
410
 
@@ -574,7 +570,7 @@ const BaseLayout=()=>{
574
570
  </div>
575
571
  <div className="flex">
576
572
  <FaQuestion data-tooltip-id="header" data-tooltip-content="Documentation" onClick={()=> {
577
- window.open("https://data.primals.net/en/documentation/", "_blank");
573
+ window.open("/en/documentation/", "_blank");
578
574
  }} />
579
575
  </div>
580
576
  </header>} />
@@ -110,6 +110,18 @@ h2 {
110
110
  border-bottom: 1px solid #969696;
111
111
  }
112
112
 
113
+ .p-1 {
114
+ padding: 4px;
115
+ }
116
+ .p-2 {
117
+ padding: 8px;
118
+ }
119
+ .p-3 {
120
+ padding: 16px;
121
+ }
122
+ .p-4 {
123
+ padding: 32px;
124
+ }
113
125
  .prior {
114
126
  position: relative;
115
127
  text-align: center;