mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
feat: adding time string to notifications
This commit is contained in:
parent
b30295d840
commit
91ea07905d
@ -132,6 +132,9 @@ const App = () => {
|
||||
const handleShowSettings = () => setShowSettings(true);
|
||||
|
||||
function onNotify(value: UpdateNotification) {
|
||||
const currentTime = new Date();
|
||||
const timeString = currentTime.toISOString().substr(11, 8);
|
||||
|
||||
dispatch({
|
||||
type: 'UPDATE_ATTRIBUTE',
|
||||
parent_path: value.data.parent_path,
|
||||
@ -140,15 +143,20 @@ const App = () => {
|
||||
});
|
||||
const newNotification = {
|
||||
id: Math.random(),
|
||||
time: timeString,
|
||||
text: `Attribute ${value.data.parent_path}.${value.data.name} updated to ${value.data.value}.`
|
||||
};
|
||||
setNotifications((prevNotifications) => [newNotification, ...prevNotifications]);
|
||||
}
|
||||
|
||||
function onException(value: ExceptionNotification) {
|
||||
const currentTime = new Date();
|
||||
const timeString = currentTime.toISOString().substr(11, 8);
|
||||
|
||||
const newNotification = {
|
||||
type: 'exception',
|
||||
id: Math.random(),
|
||||
time: timeString,
|
||||
text: `${value.data.type}: ${value.data.exception}.`
|
||||
};
|
||||
setNotifications((prevNotifications) => [newNotification, ...prevNotifications]);
|
||||
@ -212,15 +220,16 @@ const App = () => {
|
||||
delay={notification.type === 'exception' ? 0 : 2000} // No delay for 'exception' type notifications
|
||||
>
|
||||
<Toast.Header
|
||||
closeButton={false}
|
||||
className={
|
||||
closeButton={notification.type === 'exception'}
|
||||
className={`${
|
||||
notification.type === 'exception'
|
||||
? 'exceptionToast'
|
||||
: 'notificationToast'
|
||||
}>
|
||||
<strong className="mr-auto">
|
||||
} text-right`}>
|
||||
<strong className="me-auto">
|
||||
{notification.type === 'exception' ? 'Exception' : 'Notification'}
|
||||
</strong>
|
||||
<small>{notification.time}</small>
|
||||
</Toast.Header>
|
||||
<Toast.Body>{notification.text}</Toast.Body>
|
||||
</Toast>
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.b6b367bd.css",
|
||||
"main.js": "/static/js/main.1e89ddc5.js",
|
||||
"main.css": "/static/css/main.d5ec2545.css",
|
||||
"main.js": "/static/js/main.b51434ec.js",
|
||||
"index.html": "/index.html",
|
||||
"main.b6b367bd.css.map": "/static/css/main.b6b367bd.css.map",
|
||||
"main.1e89ddc5.js.map": "/static/js/main.1e89ddc5.js.map"
|
||||
"main.d5ec2545.css.map": "/static/css/main.d5ec2545.css.map",
|
||||
"main.b51434ec.js.map": "/static/js/main.b51434ec.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.b6b367bd.css",
|
||||
"static/js/main.1e89ddc5.js"
|
||||
"static/css/main.d5ec2545.css",
|
||||
"static/js/main.b51434ec.js"
|
||||
]
|
||||
}
|
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.1e89ddc5.js"></script><link href="/static/css/main.b6b367bd.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.b51434ec.js"></script><link href="/static/css/main.d5ec2545.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
src/pydase/frontend/static/css/main.d5ec2545.css.map
Normal file
1
src/pydase/frontend/static/css/main.d5ec2545.css.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
src/pydase/frontend/static/js/main.b51434ec.js.map
Normal file
1
src/pydase/frontend/static/js/main.b51434ec.js.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user