diff --git a/plugins/dynamix.vm.manager/templates/Custom.form.php b/plugins/dynamix.vm.manager/templates/Custom.form.php
index 63d1f4135..5ce06d50d 100644
--- a/plugins/dynamix.vm.manager/templates/Custom.form.php
+++ b/plugins/dynamix.vm.manager/templates/Custom.form.php
@@ -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('');
+ var gpu = $(this).val();
+ if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('');
});
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");
diff --git a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php
index 3b773be18..3f80cc774 100644
--- a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php
+++ b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php
@@ -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('');
+ var gpu = $(this).val();
+ if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('');
});
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");
diff --git a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php
index 10a1a1810..df990c973 100644
--- a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php
+++ b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php
@@ -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('');
+ var gpu = $(this).val();
+ if (gpu != 'vnc' && !gpus.includes(gpu)) $('form#vmform').append('');
});
var postdata = $button.closest('form').find('input,select').serialize().replace(/'/g,"%27");