Compare commits
2 Commits
7cf063431d
...
b0a66ed982
| Author | SHA1 | Date | |
|---|---|---|---|
| b0a66ed982 | |||
| 7171e5ea09 |
@@ -303,7 +303,7 @@
|
|||||||
ws.onmessage = (ev) => {
|
ws.onmessage = (ev) => {
|
||||||
try {
|
try {
|
||||||
const msg = JSON.parse(ev.data);
|
const msg = JSON.parse(ev.data);
|
||||||
if (msg.type === "machine_update" && msg.data) {
|
if (msg.data) {
|
||||||
machineData[id] = { ...msg.data, _ts: msg.timestamp };
|
machineData[id] = { ...msg.data, _ts: msg.timestamp };
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
@@ -319,10 +319,15 @@
|
|||||||
|
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
wsStatus[id] = "disconnected";
|
wsStatus[id] = "disconnected";
|
||||||
|
// Usuwamy dane maszyny przy rozłączeniu – nie możemy potwierdzić
|
||||||
|
// aktualnego stanu, więc nie trzymamy przestarzałego alarmu w cache.
|
||||||
|
// Po ponownym połączeniu serwer wyśle aktualny stan.
|
||||||
|
delete machineData[id];
|
||||||
|
updateDisplay();
|
||||||
refreshStatus();
|
refreshStatus();
|
||||||
setTimeout(() => connect(id), RECONNECT_MS);
|
setTimeout(() => connect(id), RECONNECT_MS);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Display logic ─────────────────────────────────────────────────────────
|
// ── Display logic ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -373,7 +378,7 @@
|
|||||||
card.className = "machine-card";
|
card.className = "machine-card";
|
||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<div class="card-machine-id">${d.machine ?? id}</div>
|
<div class="card-machine-id">${d.machine ?? id}</div>
|
||||||
<!--- <div class="card-status">${d.status ?? "ALARM"}</div> -->
|
<!-- <div class="card-status">${d.status ?? "ALARM"}</div> -->
|
||||||
`;
|
`;
|
||||||
grid.appendChild(card);
|
grid.appendChild(card);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user