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

refactor(console): a console's URL names its compute and VM

The console page is /console/<compute>/<uuid>/ with the view and display
options in the query. It was /console/?token=<compute>-<uuid>, a "token"
that was only the VM's address, parsed alongside a signed token that no
link ever sent. The list's console button takes the VM's UUID from the
database instead of asking libvirt for each row, and no longer defines a
global function per row.
This commit is contained in:
catborise 2026-10-26 20:28:14 +03:00
parent 1a6dcc3e54
commit f6d4886d1b
5 changed files with 48 additions and 102 deletions

View file

@ -59,16 +59,11 @@
{% endif %}
{% if "console" in actions %}
<button class="btn btn-sm btn-secondary" type="button" onclick='open_console("{{ instance.compute.id }}-{{ instance.get_uuid }}")'
<button class="btn btn-sm btn-secondary" type="button" data-url="{% url 'console' instance.compute_id instance.uuid %}"
onclick="window.open(this.dataset.url, '', 'width=850,height=650')"
title="{% trans "Console" %}">{% bs_icon 'eye-fill' %}</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" title="{% trans "VNC Console" %}" disabled>{% bs_icon 'eye-fill' %}</button>
{% endif %}
</div>
<script>
function open_console(uuid) {
url = '{% url 'console' %}?token=' + uuid + '';
window.open(url, '', 'width=850,height=650')
}
</script>
{% endif %}

View file

@ -161,8 +161,8 @@
const vo = $("#view_only").is(':checked');
const rs = $("#resize_session").is(':checked');
const cv = $("#clip_viewport").is(':checked');
url = '{% url 'console' %}?token={{ compute.id }}-{{ instance.get_uuid }}&view=' + view_style + '' + '&view_only=' + vo + '' + '&scale=' + sc + '' + '&clip_viewport=' + cv + '' + '&resize_session=' + rs + '';
window.open(url, '', 'width=850,height=600')
const options = new URLSearchParams({view: view_style, view_only: vo, scale: sc, clip_viewport: cv, resize_session: rs});
window.open('{% url 'console' compute.id instance.uuid %}?' + options, '', 'width=850,height=600')
}
</script>
{% endif %}