From 3d26e5837a46a11b17b5b0085a8288dcf687f1e9 Mon Sep 17 00:00:00 2001 From: Emerson Felipe Date: Wed, 16 Oct 2024 12:34:04 +0000 Subject: [PATCH] Add WebSocket verification and inform on GUI in case of failure. --- .../templates/netbox_proxbox/home.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/netbox_proxbox/templates/netbox_proxbox/home.html b/netbox_proxbox/templates/netbox_proxbox/home.html index 2830283..0887164 100755 --- a/netbox_proxbox/templates/netbox_proxbox/home.html +++ b/netbox_proxbox/templates/netbox_proxbox/home.html @@ -28,6 +28,20 @@ }; + ws.onerror = function(error) { + console.log("WebSocket error observed: ", error); + + fullUpdateButton = document.getElementById('full-update-button') + fullUpdateButton.className = "btn btn-red" + + fullUpdateMessage = document.getElementById('full-update-error-message') + fullUpdateMessage.className = "text-red" + fullUpdateMessage.innerHTML = ` +

+ WebSocket communication failed with ${error.currentTarget.url} +
The most probably cause is Proxbox Backend not running properly. +

` + } function sendMessage(event) { // Send Websocket Message @@ -151,11 +165,12 @@
+
{# Full Update Button#}
{% if perms.netbox_proxbox.add_proxmoxvm %} - + {% endif %}