GUI for Shopping Cart Analysis rewritten
This commit is contained in:
parent
1b9e4884dc
commit
f05c267efc
|
@ -15,7 +15,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes data to readable format for Tabulator
|
* Changes data to readable format for table
|
||||||
*
|
*
|
||||||
* @author Karsten Eden
|
* @author Karsten Eden
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
|
@ -33,7 +33,6 @@ public class ShoppingCartDiagram extends HttpServlet {
|
||||||
PrintWriter out = resp.getWriter();
|
PrintWriter out = resp.getWriter();
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
List<Columns> colList = new ArrayList<>();
|
List<Columns> colList = new ArrayList<>();
|
||||||
|
|
||||||
if (req.getParameter("id") == null) {
|
if (req.getParameter("id") == null) {
|
||||||
|
@ -45,13 +44,13 @@ public class ShoppingCartDiagram extends HttpServlet {
|
||||||
File file = Data.get(uuid);
|
File file = Data.get(uuid);
|
||||||
|
|
||||||
ShoppingCart cart = new ShoppingCart(file);
|
ShoppingCart cart = new ShoppingCart(file);
|
||||||
|
Map<List<String>, List<String>> result = new HashMap<>();
|
||||||
Map<List<String>, List<String>> map = cart.getResult();
|
result = cart.getResult();
|
||||||
|
|
||||||
List<String> col1 = new ArrayList<>();
|
List<String> col1 = new ArrayList<>();
|
||||||
List<String> col2 = new ArrayList<>();
|
List<String> col2 = new ArrayList<>();
|
||||||
|
|
||||||
for(Map.Entry<List<String>, List<String>> entry : map.entrySet()){
|
for(Map.Entry<List<String>, List<String>> entry : result.entrySet()){
|
||||||
col1.add(entry.getKey().toString());
|
col1.add(entry.getKey().toString());
|
||||||
col2.add(entry.getValue().toString());
|
col2.add(entry.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
<!--Script für Diagramme-->
|
<!--Script für Diagramme-->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js" integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js" integrity="sha256-xKeoJ50pzbUGkpQxDYHD7o7hxe0LaOGeguUidbq6vis=" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.2.7/dist/js/tabulator.min.js"></script>
|
|
||||||
|
|
||||||
<!--Script für Materlialize-->
|
<!--Script für Materlialize-->
|
||||||
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
media="screen,projection"/>
|
media="screen,projection"/>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"
|
||||||
integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous"/>
|
integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous"/>
|
||||||
<link href="https://unpkg.com/tabulator-tables@4.2.7/dist/css/tabulator.min.css" rel="stylesheet">
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
|
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@
|
||||||
<span class="card-title center">Warenkorbanalyse</span>
|
<span class="card-title center">Warenkorbanalyse</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div id="shopping_cart_table">
|
<table id="shopping_cart_table">
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
let table = new Tabulator("#shopping_cart_table", {
|
/*let table = new Tabulator("#shopping_cart_table", {
|
||||||
layout:"fitColumns",
|
layout:"fitColumns",
|
||||||
columns:[
|
columns:[
|
||||||
{title:"Produkte", field:"col1", headerSort:false},
|
{title:"Produkte", field:"col1", headerSort:false},
|
||||||
|
@ -15,5 +15,42 @@ function updateShoppingCartTable(id) {
|
||||||
} else request('shopping_cart').then(function () {
|
} else request('shopping_cart').then(function () {
|
||||||
table.setData();
|
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 = $("<thead>");
|
||||||
|
row.append("<tr>");
|
||||||
|
row.append("<th>Artikel</th>");
|
||||||
|
row.append("<th>Wird häufig zusammen gekauft mit</th>")
|
||||||
|
row.append("</tr>");
|
||||||
|
row.append("</thead>");
|
||||||
|
row.append("<tbody>");
|
||||||
|
for (x in shopping_cart_result){
|
||||||
|
row.append("<tr>");
|
||||||
|
row.append("<td>" + shopping_cart_result[x].col1 + "</td>");
|
||||||
|
row.append("<td>" + shopping_cart_result[x].col2 + "</td>");
|
||||||
|
row.append("</tr>");
|
||||||
|
}
|
||||||
|
row.append("</tbody>");
|
||||||
|
$("#shopping_cart_table").append(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue