|
@@ -8,6 +8,8 @@ const modalGrid = document.getElementById("service-modal-grid");
|
|
|
const services = new Map();
|
|
const services = new Map();
|
|
|
const tiles = new Map();
|
|
const tiles = new Map();
|
|
|
let openServiceName = "";
|
|
let openServiceName = "";
|
|
|
|
|
+let socket = null;
|
|
|
|
|
+let reconnectTimer = 0;
|
|
|
|
|
|
|
|
function formatTimestamp(value) {
|
|
function formatTimestamp(value) {
|
|
|
const date = new Date(value);
|
|
const date = new Date(value);
|
|
@@ -200,11 +202,25 @@ function upsertService(service) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function scheduleReconnect() {
|
|
|
|
|
+ if (reconnectTimer) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ reconnectTimer = window.setTimeout(function() {
|
|
|
|
|
+ reconnectTimer = 0;
|
|
|
|
|
+ connectWebSocket();
|
|
|
|
|
+ }, 2000);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function connectWebSocket() {
|
|
function connectWebSocket() {
|
|
|
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
|
- const socket = new WebSocket(protocol + "//" + window.location.host + "/ws");
|
|
|
|
|
|
|
+ socket = new WebSocket(protocol + "//" + window.location.host + "/ws");
|
|
|
|
|
|
|
|
socket.addEventListener("open", function() {
|
|
socket.addEventListener("open", function() {
|
|
|
|
|
+ loadInitialStatus().catch(function(error) {
|
|
|
|
|
+ console.error("Failed to reload status after websocket reconnect:", error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
socket.addEventListener("message", function(event) {
|
|
socket.addEventListener("message", function(event) {
|
|
@@ -216,7 +232,8 @@ function connectWebSocket() {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
socket.addEventListener("close", function() {
|
|
socket.addEventListener("close", function() {
|
|
|
- window.setTimeout(connectWebSocket, 2000);
|
|
|
|
|
|
|
+ socket = null;
|
|
|
|
|
+ scheduleReconnect();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
socket.addEventListener("error", function() {
|
|
socket.addEventListener("error", function() {
|