mirror of https://git.48k.eu/ogcp
Add image details action
This action is used to visualize the specific details of an image, as its ID, name, size, etc.multi-ogserver
parent
d83e456daf
commit
da9b2ea9c2
|
@ -7,7 +7,7 @@
|
|||
|
||||
from wtforms import (
|
||||
Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
|
||||
StringField, RadioField, FormField, FieldList
|
||||
StringField, RadioField, FormField, FieldList, DecimalField
|
||||
)
|
||||
from wtforms.validators import InputRequired
|
||||
from flask_wtf import FlaskForm
|
||||
|
@ -143,3 +143,12 @@ class DeleteRoomForm(FlaskForm):
|
|||
room = SelectField(label=_('Room'),
|
||||
validators=[InputRequired()])
|
||||
submit = SubmitField(label=_('Submit'))
|
||||
|
||||
class ImageDetailsForm(FlaskForm):
|
||||
id = StringField(label=_('Id'))
|
||||
name = StringField(label=_('Name'))
|
||||
size = DecimalField(label=_('Size (GiB)'))
|
||||
datasize = DecimalField(label=_('Datasize (GiB)'))
|
||||
modified = StringField(label=_('Modified'))
|
||||
permissions = StringField(label=_('Permissions'))
|
||||
software_id = StringField(label=_('Software id'))
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'base.html' %}
|
||||
{% import "bootstrap/wtf.html" as wtf %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1 class="m-5">{{_('Image details')}}</h1>
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
method='post',
|
||||
button_map={'create': 'primary'},
|
||||
extra_classes="mx-5") }}
|
||||
|
||||
{% endblock %}
|
|
@ -25,5 +25,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block commands %}
|
||||
<input class="btn btn-light" type="submit" value="{{ _('Image details') }}"
|
||||
form="imagesForm" formaction="{{ url_for('action_image_info') }}" formmethod="get">
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue