alarm clear on disconnect
This commit is contained in:
@@ -190,7 +190,7 @@
|
|||||||
<div id="machines-grid"></div>
|
<div id="machines-grid"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="status-bar">WS: 0 / 0</div>
|
<!-- <div id="status-bar">WS: 0 / 0</div> -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const MACHINES = [
|
const MACHINES = [
|
||||||
@@ -239,7 +239,7 @@ function connect(id) {
|
|||||||
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();
|
||||||
}
|
}
|
||||||
@@ -253,6 +253,11 @@ function connect(id) {
|
|||||||
|
|
||||||
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);
|
||||||
};
|
};
|
||||||
@@ -305,7 +310,7 @@ function renderCards(alarms) {
|
|||||||
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