summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-08-24 17:01:27 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:36 +0200
commitc543ba25a642ebecd1955ad8c1d2c03ad3b3a7f1 (patch)
tree26e9355f578c99b1dad7a4e9d3743eb6f35e863e
parent873bee30aa9c6385420741fb23615cf5d20daffb (diff)
Adapt images tree to work with several ogServers
Images view fetch images from all ogServers configured and show them in the left tree as a nested list. ogServers are represented as the parents of their images.
-rw-r--r--ogcp/templates/images.html22
-rw-r--r--ogcp/views.py13
2 files changed, 20 insertions, 15 deletions
diff --git a/ogcp/templates/images.html b/ogcp/templates/images.html
index 7ef1efc..4231df2 100644
--- a/ogcp/templates/images.html
+++ b/ogcp/templates/images.html
@@ -11,14 +11,20 @@
{% endblock %}
{% block sidebar %}
- <ul id="images" class="nav flex-column nav-pills">
- {% for image in images %}
- <li id="{{ image["name"] }}_{{ image["id"] }}" class="nav-item">
- <input class="form-check-input" type="checkbox" form="imagesForm"
- value="{{ image["id"] }}"
- {% if image.get("selected", False) %}checked{% endif %}
- name="{{ image["name"] }}_{{ image["id"] }}" />
- {{ image["name"] }}
+ <ul id="servers" class="nav flex-column nav-pills">
+ {% for response in responses %}
+ <li class="nav-item"><b>{{ response["server"]["name"] }}</b>
+ <ul id="images" class="nav flex-column nav-pills">
+ {% for image in response["json"]["images"] %}
+ <li id="{{ image["name"] }}_{{ image["id"] }}" class="nav-item">
+ <input class="form-check-input" type="checkbox" form="imagesForm"
+ value="{{ image["id"] }}"
+ {% if image.get("selected", False) %}checked{% endif %}
+ name="{{ image["name"] }}_{{ image["id"] }}" />
+ {{ image["name"] }}
+ </li>
+ {% endfor %}
+ </ul>
</li>
{% endfor %}
</ul>
diff --git a/ogcp/views.py b/ogcp/views.py
index 316bcf1..3b0d134 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1377,9 +1377,8 @@ def commands():
@app.route('/images/', methods=['GET'])
@login_required
def images():
- r = g.server.get('/images')
- images = r.json()['images']
- return render_template('images.html', images=images)
+ responses = multi_request('get', '/images')
+ return render_template('images.html', responses=responses)
@app.route('/repositories/', methods=['GET'])
@@ -1645,10 +1644,10 @@ def action_image_info():
form.permissions.data = image['permissions']
form.software_id.data = image['software_id']
- images = g.server.get('/images').json()['images']
+ responses = multi_request('get', '/images')
return render_template('actions/image_details.html', form=form,
- images=images)
+ responses=responses)
@app.route('/action/image/delete', methods=['GET', 'POST'])
@login_required
@@ -1671,14 +1670,14 @@ def action_image_delete():
if not validate_elements(images, max_len=1):
return redirect(url_for('images'))
image_name, image_id = images[0]
- r = g.server.get('/images')
+ responses = multi_request('get', '/images')
form.ids.data = image_id
if not validate_elements(images, max_len=1):
flash(_('Please select one image to delete'), category='error')
return redirect(url_for('images'))
return render_template('actions/delete_image.html', form=form,
image_name=image_name.split('_', 1)[0], image_id=image_id,
- images=r.json()['images'])
+ responses=responses)
@app.route('/action/log', methods=['GET'])
@login_required