Add "reset sorting" to docker and VM list

This commit is contained in:
bergware
2018-03-17 15:01:15 +01:00
parent a3fe701dfe
commit a884558664
4 changed files with 43 additions and 21 deletions
+5 -1
View File
@@ -111,7 +111,7 @@ 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 class="five">Autostart</th><th class="five" style="text-align:right;padding-right:24px"><i class="fa fa-sort"></i></th></tr></thead>
<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" style="text-align:right;padding-right:24px"><a href="#" style="cursor:hand" onclick="resetSorting()" title="Reset sorting"><i class="fa fa-sort"></i></a></th></tr></thead>
<tbody id="kvm_list"><tr><td colspan='9' style='text-align:center;padding:24px'><i class='fa fa-circle-o-notch fa-spin fa-3x fa-fw'></i></td></tr></tbody>
</table>
<input type="button" onclick="addVM()" id="btnAddVM" value="Add VM" style="display:none">
@@ -136,6 +136,10 @@ function resize(bind) {
}
}
<?endif;?>
function resetSorting() {
$('input[type=button]').prop('disabled',true);
$.post('/plugins/dynamix.vm.manager/include/UserPrefs.php',{reset:true},function(){loadlist();});
}
function loadlist() {
$.get('/plugins/dynamix.vm.manager/include/VMMachines.php',function(d) {
var data = d.split(/\0/);
@@ -12,12 +12,17 @@
*/
?>
<?
$prefs = '/boot/config/plugins/dynamix.vm.manager';
$names = explode(';',$_POST['names']);
$index = explode(';',$_POST['index']);
$save = []; $i = 0;
$user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
foreach ($names as $name) if ($name) $save[] = $index[$i++]."=\"".$name."\""; else $i++;
if (!is_dir($prefs)) mkdir($prefs);
file_put_contents("$prefs/userprefs.cfg", implode("\n",$save)."\n");
if (isset($_POST['reset'])) {
@unlink($user_prefs);
} else {
$names = explode(';',$_POST['names']);
$index = explode(';',$_POST['index']);
$save = []; $i = 0;
foreach ($names as $name) if ($name) $save[] = $index[$i++]."=\"".$name."\""; else $i++;
if (!is_dir(dirname($user_prefs))) mkdir(dirname($user_prefs));
file_put_contents($user_prefs, implode("\n",$save)."\n");
}
?>