mirror of
https://github.com/unraid/webgui.git
synced 2026-01-27 03:59:01 -06:00
Change to text and field names
Use Virtual Console as text Add ports view only on Template Use VMRC for field names and new functions.
This commit is contained in:
@@ -67,18 +67,18 @@ foreach ($vms as $vm) {
|
||||
$diskdesc = 'Current physical size: '.$lv->get_disk_capacity($res, true);
|
||||
}
|
||||
$arrValidDiskBuses = getValidDiskBuses();
|
||||
$vncport = $lv->domain_get_vnc_port($res);
|
||||
$autoport = $lv->domain_get_autoport($res);
|
||||
$virtual = '';
|
||||
$vmrcport = $lv->domain_get_vnc_port($res);
|
||||
$autoport = $lv->domain_get_vmrc_autoport($res);
|
||||
$vmrcurl = '';
|
||||
$graphics = '';
|
||||
if ($vncport > 0) {
|
||||
if ($vmrcport > 0) {
|
||||
$wsport = $lv->domain_get_ws_port($res);
|
||||
$protocol = $lv->domain_get_web_protocol($res) ;
|
||||
$virtual = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $virtual .= '&port='.$vncport ; else $virtual .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
$graphics = strtoupper($protocol).":".$vncport;
|
||||
} elseif ($vncport == -1 || $autoport == "yes") {
|
||||
$protocol = $lv->domain_get_web_protocol($res) ;
|
||||
$protocol = $lv->domain_get_vmrc_protocol($res) ;
|
||||
$vmrcurl = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $vmrcurl .= '&port='.$vmrcport ; else $vmrcurl .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
$graphics = strtoupper($protocol).":".$vmrcport;
|
||||
} elseif ($vmrcport == -1 || $autoport == "yes") {
|
||||
$protocol = $lv->domain_get_vmrc_protocol($res) ;
|
||||
$graphics = strtoupper($protocol).':auto';
|
||||
} elseif (!empty($arrConfig['gpu'])) {
|
||||
$arrValidGPUDevices = getValidGPUDevices();
|
||||
@@ -96,7 +96,7 @@ foreach ($vms as $vm) {
|
||||
$graphics = str_replace("\n", "<br>", trim($graphics));
|
||||
}
|
||||
unset($dom);
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($virtual),addslashes($log));
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),addslashes($log));
|
||||
$kvm[] = "kvm.push({id:'$uuid',state:'$state'});";
|
||||
switch ($state) {
|
||||
case 'running':
|
||||
|
||||
@@ -666,7 +666,7 @@
|
||||
|
||||
$pcidevs='';
|
||||
$gpudevs_used=[];
|
||||
$vnc='';
|
||||
$vmrc='';
|
||||
if (!empty($gpus)) {
|
||||
foreach ($gpus as $i => $gpu) {
|
||||
// Skip duplicate video devices
|
||||
@@ -697,7 +697,7 @@
|
||||
if (!empty($gpu['protocol'])) {
|
||||
$strProtocol = $gpu['protocol'];
|
||||
} else $strProtocol = " vnc" ;
|
||||
$vnc = "<input type='tablet' bus='usb'/>
|
||||
$vmrc = "<input type='tablet' bus='usb'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='$strProtocol' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' $passwdstr $strKeyMap>
|
||||
@@ -824,7 +824,7 @@
|
||||
$ctrl
|
||||
$sharestr
|
||||
$netstr
|
||||
$vnc
|
||||
$vmrc
|
||||
<console type='pty'/>
|
||||
$scsicontroller
|
||||
$pcidevs
|
||||
@@ -1799,7 +1799,7 @@
|
||||
return $var;
|
||||
}
|
||||
|
||||
function domain_get_autoport($domain) {
|
||||
function domain_get_vmrc_autoport($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics/@autoport', false);
|
||||
$var = (int)$tmp[0];
|
||||
unset($tmp);
|
||||
@@ -1807,7 +1807,7 @@
|
||||
return $var;
|
||||
}
|
||||
|
||||
function domain_get_web_protocol($domain) {
|
||||
function domain_get_vmrc_protocol($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/devices/graphics/@type', false);
|
||||
$var = $tmp[0];
|
||||
unset($tmp);
|
||||
|
||||
@@ -860,7 +860,7 @@
|
||||
|
||||
return $arrValidVNCModels;
|
||||
}
|
||||
function getValidProtocols() {
|
||||
function getValidVMRCProtocols() {
|
||||
$arrValidProtocols = [
|
||||
'vnc' => 'VNC',
|
||||
'spice' => 'SPICE'
|
||||
@@ -991,15 +991,18 @@
|
||||
$arrAudioDevices = [];
|
||||
$arrOtherDevices = [];
|
||||
|
||||
// check for vnc; add to arrGPUDevices
|
||||
$intVNCPort = $lv->domain_get_vnc_port($res);
|
||||
$autoport = $lv->domain_get_autoport($res);
|
||||
if (!empty($intVNCPort) || $autoport == "yes") {
|
||||
// check for vnc/spice; add to arrGPUDevices
|
||||
$vmrcport = $lv->domain_get_vnc_port($res);
|
||||
$autoport = $lv->domain_get_vmrc_autoport($res);
|
||||
if (empty($vmrcport) && $autoport == "yes") $vmrcport = -1 ;
|
||||
if (!empty($vmrcport)) {
|
||||
$arrGPUDevices[] = [
|
||||
'id' => 'virtual' ,
|
||||
'protocol' => $lv->domain_get_web_protocol($res),
|
||||
'protocol' => $lv->domain_get_vmrc_protocol($res),
|
||||
'model' => $lv->domain_get_vnc_model($res),
|
||||
'keymap' => $lv->domain_get_vnc_keymap($res)
|
||||
'keymap' => $lv->domain_get_vnc_keymap($res),
|
||||
'port' => $vmrcport,
|
||||
'wsport' => $lv->domain_get_ws_port($res)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1174,7 +1177,7 @@
|
||||
}
|
||||
// settings not in the GUI, but maybe customized
|
||||
unset($new['memoryBacking'], $new['clock'], $new['features']);
|
||||
// preserve vnc port settings
|
||||
// preserve vnc/spice port settings
|
||||
unset($new['devices']['graphics']['@attributes']['port'],$new['devices']['graphics']['@attributes']['autoport']);
|
||||
if (!$new['devices']['graphics']) unset($old['devices']['graphics']);
|
||||
// update parent arrays
|
||||
|
||||
@@ -20,7 +20,7 @@ function addVMContext(name, uuid, template, state, virtualurl, log){
|
||||
var x = path.indexOf("?");
|
||||
if (x!=-1) path = path.substring(0,x);
|
||||
if (virtualurl !== "") {
|
||||
opts.push({text:_("Virtual Remote"), icon:"fa-desktop", action:function(e) {
|
||||
opts.push({text:_("VM Console"), icon:"fa-desktop", action:function(e) {
|
||||
e.preventDefault();
|
||||
window.open(virtualurl, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
}});
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
$arrValidDiskBuses = getValidDiskBuses();
|
||||
$arrValidCdromBuses = getValidCdromBuses();
|
||||
$arrValidVNCModels = getValidVNCModels();
|
||||
$arrValidProtocols = getValidProtocols();
|
||||
$arrValidProtocols = getValidVMRCProtocols();
|
||||
$arrValidKeyMaps = getValidKeyMaps();
|
||||
$arrValidNetworks = getValidNetworks();
|
||||
$strCPUModel = getHostCPUModel();
|
||||
@@ -80,7 +80,8 @@
|
||||
'id' => 'virtual',
|
||||
'protocol' => 'vnc',
|
||||
'model' => 'qxl',
|
||||
'keymap' => 'en-us'
|
||||
'keymap' => 'en-us',
|
||||
'port' => -1
|
||||
]
|
||||
],
|
||||
'audio' => [
|
||||
@@ -124,16 +125,15 @@
|
||||
} else {
|
||||
// form view
|
||||
if ($lv->domain_new($_POST)) {
|
||||
// Fire off the vnc popup if available
|
||||
// Fire off the vnc/spice popup if available
|
||||
$dom = $lv->get_domain_by_name($_POST['domain']['name']);
|
||||
$vncport = $lv->domain_get_vnc_port($dom);
|
||||
$vmrcport = $lv->domain_get_vnc_port($dom);
|
||||
$wsport = $lv->domain_get_ws_port($dom);
|
||||
$protocol = $lv->domain_get_web_protocol($dom);
|
||||
$reply = ['success' => true];
|
||||
if ($vncport > 0) {
|
||||
$reply['virtualurl'] = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $reply['virtualurl'] .= '&port='.$vncport ; else $virtual .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
//$reply['spiceurl'] = autov('/plugins/dynamix.vm.manager/spice.html',true).'&autoconnect=true&host='.$_SERVER['HTTP_HOST'].'&port='.$vncport;
|
||||
if ($vmrcport > 0) {
|
||||
$reply['vmrcurl'] = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $reply['vmrcurl'] .= '&port='.$vmrcport ; else $reply['vmrcurl'] .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
}
|
||||
} else {
|
||||
$reply = ['error' => $lv->get_last_error()];
|
||||
@@ -874,15 +874,29 @@
|
||||
|
||||
<?if ($i == 0) { ?>
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced protocol">
|
||||
<td>_(Virtual Protocol)_:</td>
|
||||
<td>_(VM Console Protocol)_:</td>
|
||||
<td>
|
||||
<select id="protocol" name="gpu[<?=$i?>][protocol]" class="narrow" title="_(protocol for virtual screen)_">
|
||||
<select id="protocol" name="gpu[<?=$i?>][protocol]" class="narrow" title="_(protocol for virtual console)_">
|
||||
<?mk_dropdown_options($arrValidProtocols, $arrGPU['protocol']);?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced port">
|
||||
<td>_(VM Console Port)_:</td>
|
||||
<td>
|
||||
<input type="number" min="5900" max="5999" id="port" name="gpu[<?=$i?>][port]" class="textTemplate" title="_(port for virtual console)_" value="<?=$arrGPU['port']?>" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<?if ($arrGPU['protocol']=="vnc") { ?>
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced wsport">
|
||||
<td>_(VM Console WS Port)_:</td>
|
||||
<td>
|
||||
<input type="number" min="5700" max="5799" id="wsport" name="gpu[<?=$i?>][wsport]" class="textTemplate" title="_(port for virtual console)_" value="<?=$arrGPU['wsport']?>" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vncmodel">
|
||||
<td>_(Virtual Video Driver)_:</td>
|
||||
<td>_(VM Console Video Driver)_:</td>
|
||||
<td>
|
||||
<select id="vncmodel" name="gpu[<?=$i?>][model]" class="narrow" title="_(video for VNC)_">
|
||||
<?mk_dropdown_options($arrValidVNCModels, $arrGPU['model']);?>
|
||||
@@ -891,11 +905,11 @@
|
||||
</tr>
|
||||
|
||||
<tr class="vncpassword">
|
||||
<td>_(Virtual Password)_:</td>
|
||||
<td>_(VM Console Password)_:</td>
|
||||
<td><input type="password" name="domain[password]" autocomplete='new-password' title="_(password for VNC)_" placeholder="_(password for VNC)_ (_(optional)_)" /></td>
|
||||
</tr>
|
||||
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vnckeymap">
|
||||
<td>_(Virtual Keyboard)_:</td>
|
||||
<td>_(VM Console Keyboard)_:</td>
|
||||
<td>
|
||||
<select name="gpu[<?=$i?>][keymap]" title="_(keyboard for VNC)_">
|
||||
<?mk_dropdown_options($arrValidKeyMaps, $arrGPU['keymap']);?>
|
||||
@@ -924,17 +938,17 @@
|
||||
|
||||
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vncmodel">
|
||||
<b>virtual Video Driver</b><br>
|
||||
If you wish to assign a different video driver to use for a VNC connection, specify one here.
|
||||
If you wish to assign a different video driver to use for a VM Console connection, specify one here.
|
||||
</p>
|
||||
|
||||
<p class="vncpassword">
|
||||
<b>virtual Password</b><br>
|
||||
If you wish to require a password to connect to the VM over a VNC connection, specify one here.
|
||||
If you wish to require a password to connect to the VM over a VM Console connection, specify one here.
|
||||
</p>
|
||||
|
||||
<p class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vnckeymap">
|
||||
<b>virtual Keyboard</b><br>
|
||||
If you wish to assign a different keyboard layout to use for a VNC connection, specify one here.
|
||||
If you wish to assign a different keyboard layout to use for a VM Console connection, specify one here.
|
||||
</p>
|
||||
|
||||
<p class="<?if ($arrGPU['id'] == 'virtual') echo 'was';?>advanced romfile">
|
||||
@@ -1525,7 +1539,7 @@ $(function() {
|
||||
} while (gpu);
|
||||
form.find('select[name="gpu[0][id]"] option').each(function(){
|
||||
var gpu = $(this).val();
|
||||
if (gpu != 'VNC' && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
|
||||
if (gpu != 'virtual' && !gpus.includes(gpu)) form.append('<input type="hidden" name="pci[]" value="'+gpu+'#remove">');
|
||||
});
|
||||
// remove unused sound cards
|
||||
var sound = [], i = 0;
|
||||
@@ -1551,10 +1565,10 @@ $(function() {
|
||||
|
||||
$.post("/plugins/dynamix.vm.manager/templates/Custom.form.php", postdata, function( data ) {
|
||||
if (data.success) {
|
||||
if (data.virtualurl) {
|
||||
var vnc_window=window.open(data.virtualurl, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
if (data.vmrcurl) {
|
||||
var vmrc_window=window.open(data.virtualurl, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
try {
|
||||
vnc_window.focus();
|
||||
vmrc_window.focus();
|
||||
} catch (e) {
|
||||
swal({title:"_(Browser error)_",text:"_(Pop-up Blocker is enabled! Please add this site to your exception list)_",type:"warning",confirmButtonText:"_(Ok)_"},function(){ done() });
|
||||
return;
|
||||
|
||||
@@ -82,20 +82,20 @@ if ($_POST['vms'] && ($display=='icons' || $display=='vms')) {
|
||||
$dom = $lv->domain_get_info($res);
|
||||
$id = $lv->domain_get_id($res);
|
||||
$state = $lv->domain_state_translate($dom['state']);
|
||||
$vncport = $lv->domain_get_vnc_port($res);
|
||||
$virtual = '';
|
||||
if ($vncport > 0) {
|
||||
$vmrcport = $lv->domain_get_vnc_port($res);
|
||||
$vmrcurl = '';
|
||||
if ($vmrcport > 0) {
|
||||
$wsport = $lv->domain_get_ws_port($res);
|
||||
$protocol = $lv->domain_get_web_protocol($res) ;
|
||||
$virtual = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $virtual .= '&port='.$vncport ; else $virtual .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
$protocol = $lv->domain_get_vmrc_protocol($res) ;
|
||||
$vmrcurl = autov('/plugins/dynamix.vm.manager/'.$protocol.'.html',true).'&autoconnect=true&host=' . $_SERVER['HTTP_HOST'] ;
|
||||
if ($protocol == "spice") $vmrcurl .= '&port='.$vmrcport ; else $vmrcurl .= '&port=&path=/wsproxy/' . $wsport . '/';
|
||||
} else {
|
||||
$vncport = ($vncport < 0) ? "auto" : "";
|
||||
$vmrcport = ($vmrcport < 0) ? "auto" : "";
|
||||
}
|
||||
$template = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
|
||||
if (empty($template)) $template = 'Custom';
|
||||
$log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($virtual), addslashes($log));
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), addslashes($log));
|
||||
$icon = $lv->domain_get_icon_url($res);
|
||||
switch ($state) {
|
||||
case 'running':
|
||||
|
||||
Reference in New Issue
Block a user