diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-07-05 10:34:27 +0200 |
---|---|---|
committer | lupoDharkael <izhe@hotmail.es> | 2024-07-09 09:52:21 +0200 |
commit | a88e5fed7dec1dd41b3feec0905f4c9925515665 (patch) | |
tree | dcb8501a95ae00451d20e4996a81852ef299f22c /ogcp/templates/actions/image_update.html | |
parent | f85f0771cd0acaa44fe812f36d08af141e0e663a (diff) |
ogcp: select images of selected partition in image/update
Select the image field value containing the restored image of the
partition selected by the user.
Create a dictionary where the key is the value= of the partition
field and the value is the id of the image restored in the
partition. Add each dictionary entry only only if the corresponding
image exists in the repository.
Pass the dictionary to the HTML template and convert it to JS.
Diffstat (limited to 'ogcp/templates/actions/image_update.html')
-rw-r--r-- | ogcp/templates/actions/image_update.html | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/ogcp/templates/actions/image_update.html b/ogcp/templates/actions/image_update.html index 361165a..352b0d0 100644 --- a/ogcp/templates/actions/image_update.html +++ b/ogcp/templates/actions/image_update.html @@ -13,10 +13,43 @@ {{ macros.cmd_selected_clients(selected_clients) }} -{{ wtf.quick_form(form, - action=url_for('action_image_update'), - method='post', - button_map={'update': 'primary'}, - extra_classes='mx-5') }} +<form class="form mx-5" method="POST" action="{{ url_for('action_image_update') }}"> + {{ form.hidden_tag() }} + + {{ form.ip }} + + <div class="form-group"> + {{ form.os.label(class="form-label") }} + {{ form.os(class="form-control", onchange="onPartitionClicked(this.value)") }} + </div> + + <div class="form-group"> + {{ form.image.label(class="form-label") }} + {{ form.image(class="form-control") }} + </div> + + <div class="form-group form-check"> + {{ form.backup(class="form-check-input") }} + {{ form.backup.label(class="form-check-label") }} + </div> + + <div class="form-group"> + {{ form.update(class="btn btn-primary") }} + </div> +</form> + +<script> + const partContent = {{ part_content|tojson|safe }}; + const imageField = document.querySelector('select[name="{{ form.image.name }}"]'); + const partField = document.querySelector('select[name="{{ form.os.name }}"]'); + + function onPartitionClicked(selectedValue) { + if (selectedValue in partContent) { + imageField.value = partContent[selectedValue] + } + } + + onPartitionClicked(partField.value) +</script> {% endblock %} |