Merge pull request #1752 from SimonFair/WebUI

Add nogpu option.
This commit is contained in:
tom mortensen
2024-06-04 14:18:35 -07:00
committed by GitHub
5 changed files with 22 additions and 10 deletions

View File

@@ -94,6 +94,7 @@ foreach ($vms as $vm) {
if (!empty($arrConfig['gpu'])) {
$arrValidGPUDevices = getValidGPUDevices();
foreach ($arrConfig['gpu'] as $arrGPU) {
if ($arrGPU['id'] == "nogpu") {$graphics .= "No GPU"."\n";continue;}
foreach ($arrValidGPUDevices as $arrDev) {
if ($arrGPU['id'] == $arrDev['id']) {
if (count(array_filter($arrValidGPUDevices, function($v) use ($arrDev) { return $v['name'] == $arrDev['name']; })) > 1) {

View File

@@ -799,7 +799,7 @@
if (empty($gpu['id']) || in_array($gpu['id'], $gpudevs_used)) {
continue;
}
if ($gpu['id'] == 'nogpu') break;
if ($gpu['id'] == 'virtual') {
$strKeyMap = '';
if (!empty($gpu['keymap'])) {

View File

@@ -1281,6 +1281,11 @@ private static $encoding = 'UTF-8';
continue;
}
}
if (empty($arrGPUDevices)) {
$arrGPUDevices[] = [
'id' => 'nogpu',
];
}
// Add claimed USB devices by this VM to the available USB devices
/*

View File

@@ -90,6 +90,7 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
var consolesplit = consolein.split(";");
var console = consolesplit[0];
var rdpopt = consolesplit[1];
var rundivider = false;
if (x!=-1) path = path.substring(0,x);
if (vmrcurl !== "" && state == "running") {
if (console == "web" || console == "both") {
@@ -104,21 +105,26 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
e.preventDefault();
ajaxVMDispatchconsoleRV({action:"domain-consoleRV", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
}});
}
}
rundivider = true;
}
if (state == "running") {
if (webui != "") {
opts.push({text:_("Open WebUI") , icon:"fa-globe", action:function(e) {
e.preventDefault();
ajaxVMDispatchWebUI({action:"domain-openWebUI", uuid:uuid, vmrcurl:webui}, "loadlist") ;
}});
rundivider = true;
}
if (rdpopt == "yes") {
opts.push({text:_("VM Remote Desktop Protocol(RDP)"), icon:"fa-desktop", action:function(e) {
e.preventDefault();
ajaxVMDispatchconsoleRV({action:"domain-consoleRDP", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
}});
rundivider = true;
}
opts.push({divider:true});
}
if (rundivider) opts.push({divider:true});
context.settings({right:false,above:false});
if (state == "running") {
opts.push({text:_("Stop"), icon:"fa-stop", action:function(e) {

View File

@@ -1140,14 +1140,14 @@
} else {
echo mk_option($arrGPU['id'], '', _('None'));
}
echo mk_option($arrGPU['id'], 'nogpu', _('No GPU'));
foreach($arrValidGPUDevices as $arrDev) {
echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
<?
if ($arrGPU['id'] != 'virtual') $multifunction = "" ; else $multifunction = " disabled " ;
if ($arrGPU['id'] != 'virtual' && $arrGPU['id'] != 'nogpu') $multifunction = "" ; else $multifunction = " disabled " ;
?>
<span id="GPUMulti<?=$i?>" name="gpu[<?=$i?>][multi]" class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced gpumultiline<?=$i?>" >_(Multifunction)_:</span>
@@ -1234,7 +1234,7 @@
</td>
</tr>
<?}?>
<tr class="<?if ($arrGPU['id'] == 'virtual') echo 'was';?>advanced romfile">
<tr class="<?if ($arrGPU['id'] == 'virtual' || $arrGPU['id'] == 'nogpu') echo 'was';?>advanced romfile">
<td>_(Graphics ROM BIOS)_:</td>
<td>
<input type="text" name="gpu[<?=$i?>][rom]" autocomplete="off" spellcheck="false" data-pickcloseonfile="true" data-pickfilter="rom,bin" data-pickmatch="^[^.].*" data-pickroot="/mnt/" value="<?=htmlspecialchars($arrGPU['rom'])?>" placeholder="_(Path to ROM BIOS file)_ (_(optional)_)" title="_(Path to ROM BIOS file)_ (_(optional)_)" />
@@ -2341,12 +2341,12 @@ $(function() {
slideUpRows($vnc_sections);
$vnc_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
var MultiSel = document.getElementById("GPUMultiSel0") ;
MultiSel.disabled = false ;
if (myvalue=="nogpu") MultiSel.disabled = true ; else MultiSel.disabled = false ;
}
}
$romfile = $(this).closest('table').find('.romfile');
if (myvalue == 'virtual' || myvalue == '') {
if (myvalue == 'virtual' || myvalue == '' || myvalue =="nogpu") {
slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
$romfile.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
} else {
@@ -2396,7 +2396,7 @@ $(function() {
} while (gpu);
form.find('select[name="gpu[0][id]"] option').each(function(){
var gpu = $(this).val();
if (gpu != 'virtual' && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
if ((gpu != 'virtual' && gpu != 'nogpu') && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
});
// remove unused sound cards
var sound = [], i = 0;
@@ -2471,7 +2471,7 @@ $(function() {
} while (gpu);
form.find('select[name="gpu[0][id]"] option').each(function(){
var gpu = $(this).val();
if (gpu != 'virtual' && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
if ((gpu != 'virtual' && gpu != 'nogpu') && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
});
// remove unused sound cards
var sound = [], i = 0;