views: Preselect client's associated repo

Make the create-image menu preselect the repo of the selected client
master
Javier Hernandez 2023-12-15 11:35:30 +01:00 committed by OpenGnSys Support Team
parent 24aab951a8
commit a9d367e795
1 changed files with 6 additions and 1 deletions

View File

@ -1233,9 +1233,14 @@ def action_image_create():
f"| {PART_TYPE_CODES[part.get('code')]} "
f"{FS_CODES[part.get('filesystem')]}")
)
r = server.get('/client/info', payload={'client': list(ips)})
client_repo_id = r.json()['repo_id']
repositories = get_repositories(server)
form.repository.choices = [ (repo['id'], repo['name']) for repo in repositories
if client_repo_id == repo['id']]
for repo in repositories:
form.repository.choices.append((repo['id'], repo['name']))
if client_repo_id != repo['id']:
form.repository.choices.append((repo['id'], repo['name']))
scopes, clients = get_scopes(set(ips))
return render_template('actions/image_create.html', form=form,