mirror of
https://github.com/unraid/webgui.git
synced 2026-03-08 03:49:53 -05:00
Added user preference for VM list
Changed animation to spinning 'knob'
This commit is contained in:
@@ -50,12 +50,12 @@ img.stopped{opacity:0.3}
|
||||
<script>
|
||||
function startAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='false') $('#'+ct.id).addClass('fa-spin');
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='false') $('#'+ct.id).find('i').addClass('fa-spin');
|
||||
$.post('/plugins/dynamix.docker.manager/include/ContainerManager.php',{action:'start'}, function(){loadlist();});
|
||||
}
|
||||
function stopAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='true') $('#'+ct.id).addClass('fa-spin');
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='true') $('#'+ct.id).find('i').addClass('fa-spin');
|
||||
$.post('/plugins/dynamix.docker.manager/include/ContainerManager.php',{action:'stop'}, function(){loadlist();});
|
||||
}
|
||||
<?if ($display['resize']):?>
|
||||
|
||||
@@ -144,7 +144,7 @@ function rmImage(image, imageName) {
|
||||
|
||||
function eventControl(params, reload) {
|
||||
var spin = typeof reload != 'undefined';
|
||||
if (spin) $('#'+params['container']).addClass('fa-spin');
|
||||
if (spin) $('#'+params['container']).find('i').addClass('fa-spin');
|
||||
$.post(eventURL, params, function(data) {
|
||||
if (data.success === true) {
|
||||
if (spin) setTimeout(reload+'()',500); else location=window.location.href;
|
||||
|
||||
@@ -86,10 +86,7 @@ if ($subaction) {
|
||||
}
|
||||
echo "<script>clearHistory();</script>";
|
||||
}
|
||||
if ($libvirt_running=='yes') {
|
||||
$vms = $lv->get_domains() ?: [];
|
||||
sort($vms);
|
||||
}
|
||||
if ($libvirt_running=='yes') $vms = $lv->get_domains();
|
||||
if (empty($vms)) {
|
||||
$msg = $libvirt_running=='yes'
|
||||
? 'No VMs defined. Create from template or add XML.'
|
||||
@@ -110,10 +107,11 @@ div.four label.cpu2{width:33%}
|
||||
div.Panel{float:unset;margin:4px;height:inherit;border:none;}
|
||||
div.Panel:hover{background-color:unset;}
|
||||
div.PanelText{display:none;}
|
||||
th.five{width:5%}
|
||||
</style>
|
||||
<table class="tablesorter shift kvm" id="kvm_table">
|
||||
<thead><tr><th><i class="fa fa-th-list"></i></th><th>Name</th><th>Description</th><th>CPUs</th><th>Memory</th><th>vDisks</th><th>Graphics</th><th>Autostart</th></tr></thead>
|
||||
<tbody id="kvm_list"><tr><td colspan='8' style='text-align:center;padding-top:12px'><i class='fa fa-spinner fa-spin icon'></i>Please wait... retrieving VM information</td></tr></tbody>
|
||||
<thead><tr><th><i class="fa fa-th-list"></i></th><th>Name</th><th>Description</th><th>CPUs</th><th>Memory</th><th>vDisks</th><th>Graphics</th><th class="five">Autostart</th><th class="five"><i class="fa fa-sort"></i></th></tr></thead>
|
||||
<tbody id="kvm_list"><tr><td colspan='9' style='text-align:center;padding-top:12px'><i class='fa fa-spinner fa-spin icon'></i>Please wait... retrieving VM information</td></tr></tbody>
|
||||
</table>
|
||||
<input type="button" onclick="addVM()" id="btnAddVM" value="Add VM"/>
|
||||
<input type="button" onclick="startAll()" value="Start all VMs"/>
|
||||
@@ -126,12 +124,12 @@ div.PanelText{display:none;}
|
||||
<script>
|
||||
function startAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state!='running') $('#vm-'+vm.id).addClass('fa-spin');
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state!='running') $('#vm-'+vm.id).find('i').addClass('fa-spin');
|
||||
$.post('/plugins/dynamix.vm.manager/classes/VMManager.php',{action:'start'}, function(){loadlist();});
|
||||
}
|
||||
function stopAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state=='running') $('#vm-'+vm.id).addClass('fa-spin');
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state=='running') $('#vm-'+vm.id).find('i').addClass('fa-spin');
|
||||
$.post('/plugins/dynamix.vm.manager/classes/VMManager.php',{action:'stop'}, function(){loadlist();});
|
||||
}
|
||||
function vncOpen() {
|
||||
@@ -210,6 +208,27 @@ foreach ($vms as $vm) {
|
||||
});
|
||||
context.init({preventDoubleContext:false});
|
||||
$('input[type=button]').prop('disabled',false);
|
||||
$('i.up,i.down').click(function() {
|
||||
var row1 = $(this).parents('tr:first');
|
||||
var row2 = row1.next();
|
||||
var color1 = row1.css('background-color');
|
||||
if ($(this).is('.up')) {
|
||||
var color2 = row1.prev().prev().css('background-color');
|
||||
row1.prev().prev().css('background-color',color1);
|
||||
row1.css('background-color',color2);
|
||||
row1.insertBefore(row1.prev().prev());
|
||||
row2.insertBefore(row2.prev().prev());
|
||||
} else {
|
||||
var color2 = row1.next().next().css('background-color');
|
||||
row1.next().next().css('background-color',color1);
|
||||
row1.css('background-color',color2);
|
||||
row2.insertAfter(row2.next().next());
|
||||
row1.insertAfter(row1.next().next());
|
||||
}
|
||||
var names = ''; var index = '';
|
||||
row1.parent().children().find('td.vm-name').each(function(){names+=$(this).text()+';';index+=$(this).parent().parent().children().index($(this).parent())+';';});
|
||||
$.post('/plugins/dynamix.vm.manager/classes/UserPrefs.php',{names:names,index:index});
|
||||
});
|
||||
});
|
||||
}
|
||||
$(function() {
|
||||
|
||||
21
plugins/dynamix.vm.manager/classes/UserPrefs.php
Normal file
21
plugins/dynamix.vm.manager/classes/UserPrefs.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2015-2018, Derek Macias, Eric Schultz, Jon Panozzo.
|
||||
* Copyright 2012-2018, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$names = explode(';',$_POST['names']);
|
||||
$index = explode(';',$_POST['index']);
|
||||
$save = []; $i = 0;
|
||||
|
||||
foreach ($names as $name) if ($name) $save[] = "$name=\"".$index[$i++]."\"";
|
||||
file_put_contents('/boot/config/plugins/dynamix.vm.manager/userprefs.txt', implode("\n",$save)."\n");
|
||||
?>
|
||||
@@ -16,12 +16,19 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
require_once "$docroot/plugins/dynamix.vm.manager/classes/libvirt_helpers.php";
|
||||
|
||||
$vms = $lv->get_domains() ?: [];
|
||||
sort($vms);
|
||||
$txt = '/boot/config/plugins/dynamix.vm.manager/userprefs.txt';
|
||||
$vms = $lv->get_domains();
|
||||
if (empty($vms)) {
|
||||
echo '<tr><td colspan="8" style="text-align:center;padding-top:12px">No Virtual Machines installed</td></tr>';
|
||||
return;
|
||||
}
|
||||
if (file_exists($txt)) {
|
||||
$prefs = parse_ini_file($txt); $sort = [];
|
||||
foreach ($vms as $vm) $sort[] = $prefs[$vm] ?? 999;
|
||||
array_multisort($sort,SORT_NUMERIC,$vms);
|
||||
} else {
|
||||
natsort($vms);
|
||||
}
|
||||
$i = 0;
|
||||
$menu = [];
|
||||
$kvm = ['var kvm=[];'];
|
||||
@@ -75,13 +82,14 @@ foreach ($vms as $vm) {
|
||||
/* VM information */
|
||||
echo "<tr style='background-color:".bcolor($i)."'>";
|
||||
echo "<td style='width:48px;padding:4px'>".renderVMContentIcon($uuid, $vm, $vmicon, $state)."</td>";
|
||||
echo "<td><a href='#' onclick='return toggle_id(\"name{$i}\")' title='click for more VM info'>$vm</a></td>";
|
||||
echo "<td class='vm-name'><a href='#' onclick='return toggle_id(\"name{$i}\")' title='click for more VM info'>$vm</a></td>";
|
||||
echo "<td>$desc</td>";
|
||||
echo "<td><a class='vcpu{$i}' style='cursor:pointer'>$vcpu</a></td>";
|
||||
echo "<td>$mem</td>";
|
||||
echo "<td title='$diskdesc'>$disks</td>";
|
||||
echo "<td>$graphics</td>";
|
||||
echo "<td><input class='autostart' type='checkbox' name='auto_{$vm}' title='Toggle VM auostart' uuid='$uuid' $auto></td></tr>";
|
||||
echo "<td><input class='autostart' type='checkbox' name='auto_{$vm}' title='Toggle VM auostart' uuid='$uuid' $auto></td>";
|
||||
echo "<td><a href='#' title='Move row up'><i class='fa fa-arrow-up up'></i></a> <a href='#' title='Move row down'><i class='fa fa-arrow-down down'></i></a></td></tr>";
|
||||
|
||||
/* Disk device information */
|
||||
echo "<tr id='name".($i++)."' style='display:none'>";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function ajaxVMDispatch(params, reload){
|
||||
var spin = typeof reload != 'undefined';
|
||||
if (spin) $('#vm-'+params['uuid']).addClass('fa-spin');
|
||||
if (spin) $('#vm-'+params['uuid']).find('i').addClass('fa-spin');
|
||||
$.post("/plugins/dynamix.vm.manager/VMajax.php", params, function(data) {
|
||||
if (data.error) {
|
||||
swal({title:"Execution error",text:data.error,type:"error"});
|
||||
|
||||
@@ -52,8 +52,15 @@ if (pgrep('dockerd')!==false && ($display['dashapps']=='icons' || $display['dash
|
||||
|
||||
if (pgrep('libvirtd')!==false && ($display['dashapps']=='icons' || $display['dashapps']=='vms')) {
|
||||
require_once "$docroot/plugins/dynamix.vm.manager/classes/libvirt_helpers.php";
|
||||
$vms = $lv->get_domains() ?: [];
|
||||
sort($vms);
|
||||
$txt = '/boot/config/plugins/dynamix.vm.manager/userprefs.txt';
|
||||
$vms = $lv->get_domains();
|
||||
if (file_exists($txt)) {
|
||||
$prefs = parse_ini_file($txt); $sort = [];
|
||||
foreach ($vms as $vm) $sort[] = $prefs[$vm] ?? 999;
|
||||
array_multisort($sort,SORT_NUMERIC,$vms);
|
||||
} else {
|
||||
natsort($vms);
|
||||
}
|
||||
foreach ($vms as $vm) {
|
||||
$res = $lv->get_domain_by_name($vm);
|
||||
$uuid = libvirt_domain_get_uuid_string($res);
|
||||
|
||||
Reference in New Issue
Block a user