diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index b008673..406de44 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1479,10 +1479,34 @@ def commands(): scopes, clients = get_scopes() return render_template('commands.html', scopes=scopes, clients=clients) +def get_images_grouped_by_repos(): + responses = multi_request('get', '/images') + servers=[] + for resp in responses: + server={} + server['server'] = resp['server'] + images=resp['json']['images'] + all_repos=get_repositories(resp['server']) + repos={} + for image in images: + repo_id=image['repo_id'] + repo_data={} + if repo_id not in repos: + repo_name = [repo['name'] for repo in all_repos + if repo_id == repo['id']][0] + repos[repo_id] = {} + repos[repo_id]['name'] = repo_name + repos[repo_id]['images'] = [image] + else: + repos[repo_id]['images'].append(image) + server['repos'] = repos + servers.append(server) + return servers + @app.route('/images/', methods=['GET']) @login_required def images(): - responses = multi_request('get', '/images') + responses = get_images_grouped_by_repos() return render_template('images.html', responses=responses) @@ -1942,7 +1966,7 @@ def action_image_info(): form.software_id.data = image['software_id'] form.description.data = image['description'] - responses = multi_request('get', '/images') + responses = get_images_grouped_by_repos() return render_template('actions/image_details.html', form=form, responses=responses) @@ -1972,7 +1996,7 @@ def action_image_delete(): return redirect(url_for('images')) image_name, image_id = images[0] server = get_server_from_ip_port(params['image-server']) - responses = multi_request('get', '/images') + responses = get_images_grouped_by_repos() form.ids.data = image_id form.server.data = params['image-server'] if not validate_elements(images, max_len=1): |