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; exit;
} }
} }
include('header.php');
$mode="";
//form for edit and new vms //form for edit and new vms
if (isset($_REQUEST['edit'])){ if (isset($_REQUEST['edit'])){
$mode="editvm";
$formname="editvm"; $formname="editvm";
$eid=clean($_REQUEST['edit']); $eid=clean($_REQUEST['edit']);
$sql="SELECT * FROM vms WHERE id='$eid'"; $sql="SELECT * FROM vms WHERE id='$eid'";
@ -49,8 +52,9 @@ if (isset($_REQUEST['edit'])){
} elseif(isset($_REQUEST['newvm'])) { } elseif(isset($_REQUEST['newvm'])) {
$formname="newvm"; $formname="newvm";
$editid=""; $editid="";
$mode="newvm";
} }
//echo $e[vmname];
if (isset($formname)){ if (isset($formname)){
echo "<h2>$formname</h2></br>"; echo "<h2>$formname</h2></br>";
echo "<form name=$formname action=? method=post>"; echo "<form name=$formname action=? method=post>";
@ -61,36 +65,41 @@ while ($col = $res->fetchArray(SQLITE3_ASSOC)) {
for ($col=0; $col <count($arrColnames); $col++){ for ($col=0; $col <count($arrColnames); $col++){
if ($arrColnames[$col]!="id"){ if ($arrColnames[$col]!="id"){
if ($arrColnames[$col] == "bootoption"){ 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"){ } 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 { } else {
if (isset($e[$arrColnames[$col]])){ if (isset($e[$arrColnames[$col]])){
$val = $e[$arrColnames[$col]]; $val = $e[$arrColnames[$col]];
} else { } else {
$val = ""; $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 //insert in db
if(isset($_REQUEST['mode'])){ if(isset($_REQUEST['mode'])){
if($_REQUEST['mode']=="newvm"){ if($_REQUEST['mode']=="newvm"){
$mode="newvm";
$sqls="INSERT INTO vms "; $sqls="INSERT INTO vms ";
$sqlc="("; $sqlc="(";
$sqlv=" VALUES ("; $sqlv=" VALUES (";
@ -108,9 +117,8 @@ $sqlv.=")";
$sql = "$sqls$sqlc$sqlv"; $sql = "$sqls$sqlc$sqlv";
echo $sql; echo $sql;
$result = $db_handle->exec($sql); $result = $db_handle->exec($sql);
//$result = $db_handle->query($sql);
print_r($result);
} elseif ($_REQUEST['mode']=="editvm"){ } elseif ($_REQUEST['mode']=="editvm"){
$mode="editvm";
$sql="UPDATE vms SET "; $sql="UPDATE vms SET ";
foreach(array_keys($_REQUEST) as $rkey){ foreach(array_keys($_REQUEST) as $rkey){
if (($rkey!="mode")&&($rkey!="editid")){ if (($rkey!="mode")&&($rkey!="editid")){
@ -124,4 +132,16 @@ $sql .= " WHERE id='$eid'";
$result = $db_handle->exec($sql); $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