mirror of https://git.48k.eu/ogcp
Add list images action
Add list images action that shows a list of all the images in each server and their propertiesmaster
parent
5892d5c8c3
commit
556e06cc3d
|
@ -0,0 +1,41 @@
|
|||
{% extends 'images.html' %}
|
||||
{% import "bootstrap/wtf.html" as wtf %}
|
||||
|
||||
{% set btn_back = true %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1 class="m-5">{{_('List images')}}</h1>
|
||||
{% for r in responses %}
|
||||
{% set server = r['server']['name']%}
|
||||
{% set repos = r['repos'] %}
|
||||
{% for repo in repos.values() %}
|
||||
{% set repo_name = repo['name'] %}
|
||||
{% set images = repo['images'] %}
|
||||
{% if images %}
|
||||
{{ repo_name }} ({{ server }})
|
||||
<table class="table table-hover">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Size (MiB)</th>
|
||||
<th>Datasize (MiB)</th>
|
||||
<th>Last update</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-left">
|
||||
{% for img in images %}
|
||||
<tr>
|
||||
<th>{{img['name']}}</th>
|
||||
<td>{{img['size'] / 1024 ** 2}}</td>
|
||||
<td>{{img['datasize'] / 1024 ** 2}}</td>
|
||||
<td>{{img['modified']}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
|
@ -60,6 +60,8 @@
|
|||
{% block commands %}
|
||||
<input class="btn btn-light" type="submit" value="{{ _('Image details') }}"
|
||||
form="imagesForm" formaction="{{ url_for('action_image_info') }}" formmethod="get">
|
||||
<input class="btn btn-light" type="submit" value="{{ _('List images') }}"
|
||||
form="imagesForm" formaction="{{ url_for('action_image_list') }}" formmethod="get">
|
||||
<input class="btn btn-light" type="submit" value="{{ _('Delete image') }}"
|
||||
form="imagesForm" formaction="{{ url_for('action_image_delete') }}" formmethod="get">
|
||||
{% if btn_back %}
|
||||
|
|
|
@ -2504,6 +2504,31 @@ def user_delete_get():
|
|||
return render_template('auth/delete_user.html', form=form)
|
||||
|
||||
|
||||
@app.route('/action/image/list', methods=['GET'])
|
||||
@login_required
|
||||
def action_image_list():
|
||||
params = request.args.to_dict()
|
||||
ids = parse_elements(params)
|
||||
server = get_server_from_ip_port(params['image-server'])
|
||||
r = server.get('/images')
|
||||
if not r:
|
||||
return ogserver_down('images')
|
||||
if r.status_code != requests.codes.ok:
|
||||
return ogserver_error('images')
|
||||
tmp = r.json()['images']
|
||||
images = []
|
||||
for img in tmp:
|
||||
if img['id'] in ids:
|
||||
images.append(img)
|
||||
try:
|
||||
images = get_images_grouped_by_repos()
|
||||
except ServerError:
|
||||
return ogserver_down('images')
|
||||
except ServerErrorCode:
|
||||
return ogserver_error('images')
|
||||
return render_template('actions/list_images.html',
|
||||
responses=images)
|
||||
|
||||
@app.route('/user/delete', methods=['POST'])
|
||||
@login_required
|
||||
def user_delete_post():
|
||||
|
|
Loading…
Reference in New Issue