cleanup
This commit is contained in:
parent
6c296d90fb
commit
c35b6d927a
|
@ -44,7 +44,15 @@ function serverdepropdown($server, $val, $what){
|
|||
}
|
||||
echo "$enddiv</div></div></div><input type=hidden id=".$what."buttonh name=$what value=$val>";
|
||||
}
|
||||
|
||||
function formatbuttons($label, $val){
|
||||
echo "<div class=row><div class=col>$label</div><div class=col><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=".$label."button$label data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=formatbutton$label>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('".$label."button$label','')\"> </a>";
|
||||
echo "<div class=dropdown-divider></div>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('".$label."button$label','raw')\">raw</a>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('".$label."button$label','qcow2')\">qcow2</a>";
|
||||
echo "</div></div></div></div></div><input type=hidden id=".$label."button".$label."h name=$label value=\"$val\">";
|
||||
}
|
||||
//read config file
|
||||
$configfile = new SplFileObject("/etc/nlvmi/nlvmi.conf");
|
||||
while (!$configfile->eof()) {
|
||||
|
@ -319,39 +327,14 @@ if (isset($_SESSION['username'])){
|
|||
}
|
||||
}
|
||||
if (isset($_POST['serverbuttoni'])){
|
||||
serverdepropdown($_POST['serverbuttoni'], "no drive1", 'drive1');
|
||||
formatbuttons('format1', '');
|
||||
serverdepropdown($_POST['serverbuttoni'], "no drive2", 'drive2');
|
||||
formatbuttons('format2', '');
|
||||
serverdepropdown($_POST['serverbuttoni'], "no drive3", 'drive3');
|
||||
formatbuttons('format3', '');
|
||||
serverdepropdown($_POST['serverbuttoni'], "no cdrom", 'cdrom');
|
||||
exit;
|
||||
//not nice, i know... Will do a function later...
|
||||
} elseif (isset($_POST['serverbuttona'])){
|
||||
serverdepropdown($_POST['serverbuttona'], "no drive1", 'drive1');
|
||||
echo "<div class=row><div class=col>format1</div><div class=col><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=format1buttonformat1 data-toggle=dropdown aria-haspopup=true aria-expanded=false></button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=formatbuttonformat1>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format1buttonformat1','')\"> </a>";
|
||||
echo "<div class=dropdown-divider></div>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format1buttonformat1','raw')\">raw</a>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format1buttonformat1','qcow2')\">qcow2</a>";
|
||||
echo "</div></div></div></div></div></div></div><input type=hidden id=format1buttonformat1h name=format1 value=\"no drive1\">";
|
||||
exit;
|
||||
} elseif (isset($_POST['serverbuttonb'])){
|
||||
serverdepropdown($_POST['serverbuttonb'], "no drive2", 'drive2');
|
||||
echo "<div class=row><div class=col>format2</div><div class=col><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=format2buttonformat2 data-toggle=dropdown aria-haspopup=true aria-expanded=false></button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=formatbuttonformat2>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format2buttonformat2','')\"> </a>";
|
||||
echo "<div class=dropdown-divider></div>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format2buttonformat2','raw')\">raw</a>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format2buttonformat2','qcow2')\">qcow2</a>";
|
||||
echo "</div></div></div></div></div><input type=hidden id=format2buttonformat2h name=format2 value=\"no drive1\">";
|
||||
exit;
|
||||
} elseif (isset($_POST['serverbuttonc'])){
|
||||
serverdepropdown($_POST['serverbuttonc'], "no drive3", 'drive3');
|
||||
echo "<div class=row><div class=col>format3</div><div class=col><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=format3buttonformat3 data-toggle=dropdown aria-haspopup=true aria-expanded=false></button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=formatbuttonformat3>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format3buttonformat3','')\"> </a>";
|
||||
echo "<div class=dropdown-divider></div>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format3buttonformat3','raw')\">raw</a>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('format3buttonformat3','qcow2')\">qcow2</a>";
|
||||
echo "</div></div></div></div></div><input type=hidden id=format3buttonformat3h name=format3 value=\"no drive1\">";
|
||||
exit;
|
||||
}
|
||||
|
||||
//ajax queries are all done, time for the header
|
||||
|
@ -534,13 +517,7 @@ if (isset($_SESSION['username'])){
|
|||
echo "</div></div></div></div><input type=hidden id=archbuttonh name=arch value=x86_64>";
|
||||
// echo "$arrColnames[$col] <select name=arch><option value=qemu-system-x86_64>x86_64</option></select></br>";
|
||||
} elseif (preg_match('/format/', $arrColnames[$col])){
|
||||
echo "<div class=row><div class=col>$arrColnames[$col]</div><div class=col><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=$arrColnames[$col]button$arrColnames[$col] data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=formatbutton$arrColnames[$col]>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('$arrColnames[$col]button$arrColnames[$col]','')\"> </a>";
|
||||
echo "<div class=dropdown-divider></div>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('$arrColnames[$col]button$arrColnames[$col]','raw')\">raw</a>";
|
||||
echo "<a class=dropdown-item href=\"javascript:dropdown('$arrColnames[$col]button$arrColnames[$col]','qcow2')\">qcow2</a>";
|
||||
echo "</div></div></div></div></div></div><input type=hidden id=$arrColnames[$col]button$arrColnames[$col]h name=$arrColnames[$col] value=\"$val\">";
|
||||
formatbuttons($arrColnames[$col], $val);
|
||||
} elseif ($arrColnames[$col] == "autostart"){
|
||||
$checked="";
|
||||
if ($val=="1"){
|
||||
|
@ -548,7 +525,7 @@ if (isset($_SESSION['username'])){
|
|||
}
|
||||
echo "<div class=row><div class=col-md-1 style=text-align:right>autostart</div><div class=col-md-2><input data-onstyle=\"success\" data-offstyle=danger name=autostart id=\"autostart\" type=\"checkbox\" data-toggle=\"toggle\" data-on=\"boot with host\" data-off=\"no autostart\" $checked></div></div>";
|
||||
} elseif ($arrColnames[$col] == "cdrom"){
|
||||
echo "<div id=cdromdiv>";
|
||||
//echo "<div id=cdromdiv>";
|
||||
serverdepropdown($server, $val, "cdrom");
|
||||
echo "</div>";
|
||||
} elseif (preg_match('/tapdev/', $arrColnames[$col])) {
|
||||
|
@ -558,9 +535,10 @@ if (isset($_SESSION['username'])){
|
|||
} elseif (preg_match('/brdev/', $arrColnames[$col])) {
|
||||
echo "<div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><input class=form-control type=text name=$arrColnames[$col] value=\"$val\" placeholder=\"$placehold[$colname]\"></div></div>";
|
||||
} elseif (preg_match('/drive/', $arrColnames[$col])){
|
||||
echo "<div id=$arrColnames[$col]div>";
|
||||
if ($arrColnames[$col]=="drive1"){
|
||||
echo "<div id=drivesdiv>";
|
||||
}
|
||||
serverdepropdown($server, $val, $arrColnames[$col]);
|
||||
|
||||
} elseif ($arrColnames[$col] == "server"){
|
||||
echo "<div class=row><div class=col-md-1 style=text-align:right>$arrColnames[$col]</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=$arrColnames[$col]button data-toggle=dropdown aria-haspopup=true aria-expanded=false>$val</button>";
|
||||
echo "<div class=dropdown-menu aria-labelledby=$arrColnames[$col]button>";
|
||||
|
@ -583,9 +561,6 @@ if (isset($_SESSION['username'])){
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(($mode!="newvm")&&($mode!="editvm")&&($mode!='usermgmt')){
|
||||
if ($_SESSION['isadmin']=="1"){
|
||||
$sqllimit="";
|
||||
|
|
29
web/nlvmi.js
29
web/nlvmi.js
|
@ -15,36 +15,11 @@ function dropdown(i,e) {
|
|||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "?rand="+ makeid(),
|
||||
data: "serverbuttoni="+e,
|
||||
data: "serverbuttoni="+ e,
|
||||
success: function(response) {
|
||||
document.getElementById('cdromdiv').innerHTML = response;
|
||||
document.getElementById('drivesdiv').innerHTML = response;
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "?rand="+ makeid(),
|
||||
data: "serverbuttona="+e,
|
||||
success: function(response) {
|
||||
document.getElementById('drive1div').innerHTML = response;
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "?rand="+ makeid(),
|
||||
data: "serverbuttonb="+e,
|
||||
success: function(response) {
|
||||
document.getElementById('drive2div').innerHTML = response;
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "?rand="+ makeid(),
|
||||
data: "serverbuttonc="+e,
|
||||
success: function(response) {
|
||||
document.getElementById('drive3div').innerHTML = response;
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue