1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 20:26:48 +00:00

fix(instances): the VM page reloads only when the VM state changes

The VM page polls the VM state every 5 s and reloads when it differs
from the state the page was rendered with. Since the polling moved to
pollWhileVisible, that state was kept in a top-level "var status",
which is not a page variable but the browser's window.status. Where the
browser does not keep a value there, the poll compared the answer with
"" and reloaded the page every 5 s, back to its first tab.

The variable is now vm_status. A Node test runs the page's script with
a window.status that keeps nothing.
This commit is contained in:
catborise 2026-10-06 12:27:45 +03:00
parent c2fea2aa39
commit 490b337453
2 changed files with 34 additions and 2 deletions

View file

@ -652,11 +652,12 @@
</script>
<script>
backgroundJobRunning = false;
var status = {{ instance.status|lower }};
// not "status": that is window.status, which the browser may not keep
var vm_status = {{ instance.status|lower }};
var status_poll = pollWhileVisible(5000, function () {
return $.getJSON("{% url 'instances:status' instance.id %}");
}, function get_status(data) {
if (data['status'] != status && !backgroundJobRunning) {
if (data['status'] != vm_status && !backgroundJobRunning) {
window.location.reload()
}
});