summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2021-09-03 14:51:15 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2021-09-03 14:51:15 +0200
commitda9b2ea9c2ef37eb191ba0a9e78e62ce942dc912 (patch)
tree6e54487fc3ab2fb028402c8d84c06efe82caccc9 /ogcp/views.py
parentd83e456daf20e070a3eee51d885166566177c369 (diff)
Add image details action
This action is used to visualize the specific details of an image, as its ID, name, size, etc.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 3e80120..11e3693 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -9,7 +9,7 @@ from flask import (
g, render_template, url_for, flash, redirect, request, jsonify, make_response
)
from ogcp.forms.action_forms import (
- WOLForm, SetupForm, ClientDetailsForm, HardwareForm,
+ WOLForm, SetupForm, ClientDetailsForm, ImageDetailsForm, HardwareForm,
SessionForm, ImageRestoreForm, ImageCreateForm, SoftwareForm, BootModeForm,
RoomForm, DeleteRoomForm, CenterForm, DeleteCenterForm
)
@@ -774,3 +774,27 @@ def images():
r = g.server.get('/images')
images = r.json()['images']
return render_template('images.html', images=images)
+
+@app.route('/action/image/info', methods=['GET'])
+@login_required
+def action_image_info():
+ form = ImageDetailsForm()
+ ids = parse_elements(request.args.to_dict())
+ if not validate_elements(ids, max_len=1):
+ return redirect(url_for('images'))
+
+ id = ids.pop()
+ r = g.server.get('/images')
+ images = r.json()['images']
+ image = next(img for img in images if img['id'] == int(id))
+
+ form.id.data = image['id']
+ form.name.data = image['name']
+ # Bytes to Gibibytes
+ form.size.data = image['size'] / 1024 ** 3
+ form.datasize.data = image['datasize'] / 1024 ** 3
+ form.modified.data = image['modified']
+ form.permissions.data = image['permissions']
+ form.software_id.data = image['software_id']
+
+ return render_template('actions/image_details.html', form=form)