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,137 +1,137 @@
|
|
|
1
|
-
import React, {useState, useEffect, useRef, useCallback, forwardRef} from 'react';
|
|
2
|
-
import { FaCheck, FaSpinner, FaExclamationTriangle, FaBell, FaTimes, FaTrash } from 'react-icons/fa'; // Example icons
|
|
3
|
-
import { useNotificationContext } from './NotificationProvider.jsx'; // Import the context
|
|
4
|
-
import './Notification.scss';
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
const { addNotification } = useNotificationContext();
|
|
8
|
-
const notificationData = {
|
|
9
|
-
title: 'New Notification',
|
|
10
|
-
message: 'This is a new notification message.',
|
|
11
|
-
icon: <FaBell />,
|
|
12
|
-
status: ['ongoing','completed','error'][Math.floor(Math.random()*3)]
|
|
13
|
-
};
|
|
14
|
-
*/
|
|
15
|
-
// Helper function to generate a unique ID
|
|
16
|
-
const generateNotificationId = () => {
|
|
17
|
-
return Math.random().toString(36).substring(2, 9);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const Notification = ({ notification, onClick }) => {
|
|
21
|
-
const { markAsRead, removeNotification } = useNotificationContext();
|
|
22
|
-
const [dismissTimer, setDismissTimer] = useState(null);
|
|
23
|
-
const notificationRef = useRef(null);
|
|
24
|
-
const isMounted = useRef(false)
|
|
25
|
-
|
|
26
|
-
const handleMarkAsRead = useCallback(() => {
|
|
27
|
-
markAsRead(notification.id);
|
|
28
|
-
}, [markAsRead, notification.id]);
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const t = setTimeout(()=>{
|
|
32
|
-
markAsRead(notification.id);
|
|
33
|
-
}, notification.timeout || 12000);
|
|
34
|
-
return () => {
|
|
35
|
-
clearTimeout(t);
|
|
36
|
-
}
|
|
37
|
-
}, [notification]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (notification.isRead) {
|
|
41
|
-
const timer = setTimeout(() => {
|
|
42
|
-
removeNotification(notification.id);
|
|
43
|
-
}, 30000);
|
|
44
|
-
|
|
45
|
-
return () => {
|
|
46
|
-
clearTimeout(timer);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}, [notification.isRead, notification.id, removeNotification]);
|
|
50
|
-
|
|
51
|
-
let statusIcon;
|
|
52
|
-
switch (notification.status) {
|
|
53
|
-
case 'ongoing':
|
|
54
|
-
statusIcon = <FaSpinner className="spinner" />;
|
|
55
|
-
break;
|
|
56
|
-
case 'completed':
|
|
57
|
-
statusIcon = <FaCheck />;
|
|
58
|
-
break;
|
|
59
|
-
case 'error':
|
|
60
|
-
statusIcon = <FaExclamationTriangle />;
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
statusIcon = null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const removeBtn = notification.isRead ? <button onClick={() => {
|
|
67
|
-
removeNotification(notification.id);
|
|
68
|
-
}}><FaTrash /></button> : <></>
|
|
69
|
-
return (
|
|
70
|
-
<div ref={notificationRef} onClick={onClick} className={`notification ${notification.isExpanded ? 'expanded' : 'collapsed'} ${notification.status}`}>
|
|
71
|
-
<div className="notification-header">
|
|
72
|
-
{notification.icon && <span className="notification-icon">{notification.icon}</span>}
|
|
73
|
-
<span className="notification-title">{notification.title}</span>
|
|
74
|
-
{statusIcon && <span className="notification-status">{statusIcon}</span>}
|
|
75
|
-
{removeBtn}
|
|
76
|
-
</div>
|
|
77
|
-
{<div className="notification-content">
|
|
78
|
-
<p className="notification-message">{notification.message}</p>
|
|
79
|
-
</div>}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const NotificationList = forwardRef((props, ref) => {
|
|
85
|
-
const { notifications, markAsRead, removeNotification, addNotification, unreadCount } = useNotificationContext();
|
|
86
|
-
const [showBubble, setShowBubble] = useState(false);
|
|
87
|
-
|
|
88
|
-
const toggleBubble = useCallback(() => {
|
|
89
|
-
// Lorsque l'on ouvre la bulle, on marque toutes les notifications comme lues.
|
|
90
|
-
if (!showBubble) {
|
|
91
|
-
notifications.forEach(n => {
|
|
92
|
-
if (!n.isRead) {
|
|
93
|
-
markAsRead(n.id);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
// Ensuite, on bascule la visibilité du contenu de la bulle.
|
|
98
|
-
setShowBubble(prev => !prev);
|
|
99
|
-
}, [showBubble, notifications, markAsRead]);
|
|
100
|
-
|
|
101
|
-
const readNotifications = notifications.filter(n => n.isRead) || [];
|
|
102
|
-
const unreadNotifications = notifications.filter(n => !n.isRead) || [];
|
|
103
|
-
return (
|
|
104
|
-
<><div className="notification-container">
|
|
105
|
-
<div className="notifications-right">
|
|
106
|
-
{unreadNotifications.map(notification => (
|
|
107
|
-
<Notification
|
|
108
|
-
onClick={() => {
|
|
109
|
-
markAsRead(notification.id)
|
|
110
|
-
}}
|
|
111
|
-
key={notification.id}
|
|
112
|
-
notification={notification}
|
|
113
|
-
/>
|
|
114
|
-
))}
|
|
115
|
-
{unreadCount > 0 && <div className={"notification-bubble-count"}>{unreadCount}</div>}
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
{unreadCount > 0 && <button onClick={toggleBubble} className={`notification-bubble fab ${showBubble ? 'visible' : ''}`}>
|
|
120
|
-
<div>
|
|
121
|
-
<FaBell/>
|
|
122
|
-
{unreadCount > 0 && <span className="notification-bubble-count">{unreadCount}</span>}
|
|
123
|
-
</div>
|
|
124
|
-
{showBubble && <div className='notifications-bubble-content'>
|
|
125
|
-
{readNotifications.map(notification => (
|
|
126
|
-
<Notification
|
|
127
|
-
key={notification.id}
|
|
128
|
-
notification={notification}
|
|
129
|
-
/>
|
|
130
|
-
))}
|
|
131
|
-
</div>}
|
|
132
|
-
</button>}
|
|
133
|
-
</>
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
NotificationList.displayName = "NotificationList";
|
|
1
|
+
import React, {useState, useEffect, useRef, useCallback, forwardRef} from 'react';
|
|
2
|
+
import { FaCheck, FaSpinner, FaExclamationTriangle, FaBell, FaTimes, FaTrash } from 'react-icons/fa'; // Example icons
|
|
3
|
+
import { useNotificationContext } from './NotificationProvider.jsx'; // Import the context
|
|
4
|
+
import './Notification.scss';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
const { addNotification } = useNotificationContext();
|
|
8
|
+
const notificationData = {
|
|
9
|
+
title: 'New Notification',
|
|
10
|
+
message: 'This is a new notification message.',
|
|
11
|
+
icon: <FaBell />,
|
|
12
|
+
status: ['ongoing','completed','error'][Math.floor(Math.random()*3)]
|
|
13
|
+
};
|
|
14
|
+
*/
|
|
15
|
+
// Helper function to generate a unique ID
|
|
16
|
+
const generateNotificationId = () => {
|
|
17
|
+
return Math.random().toString(36).substring(2, 9);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const Notification = ({ notification, onClick }) => {
|
|
21
|
+
const { markAsRead, removeNotification } = useNotificationContext();
|
|
22
|
+
const [dismissTimer, setDismissTimer] = useState(null);
|
|
23
|
+
const notificationRef = useRef(null);
|
|
24
|
+
const isMounted = useRef(false)
|
|
25
|
+
|
|
26
|
+
const handleMarkAsRead = useCallback(() => {
|
|
27
|
+
markAsRead(notification.id);
|
|
28
|
+
}, [markAsRead, notification.id]);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const t = setTimeout(()=>{
|
|
32
|
+
markAsRead(notification.id);
|
|
33
|
+
}, notification.timeout || 12000);
|
|
34
|
+
return () => {
|
|
35
|
+
clearTimeout(t);
|
|
36
|
+
}
|
|
37
|
+
}, [notification]);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (notification.isRead) {
|
|
41
|
+
const timer = setTimeout(() => {
|
|
42
|
+
removeNotification(notification.id);
|
|
43
|
+
}, 30000);
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}, [notification.isRead, notification.id, removeNotification]);
|
|
50
|
+
|
|
51
|
+
let statusIcon;
|
|
52
|
+
switch (notification.status) {
|
|
53
|
+
case 'ongoing':
|
|
54
|
+
statusIcon = <FaSpinner className="spinner" />;
|
|
55
|
+
break;
|
|
56
|
+
case 'completed':
|
|
57
|
+
statusIcon = <FaCheck />;
|
|
58
|
+
break;
|
|
59
|
+
case 'error':
|
|
60
|
+
statusIcon = <FaExclamationTriangle />;
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
statusIcon = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const removeBtn = notification.isRead ? <button onClick={() => {
|
|
67
|
+
removeNotification(notification.id);
|
|
68
|
+
}}><FaTrash /></button> : <></>
|
|
69
|
+
return (
|
|
70
|
+
<div ref={notificationRef} onClick={onClick} className={`notification ${notification.isExpanded ? 'expanded' : 'collapsed'} ${notification.status}`}>
|
|
71
|
+
<div className="notification-header">
|
|
72
|
+
{notification.icon && <span className="notification-icon">{notification.icon}</span>}
|
|
73
|
+
<span className="notification-title">{notification.title}</span>
|
|
74
|
+
{statusIcon && <span className="notification-status">{statusIcon}</span>}
|
|
75
|
+
{removeBtn}
|
|
76
|
+
</div>
|
|
77
|
+
{<div className="notification-content">
|
|
78
|
+
<p className="notification-message">{notification.message}</p>
|
|
79
|
+
</div>}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const NotificationList = forwardRef((props, ref) => {
|
|
85
|
+
const { notifications, markAsRead, removeNotification, addNotification, unreadCount } = useNotificationContext();
|
|
86
|
+
const [showBubble, setShowBubble] = useState(false);
|
|
87
|
+
|
|
88
|
+
const toggleBubble = useCallback(() => {
|
|
89
|
+
// Lorsque l'on ouvre la bulle, on marque toutes les notifications comme lues.
|
|
90
|
+
if (!showBubble) {
|
|
91
|
+
notifications.forEach(n => {
|
|
92
|
+
if (!n.isRead) {
|
|
93
|
+
markAsRead(n.id);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Ensuite, on bascule la visibilité du contenu de la bulle.
|
|
98
|
+
setShowBubble(prev => !prev);
|
|
99
|
+
}, [showBubble, notifications, markAsRead]);
|
|
100
|
+
|
|
101
|
+
const readNotifications = notifications.filter(n => n.isRead) || [];
|
|
102
|
+
const unreadNotifications = notifications.filter(n => !n.isRead) || [];
|
|
103
|
+
return (
|
|
104
|
+
<><div className="notification-container">
|
|
105
|
+
<div className="notifications-right">
|
|
106
|
+
{unreadNotifications.map(notification => (
|
|
107
|
+
<Notification
|
|
108
|
+
onClick={() => {
|
|
109
|
+
markAsRead(notification.id)
|
|
110
|
+
}}
|
|
111
|
+
key={notification.id}
|
|
112
|
+
notification={notification}
|
|
113
|
+
/>
|
|
114
|
+
))}
|
|
115
|
+
{unreadCount > 0 && <div className={"notification-bubble-count"}>{unreadCount}</div>}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{unreadCount > 0 && <button onClick={toggleBubble} className={`notification-bubble fab ${showBubble ? 'visible' : ''}`}>
|
|
120
|
+
<div>
|
|
121
|
+
<FaBell/>
|
|
122
|
+
{unreadCount > 0 && <span className="notification-bubble-count">{unreadCount}</span>}
|
|
123
|
+
</div>
|
|
124
|
+
{showBubble && <div className='notifications-bubble-content'>
|
|
125
|
+
{readNotifications.map(notification => (
|
|
126
|
+
<Notification
|
|
127
|
+
key={notification.id}
|
|
128
|
+
notification={notification}
|
|
129
|
+
/>
|
|
130
|
+
))}
|
|
131
|
+
</div>}
|
|
132
|
+
</button>}
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
NotificationList.displayName = "NotificationList";
|
|
137
137
|
export {NotificationList, generateNotificationId}; // Export for use elsewherex
|