diff --git a/main.js b/main.js new file mode 100644 index 0000000..8c89bb6 --- /dev/null +++ b/main.js @@ -0,0 +1,35 @@ +/* + * By: Arjun Patel + * Date: 7/30/18 + * + */ + +/* + * jQuery function call on DOM loading + */ +$(function() { + + // Event Handlers + $("#inputFile").change(function(e) { + onChangeInput(e); + $('#inputFile').css("background-color", "#0d7aa5"); + }); + + + // Helper Function to read/load specific file + function onChangeInput(event) { + var reader = new FileReader(); + reader.onload = onReaderLoad; + reader.readAsText(event.target.files[0]); + } + + // 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("

" + order.customer_id + "

" + order.order_no + "

" + order.part_id + "

" + order.parent_part + "

" + order.price + "

" + order.qty + "

" + order.paid + "

").fadeIn(); + }); + } +}); diff --git a/sample_data.json b/sample_data.json index c6358c0..52d0b7b 100644 --- a/sample_data.json +++ b/sample_data.json @@ -1,25 +1,58 @@ -[{ - "first" : "John", - "last" : "Smith", - "email" : "johnsmith@gmail.com", - "phone" : 9492039201, - "address" : "12123 Stock Ave, Stockton, CA 92112", - "age" : 34 -}, { - "first" : "Mike", - "last" : "Jordan", - "email" : "mekadn@gmail.com", - "phone" : 8321829301, - "address" : "2121 Elk Tree, Victorville, CA 73821", - "age" : 21 -}, -{ - "first" : "Alex", - "last" : "Bergues", - "email" : "abuesg@gmail.com", - "phone" : "9120219293", - "address" : "81239 Oak Grove Ave, Folsom, CA 22012", - "age" : 50 + "orders" : + [{ + "customer_id" : 1, + "order_no" : 1, + "part_id" : 1111, + "parent_part" : 1111, + "price" : 1000, + "qty" : 2, + "paid" : 2000 + }, + { + "customer_id" : 1, + "order_no" : 2, + "part_id" : 2321, + "parent_part" : 1111, + "price" : 500, + "qty" : 2, + "paid" : 1000 + }, + { + "customer_id" : 2, + "order_no" : 3, + "part_id" : 1232, + "parent_part" : 2222, + "price" : 200, + "qty" : 1, + "paid" : 200 + }, + { + "customer_id" : 3, + "order_no" : 4, + "part_id" : 12321, + "parent_part" : 3333, + "price" : 100, + "qty" : 1, + "paid" : 100 + }, + { + "customer_id" : 3, + "order_no" : 5, + "part_id" : 3331, + "parent_part" : 1111, + "price" : 500, + "qty" : 1, + "paid" : 500 + }, + { + "customer_id" : 4, + "order_no" : 6, + "part_id" : 2343, + "parent_part" : 1222, + "price" : 150, + "qty" : 1, + "paid" : 150 + } + ] } -] \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..a512697 --- /dev/null +++ b/styles.css @@ -0,0 +1,79 @@ +html { + height: 100%; + width: 100%; + margin: 0; + padding: 0; + display: flex; + font-family: 'Montserrat', sans-serif; +} +body { + flex: 1; + display: flex; + justify-content: center; + align-items: center; + background-color: #eff3f4; +} +.flexBasicRow { + flex: 1; + display: flex; + align-items: stretch; + justify-content: center; + align-self: stretch; + min-width: 800px; +} +.flexBasicCol { + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-start; + align-self: stretch; +} +.flex-1 { + flex: 1; +} +.pageHeader { + font-size: 1.5em; + font-weight: bold; + background-color: #0d7aa5; + padding: 1em; + color: white; + margin: 0; + align-self: stretch; + text-align: center; +} +#inputFile { + text-align: center; + padding: 1em; + margin: 1em; + background:#d0d4db; + border: none; + position:relative; + color:#fff; + border-radius:2px; + text-align:center; + float:left; + cursor:pointer; + transition: 1s; + -webkit-transition: 1s; +} +.card { + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + margin: 2em; +} +#table { + display: none; +} +.headRow { + background-color: #0d7aa5; + color: white; + align-self: stretch; +} +.col { + flex: 1; + margin: 0; + padding: 5px; + border-right: 1px solid white; + text-align: center; + text-overflow: ellipsis; + overflow: hidden; +} diff --git a/upload.html b/upload.html index bf497dc..ede7b42 100644 --- a/upload.html +++ b/upload.html @@ -1,11 +1,36 @@ - - Data Flow - + + Data Flow + + + + + + +
+
+ + +
+
+
+

customer_id

+

order_no

+

part_id

+

parent_part

+

price

+

qty

+

paid

+
+
+
+ + +