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.
master
Javier Hernandez 2024-01-22 12:21:39 +01:00 committed by OpenGnSys Support Team
parent 4060b64612
commit ef46aa0599
1 changed files with 11 additions and 1 deletions

View File

@ -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())