diff --git a/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java b/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java index 33f8f8c..9e62281 100644 --- a/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java +++ b/src/main/java/de/hsel/spm/baudas/web/ShoppingCartDiagram.java @@ -15,7 +15,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; /** - * Changes data to readable format for Tabulator + * Changes data to readable format for table * * @author Karsten Eden * @version 0.1 @@ -33,7 +33,6 @@ public class ShoppingCartDiagram extends HttpServlet { PrintWriter out = resp.getWriter(); Gson gson = new Gson(); - List colList = new ArrayList<>(); if (req.getParameter("id") == null) { @@ -45,13 +44,13 @@ public class ShoppingCartDiagram extends HttpServlet { File file = Data.get(uuid); ShoppingCart cart = new ShoppingCart(file); - - Map, List> map = cart.getResult(); + Map, List> result = new HashMap<>(); + result = cart.getResult(); List col1 = new ArrayList<>(); List col2 = new ArrayList<>(); - for(Map.Entry, List> entry : map.entrySet()){ + for(Map.Entry, List> entry : result.entrySet()){ col1.add(entry.getKey().toString()); col2.add(entry.getValue().toString()); } diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp index c00e169..d9ff19f 100644 --- a/src/main/webapp/footer.jsp +++ b/src/main/webapp/footer.jsp @@ -3,8 +3,6 @@ - - diff --git a/src/main/webapp/header.jsp b/src/main/webapp/header.jsp index 9daab49..5cd9784 100644 --- a/src/main/webapp/header.jsp +++ b/src/main/webapp/header.jsp @@ -12,7 +12,6 @@ media="screen,projection"/> - diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 2365169..2f6c639 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -70,8 +70,8 @@ Warenkorbanalyse
-
-
+ +
diff --git a/src/main/webapp/js/shopping_cart.js b/src/main/webapp/js/shopping_cart.js index 1ea2d35..0365594 100644 --- a/src/main/webapp/js/shopping_cart.js +++ b/src/main/webapp/js/shopping_cart.js @@ -1,4 +1,4 @@ -let table = new Tabulator("#shopping_cart_table", { +/*let table = new Tabulator("#shopping_cart_table", { layout:"fitColumns", columns:[ {title:"Produkte", field:"col1", headerSort:false}, @@ -15,5 +15,42 @@ function updateShoppingCartTable(id) { } else request('shopping_cart').then(function () { table.setData(); }); +}*/ + +let shopping_cart_result; + +function updateShoppingCartTable(id) { + if(typeof id !== 'undefined') { + request('shopping_cart', id).then(function (data) { + shopping_cart_result = data; + drawShoppingCartTable(); + }); + }else request('shopping_cart_result').then(function(data) { + shopping_cart_result = data; + drawShoppingCartTable(); + }); +} + +function drawShoppingCartTable(){ + let table = document.getElementById("shopping_cart_table"); + while(table.hasChildNodes()){ + table.removeChild(table.firstChild); + } + + let row = $(""); + row.append(""); + row.append("Artikel"); + row.append("Wird häufig zusammen gekauft mit") + row.append(""); + row.append(""); + row.append(""); + for (x in shopping_cart_result){ + row.append(""); + row.append("" + shopping_cart_result[x].col1 + ""); + row.append("" + shopping_cart_result[x].col2 + ""); + row.append(""); + } + row.append(""); + $("#shopping_cart_table").append(row); }