1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(instances): a dependent list on the create pages shows only the latest choice

The machine types, volumes, templates and disk buses load when their
parent changes. A slow answer for an earlier choice could arrive last and
fill the list for the newer one, and while a list loaded it still held
the previous choice's items, which could be submitted.

Each list now empties when its load starts, and a newer load aborts the
older request, so only the answer for the current choice fills it. Chosen
volumes stay: they are found by name in any pool.

Fixes #177

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-24 12:07:23 +03:00
parent 4f0ae3b30d
commit 49cf16ecbe
4 changed files with 56 additions and 10 deletions

View file

@ -70,12 +70,15 @@
{% endblock %}
{% block script %}
<script>
// the machine types of the chosen architecture, the default one selected
// the machine types of the chosen architecture, the default one selected;
// the list is empty while it loads, and a newer load aborts the older one
function load_machines(arch) {
const next = document.querySelector("#next");
const next = document.querySelector("#next"), list = document.querySelector("#select_chipset");
next.disabled = true;
$.getJSON("/computes/{{ compute_id }}/archs/" + encodeURIComponent(arch) + "/machines", function (data) {
document.querySelector("#select_chipset").replaceChildren(...data['machines'].map(
list.replaceChildren();
if (list.request) list.request.abort();
list.request = $.getJSON("/computes/{{ compute_id }}/archs/" + encodeURIComponent(arch) + "/machines", function (data) {
list.replaceChildren(...data['machines'].map(
item => new Option(item, item, false, item === "{{ default_machine|escapejs }}")));
next.disabled = !data['machines'].length;
});