GUI for Shopping Cart Analysis done
This commit is contained in:
parent
f8c1eb9362
commit
1b9e4884dc
11
src/main/java/de/hsel/spm/baudas/web/Columns.java
Normal file
11
src/main/java/de/hsel/spm/baudas/web/Columns.java
Normal file
@ -0,0 +1,11 @@
|
||||
package de.hsel.spm.baudas.web;
|
||||
|
||||
public class Columns {
|
||||
private String col1; //NOPMD
|
||||
private String col2; //NOPMD
|
||||
|
||||
public Columns(String col1, String col2){
|
||||
this.col1 = col1;
|
||||
this.col2 = col2;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package de.hsel.spm.baudas.web;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import de.hsel.spm.baudas.analysis.ShoppingCart;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Changes data to readable format for Tabulator
|
||||
*
|
||||
* @author Karsten Eden
|
||||
* @version 0.1
|
||||
* @since 0.1
|
||||
*/
|
||||
@WebServlet("/shopping_cart")
|
||||
public class ShoppingCartDiagram extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 5026732432605473505L;
|
||||
|
||||
protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException {
|
||||
req.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
resp.setContentType("application/json");
|
||||
PrintWriter out = resp.getWriter();
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
List<Columns> colList = new ArrayList<>();
|
||||
|
||||
if (req.getParameter("id") == null) {
|
||||
out.print(gson.toJson(colList));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = UUID.fromString(req.getParameter("id"));
|
||||
File file = Data.get(uuid);
|
||||
|
||||
ShoppingCart cart = new ShoppingCart(file);
|
||||
|
||||
Map<List<String>, List<String>> map = cart.getResult();
|
||||
|
||||
List<String> col1 = new ArrayList<>();
|
||||
List<String> col2 = new ArrayList<>();
|
||||
|
||||
for(Map.Entry<List<String>, List<String>> entry : map.entrySet()){
|
||||
col1.add(entry.getKey().toString());
|
||||
col2.add(entry.getValue().toString());
|
||||
}
|
||||
|
||||
for(int i = 0; i < col1.size(); i++ ){
|
||||
colList.add(new Columns(col1.get(i).replaceAll("\\[", "").replaceAll("\\]", ""), col2.get(i).replaceAll("\\[", "").replaceAll("\\]", "")));
|
||||
}
|
||||
|
||||
out.print(gson.toJson(colList));
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
<!--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 type="text/javascript" src="https://unpkg.com/tabulator-tables@4.2.7/dist/js/tabulator.min.js"></script>
|
||||
|
||||
<!--Script für Materlialize-->
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
@ -16,6 +17,7 @@
|
||||
<script src="js/week_overview.js"></script>
|
||||
<script src="js/shopping_times.js"></script>
|
||||
<script src="js/top_flop.js"></script>
|
||||
<script src="js/shopping_cart.js"></script>
|
||||
|
||||
<%--<script src="js/sold_articles.js"></script>--%>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
media="screen,projection"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"
|
||||
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 HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
|
||||
|
||||
|
@ -64,14 +64,13 @@
|
||||
</div>
|
||||
|
||||
<!--Warenkorbanlyse-->
|
||||
<div id="shopping_card_analysis" class="col s12 m6">
|
||||
<div id="shopping_card_analysis" class="col s12 m12">
|
||||
<div class="card white">
|
||||
<div class="center">
|
||||
<span class="card-title center">Warenkorbanalyse</span>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Warenkorbanalyse</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
<div id="shopping_cart_table">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,6 +38,7 @@ function updateAll(uuid) {
|
||||
updateWeekOverviewChart(uuid);
|
||||
updateShoppingTimesChart(uuid);
|
||||
updateTopFlopChart(uuid);
|
||||
updateShoppingCartTable(uuid);
|
||||
//add new charts here.
|
||||
}
|
||||
|
||||
|
19
src/main/webapp/js/shopping_cart.js
Normal file
19
src/main/webapp/js/shopping_cart.js
Normal file
@ -0,0 +1,19 @@
|
||||
let table = new Tabulator("#shopping_cart_table", {
|
||||
layout:"fitColumns",
|
||||
columns:[
|
||||
{title:"Produkte", field:"col1", headerSort:false},
|
||||
{title:"zusammen mit", field:"col2", headerSort:false},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
function updateShoppingCartTable(id) {
|
||||
if (typeof id !== 'undefined') {
|
||||
request('shopping_cart', id).then(function () {
|
||||
table.setData("/bauDas/shopping_cart?id="+id);
|
||||
});
|
||||
} else request('shopping_cart').then(function () {
|
||||
table.setData();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user