mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
fix(instances): a VM list notices a change made while the page was read
The VM lists took the poll's first answer as what the page showed: a VM started or stopped between the page's read and that answer kept its old state and buttons until the next change. The page now carries the states read before its rows, and the poll compares its first answer with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
7dd68aaca4
commit
effe2a33f0
8 changed files with 29 additions and 18 deletions
|
|
@ -80,6 +80,8 @@ def index(request):
|
|||
|
||||
# a user who sees no hosts makes the panel read only those of their own VMs
|
||||
computes = _listed_computes(request.user, list(Compute.objects.all().order_by("name")))
|
||||
# read first: the poll's first answer then tells a change made while the page was read
|
||||
vm_states = utils.vm_states(request.user, computes)
|
||||
for compute in computes:
|
||||
refresh_instance_database(compute)
|
||||
|
||||
|
|
@ -109,7 +111,7 @@ def index(request):
|
|||
"reachable_computes": [c for c in computes if c.status is True and c.ram_usage is not None],
|
||||
"unreachable_computes": [c for c in computes if c.status is not True],
|
||||
"states": [label for label, _color in STATES.values()] + [UNKNOWN[0]],
|
||||
"states_url": reverse("instances:states")},
|
||||
"states_url": reverse("instances:states"), "vm_states": vm_states},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue