Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions WebContent/AddProduct.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Add Product</title>
</head>
<script>
function loadDoc()
{
var id=document.getElementById('id').value;
var code=document.getElementById('code').value;
var name=document.getElementById('name').value;
var desc=document.getElementById('desc').value;
var price=document.getElementById('price').value;
var category=document.getElementById('category').value;
var obj={
"id":id,
"code":code,
"name":name,
"desc":desc,
"price":price,
"category":category
}
var s=JSON.stringify(obj);
//console.log(s);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var obj1=this.responseText;
var x="<h3>Product Created </h3><br>";
document.getElementById('success').innerHTML=x;

}
else if(this.readyState == 4 && this.status == 400)
{
var obj1 = this.responseText;
console.log(obj1);

}
};
xhttp.open("POST", "http://localhost:8080/OrderManagementSystem/home/products/", true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(s);

}
</script>
<body>


<div id="main">
<div id="table">
<div id="header">
<p>Add a product</p>
</div>
<div id="mainBody">
<form method="post">
<label>Product ID</label>
<input type="text" id="id" name="id">
<label>Product code</label>
<input type="text" id="code" name="code">
<label>Product name</label>
<input type="text" id="name" name="name">
<label>Description</label>
<input type="text" id="desc" name="description">
<label>Product cost</label>
<input type="number" id="price" name="price">
<label>Category</label>
<select id="category" name="category">
<option value="GROCERY_AND_STAPLES">GROCERY_AND_STAPLES</option>
<option value="VEGETABLES_AND_FRUITS">VEGETABLES_AND_FRUITS</option>
<option value="HOME_AND_KITCHEN">HOME_AND_KITCHEN</option>
<option value="PERSONAL_CARE">PERSONAL_CARE</option>
<option value="BISCUITS_SNACKS_CHOCOLATES">BISCUITS_SNACKS_CHOCOLATES</option>
<option value="HOUSEHOLD_ITEMS">HOUSEHOLD_ITEMS</option>
<option value="BREAKFAST_AND_DAIRY">BREAKFAST_AND_DAIRY</option>
<option value="BEVERAGES">BEVERAGES</option>

</select>
<button type="submit" onclick="loadDoc()">Submit Details</button>
</form>

</div>
</div>
</div>

<div id="success"></div>
</body>
</html>
48 changes: 48 additions & 0 deletions WebContent/GetAllProduct.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Get all products</title>
</head>

<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var txt="";
if (this.readyState == 4 && this.status == 200) {

var obj1=JSON.parse(this.responseText);
var x="<table><tr><th>Id</th><th>Code</th><th>Name</th><th>description</th><th>Price</th><th>Category</th></tr>";
for(i in obj1)
{
x+="<tr><td>"+obj1[i].id+"</td><td>"+obj1[i].code+"</td><td>"+obj1[i].name+"</td><td>"+obj1[i].desc+"</td><td>"+obj1[i].price+"</td><td>"+obj1[i].category+"</td></tr>";
}
x=="</table>"
document.getElementById('success').innerHTML=x;

}
else if(this.readyState == 4 && this.status == 400)
{
var obj1=JSON.parse(this.responseText);


for(i in obj1){
var x="<table><tr><td>"+obj1[i]+"</td></tr></table>"
document.getElementById('success').innerHTML=x;
}
}
};
xhttp.open("GET", "http://localhost:8080/OrderManagementSystem/home/products/all-products", true);
xhttp.send();
}
window.onload=loadDoc();
</script>
<body>
<div id="success">
</div>



</body>
</html>
51 changes: 51 additions & 0 deletions WebContent/ViewProduct.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<script>
function loadDoc() {
var z=document.getElementById('id').value;

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var txt="";
if (this.readyState == 4 && this.status == 200) {

var obj1=JSON.parse(this.responseText);
var x="<table><tr><th>Id</th><th>Code</th><th>Name</th><th>Description</th><th>Price</th><th>Category</th></tr>";
x+="<tr><td>"+obj1.id+"</td><td>"+obj1.code+"</td><td>"+obj1.name+"</td><td>"+obj1.desc+"</td><td>"+obj1.price+"</td><td>"+obj1.category+"</td></tr>";
x+="</table>";
document.getElementById('success').innerHTML=x;


}
else if(this.readyState == 4 && this.status == 400)
{
var obj1=JSON.parse(this.responseText);


for(i in obj1){
var x="<table><tr><td>"+obj1[i]+"</td></tr></table>"
document.getElementById('success').innerHTML=x;
}
}
};
xhttp.open("GET", "http://localhost:8080/OrderManagementSystem/home/products/"+z, true);
xhttp.send();
}

</script>
<body>
<div id="upper">
<h3>Enter the Product Id</h3>
<input type="text" placeholder="User Id" required id="id" >
<button onclick="loadDoc()">Submit</button>
</div>
<br>
<br>
<div id="success">
</div>
</body>
</html>