asdasd
This commit is contained in:
@@ -53,4 +53,30 @@
|
||||
resetForm();
|
||||
});
|
||||
}
|
||||
|
||||
const updateStatus = (card, status) => {
|
||||
const dot = card.querySelector('[data-host-status]');
|
||||
if (!dot) return;
|
||||
dot.classList.remove('status-ok', 'status-auth', 'status-down');
|
||||
if (status === 'ok') dot.classList.add('status-ok');
|
||||
else if (status === 'down') dot.classList.add('status-down');
|
||||
else dot.classList.add('status-auth');
|
||||
};
|
||||
|
||||
const fetchStatus = (card) => {
|
||||
const id = card.dataset.hostId;
|
||||
if (!id) return;
|
||||
fetch(`${window.location.pathname}?status_json=1&id=${encodeURIComponent(id)}`, { cache: 'no-store' })
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (data && data.ok) {
|
||||
updateStatus(card, data.status);
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
document.querySelectorAll('.host-card').forEach((card) => {
|
||||
fetchStatus(card);
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user