newest changes
This commit is contained in:
+42
-5
@@ -26,10 +26,47 @@ $(function() {
|
||||
// General function to parse JSON
|
||||
function onReaderLoad(event) {
|
||||
var obj = JSON.parse(event.target.result);
|
||||
console.log(obj.orders);
|
||||
obj.orders.map((order) => {
|
||||
console.log(order);
|
||||
$('#table').append("<div class='flexBasicRow'><p class='col'>" + order.customer_id + "</p><p class='col'>" + order.order_no + "</p><p class='col'>" + order.part_id + "</p><p class='col'>" + order.parent_part + "</p><p class='col'>" + order.price + "</p><p class='col'>" + order.qty + "</p></p><p class='col'>" + order.paid + "</p></div>").fadeIn();
|
||||
});
|
||||
console.log(obj);
|
||||
|
||||
insertOrders(obj);
|
||||
getOrders(addToDOM);
|
||||
}
|
||||
|
||||
addToDOM = (orders) => {
|
||||
orders.map((order) => {
|
||||
$('#table').append("<div class='flexBasicRow'><p class='col'>" + order.customer_id + "</p><p class='col'>" + order.order_no + "</p><p class='col'>" + order.part_id + "</p><p class='col'>" + order.parent_part + "</p><p class='col'>" + order.price + "</p><p class='col'>" + order.qty + "</p></p><p class='col'>" + order.paid + "</p></div>").fadeIn();
|
||||
});
|
||||
}
|
||||
|
||||
insertOrders = (orders) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "http://localhost:3000/insertorders",
|
||||
data: orders,
|
||||
success: function (data) {
|
||||
alert("Success");
|
||||
},
|
||||
dataType: "json",
|
||||
error : function(request, error) {
|
||||
console.log("Request: " + JSON.stringify(request));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getOrders = (callback) => {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "http://localhost:3000/getorders",
|
||||
data: {},
|
||||
success: function (res) {
|
||||
orders = res.result;
|
||||
|
||||
callback(orders);
|
||||
},
|
||||
dataType: "json",
|
||||
error : function(request, error) {
|
||||
console.log("Request: " + JSON.stringify(request));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Data Flow</title>
|
||||
|
||||
<!-- Package/dependencies -->
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="styles.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="flexBasicCol">
|
||||
<div class="flexBasicCol card">
|
||||
<p class="pageHeader">Input a JSON file with order details</p>
|
||||
<input type="file" id="inputFile" value="Import" />
|
||||
</div>
|
||||
|
||||
<div class="flexBasicCol card" id="table">
|
||||
<div class="flexBasicRow headRow">
|
||||
<p class="col">customer_id</p>
|
||||
<p class="col">order_no</p>
|
||||
<p class="col">part_id</p>
|
||||
<p class="col">parent_part</p>
|
||||
<p class="col">price</p>
|
||||
<p class="col">qty</p>
|
||||
<p class="col">paid</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Importing JS files after for efficient render -->
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user