mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
The VM page polls the VM's state every 5 s and reloads when it changes. When the host stopped answering, the poll failed and nothing changed on the page: it kept showing the last state, figures and actions as if they were current. A notice now says that the page could not be refreshed and may be out of date while the poll fails (a host that does not answer, a session that ended); it goes away with the next answer. Checked on compute1 in headless Chromium with its libvirt port dropped and restored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
17 lines
934 B
JavaScript
17 lines
934 B
JavaScript
// The VM page reloads when the VM's state changes (instance.html, #vm-summary).
|
|
backgroundJobRunning = false;
|
|
// not "status": that is window.status, which the browser may not keep
|
|
var vm_summary = document.getElementById("vm-summary");
|
|
var vm_status = Number(vm_summary.dataset.status);
|
|
var host_lost = document.getElementById("vm-host-lost");
|
|
var status_poll = pollWhileVisible(5000, function () {
|
|
// a failed read (a host that does not answer, a session that ended) leaves the
|
|
// page as it was: it says so until a read is answered
|
|
return $.getJSON(vm_summary.dataset.statusUrl).fail(function () { host_lost.hidden = false; });
|
|
}, function get_status(data) {
|
|
host_lost.hidden = true;
|
|
// the page in use (a dialog open, a field in use, an XML edit not saved): the reload waits (poll.js)
|
|
if (data['status'] != vm_status && !backgroundJobRunning && !pageInUse()) {
|
|
window.location.reload();
|
|
}
|
|
});
|