mirror of
https://github.com/unraid/webgui.git
synced 2026-05-03 16:29:45 -05:00
Initial Commit
Templates Export/Import Changes for virgl(Virtio3d) Bios flag.
This commit is contained in:
@@ -486,7 +486,7 @@ $(function() {
|
||||
<tbody id="kvm_list"><tr><td colspan='8'></td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<input type="button" onclick="addVM()" id="btnAddVM" value="_(Add VM)_" style="display:none">
|
||||
<input type="button" onclick="addVM()" id="btnAddVM" value="_(Add VM/Templates)_" style="display:none">
|
||||
<input type="button" onclick="startAll()" value="_(Start All)_" style="display:none">
|
||||
<input type="button" onclick="stopAll()" value="_(Stop All)_" style="display:none">
|
||||
|
||||
|
||||
@@ -38,6 +38,16 @@ Markdown="false"
|
||||
if (strpos($strName,"User-") === false) $user = ""; else $user = ' class="user"';
|
||||
?>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.switchbutton.css')?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.filetree.css")?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/webGui/styles/jquery.ui.css")?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-$theme.css")?>">
|
||||
|
||||
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
|
||||
<script src="<?autov('/plugins/dynamix.vm.manager/javascript/dynamix.vm.manager.js')?>"></script>
|
||||
<script src="<?autov('/plugins/dynamix.vm.manager/javascript/vmmanager.js')?>"></script>
|
||||
<script src="<?autov("/webGui/javascript/jquery.filetree.js")?>"></script>
|
||||
|
||||
<div class="vmtemplate">
|
||||
<a href="/VMs/AddVM?template=<?=htmlspecialchars(urlencode($strName))?>">
|
||||
<span name="<?=htmlspecialchars($strName)?>" <?=$user?>><img src="/plugins/dynamix.vm.manager/templates/images/<?=htmlspecialchars($arrTemplate['icon'])?>" title="<?=htmlspecialchars($strName)?>"></span>
|
||||
@@ -46,7 +56,9 @@ Markdown="false"
|
||||
</div>
|
||||
<? endforeach; ?>
|
||||
<br>
|
||||
<center><button type='button' onclick='done()'>_(Cancel)_</button></center>
|
||||
<center><button type='button' onclick='done()'>_(Cancel)_</button>
|
||||
<button type='button' onclick='import_template()'>_(Import from file)_</button>
|
||||
<button type='button' onclick='$("#fileupload").click();'>_(Upload)_</button></center>
|
||||
<br>
|
||||
|
||||
<script>
|
||||
@@ -59,15 +71,200 @@ function confirmRemoveUserTemplate(template) {
|
||||
swal({title:"_(Proceed)_?",text:"Remove user template: " + template ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(p){if (p) removeUserTemplate(template); else refresh();});
|
||||
}
|
||||
|
||||
function saveUserTemplateFile(name,template) {
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"no"},function($return){
|
||||
if ($return.success == false) {
|
||||
swal({title:"_(File exists)_?",text:"Replace file: " + name ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){
|
||||
if (p) {
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"yes"},function($return){
|
||||
if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});
|
||||
});
|
||||
}
|
||||
else {
|
||||
if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveUserTemplateImport(name,template) {
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-import',name:name,template:template,replace:"no"},function($return){
|
||||
if ($return.success == false) {
|
||||
swal({title:"_(File exists)_?",text:"Replace file: " + name.split(".")[0] ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(No)_"},function(p){
|
||||
if (p) {
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-save',name:name,template:template,replace:"yes"},function($return){
|
||||
if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name.split(".")[0] + " " + $return.error ,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});
|
||||
if ($return.success == true) refresh();
|
||||
});
|
||||
}
|
||||
else {
|
||||
if ($return.success == false) swal({title:"_(Error occured)_?",text:"Action error " + name + " " + $return.error ,type:'error',html:true,showCancelButton:true,confirmButtonText:"_(OK)_"});
|
||||
};
|
||||
});
|
||||
}
|
||||
if ($return.success == true) refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function downloadJSON(data, filename = 'data.json') {
|
||||
// Convert the data to a JSON string
|
||||
const jsonString = JSON.stringify(data, null, 2); // Beautify with 2 spaces
|
||||
// Create a Blob from the JSON string
|
||||
const blob = new Blob([jsonString], { type: 'application/json' });
|
||||
// Generate a temporary URL for the Blob
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
// Create a link element
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename; // Specify the file name
|
||||
|
||||
// Trigger the download by programmatically clicking the link
|
||||
link.click();
|
||||
|
||||
// Clean up by revoking the object URL
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function export_template(template){
|
||||
const templatejson = <?=json_encode($ut)?>;
|
||||
var json = templatejson[template];
|
||||
var box = $("#dialogWindow");
|
||||
box.html($("#templateexport").html());
|
||||
box.find('#target').attr('value',template+".json");
|
||||
box.find('#target2').attr('value',"/mnt/").fileTreeAttach(null,null,function(path){
|
||||
box.find('#target2').val(path).change();
|
||||
});
|
||||
box.dialog({
|
||||
title: "_(Select File)_",
|
||||
height: 530,
|
||||
width: 900,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"_(Save)_": function(){
|
||||
var target = box.find('#target');
|
||||
if (target.length) target = target.val(); else target = '';
|
||||
var target2 = box.find('#target2');
|
||||
if (target2.length) target2 = target2.val(); else target2 = '';
|
||||
box.find('#target').prop('disabled',true);
|
||||
box.find('#target2').prop('disabled',true);
|
||||
saveUserTemplateFile(target2+target,json);
|
||||
box.dialog('close');
|
||||
},
|
||||
"_(Cancel)_": function(){
|
||||
box.dialog('close');
|
||||
},
|
||||
"_(Download)_": function(){
|
||||
downloadJSON(json,template+'.json');
|
||||
box.dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
dialogStyle();
|
||||
}
|
||||
|
||||
function import_template(){
|
||||
var box = $("#dialogWindow");
|
||||
box.html($("#templateimport").html());
|
||||
box.find('#targetimp').attr('value',"/mnt").fileTreeAttach(null,null,function(path){
|
||||
box.find('#targetimp').val(path).change();
|
||||
});
|
||||
box.dialog({
|
||||
title: "_(Select File)_",
|
||||
height: 530,
|
||||
width: 900,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"_(Import)_": function(){
|
||||
var targetimp = box.find('#targetimp');
|
||||
if (targetimp.length) targetimp = targetimp.val(); else targetimp = '';
|
||||
box.find('#targetimp').prop('disabled',true);
|
||||
saveUserTemplateImport(targetimp,"*file");
|
||||
box.dialog('close');
|
||||
},
|
||||
"_(Cancel)_": function(){
|
||||
box.dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
dialogStyle();
|
||||
}
|
||||
|
||||
function dialogStyle() {
|
||||
$('.ui-dialog-titlebar-close').css({'display':'none'});
|
||||
$('.ui-dialog-title').css({'text-align':'center','width':'100%','font-size':'1.8rem'});
|
||||
$('.ui-dialog-content').css({'padding-top':'15px','vertical-align':'bottom'});
|
||||
$('.ui-button-text').css({'padding':'0px 5px'});
|
||||
}
|
||||
|
||||
function exportTemplate(template) {
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMajax.php',{action:'vm-template-export',template:template},function(){
|
||||
refresh();});
|
||||
}
|
||||
|
||||
function uploadFile(files,index,start,time) {
|
||||
var file = files[0];
|
||||
var blob = file;
|
||||
reader.onloadend = function(e){
|
||||
uploadedData = JSON.parse(e.target.result);
|
||||
//alert('File uploaded successfully. Click "Process JSON" to proceed.');
|
||||
saveUserTemplateImport(file.name,uploadedData);
|
||||
};
|
||||
reader.readAsText(blob);
|
||||
}
|
||||
|
||||
function startUpload(files) {
|
||||
if (files.length==0) return;
|
||||
reader = new FileReader();
|
||||
//window.onbeforeunload = function(e){return '';};
|
||||
uploadFile(files);
|
||||
}
|
||||
|
||||
var sortableHelper = function(e,ui){
|
||||
var child = ui.next();
|
||||
if (child.is(':visible')) child.addClass('unhide').hide();
|
||||
ui.children().each(function(){$(this).width($(this).width());});
|
||||
return ui;
|
||||
};
|
||||
|
||||
$(function(){
|
||||
$('div.vmtemplate').each(function(){
|
||||
var templatename = $(this).find('span').attr('name');
|
||||
$(this).find('span.user').append('<i class="fa fa-trash bin" title="_(Remove User Template)_" onclick="confirmRemoveUserTemplate("' + templatename + '");return false"></i>');
|
||||
$(this).find('span.user').append('<br><i class="fa fa-external-link-square export" title="_(Export User Template)_" onclick="export_template("' + templatename + '");return false"></i>');
|
||||
$(this).hover(function(){$(this).find('i.bin').show();},function(){$(this).find('i.bin').hide();});
|
||||
$(this).hover(function(){$(this).find('i.export').show();},function(){$(this).find('i.export').hide();});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
||||
i.bin{display:none;font-size:1.8rem;position:absolute;margin-left:12px}
|
||||
</style>
|
||||
i.export{display:none;font-size:1.8rem;position:left;margin-left:1px}
|
||||
</style>
|
||||
|
||||
<div id="dialogWindow"></div>
|
||||
<div id="iframe-popup"></div>
|
||||
|
||||
<div id="templateexport" class="template">
|
||||
<dl>
|
||||
<dt>_(Save File Name)_:</dt>
|
||||
<dd><input type="text" id="target" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="iso"></dd>
|
||||
<dt>_(Save Path)_:</dt>
|
||||
<dd><input type="text" id="target2" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="iso"></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div id="templateimport" class="template">
|
||||
<dl>
|
||||
<dt>_(File for import)_:</dt>
|
||||
<dd><input type="text" id="targetimp" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="json"></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<input hidden type="file" id="fileupload" value="" onchange="startUpload(this.files)"
|
||||
@@ -868,6 +868,50 @@ case 'vm-template-remove':
|
||||
$arrResponse = ['success' => true];
|
||||
break;
|
||||
|
||||
case 'vm-template-save':
|
||||
$template = $_REQUEST['template'];
|
||||
$name = $_REQUEST['name'];
|
||||
$replace = $_REQUEST['replace'];
|
||||
|
||||
if (is_file($name) && $replace == "no"){
|
||||
$arrResponse = ['success' => false, 'error' => _("File exists.")];
|
||||
} else {
|
||||
$error = file_put_contents($name,json_encode($template));
|
||||
if ($error !== false) $arrResponse = ['success' => true];
|
||||
else {
|
||||
$arrResponse = ['success' => false, 'error' => _("File write failed.")];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'vm-template-import':
|
||||
$template = $_REQUEST['template'];
|
||||
$name = $_REQUEST['name'];
|
||||
$replace = $_REQUEST['replace'];
|
||||
$templateslocation = "/boot/config/plugins/dynamix.vm.manager/savedtemplates.json";
|
||||
|
||||
if ($template="*file") {
|
||||
$template=json_decode(file_get_contents($name));
|
||||
}
|
||||
|
||||
$namepathinfo = pathinfo($name);
|
||||
$template_name = $namepathinfo['filename'];
|
||||
|
||||
if (is_file($templateslocation)){
|
||||
$ut = json_decode(file_get_contents($templateslocation),true) ;
|
||||
if (isset($ut[$template_name]) && $replace == "no"){
|
||||
$arrResponse = ['success' => false, 'error' => _("Template exists.")];
|
||||
} else {
|
||||
$ut[$template_name] = $template;
|
||||
$error = file_put_contents($templateslocation,json_encode($ut,JSON_PRETTY_PRINT));;
|
||||
if ($error !== false) $arrResponse = ['success' => true];
|
||||
else {
|
||||
$arrResponse = ['success' => false, 'error' => _("Tempalte file write failed.")];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$arrResponse = ['error' => _('Unknown action')." '$action'"];
|
||||
break;
|
||||
|
||||
@@ -847,6 +847,19 @@
|
||||
if (($gpu['copypaste'] == "yes") && ($strProtocol == "spice")) $vmrcmousemode = "<mouse mode='server'/>" ; else $vmrcmousemode = "" ;
|
||||
if ($strProtocol == "spice") $virtualaudio = "spice" ; else $virtualaudio = "none" ;
|
||||
|
||||
$strEGLHeadless = "";
|
||||
$strAccel3d ="";
|
||||
if ($strModelType == "virtio3d") {
|
||||
$strModelType = "virtio";
|
||||
if (!isset($gpu['render'])) $gpu['render'] = "auto";
|
||||
if ($gpu['render'] == "auto") {
|
||||
$strEGLHeadless = '<graphics type="egl-headless"><gl enable="yes"/></graphics>';
|
||||
$strAccel3d = "<acceleration accel3d='yes'/>";
|
||||
} else {
|
||||
$strEGLHeadless = '<graphics type="egl-headless"><gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:'.$gpu['render'].'-render"/></graphics>';
|
||||
$strAccel3d ="<acceleration accel3d='yes'/>";
|
||||
}}
|
||||
|
||||
$vmrc = "<input type='tablet' bus='usb'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
@@ -854,8 +867,11 @@
|
||||
<listen type='address' address='0.0.0.0'/>
|
||||
$vmrcmousemode
|
||||
</graphics>
|
||||
$strEGLHeadless
|
||||
<video>
|
||||
<model type='$strModelType'/>
|
||||
<model type='$strModelType'>
|
||||
$strAccel3d
|
||||
</model>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
|
||||
</video>
|
||||
<audio id='1' type='$virtualaudio'/>";
|
||||
@@ -2158,7 +2174,7 @@
|
||||
}
|
||||
|
||||
function domain_get_vnc_port($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics/@port', false);
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics[@type="spice" or @type="vnc"]/@port', false);
|
||||
$var = (int)$tmp[0];
|
||||
unset($tmp);
|
||||
|
||||
@@ -2166,7 +2182,7 @@
|
||||
}
|
||||
|
||||
function domain_get_vmrc_autoport($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics/@autoport', false);
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics[@type="spice" or @type="vnc"]/@autoport', false);
|
||||
$var = $tmp[0];
|
||||
unset($tmp);
|
||||
|
||||
@@ -2189,6 +2205,23 @@
|
||||
$var = $tmp[0];
|
||||
unset($tmp);
|
||||
|
||||
if ($var=="virtio") {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/video/model/acceleration/@accel3d', false);
|
||||
if ($tmp[0] == "yes") $var = "virtio3d";
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
function domain_get_vnc_render($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics[@type="egl-headless"]/gl/@rendernode', false);
|
||||
if (!$tmp)
|
||||
return 'auto';
|
||||
|
||||
$var = $tmp[0];
|
||||
unset($tmp);
|
||||
$var = str_replace(['/dev/dri/by-path/pci-0000:','-render'],['',''],$var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
||||
@@ -866,6 +866,15 @@ private static $encoding = 'UTF-8';
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to get the boot_vga driver for this pci device
|
||||
$strBootVGA = '';
|
||||
if (is_file('/sys/bus/pci/devices/0000:' . $arrMatch['id'] . '/boot_vga') && $strClass == 'vga') {
|
||||
$strFileVal = file_get_contents('/sys/bus/pci/devices/0000:' . $arrMatch['id'] . '/boot_vga');
|
||||
if (!empty($strFileVal)) {
|
||||
$strBootVGA = trim($strFileVal);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up the vendor and product name
|
||||
$arrMatch['vendorname'] = sanitizeVendor($arrMatch['vendorname']);
|
||||
$arrMatch['productname'] = sanitizeProduct($arrMatch['productname']);
|
||||
@@ -880,6 +889,7 @@ private static $encoding = 'UTF-8';
|
||||
'productname' => $arrMatch['productname'],
|
||||
'class' => $strClass,
|
||||
'driver' => $strDriver,
|
||||
'bootvga' => $strBootVGA,
|
||||
'name' => $arrMatch['vendorname'] . ' ' . $arrMatch['productname'],
|
||||
'blacklisted' => $boolBlacklisted
|
||||
];
|
||||
@@ -1116,6 +1126,7 @@ private static $encoding = 'UTF-8';
|
||||
'cirrus' => 'Cirrus',
|
||||
'qxl' => 'QXL (best)',
|
||||
'virtio' => 'Virtio(2d)',
|
||||
'virtio3d' => 'Virtio(3d)',
|
||||
'vmvga' => 'vmvga'
|
||||
];
|
||||
|
||||
@@ -1269,6 +1280,7 @@ private static $encoding = 'UTF-8';
|
||||
'autoport' => $autoport,
|
||||
'copypaste' => $getcopypaste,
|
||||
'guest' => ['multi' => 'off' ],
|
||||
'render' => $lv->domain_get_vnc_render($res),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1481,7 +1493,7 @@ private static $encoding = 'UTF-8';
|
||||
unset($old['devices']['input']);
|
||||
// preserve vnc/spice port settings
|
||||
// unset($new['devices']['graphics']['@attributes']['port'],$new['devices']['graphics']['@attributes']['autoport']);
|
||||
if (!$new['devices']['graphics']) unset($old['devices']['graphics']);
|
||||
unset($old['devices']['graphics']);
|
||||
if (!isset($new['devices']['graphics']['@attributes']['keymap']) && isset($old['devices']['graphics']['@attributes']['keymap'])) unset($old['devices']['graphics']['@attributes']['keymap']) ;
|
||||
// update parent arrays
|
||||
if (!$old['devices']['hostdev']) unset($old['devices']['hostdev']);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.fileTree{background:#f2f2f2;width:300px;max-height:150px;overflow-y:scroll;overflow-x:hidden;position:relative;z-index:100;display:none}
|
||||
@@ -0,0 +1,2 @@
|
||||
.fileTree{background:#1c1c1c;width:300px;max-height:150px;overflow-y:scroll;overflow-x:hidden;position:relative;z-index:100;display:none}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.fileTree{background:#1c1c1c;width:300px;max-height:150px;overflow-y:scroll;overflow-x:hidden;position:relative;z-index:100;display:none}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.fileTree{background:#f2f2f2;width:300px;max-height:150px;overflow-y:scroll;overflow-x:hidden;position:relative;z-index:100;display:none}
|
||||
|
||||
@@ -2,3 +2,7 @@
|
||||
.vmtemplate{display:inline-block;width:80px;height:90px;margin-bottom:15px;margin-left:10px;text-align:center;vertical-align:top}
|
||||
.vmtemplate img{width:48px;height:48px}
|
||||
.vmtemplate p{text-align:center;margin-top:8px;line-height:12px}
|
||||
div.template,div#dialogWindow,input#upload{display:none}
|
||||
#resetsort{margin-left:12px;display:inline-block;width:32px}
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset button[disabled]{cursor:default;color:#808080;background:-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 0 no-repeat,-webkit-gradient(linear,left top,right top,from(#404040),to(#808080)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#404040),to(#404040)) 0 100% no-repeat,-webkit-gradient(linear,left bottom,left top,from(#808080),to(#808080)) 100% 100% no-repeat;background:linear-gradient(90deg,#404040 0,#808080) 0 0 no-repeat,linear-gradient(90deg,#404040 0,#808080) 0 100% no-repeat,linear-gradient(0deg,#404040 0,#404040) 0 100% no-repeat,linear-gradient(0deg,#808080 0,#808080) 100% 100% no-repeat;background-size:100% 2px,100% 2px,2px 100%,2px 100%}
|
||||
.dropdown-menu{z-index:10001}
|
||||
|
||||
@@ -102,7 +102,8 @@
|
||||
'keymap' => 'none',
|
||||
'port' => -1 ,
|
||||
'wsport' => -1,
|
||||
'copypaste' => 'no'
|
||||
'copypaste' => 'no',
|
||||
'render' => 'auto'
|
||||
]
|
||||
],
|
||||
'audio' => [
|
||||
@@ -1159,8 +1160,8 @@
|
||||
|
||||
<?foreach ($arrConfig['gpu'] as $i => $arrGPU) {
|
||||
$strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : '';
|
||||
|
||||
?>
|
||||
$bootgpuhidden = " hidden ";
|
||||
?>
|
||||
<table data-category="Graphics_Card" data-multiple="true" data-minimum="1" data-maximum="<?=count($arrValidGPUDevices)+1?>" data-index="<?=$i?>" data-prefix="<?=$strLabel?>">
|
||||
<tr>
|
||||
<td>_(Graphics Card)_:</td>
|
||||
@@ -1249,9 +1250,19 @@
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vncmodel">
|
||||
<td>_(VM Console Video Driver)_:</td>
|
||||
<td>
|
||||
<select id="vncmodel" name="gpu[<?=$i?>][model]" class="narrow" title="_(video for VM Console)_">
|
||||
<select id="vncmodel" name="gpu[<?=$i?>][model]" class="narrow" title="_(video for VM Console)_" onchange="VMConsoleDriverChange(this)">
|
||||
<?mk_dropdown_options($arrValidVNCModels, $arrGPU['model']);?>
|
||||
</select>
|
||||
<?if ($arrGPU['model'] == "virtio3d") $vmcrender = "" ; else $vmcrender = " hidden ";?>
|
||||
<span id="vncrendertext" <?=$vncrender?>>_(Render GPU)_:</span>
|
||||
<select id="vncrender" name="gpu[<?=$i?>][render]">
|
||||
<?
|
||||
echo mk_option($arrGPU['render'], 'auto', _('Auto'));
|
||||
foreach($arrValidGPUDevices as $arrDev) {
|
||||
echo mk_option($arrGPU['render'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1274,6 +1285,10 @@
|
||||
<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)_)" />
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
if ($arrValidGPUDevices[$arrGPU['id']]['bootvga'] == "1") $bootgpuhidden = "";
|
||||
?>
|
||||
<tr id="gpubootvga<?=$i?>" <?=$bootgpuhidden?>><td>_(Graphics ROM Needed?)_:</td><td><span class="orange-text"><i class="fa fa-warning"></i> _(GPU is primary adapater, vbios may be required.)_</span></td></tr>
|
||||
</table>
|
||||
<?if ($i == 0 || $i == 1) {?>
|
||||
<blockquote class="inline_help">
|
||||
@@ -1350,6 +1365,7 @@
|
||||
<input type="text" name="gpu[{{INDEX}}][rom]" autocomplete="off" spellcheck="false" data-pickcloseonfile="true" data-pickfilter="rom,bin" data-pickmatch="^[^.].*" data-pickroot="/mnt/" value="" placeholder="_(Path to ROM BIOS file)_ (_(optional)_)" title="_(Path to ROM BIOS file)_ (_(optional)_)" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="gpubootvga{{INDEX}}"><td>_(Graphics ROM Needed?)_:</td><td><span class="orange-text"><i class="fa fa-warning"></i> _(GPU is primary adapater, vbios may be required.)_</span></td></tr>
|
||||
</table>
|
||||
</script>
|
||||
|
||||
@@ -2084,6 +2100,19 @@ function AutoportChange(autoport) {
|
||||
}
|
||||
}
|
||||
|
||||
function VMConsoleDriverChange(driver) {
|
||||
if (driver.value != "virtio3d") {
|
||||
document.getElementById("vncrender").style.visibility="hidden";
|
||||
document.getElementById("vncrendertext").style.visibility="hidden";
|
||||
|
||||
} else {
|
||||
document.getElementById("vncrender").style.display="inline";
|
||||
document.getElementById("vncrender").style.visibility="visible";
|
||||
document.getElementById("vncrendertext").style.display="inline";
|
||||
document.getElementById("vncrendertext").style.visibility="visible";
|
||||
}
|
||||
}
|
||||
|
||||
function ProtocolChange(protocol) {
|
||||
var autoport = document.getElementById("autoport").value ;
|
||||
if (autoport == "yes") {
|
||||
@@ -2391,6 +2420,7 @@ $(function() {
|
||||
}) ;
|
||||
|
||||
$("#vmform").on("change", ".gpu", function changeGPUEvent() {
|
||||
const ValidGPUs = <?=json_encode($arrValidGPUDevices);?>;
|
||||
var myvalue = $(this).val();
|
||||
var mylabel = $(this).children('option:selected').text();
|
||||
var myindex = $(this).closest('table').data('index');
|
||||
@@ -2402,6 +2432,13 @@ $(function() {
|
||||
slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
|
||||
var MultiSel = document.getElementById("GPUMultiSel0") ;
|
||||
MultiSel.disabled = true ;
|
||||
if (document.getElementById("vncmodel").value == "virtio3d") {
|
||||
$("#vncrender").show();
|
||||
$("#vncrendertext").show();
|
||||
} else {
|
||||
$("#vncrender").hide();
|
||||
$("#vncrendertext").hide();
|
||||
}
|
||||
} else {
|
||||
slideUpRows($vnc_sections);
|
||||
$vnc_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced');
|
||||
@@ -2410,6 +2447,11 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (mylabel == "None") $("#gpubootvga"+myindex).hide();
|
||||
if (myvalue != 'virtual' && myvalue != '' && myvalue !="nogpu") {
|
||||
if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).show(); else $("#gpubootvga"+myindex).hide();
|
||||
}
|
||||
|
||||
$romfile = $(this).closest('table').find('.romfile');
|
||||
if (myvalue == 'virtual' || myvalue == '' || myvalue =="nogpu") {
|
||||
slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced'));
|
||||
|
||||
Reference in New Issue
Block a user