mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
A New volume form the pool page refused, for a name with a space or a character not allowed, redirected back with the reasons at the top of the page and lost what was typed. The form now posts to the pool page itself: a valid one makes the volume and redirects as before, a refused one renders the page with the dialog open on what was entered, the refused field marked with its reason and focused. A pool stopped meanwhile has no dialog: its page shows the reasons. The separate create_volume view and URL go.
72 lines
4.7 KiB
HTML
72 lines
4.7 KiB
HTML
{% load i18n %}
|
|
{% load django_bootstrap5 %}
|
|
{% load bootstrap_icons %}
|
|
{% if request.user.is_superuser %}
|
|
{% if state != 0 %}
|
|
{% if pool == "iso" %}
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#IsoUpload">
|
|
<span aria-hidden="true">{% bs_icon 'upload' %}</span> {% trans "Upload ISO" %}
|
|
</button>
|
|
|
|
<div class="modal fade" id="IsoUpload" tabindex="-1" role="dialog" aria-labelledby="IsoUploadLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="IsoUploadLabel">{% trans "Upload ISO Image" %}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
|
</div>
|
|
<form id="isoUploadForm" enctype="multipart/form-data" method="post" aria-label="{% trans "Upload iso form" %}">{% csrf_token %}
|
|
<div class="modal-body">
|
|
<label for="id_file" class="form-label">{% trans "ISO file" %}</label>
|
|
<input type="file" name="file" id="id_file" class="form-control" accept=".iso" required aria-describedby="id_file_help">
|
|
<div class="form-text" id="id_file_help">{% trans "The browser sends it: keep the page open until the upload ends." %}</div>
|
|
<div id="upload-status" class="d-none align-items-center gap-2 text-primary mt-3" role="status" aria-live="polite">
|
|
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
|
|
<span id="upload-status-text">{% trans "Starting upload..." %}</span>
|
|
</div>
|
|
<div id="upload-error-message" class="alert alert-danger mt-3 d-none"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<input type="hidden" name="iso_upload" value="true">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
|
<button type="submit" class="btn btn-primary">{% trans "Upload" %}</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div> <!-- /.modal-content -->
|
|
</div> <!-- /.modal-dialog -->
|
|
</div> <!-- /.modal -->
|
|
{% else %}
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#AddImage">
|
|
<span aria-hidden="true">{% bs_icon 'plus-lg' %}</span> {% trans "New volume" %}
|
|
</button>
|
|
|
|
<div class="modal fade" id="AddImage" tabindex="-1" role="dialog" aria-labelledby="AddImageLabel" aria-hidden="true"
|
|
{% if form.errors %}data-open{% endif %}>
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="AddImageLabel">{% trans "New volume" %}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="create-volume" method="post" aria-label="{% trans "Create volume to storage form" %}">
|
|
{% csrf_token %}
|
|
<div class="row">
|
|
<div class="col-12">{% bootstrap_field form.name %}</div>
|
|
<div class="col-sm-6">{% bootstrap_field form.size %}</div>
|
|
<div class="col-sm-6">{% bootstrap_field form.format %}</div>
|
|
<div class="col-12">{% bootstrap_field form.meta_prealloc %}</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
|
<button type="submit" form="create-volume" class="btn btn-primary" name="create_volume">{% trans "Create" %}</button>
|
|
</div>
|
|
</div> <!-- /.modal-content -->
|
|
</div> <!-- /.modal-dialog -->
|
|
</div> <!-- /.modal -->
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|