mirror of https://git.48k.eu/ogcp
Make partition id non editable in partition form
Show the partition id as a non editable label in each partition of the Partition and Format form. Assign sequential partition id from top to down and recalculate every partition id when a partition is removed.master
parent
a04ef4e421
commit
6034ba2537
|
@ -30,8 +30,8 @@ class WOLForm(FlaskForm):
|
|||
submit = SubmitField(label=_l('Submit'))
|
||||
|
||||
class PartitionForm(FlaskForm):
|
||||
partition = SelectField(label=_l('Partition'),
|
||||
choices=range(1,10))
|
||||
partition = IntegerField(label=_l('Partition'),
|
||||
render_kw={'readonly': True})
|
||||
part_type = SelectField(label=_l('Type'),
|
||||
choices=[('LINUX', 'Linux'),
|
||||
('NTFS', 'NTFS'),
|
||||
|
|
|
@ -313,6 +313,8 @@ function AddPartition(evt) {
|
|||
const id = $(this).attr('id').replace(/(.*)-(\d{1,4})-(.*)/, `$1-${elem_num}-$3`);
|
||||
$(this).attr('name', id).attr('id', id).val('').removeAttr("checked");
|
||||
});
|
||||
let part_field = row.find('td').filter(':first')[0];
|
||||
part_field.innerText = elem_num + 1;
|
||||
row.show();
|
||||
oldrow.after(row);
|
||||
}
|
||||
|
@ -329,6 +331,9 @@ function RemovePartition(evt) {
|
|||
const id = $(this).attr('id').replace(/(.*)-(\d{1,4})-(.*)/, `$1-${index}-$3`);
|
||||
$(this).attr('name', id).attr('id', id);
|
||||
}
|
||||
|
||||
let part_field = $(this).find('td').filter(':first')[0];
|
||||
part_field.innerText = index + 1;
|
||||
$(this).find('input').filter(':first').each(update_references);
|
||||
$(this).find('.form-control').each(update_references);
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
{% for partition in form.partitions %}
|
||||
<tr data-toggle="fieldset-entry">
|
||||
{{ partition.hidden_tag() }}
|
||||
<td>{{ partition.partition(class_="form-control") }}</td>
|
||||
<td>{{ partition.partition.data }}</td>
|
||||
<td>{{ partition.part_type(class_="form-control") }}</td>
|
||||
<td>{{ partition.fs(class_="form-control") }}</td>
|
||||
<td>{{ partition.size(class_="form-control") }}</td>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<!-- ChartJS -->
|
||||
<script src="{{ url_for('static', filename='AdminLTE/plugins/chart.js/Chart.min.js') }}"></script>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/ogcp.js') }}?v=2"></script>
|
||||
<script src="{{ url_for('static', filename='js/ogcp.js') }}?v=3"></script>
|
||||
|
||||
<script>
|
||||
// error messages
|
||||
|
|
|
@ -659,24 +659,24 @@ def action_setup_modify():
|
|||
'cache_size': str(0),
|
||||
'partition_setup': []}
|
||||
|
||||
required_partitions = ["1", "2", "3", "4"]
|
||||
partition_index = 0
|
||||
|
||||
for partition in form.partitions:
|
||||
print(partition)
|
||||
partition_setup = {'partition': str(partition.partition.data),
|
||||
partition_index += 1
|
||||
partition_setup = {'partition': str(partition_index),
|
||||
'code': str(partition.part_type.data),
|
||||
'filesystem': str(partition.fs.data),
|
||||
'size': str(partition.size.data * 1024),
|
||||
'format': str(int(partition.format_partition.data))}
|
||||
payload['partition_setup'].append(partition_setup)
|
||||
if partition.partition.data in required_partitions:
|
||||
required_partitions.remove(partition.partition.data)
|
||||
|
||||
if partition.part_type.data == 'CACHE':
|
||||
payload['cache'] = '1'
|
||||
payload['cache_size'] = str(partition.size.data * 1024)
|
||||
|
||||
for partition in required_partitions:
|
||||
for partition_index in range(len(form.partitions) + 1, 5):
|
||||
empty_part = {
|
||||
'partition': partition,
|
||||
'partition': str(partition_index),
|
||||
'code': 'EMPTY',
|
||||
'filesystem': 'EMPTY',
|
||||
'size': '0',
|
||||
|
|
Loading…
Reference in New Issue