VM edit: rebuild correctly graphic cards

This commit is contained in:
bergware
2018-09-06 16:37:04 +02:00
parent 33f06df07c
commit 1767d00384
3 changed files with 24 additions and 6 deletions

View File

@@ -1431,9 +1431,15 @@ $(function() {
$button.closest('form').find('input[name="usb[]"],input[name="pci[]"]').each(function(){
if (!$(this).prop('checked')) $(this).prop('checked',true).val($(this).val()+'#remove');
});
// remove graphic cards for automatic rebuild
// remove unused graphic cards
var gpus = [], i = 0;
do {
var gpu = $button.closest('form').find('select[name="gpu['+(i++)+'][id]"] option:selected').val();
if (gpu) gpus.push(gpu);
} while (gpu);
$button.closest('form').find('select[name="gpu[0][id]"] option').each(function(){
if ($(this).val() != 'vnc') $('form#vmform').append('<input type="hidden" name="pci[]" value="'+$(this).val()+'#remove">');
var gpu = $(this).val();
if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
});
<?endif?>
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");

View File

@@ -1124,9 +1124,15 @@ $(function() {
$button.closest('form').find('input[name="usb[]"],input[name="pci[]"]').each(function(){
if (!$(this).prop('checked')) $(this).prop('checked',true).val($(this).val()+'#remove');
});
// remove graphic cards for automatic rebuild
// remove unused graphic cards
var gpus = [], i = 0;
do {
var gpu = $button.closest('form').find('select[name="gpu['+(i++)+'][id]"] option:selected').val();
if (gpu) gpus.push(gpu);
} while (gpu);
$button.closest('form').find('select[name="gpu[0][id]"] option').each(function(){
if ($(this).val() != 'vnc') $('form#vmform').append('<input type="hidden" name="pci[]" value="'+$(this).val()+'#remove">');
var gpu = $(this).val();
if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
});
<?endif?>
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");

View File

@@ -1126,9 +1126,15 @@ $(function() {
$button.closest('form').find('input[name="usb[]"],input[name="pci[]"]').each(function(){
if (!$(this).prop('checked')) $(this).prop('checked',true).val($(this).val()+'#remove');
});
// remove graphic cards for automatic rebuild
// remove unused graphic cards
var gpus = [], i = 0;
do {
var gpu = $button.closest('form').find('select[name="gpu['+(i++)+'][id]"] option:selected').val();
if (gpu) gpus.push(gpu);
} while (gpu);
$button.closest('form').find('select[name="gpu[0][id]"] option').each(function(){
if ($(this).val() != 'vnc') $('form#vmform').append('<input type="hidden" name="pci[]" value="'+$(this).val()+'#remove">');
var gpu = $(this).val();
if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
});
<?endif?>
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");