data-primals-engine 1.0.10 → 1.1.0

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 (166) hide show
  1. package/client/README.md +8 -0
  2. package/client/index.html +31 -0
  3. package/client/index.js +25 -0
  4. package/client/package-lock.json +11664 -0
  5. package/client/package.json +70 -0
  6. package/client/public/demo/26899917-d1ba-4df4-bb33-48d09a8778da.jpg +0 -0
  7. package/client/public/demo/4b9894c7-12cd-466d-8fd3-a2757b09ec96.jpg +0 -0
  8. package/client/public/demo/7ed369ac-a1a2-4b45-b0cd-4fd5bcf5a75a.jpg +0 -0
  9. package/client/public/doc/API.postman_collection.json +214 -0
  10. package/client/public/github.svg +1 -0
  11. package/client/public/profilCompany.jpg +0 -0
  12. package/client/public/profilDeveloper.jpg +0 -0
  13. package/client/public/profilEngineer.jpg +0 -0
  14. package/client/public/profilPersonal.jpg +0 -0
  15. package/client/public/profils .psd +0 -0
  16. package/client/public/react.svg +9 -0
  17. package/client/src/APIInfo.jsx +328 -0
  18. package/client/src/AddWidgetTypeModal.jsx +44 -0
  19. package/client/src/AddWidgetTypeModal.scss +87 -0
  20. package/client/src/App.css +42 -0
  21. package/client/src/App.jsx +586 -0
  22. package/client/src/App.scss +1466 -0
  23. package/client/src/AssistantChat.jsx +280 -0
  24. package/client/src/AssistantChat.scss +229 -0
  25. package/client/src/Button.jsx +12 -0
  26. package/client/src/Button.scss +197 -0
  27. package/client/src/CalculationBuilder.jsx +338 -0
  28. package/client/src/CalculationStepRow.jsx +199 -0
  29. package/client/src/CalendarConfigModal.jsx +49 -0
  30. package/client/src/ChartConfigModal.jsx +402 -0
  31. package/client/src/ConditionBuilder.jsx +622 -0
  32. package/client/src/ConditionBuilder.scss +672 -0
  33. package/client/src/ConditionBuilder2.jsx +757 -0
  34. package/client/src/ContentView.jsx +274 -0
  35. package/client/src/CronBuilder.jsx +126 -0
  36. package/client/src/CronBuilder.scss +128 -0
  37. package/client/src/CronPartBuilder.jsx +150 -0
  38. package/client/src/Dashboard.jsx +210 -0
  39. package/client/src/Dashboard.scss +445 -0
  40. package/client/src/DashboardChart.jsx +362 -0
  41. package/client/src/DashboardFlexViewItem.jsx +129 -0
  42. package/client/src/DashboardView.jsx +554 -0
  43. package/client/src/DataChart.jsx +349 -0
  44. package/client/src/DataEditor.jsx +556 -0
  45. package/client/src/DataLayout.jsx +709 -0
  46. package/client/src/DataTable.jsx +996 -0
  47. package/client/src/DataTable.scss +73 -0
  48. package/client/src/Dialog.jsx +90 -0
  49. package/client/src/Dialog.scss +117 -0
  50. package/client/src/DisplayFlexNodeRenderer.jsx +115 -0
  51. package/client/src/DocumentationPageLayout.jsx +93 -0
  52. package/client/src/DocumentationPageLayout.scss +262 -0
  53. package/client/src/Draggable.jsx +222 -0
  54. package/client/src/Draggable.scss +49 -0
  55. package/client/src/ExportDialog.jsx +172 -0
  56. package/client/src/Field.jsx +1558 -0
  57. package/client/src/FlexBuilder.jsx +269 -0
  58. package/client/src/FlexBuilder.scss +226 -0
  59. package/client/src/FlexBuilderControls.jsx +170 -0
  60. package/client/src/FlexBuilderModal.jsx +75 -0
  61. package/client/src/FlexBuilderModal.scss +109 -0
  62. package/client/src/FlexBuilderPreview.jsx +48 -0
  63. package/client/src/FlexBuilderUtils.js +84 -0
  64. package/client/src/FlexDataRenderer.jsx +170 -0
  65. package/client/src/FlexDataRenderer.scss +80 -0
  66. package/client/src/FlexNode.jsx +290 -0
  67. package/client/src/FlexTreeUtils.js +129 -0
  68. package/client/src/HiddenableCell.jsx +46 -0
  69. package/client/src/HiddenableCell.scss +36 -0
  70. package/client/src/KPIDialog.jsx +39 -0
  71. package/client/src/KPIWidget.jsx +139 -0
  72. package/client/src/KanbanCard.jsx +92 -0
  73. package/client/src/KanbanColumn.jsx +29 -0
  74. package/client/src/KanbanConfigModal.jsx +115 -0
  75. package/client/src/KanbanView.jsx +113 -0
  76. package/client/src/KanbanView.scss +107 -0
  77. package/client/src/MessageRotator.jsx +77 -0
  78. package/client/src/MessageRotator.scss +14 -0
  79. package/client/src/ModelCreator.jsx +640 -0
  80. package/client/src/ModelCreator.scss +154 -0
  81. package/client/src/ModelCreatorField.jsx +810 -0
  82. package/client/src/ModelImporter.jsx +120 -0
  83. package/client/src/ModelList.jsx +205 -0
  84. package/client/src/Notification.jsx +137 -0
  85. package/client/src/Notification.scss +126 -0
  86. package/client/src/NotificationProvider.jsx +73 -0
  87. package/client/src/PackGallery.jsx +211 -0
  88. package/client/src/PackGallery.scss +156 -0
  89. package/client/src/Pagination.jsx +141 -0
  90. package/client/src/RTE.jsx +415 -0
  91. package/client/src/RTETrans.jsx +103 -0
  92. package/client/src/RelationField.jsx +247 -0
  93. package/client/src/RelationValue.jsx +230 -0
  94. package/client/src/RestoreConfirmationModal.jsx +183 -0
  95. package/client/src/RestoreDialog.jsx +134 -0
  96. package/client/src/RestoreDialog.scss +67 -0
  97. package/client/src/RichTextEditorModal.jsx +34 -0
  98. package/client/src/RichTextEditorModal.scss +54 -0
  99. package/client/src/TourSpotlight.jsx +234 -0
  100. package/client/src/TourSpotlight.scss +100 -0
  101. package/client/src/TutorialsMenu.jsx +83 -0
  102. package/client/src/TutorialsMenu.scss +217 -0
  103. package/client/src/TutorialsRewardModal.jsx +65 -0
  104. package/client/src/Utils.jsx +78 -0
  105. package/client/src/ViewSwitcher.jsx +54 -0
  106. package/client/src/ViewSwitcher.scss +74 -0
  107. package/client/src/Webpage.jsx +69 -0
  108. package/client/src/_variables.scss +21 -0
  109. package/client/src/assets/react.svg +1 -0
  110. package/client/src/constants.js +68 -0
  111. package/client/src/contexts/AuthContext.jsx +28 -0
  112. package/client/src/contexts/ModelContext.jsx +328 -0
  113. package/client/src/contexts/UIContext.jsx +52 -0
  114. package/client/src/core/data.js +35 -0
  115. package/client/src/entry-client.jsx +15 -0
  116. package/client/src/entry-server.jsx +13 -0
  117. package/client/src/filter.js +222 -0
  118. package/client/src/hooks/data.js +101 -0
  119. package/client/src/hooks/useDebounce.js +20 -0
  120. package/client/src/hooks/useDragAndDrop.js +59 -0
  121. package/client/src/hooks/useLocalStorage.js +100 -0
  122. package/client/src/hooks/useMount.js +42 -0
  123. package/client/src/hooks/useTutorials.jsx +227 -0
  124. package/client/src/hooks/useWindowSize.js +24 -0
  125. package/client/src/i18n.js +47 -0
  126. package/client/src/index.css +90 -0
  127. package/client/src/index.js +10 -0
  128. package/client/src/main.jsx +11 -0
  129. package/client/src/translations.js +15940 -0
  130. package/client/src/tutorials.js +112 -0
  131. package/client/vite.config.js +30 -0
  132. package/eslint.config.js +50 -0
  133. package/package.json +48 -27
  134. package/server.js +9 -0
  135. package/src/constants.js +12 -23
  136. package/src/core.js +9 -8
  137. package/src/data.js +81 -80
  138. package/src/defaultModels.js +114 -115
  139. package/src/email.js +8 -9
  140. package/src/engine.js +5 -5
  141. package/src/events.js +1 -2
  142. package/src/i18n.js +5390 -211
  143. package/src/middlewares/middleware-mongodb.js +94 -93
  144. package/src/migrate.js +24 -24
  145. package/src/modules/assistant.js +55 -55
  146. package/src/modules/bucket.js +10 -9
  147. package/src/modules/data.js +387 -357
  148. package/src/modules/file.js +3 -6
  149. package/src/modules/mongodb.js +6 -7
  150. package/src/modules/user.js +24 -47
  151. package/src/modules/workflow.js +68 -67
  152. package/src/openai.jobs.js +2 -2
  153. package/src/packs.js +30 -31
  154. package/src/providers.js +101 -3
  155. package/src/setenv.js +1 -1
  156. package/src/user.js +0 -17
  157. package/src/workers/crypto-worker.js +21 -20
  158. package/src/workers/import-export-worker.js +18 -18
  159. package/test/data.backup.integration.test.js +7 -12
  160. package/test/data.integration.test.js +27 -25
  161. package/test/globalSetup.js +2 -2
  162. package/test/import_export.integration.test.js +6 -6
  163. package/test/model.integration.test.js +21 -22
  164. package/test/workflow.integration.test.js +2 -5
  165. package/test/workflow.robustness.test.js +6 -13
  166. package/vitest.config.js +2 -2
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { useTutorials } from './hooks/useTutorials.jsx';
3
+ import { useAuthContext } from './contexts/AuthContext.jsx';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { FaCheckCircle, FaHourglassHalf, FaPlayCircle, FaBullseye } from 'react-icons/fa'; // Importer FaBullseye
6
+ import './TutorialsMenu.scss';
7
+
8
+ const TutorialsMenu = () => {
9
+ const { t } = useTranslation();
10
+ const { me } = useAuthContext();
11
+ // On récupère les nouvelles données du hook
12
+ const { tutorials, isLoadingTutorials, startTutorial, activeTutorialState, activeTutorialDetails } = useTutorials();
13
+
14
+ if (isLoadingTutorials) {
15
+ return <div>{t('loading')}...</div>;
16
+ }
17
+
18
+ if (!tutorials || tutorials.length === 0) {
19
+ return <p>{t('tutorial.none_available', 'Aucun tutoriel disponible pour le moment.')}</p>;
20
+ }
21
+
22
+ return (
23
+ <ul className="tutorials-list">
24
+ {tutorials.map((tutorial) => {
25
+ const isCompleted = me?.completedTutorials?.includes(tutorial.id);
26
+ const isInProgress = activeTutorialState?.id === tutorial.id;
27
+
28
+ let statusBadge;
29
+ if (isCompleted) {
30
+ statusBadge = <span className="status-badge completed"><FaCheckCircle /> {t('tutorial.status.completed', 'Terminé')}</span>;
31
+ } else if (isInProgress) {
32
+ statusBadge = <span className="status-badge in-progress"><FaHourglassHalf /> {t('tutorial.status.in_progress', 'En cours')}</span>;
33
+ }
34
+
35
+ return (
36
+ <li key={tutorial.id} className={`tutorial-item ${isCompleted ? 'is-completed' : ''} ${isInProgress ? 'is-in-progress' : ''}`}>
37
+ <div className="tutorial-header">
38
+ <div className="tutorial-info">
39
+ <h4>{t(`tutorial.${tutorial.id}.name`, tutorial.name)}</h4>
40
+ <p>{t(`tutorial.${tutorial.id}.description`, tutorial.description)}</p>
41
+ </div>
42
+ <div className="tutorial-actions">
43
+ {statusBadge}
44
+ {!isCompleted && (
45
+ <button
46
+ className="start-button"
47
+ onClick={() => startTutorial(tutorial.id)}
48
+ disabled={isInProgress}
49
+ >
50
+ <FaPlayCircle /> {isInProgress ? t('tutorial.restart', 'Reprendre') : t('tutorial.start', 'Démarrer')}
51
+ </button>
52
+ )}
53
+ </div>
54
+ </div>
55
+
56
+ {/* --- NOUVELLE SECTION POUR LES DÉTAILS DE L'ÉTAPE EN COURS --- */}
57
+ {isInProgress && activeTutorialDetails && (
58
+ <div className="tutorial-progress-details">
59
+ <h5>
60
+ <FaBullseye />
61
+ {t('tutorial.objective_title', 'Objectif de l\'étape')} ({activeTutorialState.stage}/{activeTutorialDetails.totalStages})
62
+ </h5>
63
+ <p className="stage-description">{t(`tutorial.${tutorial.id}.stage.${activeTutorialDetails.currentStage.stage}.description`, activeTutorialDetails.currentStage.description || activeTutorialDetails.currentStage.name)}</p>
64
+
65
+ {/* --- AJOUT DE LA BARRE DE PROGRESSION --- */}
66
+ <div className="progress-bar-container">
67
+ <div
68
+ className="progress-bar-fill"
69
+ style={{ width: `${(activeTutorialState.stage / activeTutorialDetails.totalStages) * 100}%` }}
70
+ ></div>
71
+ </div>
72
+
73
+ <p className="stage-condition">{t('tutorial.condition.base', `Filtre de réussite :`)}<pre>{JSON.stringify(activeTutorialDetails.currentStage.completionCondition, null, 2)}</pre></p>
74
+ </div>
75
+ )}
76
+ </li>
77
+ );
78
+ })}
79
+ </ul>
80
+ );
81
+ };
82
+
83
+ export default TutorialsMenu;
@@ -0,0 +1,217 @@
1
+ // --- Variables de Design ---
2
+ // Palette de couleurs moderne et accessible pour une personnalisation facile.
3
+ $color-bg-light: #f8f9fa; // Fond général très clair
4
+ $color-item-bg: #ffffff; // Fond des cartes de tutoriel
5
+ $color-border: #e9ecef; // Bordures subtiles
6
+ $color-shadow: rgba(0, 0, 0, 0.05); // Ombre portée douce
7
+
8
+ $color-text-primary: #212529; // Titres et textes importants
9
+ $color-text-secondary: #6c757d; // Descriptions et textes secondaires
10
+ $color-text-tertiary: #8a949e; // Conditions et textes moins importants
11
+
12
+ // Couleurs d'accentuation pour les états
13
+ $color-accent-primary: #007bff; // Bleu pour les boutons d'action
14
+ $color-accent-primary-hover: #0056b3;
15
+
16
+ $color-inprogress-bg: #fff3cd; // Jaune doux pour "en cours"
17
+ $color-inprogress-border: #ffeeba;
18
+ $color-inprogress-text: #856404;
19
+ $color-inprogress-accent: #ffc107; // Jaune plus vif pour les accents
20
+
21
+ $color-completed-bg: #e2f0d9; // Vert doux pour "terminé"
22
+ $color-completed-border: #d4edda;
23
+ $color-completed-text: #155724;
24
+ $color-completed-accent: #28a745; // Vert plus vif
25
+
26
+ // --- Styles Généraux ---
27
+ .tutorials-list {
28
+ list-style: none;
29
+ padding: 0;
30
+ margin: 0;
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: 1.5rem; // Espacement plus généreux entre les items
34
+
35
+ .tutorial-item {
36
+ background-color: $color-item-bg;
37
+ border: 1px solid $color-border;
38
+ z-index: -1;
39
+ border-radius: 12px; // Coins plus arrondis pour un look moderne
40
+ box-shadow: 0 4px 12px $color-shadow;
41
+ padding: 1.5rem;
42
+ display: flex;
43
+ flex-direction: column; // Les sections (header, détails) sont empilées
44
+ gap: 1rem;
45
+ transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
46
+
47
+ &:hover {
48
+ transform: translateY(-3px); // Effet de lévitation au survol
49
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
50
+ }
51
+
52
+ // --- Header du Tutoriel ---
53
+ .tutorial-header {
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: flex-start; // Aligner au début pour les descriptions longues
57
+ gap: 1rem;
58
+
59
+ .tutorial-info {
60
+ flex-grow: 1;
61
+ h4 {
62
+ margin: 0 0 0.5rem 0;
63
+ font-size: 1.2rem;
64
+ font-weight: 600;
65
+ color: $color-text-primary;
66
+ }
67
+ p {
68
+ margin: 0;
69
+ font-size: 0.95rem;
70
+ color: $color-text-secondary;
71
+ line-height: 1.5;
72
+ }
73
+ }
74
+
75
+ .tutorial-actions {
76
+ display: flex;
77
+ flex-direction: column;
78
+ align-items: flex-end;
79
+ gap: 0.75rem;
80
+ min-width: 140px;
81
+ text-align: right;
82
+
83
+ .status-badge {
84
+ font-size: 0.8rem;
85
+ font-weight: 600;
86
+ padding: 0.3rem 0.8rem;
87
+ border-radius: 16px;
88
+ display: inline-flex;
89
+ align-items: center;
90
+ gap: 0.4rem;
91
+ text-transform: uppercase;
92
+ letter-spacing: 0.5px;
93
+ }
94
+
95
+ .start-button {
96
+ background-color: $color-accent-primary;
97
+ color: white;
98
+ border: none;
99
+ padding: 0.6rem 1.2rem;
100
+ border-radius: 8px;
101
+ cursor: pointer;
102
+ font-weight: 600;
103
+ display: flex;
104
+ align-items: center;
105
+ gap: 0.5rem;
106
+ transition: background-color 0.2s, transform 0.1s;
107
+
108
+ &:hover:not(:disabled) {
109
+ background-color: $color-accent-primary-hover;
110
+ transform: scale(1.03);
111
+ }
112
+
113
+ &:disabled {
114
+ background-color: #a0aec0;
115
+ cursor: not-allowed;
116
+ opacity: 0.7;
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ // --- Section de Progression (pour l'étape en cours) ---
123
+ .tutorial-progress-details {
124
+ border-top: 1px solid $color-border;
125
+ padding-top: 1.25rem;
126
+ margin-top: 0.5rem;
127
+ animation: fadeIn 0.5s ease-in-out; // Animation d'apparition
128
+
129
+ h5 {
130
+ display: flex;
131
+ align-items: center;
132
+ gap: 0.6rem;
133
+ font-size: 1.1rem;
134
+ font-weight: 600;
135
+ color: $color-inprogress-text;
136
+ margin: 0 0 1rem 0;
137
+
138
+ svg {
139
+ color: $color-inprogress-accent;
140
+ }
141
+ }
142
+
143
+ .stage-description {
144
+ font-size: 1rem;
145
+ color: $color-text-secondary;
146
+ margin-bottom: 0.75rem;
147
+ font-style: italic;
148
+ }
149
+
150
+ .stage-condition {
151
+ font-size: 0.9rem;
152
+ color: $color-text-tertiary;
153
+ background-color: #f8f9fa;
154
+ padding: 0.75rem 1rem;
155
+ border-radius: 8px;
156
+ border-left: 4px solid $color-inprogress-accent;
157
+ }
158
+
159
+ // Barre de progression pour les étapes
160
+ .progress-bar-container {
161
+ background-color: #e9ecef;
162
+ border-radius: 10px;
163
+ height: 10px;
164
+ width: 100%;
165
+ overflow: hidden;
166
+ margin-top: 1rem;
167
+
168
+ .progress-bar-fill {
169
+ height: 100%;
170
+ background: linear-gradient(90deg, $color-inprogress-accent, lighten($color-inprogress-accent, 15%));
171
+ border-radius: 10px;
172
+ transition: width 0.5s ease-out;
173
+ }
174
+ }
175
+ }
176
+
177
+ // --- Modificateurs de Statut ---
178
+ &.is-in-progress {
179
+ border-color: $color-inprogress-accent;
180
+ background-color: lighten($color-inprogress-bg, 5%);
181
+
182
+ .tutorial-actions .status-badge {
183
+ background-color: $color-inprogress-bg;
184
+ color: $color-inprogress-text;
185
+ border: 1px solid $color-inprogress-border;
186
+ }
187
+ }
188
+
189
+ &.is-completed {
190
+ background-color: $color-bg-light;
191
+ opacity: 0.8;
192
+
193
+ .tutorial-info h4 {
194
+ text-decoration: line-through;
195
+ color: $color-text-secondary;
196
+ }
197
+
198
+ .tutorial-actions .status-badge {
199
+ background-color: $color-completed-bg;
200
+ color: $color-completed-text;
201
+ border: 1px solid $color-completed-border;
202
+ }
203
+ }
204
+ }
205
+ }
206
+
207
+ // Animation d'apparition pour la section des détails
208
+ @keyframes fadeIn {
209
+ from {
210
+ opacity: 0;
211
+ transform: translateY(-10px);
212
+ }
213
+ to {
214
+ opacity: 1;
215
+ transform: translateY(0);
216
+ }
217
+ }
@@ -0,0 +1,65 @@
1
+ // Fichier : client/src/TutorialRewardModal.jsx
2
+
3
+ import React from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { FaAward, FaStar } from 'react-icons/fa';
6
+ import Button from './Button.jsx';
7
+ import { useUI } from './contexts/UIContext.jsx';
8
+
9
+ // Petite fonction utilitaire pour choisir la bonne icône en fonction du type de récompense
10
+ const getRewardIcon = (reward) => {
11
+ switch (reward.type) {
12
+ case 'achievement':
13
+ // L'icône 'achievement' est définie dans le CSS, mais on utilise FaAward comme base.
14
+ return <FaAward className="reward-icon achievement" />;
15
+ case 'xp':
16
+ // L'icône 'xp' est définie dans le CSS, mais on utilise FaStar comme base.
17
+ return <FaStar className="reward-icon xp" />;
18
+ default:
19
+ return null;
20
+ }
21
+ };
22
+
23
+ const TutorialRewardModal = ({ rewards = [] }) => {
24
+ const { t } = useTranslation();
25
+ const { setIsModalOpen } = useUI();
26
+
27
+ return (
28
+ <div className="tutorial-reward-modal">
29
+ <h2>{t('tutorial.completed.title', 'Tutoriel Terminé !')}</h2>
30
+ <p>{t('tutorial.completed.congrats', 'Félicitations ! Vous avez obtenu les récompenses suivantes :')}</p>
31
+
32
+ <ul className="reward-list">
33
+ {rewards.map((reward, index) => (
34
+ <li key={index} className="reward-item">
35
+ {getRewardIcon(reward)}
36
+ <div className="reward-details">
37
+ {reward.type === 'achievement' && (
38
+ <>
39
+ <span className="reward-type">{t('reward.type.achievement', 'Succès débloqué')}</span>
40
+ <span className="reward-name">{reward.name}</span>
41
+ </>
42
+ )}
43
+ {reward.type === 'xp' && (
44
+ <>
45
+ <span className="reward-type">{t('reward.type.xp', 'Expérience gagnée')}</span>
46
+ <span className="reward-name">
47
+ {t('reward.xp.details', '{{amount}} XP en {{skill}}', { amount: reward.amount, skill: reward.skill })}
48
+ </span>
49
+ </>
50
+ )}
51
+ </div>
52
+ </li>
53
+ ))}
54
+ </ul>
55
+
56
+ <div className="actions center">
57
+ <Button onClick={() => setIsModalOpen(false)} className="btn-primary">
58
+ {t('btns.great', 'Génial !')}
59
+ </Button>
60
+ </div>
61
+ </div>
62
+ );
63
+ };
64
+
65
+ export default TutorialRewardModal;
@@ -0,0 +1,78 @@
1
+ import {Children, cloneElement, isValidElement, useCallback, useRef} from "react";
2
+
3
+ const useRefs = () => {
4
+ const refs = useRef({});
5
+
6
+ const register = useCallback((refname) => ref => {
7
+ refs.current[refname] = ref;
8
+ }, []);
9
+
10
+ return [refs, register];
11
+ }
12
+
13
+ export {useRefs};
14
+
15
+ const formatHtml = (text) => {
16
+ var map = {
17
+ '&': '&amp;',
18
+ '<': '&lt;',
19
+ '>': '&gt;',
20
+ '"': '&quot;',
21
+ "'": '&#039;'
22
+ };
23
+ return text.replace(/[&<>"']/g, function (m) {
24
+ return map[m];
25
+ });
26
+ }
27
+
28
+ export {formatHtml};
29
+
30
+ const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
31
+ export {clamp};
32
+
33
+
34
+ export const data_paginate = (datas, page, elementsPerPage) => {
35
+ if (elementsPerPage && page)
36
+ return datas.slice((page - 1) * elementsPerPage, page * elementsPerPage);
37
+ return datas;
38
+ }
39
+ export const data_filter = (datas, filter, query) => {
40
+ // Filter data
41
+ let filteredDatas = datas;
42
+ if (filter) {
43
+ filteredDatas = filteredDatas.filter(filter);
44
+ }
45
+ if (typeof (query) === 'string') {
46
+ filteredDatas = filteredDatas.filter(f => {
47
+ let inc = false;
48
+ let keys = Object.keys(f);
49
+ for (let i = 0; i < keys.length; ++i) {
50
+ if (typeof (f[keys[i]]) === 'object')
51
+ continue;
52
+ if ((f[keys[i]] + '').includes(query)) {
53
+ inc = true;
54
+ break;
55
+ }
56
+ }
57
+ return inc;
58
+ })
59
+ }
60
+ return filteredDatas;
61
+ }
62
+
63
+ const recursiveMap = (children, fn) => {
64
+ return Children.map(children, (child, index) => {
65
+ if (!isValidElement(child)) {
66
+ return child;
67
+ }
68
+
69
+ if (child.props.children) {
70
+ child = cloneElement(child, {
71
+ children: recursiveMap(child.props.children, fn)
72
+ });
73
+ }
74
+
75
+ return fn(child, index);
76
+ });
77
+ }
78
+ export {recursiveMap};
@@ -0,0 +1,54 @@
1
+ // client/src/ViewSwitcher.jsx
2
+
3
+ import React from 'react';
4
+ import { Trans, useTranslation } from 'react-i18next';
5
+ import { FaTable, FaRegCalendarAlt, FaColumns, FaCog } from 'react-icons/fa';
6
+ import Button from './Button.jsx';
7
+ import { Tooltip } from 'react-tooltip';
8
+
9
+ import "./ViewSwitcher.scss"
10
+ const viewOptions = [
11
+ { id: 'table', icon: <FaTable />, labelKey: 'views.table' },
12
+ { id: 'kanban', icon: <FaColumns />, labelKey: 'views.kanban' },
13
+ //{ id: 'calendar', icon: <FaRegCalendarAlt />, labelKey: 'views.calendar' },
14
+ ];
15
+
16
+ const ViewSwitcher = ({ currentView, onViewChange, configuredViews, onConfigureView }) => {
17
+ const { t } = useTranslation();
18
+
19
+ return (
20
+ <div className="view-switcher flex items-center gap-1 p-1 bg-gray-200 rounded-md">
21
+ {viewOptions.map(view => {
22
+ const isConfigured = view.id === 'table' || configuredViews[view.id];
23
+ const isActive = currentView === view.id;
24
+
25
+ return (
26
+ <div key={view.id} className="relative flex items-center">
27
+ <Button
28
+ onClick={() => onViewChange(view.id)}
29
+ className={`btn-view ${isActive ? 'active' : ''}`}
30
+ title={t(view.labelKey, view.id)}
31
+ >
32
+ {view.icon}
33
+ <span className="hidden md:inline-block ml-2">{t(view.labelKey, view.id)}</span>
34
+ </Button>
35
+ {/* AJOUT : Bouton de configuration pour la vue active */}
36
+ {isActive && view.id !== 'table' && (
37
+ <Button
38
+ onClick={onConfigureView}
39
+ className="btn-view-settings"
40
+ data-tooltip-id="view-settings-tooltip"
41
+ data-tooltip-content={t('views.configure', { view: t(view.labelKey) })}
42
+ >
43
+ <FaCog />
44
+ </Button>
45
+ )}
46
+ </div>
47
+ );
48
+ })}
49
+ <Tooltip id="view-settings-tooltip" />
50
+ </div>
51
+ );
52
+ };
53
+
54
+ export default ViewSwitcher;
@@ -0,0 +1,74 @@
1
+ /* client/src/ViewSwitcher.scss */
2
+
3
+ // Variables pour une maintenance facile (à adapter au thème de votre application)
4
+ $vs-primary-color: #0d6efd;
5
+ $vs-background: #e9ecef;
6
+ $vs-border-color: #dee2e6;
7
+ $vs-text-color: #495057;
8
+ $vs-white: #ffffff;
9
+ $vs-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
10
+
11
+ .view-switcher {
12
+ display: inline-flex;
13
+ align-items: center;
14
+ background-color: $vs-background;
15
+ border-radius: 8px;
16
+ padding: 4px;
17
+ border: 1px solid $vs-border-color;
18
+
19
+ // Chaque option (bouton + potentiellement le bouton de configuration) est dans un wrapper
20
+ .view-option-wrapper {
21
+ display: flex;
22
+ align-items: center;
23
+ border-radius: 6px;
24
+ // La magie de la transition pour un effet fluide
25
+ transition: background-color 0.25s ease, box-shadow 0.25s ease;
26
+
27
+ // Le style du wrapper quand il est actif
28
+ &.is-active {
29
+ background-color: $vs-white;
30
+ box-shadow: $vs-shadow;
31
+ }
32
+ }
33
+
34
+ .btn-view {
35
+ background-color: transparent;
36
+ border: none;
37
+ padding: 6px 12px;
38
+ display: flex;
39
+ align-items: center;
40
+ gap: 8px;
41
+ cursor: pointer;
42
+ color: $vs-text-color;
43
+ font-weight: 500;
44
+ transition: color 0.2s ease-in-out;
45
+ white-space: nowrap; // Emphe le texte de passer à la ligne
46
+
47
+ .md\:inline-block {
48
+ font-size: 0.9rem;
49
+ }
50
+ }
51
+
52
+ // Quand le wrapper est actif, le bouton principal change de couleur
53
+ .is-active .btn-view {
54
+ color: $vs-primary-color;
55
+ font-weight: 600;
56
+ }
57
+
58
+ // Le bouton de configuration (roue crantée)
59
+ .btn-view-settings {
60
+ background-color: transparent;
61
+ border: none;
62
+ // On le sépare visuellement
63
+ border-left: 1px solid $vs-border-color;
64
+ padding: 6px 10px;
65
+ margin-left: -4px; // Léger ajustement pour l'harmonie
66
+ color: #6c757d; // Couleur discrète
67
+ cursor: pointer;
68
+ transition: color 0.2s ease-in-out;
69
+
70
+ &:hover {
71
+ color: $vs-primary-color;
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,69 @@
1
+ import React, {useState, useEffect, useMemo, useContext} from 'react';
2
+
3
+ import "./App.scss";
4
+ import {useQuery} from "react-query";
5
+ import {useLocation} from "react-router-dom";
6
+ import {Helmet} from "react-helmet";
7
+ import {useTranslation} from "react-i18next";
8
+ import {getObjectHash} from "data-primals-engine/core";
9
+ import {useData} from "./hooks/data.js";
10
+ import {useAuthContext} from "./contexts/AuthContext.jsx";
11
+ import {getUserHash, getUserId} from "data-primals-engine/data";
12
+
13
+
14
+ function Webpage({children}) {
15
+
16
+ const { me } = useAuthContext();
17
+ const loc = useLocation();
18
+ const webpageModel = 'webpage';
19
+ const contentModel = 'content';
20
+
21
+ const id = getUserId(me);
22
+ const loco = loc.pathname.replace('/user/'+id+'/', '/');
23
+ const {data: webpages, isFetched} = useData(webpageModel, {'path':'^'+loco+'$', 'published': true},{ staleTime: 50000 });
24
+ const webpage = webpages?.[0];
25
+
26
+ const {data: contents } = useData(contentModel, {'$and': [{'webpage': webpage?._id, 'published': true}]},{ staleTime: 30000, enabled: !!webpage });
27
+
28
+ const { i18n, t } = useTranslation();
29
+ const lang = (i18n.resolvedLanguage || i18n.language).split(/[-_]/)?.[0];
30
+
31
+ return <>
32
+ {webpage && <>
33
+ <Helmet htmlAttributes={{ lang }} />
34
+ <Helmet>
35
+ <title>{t(webpage.title)}</title>
36
+ <meta name="description" content={webpage.description}/>
37
+ <meta property="og:description" content={webpage.description}/>
38
+ <meta property="twitter:description" content={webpage.description}/>
39
+ <meta property="og:title" content={t(webpage.title)}/>
40
+ <meta property="twitter:title" content={t(webpage.title)}/>
41
+ <meta property="og:image" content={webpage.image}/>
42
+ <meta property="twitter:image" content={webpage.image}/>
43
+ </Helmet>
44
+ <h1>{webpage.title}</h1>
45
+ <div className="content" dangerouslySetInnerHTML={{__html: webpage.text}}></div>
46
+ {(contents || []).map(content => {
47
+ return <div className="content">
48
+ {content.title && (<Helmet><title>{t(content.title)}</title>
49
+ <meta property="og:title" content={t(webpage.title)}/>
50
+ <meta property="twitter:title" content={t(webpage.title)}/></Helmet>)}
51
+ {content.description && (<Helmet><meta name="description" content={content.description}/>
52
+ <meta property="og:description" content={content.description}/>
53
+ <meta property="twitter:description" content={content.description}/></Helmet>)}
54
+ {content.image && (<Helmet><meta property="og:image" content={content.image}/>
55
+ <meta property="twitter:image" content={content.image}/></Helmet>)}
56
+ <article>
57
+ <h2>{t(content.title)}</h2>
58
+ <p className="subtitle"></p>
59
+ <p dangerouslySetInnerHTML={{ __html: content.text }}></p>
60
+ </article>
61
+ </div>
62
+ })}
63
+ </>
64
+ }
65
+ {!webpage && isFetched && (<Helmet><title>Page non trouvée</title></Helmet>)}
66
+ </>
67
+ }
68
+
69
+ export default Webpage;
@@ -0,0 +1,21 @@
1
+ // Variables de couleurs
2
+ $primary-color: #3498db;
3
+ $secondary-color: #2ecc71;
4
+ $primary-color-darker: darken($primary-color, 10%); // Un peu plus foncé pour hover/active
5
+ $light-color: #ecf0f1;
6
+ $dark-color: #333;
7
+ $input-background-color: #f8f8f8; // Gris très clair
8
+ $input-border-color: #ddd; // Gris clair
9
+ $input-focus-border-color: #4CAF50; // Vert clair (couleur d'accentuation)
10
+
11
+ $light-gray: #f8f8f8;
12
+ $medium-gray: #ddd;
13
+ $dark-gray: #555;
14
+
15
+ $danger-color: #ff1e00;
16
+
17
+ $shadow-color: rgba(0, 0, 0, 0.15);
18
+ $shadow-color-hover: rgba(0, 0, 0, 0.25);
19
+
20
+
21
+ // Appliquer cette palette aux différents éléments
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>