From 3587806937f7fd1bf2af38f6a894be13f09666a3 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Thu, 21 Dec 2023 13:21:46 +0100 Subject: views: Allow to change boot mode in edit client Allow user to change boot mode when editing a client. First item selected is the client's current boot mode. This is so that if the user edits the client's data, but doesnt touch bootmode, it stays the same. --- ogcp/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index e745d7d..7336142 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -916,6 +916,7 @@ def action_client_update(): "remote": form.remote.data, "room": int(form.room.data), "name": form.name.data, + "boot": form.boot.data, "mac": form.mac.data } server = get_server_from_ip_port(form.server.data) r = server.post('/client/update', payload) @@ -938,7 +939,7 @@ def action_client_update(): r = server.get('/client/info', payload) db_client = r.json() - form.mac.render_kw = {'placeholder': 'aabbccddeeaa'} + form.mac.render_kw = {'readonly': True} form.server.data = "{0}:{1}".format(server.ip, server.port) form.ip.data = db_client['ip'] form.ip.render_kw = {'readonly': True} @@ -949,7 +950,13 @@ def action_client_update(): form.remote.data = db_client['remote'] form.maintenance.data = db_client['maintenance'] form.netiface.data = db_client['netiface'] - form.boot.render_kw = {'readonly': True} + + current_mode = db_client['boot'] + r = server.get('/mode') + available_modes = [(current_mode, current_mode)] + available_modes.extend([(mode, mode) for mode in r.json()['modes'] + if mode != current_mode]) + form.boot.choices = list(available_modes) r = server.get('/scopes') room_id = db_client['room'] -- cgit v1.2.3-18-g5258