a bit more ui

This commit is contained in:
Michael Hudson-Doyle 2018-12-07 14:18:50 +13:00
parent ead723f474
commit f2d4e1ddc9
4 changed files with 26 additions and 5 deletions

View File

@ -108,7 +108,7 @@ class SSHController(BaseController):
def done(self, result):
log.debug("SSHController result %s", result)
self.model.install_server = result['install_server']
self.model.authorized_keys = result['authorized_keys']
self.model.authorized_keys = result.get('authorized_keys', [])
self.model.pwauth = result['pwauth']
self.signal.emit_signal('installprogress:identity-config-done')
self.signal.emit_signal('next-screen')

View File

@ -25,3 +25,7 @@ class SSHModel:
self.install_server = False
self.authorized_keys = None
self.pwauth = True
# Although the generated config just contains the key above,
# we store the imported id so that we can re-fill the form if
# we go back to it.
self.ssh_import_id = None

View File

@ -148,8 +148,9 @@ class IdentityForm(Form):
class IdentityView(BaseView):
title = _("Profile setup")
excerpt = _("Enter the username and password (or ssh identity) you "
"will use to log in to the system.")
excerpt = _("Enter the username and password you will use to log in to the "
"system. You can configure SSH access on the next screen but a "
"password is still needed for sudo.")
def __init__(self, model, controller):
self.model = model

View File

@ -89,7 +89,7 @@ _ssh_import_data = {
class SSHForm(Form):
install = BooleanField(_("Install OpenSSH server"))
install_server = BooleanField(_("Install OpenSSH server"))
ssh_import_id = ChoiceField(
_("Import SSH identity:"),
@ -106,6 +106,21 @@ class SSHForm(Form):
cancel_label = _("Back")
def __init__(self, initial):
super().__init__(initial=initial)
connect_signal(self.install_server.widget, 'change', self._toggle_server)
self._toggle_server(None, self.install_server.value)
def _toggle_server(self, sender, new_value):
if new_value:
self.ssh_import_id.enabled = True
self.import_username.enabled = self.ssh_import_id.value is not None
self.pwauth.enabled = self.ssh_import_id.value is not None
else:
self.ssh_import_id.enabled = False
self.import_username.enabled = False
self.pwauth.enabled = False
# validation of the import username does not read from
# ssh_import_id.value because it is sometimes done from the
# 'select' signal of the import id selector, which is called
@ -229,7 +244,7 @@ class SSHView(BaseView):
self.model = model
self.controller = controller
self.form = SSHForm(initial={"install": self.model.install_server})
self.form = SSHForm(initial={"install": self.model.install_server, "pwauth": self.model.pwauth})
connect_signal(self.form.ssh_import_id.widget, 'select',
self._select_ssh_import_id)
@ -253,6 +268,7 @@ class SSHView(BaseView):
iu.widget.valid_char_pat = data['valid_char']
iu.widget.error_invalid_char = _(data['error_invalid_char'])
iu.enabled = val is not None
self.form.pwauth.enabled = val is not None
if val is not None:
self.form_rows.base_widget.body.focus += 2
self.form.ssh_import_id_value = val