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:
parent
c2fea2aa39
commit
490b337453
2 changed files with 34 additions and 2 deletions
|
|
@ -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()
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue