alarm clear on disconnect
This commit is contained in:
@@ -190,7 +190,7 @@
|
||||
<div id="machines-grid"></div>
|
||||
</div>
|
||||
|
||||
<div id="status-bar">WS: 0 / 0</div>
|
||||
<!-- <div id="status-bar">WS: 0 / 0</div> -->
|
||||
|
||||
<script>
|
||||
const MACHINES = [
|
||||
@@ -239,7 +239,7 @@ function connect(id) {
|
||||
ws.onmessage = (ev) => {
|
||||
try {
|
||||
const msg = JSON.parse(ev.data);
|
||||
if (msg.type === "machine_update" && msg.data) {
|
||||
if (msg.data) {
|
||||
machineData[id] = { ...msg.data, _ts: msg.timestamp };
|
||||
updateDisplay();
|
||||
}
|
||||
@@ -253,6 +253,11 @@ function connect(id) {
|
||||
|
||||
ws.onclose = () => {
|
||||
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();
|
||||
setTimeout(() => connect(id), RECONNECT_MS);
|
||||
};
|
||||
@@ -305,7 +310,7 @@ function renderCards(alarms) {
|
||||
card.className = "machine-card";
|
||||
card.innerHTML = `
|
||||
<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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user