diff --git a/nodes/config/locales/en-US/ui_base.json b/nodes/config/locales/en-US/ui_base.json
index 11279bc3..6b799da6 100644
--- a/nodes/config/locales/en-US/ui_base.json
+++ b/nodes/config/locales/en-US/ui_base.json
@@ -31,7 +31,11 @@
"navigationStyleFixed": "Fixed",
"navigationStyleIcon": "Collapse to icons",
"navigationStyleTemporary": "Appear over content",
- "navigationStyleNone": "Always hide"
+ "navigationStyleNone": "Always hide",
+ "notifications": "Notifications",
+ "showReconnect": "Show reconnect notification",
+ "showDisconnect": "Show disconnect notification",
+ "reconnectNotificationDelay": "Reconnect notification delay (s)"
},
"layout": {
"pages": "Pages",
diff --git a/nodes/config/ui_base.html b/nodes/config/ui_base.html
index fbb039a0..b9f8bac8 100644
--- a/nodes/config/ui_base.html
+++ b/nodes/config/ui_base.html
@@ -347,6 +347,15 @@
},
titleBarStyle: {
value: 'default'
+ },
+ showReconnectNotification: {
+ value: true
+ },
+ reconnectNotificationDelay: {
+ value: 2
+ },
+ showDisconnectNotification: {
+ value: true
}
},
label: function () {
@@ -372,6 +381,20 @@
if (this.appIcon) {
$('#node-config-input-appIcon').val(this.appIcon)
}
+
+ if (!this.showReconnectNotification) {
+ this.showReconnectNotification = true
+ $('#node-config-input-showReconnectNotification').prop('checked', true)
+ }
+
+ if (!this.reconnectNotificationDelay) {
+ this.reconnectNotificationDelay = 2
+ $('#node-config-input-reconnectNotificationDelay').val(this.reconnectNotificationDelay)
+ }
+ if (!this.showDisconnectNotification) {
+ this.showDisconnectNotification = true
+ $('#node-config-input-showDisconnectNotification').prop('checked', true)
+ }
},
onpaletteadd: function () {
// add the Dashboard 2.0 sidebar
@@ -2429,4 +2452,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui/src/App.vue b/ui/src/App.vue
index d3d67b55..8727680b 100644
--- a/ui/src/App.vue
+++ b/ui/src/App.vue
@@ -254,6 +254,11 @@ export default {
break
}
}
+ // store the notification settings in localStorage
+ const dashboard = payload.dashboards[Object.keys(payload.dashboards)[0]]
+ localStorage.setItem('ndrb-show-reconnect-notification', JSON.stringify(dashboard.showReconnectNotification))
+ localStorage.setItem('ndrb-reconnect-notification-delay', JSON.stringify(dashboard.reconnectNotificationDelay))
+ localStorage.setItem('ndrb-show-disconnect-notification', JSON.stringify(dashboard.showDisconnectNotification))
})
},
methods: {
diff --git a/ui/src/main.mjs b/ui/src/main.mjs
index 9a5b4bf4..ffc2036f 100644
--- a/ui/src/main.mjs
+++ b/ui/src/main.mjs
@@ -139,6 +139,11 @@ fetch('_setup')
store.commit('setup/set', setup)
+ // retrieve the notification settings from localStorage
+ const showReconnectNotification = JSON.parse(localStorage.getItem('ndrb-show-reconnect-notification')) ?? true
+ const reconnectNotificationDelay = JSON.parse(localStorage.getItem('ndrb-reconnect-notification-delay')) ?? 2
+ const showDisconnectNotification = JSON.parse(localStorage.getItem('ndrb-show-disconnect-notification')) ?? true
+
let disconnected = false
let retryCount = 0 // number of reconnection attempts made
@@ -157,12 +162,15 @@ fetch('_setup')
retryCount = 0
disconnected = true
}
- // tell the user we're trying to connect
- Alerts.emit('Connection Lost', 'Attempting to reconnect to server...', 'red', {
- displayTime: 0, // displayTime 0 persists notifications until another notification closes it
- allowDismiss: false,
- showCountdown: false
- })
+
+ if (showDisconnectNotification) {
+ // tell the user we're trying to connect
+ Alerts.emit('Connection Lost', 'Attempting to reconnect to server...', 'red', {
+ displayTime: 0, // displayTime 0 persists notifications until another notification closes it
+ allowDismiss: false,
+ showCountdown: false
+ })
+ }
// attempt to reconnect
reconnect()
})
@@ -171,12 +179,21 @@ fetch('_setup')
console.log('SIO connected')
// if we've just disconnected (i.e. aren't connecting for the first time)
if (disconnected) {
+ if (showReconnectNotification) {
// send a notification/alert to the user to let them know the connection is live again
- Alerts.emit('Connected', 'Connection re-established.', '#1BC318', {
- displayTime: 1,
- allowDismiss: true,
- showCountdown: true
- })
+ Alerts.emit('Connected', 'Connection re-established.', '#1BC318', {
+ displayTime: reconnectNotificationDelay,
+ allowDismiss: true,
+ showCountdown: true
+ })
+ } else {
+ //, send a notification for 1 ms to close the disconnected notification
+ Alerts.emit('Connected', 'Connection re-established.', '#1BC318', {
+ displayTime: 0.001, // 1 ms
+ allowDismiss: false,
+ showCountdown: false
+ })
+ }
}
disconnected = false
clearTimeout(reconnectTO)