mirror of
https://github.com/unraid/webgui.git
synced 2026-02-26 12:18:56 -06:00
VM manager: display and dialog fixes
This commit is contained in:
@@ -143,35 +143,30 @@ function dialogStyle() {
|
||||
$('.ui-button-text').css({'padding':'0px 5px'});
|
||||
}
|
||||
function getisoimageboth(uuid,dev,bus,file,dev2,bus2,file2){
|
||||
var root = "<?=$domain_cfg["MEDIADIR"]?>";
|
||||
var match = ".iso";
|
||||
var box = $("#dialogWindow");
|
||||
box.html($("#templateISOboth").html());
|
||||
box.find('#target').attr('data-pickroot',root).attr('data-picktop',root).attr('data-pickmatch',match).attr('value',file).fileTreeAttach(null,null,function(path){
|
||||
box.find('#target').attr('value',file).fileTreeAttach(null,null,function(path){
|
||||
var bits = path.substr(1).split('/');
|
||||
var auto = bits.length>3 ? '' : share;
|
||||
box.find('#target').val(path+auto).change();
|
||||
});
|
||||
box.find('#target2').attr('data-pickroot',root).attr('data-picktop',root).attr('data-pickmatch',match).attr('value',file2).fileTreeAttach(null,null,function(path){
|
||||
box.find('#target2').attr('value',file2).fileTreeAttach(null,null,function(path){
|
||||
var bits = path.substr(1).split('/');
|
||||
var auto = bits.length>3 ? '' : share;
|
||||
box.find('#target2').val(path+auto).change();
|
||||
});
|
||||
box.dialog({
|
||||
title: "_(Select ISOs for CDROMs)_",
|
||||
width: 600,
|
||||
height: 630,
|
||||
width: 900,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"_(Update)_": function(){
|
||||
var target = box.find('#target');
|
||||
if (target.length) {
|
||||
target = target.val();
|
||||
} else target = '';
|
||||
if (target.length) target = target.val(); else target = '';
|
||||
var target2 = box.find('#target2');
|
||||
if (target2.length) {
|
||||
target2 = target2.val();
|
||||
} else target2 = '';
|
||||
if (target2.length) target2 = target2.val(); else target2 = '';
|
||||
box.find('#target').prop('disabled',true);
|
||||
box.find('#target2').prop('disabled',true);
|
||||
ajaxVMDispatch({action:"change-media-both", uuid:uuid, cdrom:"", dev:dev, bus:bus, file:target, dev2:dev2, bus2:bus2, file2:target2}, "loadlist");
|
||||
@@ -185,27 +180,23 @@ function getisoimageboth(uuid,dev,bus,file,dev2,bus2,file2){
|
||||
dialogStyle();
|
||||
}
|
||||
function getisoimage(uuid,dev,bus,file){
|
||||
var root = "<?=$domain_cfg["MEDIADIR"]?>";
|
||||
var match = ".iso";
|
||||
var box = $("#dialogWindow");
|
||||
box.html($("#templateISO").html());
|
||||
box.find('#target').attr('data-pickroot',root).attr('data-picktop',root).attr('data-pickmatch',match).fileTreeAttach(null,null,function(path){
|
||||
box.find('#target').attr('value',file).fileTreeAttach(null,null,function(path){
|
||||
var bits = path.substr(1).split('/');
|
||||
var auto = bits.length>3 ? '' : share;
|
||||
box.find('#target').val(path+auto).change();
|
||||
});
|
||||
box.dialog({
|
||||
title: "_(Select ISO)_",
|
||||
width: 600,
|
||||
height: 630,
|
||||
width: 900,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"_(Insert)_": function(){
|
||||
var target = box.find('#target');
|
||||
if (target.length) {
|
||||
target = target.val();
|
||||
if (!target ) {errorTarget(); return;}
|
||||
} else target = '';
|
||||
if (target.length) target = target.val(); else target = '';
|
||||
box.find('#target').prop('disabled',true);
|
||||
ajaxVMDispatch({action:"change-media", uuid:uuid, cdrom:"", dev:dev, bus:bus, file:target}, "loadlist");
|
||||
box.dialog('close');
|
||||
@@ -483,19 +474,20 @@ $(function() {
|
||||
|
||||
<div id="dialogWindow"></div>
|
||||
|
||||
<div markdown="1" id="templateISO" class="template">
|
||||
_(ISO Image)_:
|
||||
: <input type="text" id="target" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="" data-pickmatch="" data-pickroot="" data-picktop="">
|
||||
|
||||
<div id="templateISO" class="template">
|
||||
<dl>
|
||||
<dt>_(ISO Image)_:</dt>
|
||||
<dd><input type="text" id="target" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="iso" data-pickmatch=""></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div markdown="1" id="templateISOboth" class="template">
|
||||
_(CD1 ISO Image)_:
|
||||
: <input type="text" id="target" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="" data-pickmatch="" data-pickroot="" data-picktop="">
|
||||
|
||||
_(CD2 ISO Image)_:
|
||||
: <input type="text" id="target2" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="" data-pickmatch="" data-pickroot="" data-picktop="">
|
||||
|
||||
<div id="templateISOboth" class="template">
|
||||
<dl>
|
||||
<dt>_(CD1 ISO Image)_:</dt>
|
||||
<dd><input type="text" id="target" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="iso" data-pickmatch=""></dd>
|
||||
<dt>_(CD2 ISO Image)_:</dt>
|
||||
<dd><input type="text" id="target2" autocomplete="off" spellcheck="false" value="" data-pickcloseonfile="true" data-pickfolders="true" data-pickfilter="iso" data-pickmatch=""></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div id="templatesnapshotcreate" class="template">
|
||||
|
||||
@@ -88,7 +88,7 @@ foreach ($vms as $vm) {
|
||||
if ($autoport == "yes") $auto = "auto"; else $auto="manual";
|
||||
$graphics = strtoupper($vmrcprotocol).':'._($auto)."\n";
|
||||
$virtual = true ;
|
||||
}
|
||||
}
|
||||
if (!empty($arrConfig['gpu'])) {
|
||||
$arrValidGPUDevices = getValidGPUDevices();
|
||||
foreach ($arrConfig['gpu'] as $arrGPU) {
|
||||
@@ -130,10 +130,9 @@ foreach ($vms as $vm) {
|
||||
}
|
||||
|
||||
/* VM information */
|
||||
|
||||
if ($snapshots != null) $snapshotstr = _("(Snapshots :").count($snapshots).')' ; else $snapshotstr = _("(Snapshots :None)") ;
|
||||
$cdbus = $cdbus2 = $cdfile = $cdfile2 = "" ;
|
||||
$cdromcount = 0 ;
|
||||
if ($snapshots != null) $snapshotstr = _("(Snapshots :").count($snapshots).')'; else $snapshotstr = _("(Snapshots :None)");
|
||||
$cdbus = $cdbus2 = $cdfile = $cdfile2 = "";
|
||||
$cdromcount = 0;
|
||||
foreach ($cdroms as $arrCD) {
|
||||
$disk = $arrCD['file'] ?? $arrCD['partition'];
|
||||
$dev = $arrCD['device'];
|
||||
@@ -141,12 +140,12 @@ foreach ($vms as $vm) {
|
||||
if ($dev == "hda") {
|
||||
$cdbus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
|
||||
$cdfile = $arrCD['file'] ?? $arrCD['partition'];
|
||||
if ($cdfile != "") $cdromcount++ ;
|
||||
if ($cdfile != "") $cdromcount++;
|
||||
}
|
||||
if ($dev == "hdb") {
|
||||
$cdbus2 = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
|
||||
$cdfile2 = $arrCD['file'] ?? $arrCD['partition'];
|
||||
if ($cdfile2 != "") $cdromcount++ ;
|
||||
if ($cdfile2 != "") $cdromcount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +158,7 @@ foreach ($vms as $vm) {
|
||||
foreach ($ip as $arrIP) {
|
||||
$ipname = $arrIP["name"];
|
||||
if (preg_match('/^(lo|Loopback)/',$ipname)) continue; // omit loopback interface
|
||||
$iphdwadr = $arrIP["hwaddr"] == "" ? _("N/A") : $arrIP["hwaddr"];
|
||||
$iphdwadr = $arrIP["hwaddr"] == "" ? _("N/A") : $arrIP["hwaddr"];
|
||||
$iplist = $arrIP["addrs"];
|
||||
foreach ($iplist as $arraddr) {
|
||||
$ipaddrval = $arraddr["addr"];
|
||||
@@ -174,13 +173,19 @@ foreach ($vms as $vm) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($gastate == "disconnected") { $ipliststr .= "<tr><td>"._('Guest agent not installed')."</td><td></td><td></td><td></td></tr>"; $iptablestr = _('Requires guest agent installed') ; }
|
||||
else { $ipliststr = "<tr><td>"._('Guest not running')."</td><td></td><td></td><td></td><td></td></tr>"; $iptablestr = _('Requires guest running') ; }
|
||||
if ($gastate == "disconnected") {
|
||||
$ipliststr .= "<tr><td>"._('Guest agent not installed')."</td><td></td><td></td><td></td></tr>";
|
||||
$iptablestr = _('Requires guest agent installed');
|
||||
} else {
|
||||
$ipliststr = "<tr><td>"._('Guest not running')."</td><td></td><td></td><td></td><td></td></tr>";
|
||||
$iptablestr = _('Requires guest running');
|
||||
}
|
||||
}
|
||||
$iptablestr = str_replace("\n", "<br>", trim($iptablestr));
|
||||
|
||||
$changemedia = "getisoimageboth(\"{$uuid}\",\"hda\",\"{$cdbus}\",\"{$cdfile}\",\"hdb\",\"{$cdbus2}\",\"{$cdfile2}\")";
|
||||
$cdstr = $cdromcount." / 2<a class='hand' title='$title' href='#' onclick='$changemedia'> <i class='fa fa-bullseye' ></i></a>";
|
||||
$title = _('Select ISO image');
|
||||
$cdstr = $cdromcount." / 2<a class='hand' title='$title' href='#' onclick='$changemedia'><i class='fa fa-bullseye' ></i></a>";
|
||||
echo "<tr parent-id='$i' class='sortable'><td class='vm-name' style='width:220px;padding:8px'><i class='fa fa-arrows-v mover orange-text'></i>";
|
||||
echo "<span class='outer'><span id='vm-$uuid' $menu class='hand'>$image</span><span class='inner'><a href='#' onclick='return toggle_id(\"name-$i\")' title='click for more VM info'>$vm</a><br><i class='fa fa-$shape $status $color'></i><span class='state'>"._($status)." $snapshotstcount</span></span></span></td>";
|
||||
echo "<td>$desc</td>";
|
||||
@@ -195,7 +200,7 @@ foreach ($vms as $vm) {
|
||||
echo "<tr child-id='$i' id='name-$i".(in_array('name-'.$i++,$show) ? "'>" : "' style='display:none'>");
|
||||
echo "<td colspan='8' style='margin:0;padding:0'>";
|
||||
echo "<table class='tablesorter domdisk'>";
|
||||
echo "<thead class='child'><tr><th><i class='fa fa-hdd-o'></i> <b>"._('Disk devices')."</b></th><th>"._('Serial')."</b></th><th>"._('Bus')."</th><th>"._('Capacity')."</th><th>"._('Allocation')."</th><th>Boot Order</th</tr></thead>";
|
||||
echo "<thead class='child'><tr><th><i class='fa fa-hdd-o'></i> <b>",_('Disk devices'),"</b></th><th>",_('Serial'),"</b></th><th>",_('Bus'),"</th><th>",_('Capacity'),"</th><th>",_('Allocation'),"</th><th>Boot Order</th</tr></thead>";
|
||||
echo "<tbody class='child'>";
|
||||
|
||||
/* Display VM disks */
|
||||
@@ -231,60 +236,56 @@ foreach ($vms as $vm) {
|
||||
$capacity = $lv->format_size($arrCD['capacity'], 0);
|
||||
$allocation = $lv->format_size($arrCD['allocation'], 0);
|
||||
$disk = $arrCD['file'] ?? $arrCD['partition'] ?? "" ;
|
||||
$dev = $arrCD['device'];
|
||||
$bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
|
||||
$boot= $arrCD["boot order"] ?? "" ;
|
||||
if ($boot < 1) $boot="Not set";
|
||||
$dev = $arrCD['device'];
|
||||
$bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO';
|
||||
$boot = $arrCD["boot order"] ?? "" ;
|
||||
if ($boot < 1) $boot = "Not set";
|
||||
if ($disk != "" ) {
|
||||
$title = _("Eject CD Drive").".";
|
||||
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\", \"--eject\")";
|
||||
echo "<tr><td>$disk <a title='$title' href='#' onclick='$changemedia'> <i class='fa fa-eject' aria-hidden=true></i></a></td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
|
||||
$title = _('Eject CD Drive');
|
||||
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\", \"--eject\")";
|
||||
echo "<tr><td>$disk <a title='$title' href='#' onclick='$changemedia'> <i class='fa fa-eject'></i></a></td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
|
||||
} else {
|
||||
$title = _("Insert CD").".";
|
||||
$title = _('Insert CD');
|
||||
$changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\",\"--select\")";
|
||||
$disk = _("No CD image inserted in to drive");
|
||||
echo "<tr><td>$disk<a title='$title' href='#' onclick='$changemedia'> <i class='fa fa-bullseye' aria-hidden=true></i></a> </td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
|
||||
|
||||
echo "<tr><td>$disk<a title='$title' href='#' onclick='$changemedia'><i class='fa fa-bullseye'></i></a></td><td></td><td>$bus</td><td>$capacity</td><td>$allocation</td><td>$boot</td></tr>";
|
||||
}
|
||||
|
||||
}
|
||||
echo "</tbody>";
|
||||
/* Display VM IP Addresses "execute":"guest-network-get-interfaces" --pretty */
|
||||
echo "<thead class='child'><tr><th><i class='fa fa-sitemap'></i> <b>"._('Interfaces')."</b></th><th></th><th></th><th>"._('Type')."</th><th>"._('IP Address')."</th><th>"._('Prefix')."</th></tr></thead>";
|
||||
echo "<thead class='child'><tr><th><i class='fa fa-sitemap'></i> <b>",_('Interfaces')."</b></th><th></th><th></th><th>",_('Type')."</th><th>",_('IP Address'),"</th><th>",_('Prefix'),"</th></tr></thead>";
|
||||
echo "<tbody class='child'>";
|
||||
echo $ipliststr ;
|
||||
echo "</tbody>";
|
||||
/* Display VM Snapshots */
|
||||
if ($snapshots != null) {
|
||||
$j=0 ;
|
||||
$steps = array() ;
|
||||
foreach($snapshots as $snap) {
|
||||
$j = 0;
|
||||
$steps = array();
|
||||
foreach ($snapshots as $snap) {
|
||||
if ($snap['parent'] == "" || $snap['parent'] == "Base") $j++;
|
||||
$steps[$j] .= $snap['name'].';' ;
|
||||
}
|
||||
echo "<thead class='child' child-id='$i'><tr><th><i class='fa fa-clone'></i> <b>"._('Snapshots')."</b></th><th></th><th>"._('Date/Time')."</th><th>"._('Type')."</th><th>"._('Parent')."</th><th>"._('Memory')."</th></tr></thead>";
|
||||
echo "<tbody class='child'child-id='$i'>";
|
||||
foreach($steps as $stepsline)
|
||||
{
|
||||
$snapshotlist = explode(";",$stepsline) ;
|
||||
$tab = " " ;
|
||||
foreach($snapshotlist as $snapshotitem) {
|
||||
if ($snapshotitem == "") continue ;
|
||||
$snapshot = $snapshots[$snapshotitem] ;
|
||||
$snapshotstate = _(ucfirst($snapshot["state"])) ;
|
||||
$snapshotdesc = $snapshot["desc"] ;
|
||||
$snapshotmemory = _(ucfirst($snapshot["memory"]["@attributes"]["snapshot"])) ;
|
||||
$snapshotparent = $snapshot["parent"] ? $snapshot["parent"] : "None";
|
||||
$snapshotdatetime = my_time($snapshot["creationtime"],"Y-m-d" )."<br>".my_time($snapshot["creationtime"],"H:i:s") ;
|
||||
$snapmenu = sprintf("onclick=\"addVMSnapContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,$snapshot["name"],$vmpreview);
|
||||
echo "<tr><td><span id='vmsnap-$uuid' $snapmenu class='hand'>$tab|__ <i class='fa fa-clone'></i></span> ".$snapshot["name"]."</td><td>$snapshotdesc</td><td><span class='inner' style='font-size:1.1rem;'>$snapshotdatetime</span></td><td>$snapshotstate</td><td>$snapshotparent</td><td>$snapshotmemory</td></tr>";
|
||||
$tab .=" " ;
|
||||
$steps[$j] .= $snap['name'].';';
|
||||
}
|
||||
echo "<thead class='child' child-id='$i'><tr><th><i class='fa fa-clone'></i> <b>",_('Snapshots'),"</b></th><th></th><th>",_('Date/Time'),"</th><th>",_('Type'),"</th><th>",_('Parent'),"</th><th>",_('Memory'),"</th></tr></thead>";
|
||||
echo "<tbody class='child'child-id='$i'>";
|
||||
foreach ($steps as $stepsline) {
|
||||
$snapshotlist = explode(";",$stepsline);
|
||||
$tab = " ";
|
||||
foreach ($snapshotlist as $snapshotitem) {
|
||||
if ($snapshotitem == "") continue;
|
||||
$snapshot = $snapshots[$snapshotitem] ;
|
||||
$snapshotstate = _(ucfirst($snapshot["state"]));
|
||||
$snapshotdesc = $snapshot["desc"];
|
||||
$snapshotmemory = _(ucfirst($snapshot["memory"]["@attributes"]["snapshot"]));
|
||||
$snapshotparent = $snapshot["parent"] ? $snapshot["parent"] : "None";
|
||||
$snapshotdatetime = my_time($snapshot["creationtime"],"Y-m-d" )."<br>".my_time($snapshot["creationtime"],"H:i:s");
|
||||
$snapmenu = sprintf("onclick=\"addVMSnapContext('%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,$snapshot["name"],$vmpreview);
|
||||
echo "<tr><td><span id='vmsnap-$uuid' $snapmenu class='hand'>$tab|__ <i class='fa fa-clone'></i></span> ",$snapshot["name"],"</td><td>$snapshotdesc</td><td><span class='inner' style='font-size:1.1rem;'>$snapshotdatetime</span></td><td>$snapshotstate</td><td>$snapshotparent</td><td>$snapshotmemory</td></tr>";
|
||||
$tab .=" ";
|
||||
}
|
||||
echo "</tbody>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
echo "\0".implode($kvm);
|
||||
?>
|
||||
|
||||
@@ -15,7 +15,8 @@ table.domdisk tbody tr:nth-child(even){background-color:transparent!important}
|
||||
table.domdisk tbody tr:nth-child(4n-1){background-color:transparent!important}
|
||||
table.snapshot{margin-top:0}
|
||||
i.mover{margin-right:8px;display:none}
|
||||
i.fa-bullseye{padding-left:8px}
|
||||
#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}
|
||||
span.vmgraphics{font-size:1.1rem;text-align: left}
|
||||
span.vmgraphics{font-size:1.1rem;text-align:left}
|
||||
|
||||
Reference in New Issue
Block a user