mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
fix(console): small console settings and page fixes
- The VM's console settings have no "Clear keymap" box: it wrote an empty keymap attribute into the VM, and choosing Auto already removes the keymap; that change is logged as "remove console keymap". - The "Clip viewport" switch was labelled "View Clipboard". - The full console page no longer fills the password field with "None" for a VM without a console password.
This commit is contained in:
parent
a0b203749a
commit
c169ccf5fe
5 changed files with 17 additions and 6 deletions
|
|
@ -345,7 +345,7 @@
|
|||
<div id="noVNC_password_block">
|
||||
<label for="noVNC_password_input">{% trans 'Password' %}:</label>
|
||||
{% if perms.instances.passwordless_console %}
|
||||
<input id="noVNC_password_input" type="password" value="{{ console_passwd }}">
|
||||
<input id="noVNC_password_input" type="password" value="{{ console_passwd|default_if_none:"" }}">
|
||||
{% else %}
|
||||
<input id="noVNC_password_input" type="password">
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class ConsoleForm(forms.Form):
|
|||
widget=forms.PasswordInput(render_value=True),
|
||||
required=False
|
||||
)
|
||||
clear_keymap = forms.BooleanField(label=_("Clear keymap"), required=False)
|
||||
keymap = forms.ChoiceField(label=_("Keymap"), required=False)
|
||||
|
||||
def __init__(self, *args, instance, can_set_listener, **kwargs):
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
<input class="form-check-input" type="checkbox" name="clip_viewport"
|
||||
{% if app_settings.CONSOLE_CLIP_VIEWPORT == 'True' %} checked {% endif %}
|
||||
id="clip_viewport">
|
||||
<label class="form-check-label" for="clip_viewport">{% trans "View Clipboard" %}</label>
|
||||
<label class="form-check-label" for="clip_viewport">{% trans "Clip viewport" %}</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if instance.status == 1 %}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,17 @@ class VMRowTests(TestCase):
|
|||
self.assertEqual(self.rows(), [("VM vm: set console keymap de", True),
|
||||
("VM vm: set console listen address 0.0.0.0", True)])
|
||||
|
||||
def test_auto_removes_the_keymap(self):
|
||||
# no "Clear keymap" box: Auto removes it, never writes an empty keymap
|
||||
self.proxy.get_console_type.return_value = "vnc"
|
||||
self.proxy.get_console_listener_addr.return_value = "127.0.0.1"
|
||||
self.proxy.get_console_passwd.return_value = ""
|
||||
self.proxy.get_console_keymap.return_value = "de"
|
||||
self.proxy.set_console_keymap.return_value = None
|
||||
self.post("update_console", {"listen_on": "127.0.0.1", "keymap": "auto"})
|
||||
self.proxy.set_console_keymap.assert_called_once_with("auto")
|
||||
self.assertEqual(self.rows(), [("VM vm: remove console keymap", True)])
|
||||
|
||||
def test_a_console_save_logs_only_what_changed(self):
|
||||
# an address the form does not list stays: the select offers it
|
||||
self.proxy.get_console_type.return_value = "vnc"
|
||||
|
|
|
|||
|
|
@ -1979,10 +1979,11 @@ def update_console(request, pk):
|
|||
)
|
||||
messages.error(request, msg)
|
||||
|
||||
if "keymap" in form.changed_data or "clear_keymap" in form.changed_data:
|
||||
keymap = "" if form.cleaned_data["clear_keymap"] else form.cleaned_data["keymap"]
|
||||
if "keymap" in form.changed_data:
|
||||
# "auto" removes the keymap: the client's keys go through as they are
|
||||
keymap = form.cleaned_data["keymap"]
|
||||
# False: no graphics device, nothing changed
|
||||
with audit_vm(request, instance, f"set console keymap {keymap}" if keymap else "remove console keymap") as entry:
|
||||
with audit_vm(request, instance, "remove console keymap" if keymap == "auto" else f"set console keymap {keymap}") as entry:
|
||||
entry.skip = instance.proxy.set_console_keymap(keymap) is False
|
||||
|
||||
if "listen_on" in form.changed_data:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue