mirror of https://git.48k.eu/ogcp
templates: warn about image create/restore on disks other than 1
Show a warning when the user selects a partition from a disk >1 in the image update, create or restore views. Show the complete list of valid partitions from all disk.master
parent
b2aa0e3dbb
commit
00be07352d
|
@ -12,6 +12,9 @@
|
|||
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{% set partition_field_id = 'os' %}
|
||||
{% include 'partition_warning.html' %}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_image_create'),
|
||||
method='post',
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{% set partition_field_id = 'partition' %}
|
||||
{% include 'partition_warning.html' %}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_image_restore'),
|
||||
method='post',
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{% set partition_field_id = 'os' %}
|
||||
{% include 'partition_warning.html' %}
|
||||
|
||||
<form class="form mx-5" method="POST" action="{{ url_for('action_image_update') }}">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<div class="mx-5" id="partition-warning" style="display:none; color:red; font-weight: bold;">
|
||||
{{ _('Warning: You have selected a partition from a disk other than 1. This will be considered for storage only.') }}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function checkPartition() {
|
||||
var partitionSelect = document.getElementById('{{ partition_field_id }}');
|
||||
var selectedValue = partitionSelect.value;
|
||||
var warningDiv = document.getElementById('partition-warning');
|
||||
|
||||
// Extract the disk_id
|
||||
var diskId = parseInt(selectedValue.split(' ')[0]);
|
||||
|
||||
if (diskId !== 1) {
|
||||
warningDiv.style.display = 'block';
|
||||
} else {
|
||||
warningDiv.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var partitionSelect = document.getElementById('{{ partition_field_id }}');
|
||||
if (partitionSelect) {
|
||||
partitionSelect.addEventListener('change', checkPartition);
|
||||
checkPartition();
|
||||
} else {
|
||||
console.error("Element with ID '{{ partition_field_id }}' not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -1084,8 +1084,6 @@ def action_image_restore():
|
|||
part_id = partition['partition']
|
||||
if part_id == 0: # This is the disk data, not a partition.
|
||||
continue
|
||||
if disk_id != 1:
|
||||
continue
|
||||
part_code = partition['code']
|
||||
part_type = PART_TYPE_CODES.get(int(part_code), 'UNKNOWN')
|
||||
|
||||
|
@ -2372,13 +2370,14 @@ def action_image_create():
|
|||
|
||||
invalid_part_types = get_invalid_image_partition_types()
|
||||
|
||||
for part in r.json()['partitions'][1:]:
|
||||
for part in r.json()['partitions']:
|
||||
part_type = PART_TYPE_CODES.get(int(part.get('code')), 'UNKNOWN')
|
||||
|
||||
if part_type in invalid_part_types:
|
||||
part_id = part['partition']
|
||||
if part_id == 0: # This is the disk data, not a partition.
|
||||
continue
|
||||
|
||||
if part.get('disk') != 1:
|
||||
if part_type in invalid_part_types:
|
||||
continue
|
||||
|
||||
form.os.choices.append(
|
||||
|
@ -2467,15 +2466,16 @@ def action_image_update():
|
|||
invalid_part_types = get_invalid_image_partition_types()
|
||||
|
||||
part_content = {}
|
||||
for part in r.json()['partitions'][1:]:
|
||||
for part in r.json()['partitions']:
|
||||
part_type = PART_TYPE_CODES.get(int(part.get('code')), 'UNKNOWN')
|
||||
|
||||
part_id = part['partition']
|
||||
if part_id == 0: # This is the disk data, not a partition.
|
||||
continue
|
||||
|
||||
if part_type in invalid_part_types:
|
||||
continue
|
||||
|
||||
if part.get('disk') != 1:
|
||||
continue
|
||||
|
||||
partition_value = f"{part.get('disk')} {part.get('partition')} {part.get('code')}"
|
||||
partition_text = f"Disk {part.get('disk')} | Partition {part.get('partition')} "
|
||||
f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')} "
|
||||
|
|
Loading…
Reference in New Issue