summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2024-01-22 12:21:39 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-01-22 19:43:24 +0100
commitef46aa05998a7477c0aec5ff5e32bc613d113109 (patch)
treeee416e01ff8c41f2928911716588eac5b9c3f30b /ogcp/views.py
parent4060b64612c37a9606b5c072fa801e8faad35aa9 (diff)
views: Add client's name in action/setup/select
Show client's name (next to client's ip) in selectable in action/setup/select form.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index e3f1626..a0dface 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -503,7 +503,17 @@ def action_setup_select():
form = SelectClientForm()
form.ips.data = " ".join(ips)
- form.selected_client.choices = list(ips)
+
+ server = get_server_from_clients(list(ips))
+ client_choices = []
+ for ip in ips:
+ r = server.get('/client/info', payload={'client': [ip]})
+ if r.status_code != requests.codes.ok:
+ flash(('Cannot talk to ogserver. Is ogserver down?'), category='error')
+ return redirect(url_for('commands'))
+ client_name = r.json()['name']
+ client_choices.append((ip, f"{client_name} ({ip})"))
+ form.selected_client.choices = client_choices
scopes, _ = get_scopes(ips)
selected_clients = list(get_selected_clients(scopes['scope']).items())