bootstrap introduced

This commit is contained in:
mad 2018-08-12 15:09:47 +02:00
parent f5fa2a3ada
commit abcc43367d
7 changed files with 100 additions and 42 deletions

7
web/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

7
web/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
web/header.php Normal file
View File

@ -0,0 +1,13 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<script src="jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src="nlvmi.js"></script>
<title>nlvmi</title>
</head>
<body>
<div class=container-fluid><div class="row" style="background-color:lightgreen;"><div class="col"><h1><a href="?" style=color:white;>nlvmi</a></h1></div></div>

View File

@ -35,9 +35,12 @@ if ($config['DATABASETYPE']=="sqlite"){
exit;
}
}
include('header.php');
$mode="";
//form for edit and new vms
if (isset($_REQUEST['edit'])){
$mode="editvm";
$formname="editvm";
$eid=clean($_REQUEST['edit']);
$sql="SELECT * FROM vms WHERE id='$eid'";
@ -49,8 +52,9 @@ if (isset($_REQUEST['edit'])){
} elseif(isset($_REQUEST['newvm'])) {
$formname="newvm";
$editid="";
$mode="newvm";
}
//echo $e[vmname];
if (isset($formname)){
echo "<h2>$formname</h2></br>";
echo "<form name=$formname action=? method=post>";
@ -61,67 +65,83 @@ while ($col = $res->fetchArray(SQLITE3_ASSOC)) {
for ($col=0; $col <count($arrColnames); $col++){
if ($arrColnames[$col]!="id"){
if ($arrColnames[$col] == "bootoption"){
echo "$arrColnames[$col] <select name=bootoption><option value=c>C</option><option value=d>D</option></select></br>";
echo "<div class=row><div class=col-md-1 style=text-align:right>bootoption</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=bootoptionbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>C</button>";
echo "<div class=dropdown-menu aria-labelledby=bootoptionbutton>";
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','C')\">C</a>";
echo "<a class=dropdown-item href=\"javascript:dropdown('bootoptionbutton','D')\">D</a>";
echo "</div></div></div></div><input type=hidden id=bootoptionbuttonh name=bootoption value=c>";
// echo "$arrColnames[$col] <select name=bootoption><option value=c>C</option><option value=d>D</option></select></br>";
} elseif ($arrColnames[$col] == "arch"){
echo "$arrColnames[$col] <select name=arch><option value=qemu-system-x86_64>x86_64</option></select></br>";
echo "<div class=row><div class=col-md-1 style=text-align:right>bootoption</div><div class=col-md-2><div class=dropdown><button class=\"btn btn-secondary dropdown-toggle\" type=button id=archbutton data-toggle=dropdown aria-haspopup=true aria-expanded=false>x86_64</button>";
echo "<div class=dropdown-menu aria-labelledby=archbutton>";
echo "<a class=dropdown-item href=\"javascript:dropdown('archbutton','x86_64')\">x86_64</a>";
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>";
} else {
if (isset($e[$arrColnames[$col]])){
$val = $e[$arrColnames[$col]];
} else {
$val = "";
}
echo "$arrColnames[$col] <input type=text name=$arrColnames[$col] value=$val></br>";
echo "<div class=row><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></div></div>";
}
}
}
echo "$editid<input type=hidden name=mode value=$formname><input type=submit></form>";
echo "$editid<input type=hidden name=mode value=$formname><input class=\"btn btn-primary\" type=submit></form>";
}
echo "<a href=?newvm>Create a new VM</a></br>";
//getting vms from DB
$sql="SELECT * FROM vms";
$res = $db_handle->query($sql);
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
echo "<div style=\"border:solid 1px;float:left;min-width:100px;\">$row[vmname]</br><a href=?edit=$row[id]>edit</a></div>";
}
//insert in db
if(isset($_REQUEST['mode'])){
if($_REQUEST['mode']=="newvm"){
$sqls="INSERT INTO vms ";
$sqlc="(";
$sqlv=" VALUES (";
foreach(array_keys($_REQUEST) as $rkey){
if($_REQUEST['mode']=="newvm"){
$mode="newvm";
$sqls="INSERT INTO vms ";
$sqlc="(";
$sqlv=" VALUES (";
foreach(array_keys($_REQUEST) as $rkey){
if ($rkey!="mode"){
$rvalue = clean($_REQUEST[$rkey]);
$sqlc .= "$rkey,";
$sqlv .= "'$rvalue',";
}
}
$sqlc = rtrim($sqlc, ',');
$sqlc.=")";
$sqlv = rtrim($sqlv, ',');
$sqlv.=")";
$sql = "$sqls$sqlc$sqlv";
echo $sql;
$result = $db_handle->exec($sql);
//$result = $db_handle->query($sql);
print_r($result);
} elseif ($_REQUEST['mode']=="editvm"){
$sql="UPDATE vms SET ";
foreach(array_keys($_REQUEST) as $rkey){
}
$sqlc = rtrim($sqlc, ',');
$sqlc.=")";
$sqlv = rtrim($sqlv, ',');
$sqlv.=")";
$sql = "$sqls$sqlc$sqlv";
echo $sql;
$result = $db_handle->exec($sql);
} elseif ($_REQUEST['mode']=="editvm"){
$mode="editvm";
$sql="UPDATE vms SET ";
foreach(array_keys($_REQUEST) as $rkey){
if (($rkey!="mode")&&($rkey!="editid")){
$rvalue = clean($_REQUEST[$rkey]);
$sql .= " $rkey='$rvalue',";
}
}
$sql = rtrim($sql, ',');
$eid=clean($_REQUEST['editid']);
$sql .= " WHERE id='$eid'";
$result = $db_handle->exec($sql);
}
}
$sql = rtrim($sql, ',');
$eid=clean($_REQUEST['editid']);
$sql .= " WHERE id='$eid'";
$result = $db_handle->exec($sql);
if($mode!="newvm"){
echo "<a href=?newvm>Create a new VM</a></br>";
}
//getting vms from DB
$sql="SELECT * FROM vms";
$res = $db_handle->query($sql);
echo "<div class=row>";
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
echo "<div class=col style=\"border:solid 1px;\">$row[vmname]</br><a href=?edit=$row[id]>edit</a></div>";
}
echo "</div></div></body></html>";
?>

2
web/jquery-3.3.1.slim.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4
web/nlvmi.js Normal file
View File

@ -0,0 +1,4 @@
function dropdown(i,e) {
document.getElementById(i).innerHTML = e;
document.getElementById(i +'h').value = e;
}

5
web/popper.min.js vendored Normal file

File diff suppressed because one or more lines are too long