From c34639bd3a82f4c0770f86d7cd4715592005c9f9 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 7 May 2019 21:34:59 +0200 Subject: [PATCH] + working version Signed-off-by: Johannes Theiner #SPM-11: add work h development --- .../java/de/hsel/spm/baudas/web/Overview.java | 59 ++++++ .../java/de/hsel/spm/baudas/web/Result.java | 19 ++ .../java/de/hsel/spm/baudas/web/Upload.java | 2 +- .../{preview => }/data/flop_articles.json | 0 .../webapp/{preview => }/data/overview.json | 0 .../{preview => }/data/shoping_times.json | 0 .../{preview => }/data/sold_articles.json | 0 .../{preview => }/data/top_articles.json | 0 src/main/webapp/footer.jsp | 20 ++ src/main/webapp/header.jsp | 94 +++++++++ src/main/webapp/index.jsp | 197 ++++++++++++++++++ .../webapp/{preview => }/js/flop_articles.js | 0 .../js/materialize_components.js | 0 src/main/webapp/{preview => }/js/overview.js | 14 +- .../webapp/{preview => }/js/shoping_times.js | 0 .../webapp/{preview => }/js/sold_articles.js | 0 .../webapp/{preview => }/js/top_articles.js | 0 src/main/webapp/{preview => }/logoOrginal.gif | Bin src/main/webapp/preview/index.html | 2 +- src/main/webapp/preview/login.html | 2 +- src/main/webapp/preview/registration.html | 2 +- src/main/webapp/upload-test.html | 11 - .../hsel/spm/baudas/analysis/ClusterTest.java | 2 +- .../spm/baudas/analysis/WeekOverviewTest.java | 2 +- 24 files changed, 402 insertions(+), 24 deletions(-) create mode 100644 src/main/java/de/hsel/spm/baudas/web/Overview.java create mode 100644 src/main/java/de/hsel/spm/baudas/web/Result.java rename src/main/webapp/{preview => }/data/flop_articles.json (100%) rename src/main/webapp/{preview => }/data/overview.json (100%) rename src/main/webapp/{preview => }/data/shoping_times.json (100%) rename src/main/webapp/{preview => }/data/sold_articles.json (100%) rename src/main/webapp/{preview => }/data/top_articles.json (100%) create mode 100644 src/main/webapp/footer.jsp create mode 100644 src/main/webapp/header.jsp create mode 100644 src/main/webapp/index.jsp rename src/main/webapp/{preview => }/js/flop_articles.js (100%) rename src/main/webapp/{preview => }/js/materialize_components.js (100%) rename src/main/webapp/{preview => }/js/overview.js (84%) rename src/main/webapp/{preview => }/js/shoping_times.js (100%) rename src/main/webapp/{preview => }/js/sold_articles.js (100%) rename src/main/webapp/{preview => }/js/top_articles.js (100%) rename src/main/webapp/{preview => }/logoOrginal.gif (100%) delete mode 100644 src/main/webapp/upload-test.html diff --git a/src/main/java/de/hsel/spm/baudas/web/Overview.java b/src/main/java/de/hsel/spm/baudas/web/Overview.java new file mode 100644 index 0000000..b96bd0f --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/Overview.java @@ -0,0 +1,59 @@ +package de.hsel.spm.baudas.web; + +import com.google.gson.Gson; +import de.hsel.spm.baudas.analysis.WeekOverview; + +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * @author Johannes Theiner + * @version 0.1 + * @since 0.1 + **/ +@WebServlet("/week_overview") +public class Overview extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, 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(); + + WeekOverview overview = new WeekOverview(Data.get(Data.getFiles().peek().getUuid())); + + List labels = new ArrayList<>(); + + List data1 = new ArrayList<>(); + List data2 = new ArrayList<>(); + + for(Map.Entry> entry : overview.getResult().entrySet()) { + labels.add(entry.getKey()); + data1.add(entry.getValue().getKey().toString()); + data2.add(entry.getValue().getValue().toString()); + } + + List definedOrder = // define your custom order + Arrays.asList("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"); + + Comparator comparator = Comparator.comparingInt(definedOrder::indexOf); + labels.sort(comparator); + + List> data = new ArrayList<>(); + data.add(data1); + data.add(data2); + + Result result = new Result(labels, data); + + out.print(gson.toJson(result)); + } +} \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/Result.java b/src/main/java/de/hsel/spm/baudas/web/Result.java new file mode 100644 index 0000000..d2ddfd9 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/web/Result.java @@ -0,0 +1,19 @@ +package de.hsel.spm.baudas.web; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +/** + * @author Johannes Theiner + * @version 0.1 + * @since 0.1 + **/ +@Getter +@AllArgsConstructor +public class Result { + + private List labels; + private List> data; +} \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/Upload.java b/src/main/java/de/hsel/spm/baudas/web/Upload.java index f90f673..bc63ffe 100644 --- a/src/main/java/de/hsel/spm/baudas/web/Upload.java +++ b/src/main/java/de/hsel/spm/baudas/web/Upload.java @@ -56,6 +56,6 @@ public class Upload extends HttpServlet { Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING); - resp.sendRedirect("index.jsf"); + resp.sendRedirect("index.jsp"); } } \ No newline at end of file diff --git a/src/main/webapp/preview/data/flop_articles.json b/src/main/webapp/data/flop_articles.json similarity index 100% rename from src/main/webapp/preview/data/flop_articles.json rename to src/main/webapp/data/flop_articles.json diff --git a/src/main/webapp/preview/data/overview.json b/src/main/webapp/data/overview.json similarity index 100% rename from src/main/webapp/preview/data/overview.json rename to src/main/webapp/data/overview.json diff --git a/src/main/webapp/preview/data/shoping_times.json b/src/main/webapp/data/shoping_times.json similarity index 100% rename from src/main/webapp/preview/data/shoping_times.json rename to src/main/webapp/data/shoping_times.json diff --git a/src/main/webapp/preview/data/sold_articles.json b/src/main/webapp/data/sold_articles.json similarity index 100% rename from src/main/webapp/preview/data/sold_articles.json rename to src/main/webapp/data/sold_articles.json diff --git a/src/main/webapp/preview/data/top_articles.json b/src/main/webapp/data/top_articles.json similarity index 100% rename from src/main/webapp/preview/data/top_articles.json rename to src/main/webapp/data/top_articles.json diff --git a/src/main/webapp/footer.jsp b/src/main/webapp/footer.jsp new file mode 100644 index 0000000..b7edde8 --- /dev/null +++ b/src/main/webapp/footer.jsp @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/header.jsp b/src/main/webapp/header.jsp new file mode 100644 index 0000000..fd79f39 --- /dev/null +++ b/src/main/webapp/header.jsp @@ -0,0 +1,94 @@ +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> + + + + BauDas + + + + + + + + + + + + + + + +
+ + +
    +
  • +
    + +
    +
    +
    +
  • +
  • +
  • + +
    + +
  • +
  • + +
    + +
    +
  • +
  • +
  • +
    +
    +
    + File + +
    +
    + +
    +
    + +
  • +
\ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..9fbc781 --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,197 @@ +<%@ page import="java.nio.charset.StandardCharsets" %> +<%@ page contentType="text/html;charset=UTF-8" %> +<%@include file="header.jsp"%> +<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> +<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> + + + +
+ +
+
+
+ Übersicht +
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ Einkaufszeiten +
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+
+ Verkaufte Artikel +
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+ Top Artikel +
+ +
+
+ +
+
+
+
+ +
+
+
+ Flop Artikel +
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ Warenkorbanalyse +
+
+

Coming Soon

+
+
+
+
+ + +
+
+
+
+ Gruppenübersicht +
+
+

Coming Soon

+
+
+
+
+
+ + +
+ +
+
+
+
+ Marketingmaßnahme 1 +
+
+

Coming Soon

+
+
+
+
+
+
+
+
+ Marketingmaßnahme 2 +
+
+

Coming Soon

+
+
+
+
+
+
+
+
+ Marketingmaßnahme 3 +
+
+

Coming Soon

+
+
+
+
+
+
+
+
+ Marketingmaßnahme 4 +
+
+

Coming Soon

+
+
+
+
+
+ +<%@include file="footer.jsp"%> \ No newline at end of file diff --git a/src/main/webapp/preview/js/flop_articles.js b/src/main/webapp/js/flop_articles.js similarity index 100% rename from src/main/webapp/preview/js/flop_articles.js rename to src/main/webapp/js/flop_articles.js diff --git a/src/main/webapp/preview/js/materialize_components.js b/src/main/webapp/js/materialize_components.js similarity index 100% rename from src/main/webapp/preview/js/materialize_components.js rename to src/main/webapp/js/materialize_components.js diff --git a/src/main/webapp/preview/js/overview.js b/src/main/webapp/js/overview.js similarity index 84% rename from src/main/webapp/preview/js/overview.js rename to src/main/webapp/js/overview.js index 9f2c58a..48db337 100644 --- a/src/main/webapp/preview/js/overview.js +++ b/src/main/webapp/js/overview.js @@ -1,5 +1,5 @@ $.ajax({ - url: 'data/overview.json', + url: 'week_overview', dataType: 'json' }).done(function (results) { new Chart(document.getElementById("overview_chart"), { @@ -8,16 +8,16 @@ $.ajax({ labels: results.labels, datasets: [{ label: "Warenanzahl", - data: results.data1, + data: results.data[0], fill: true, backgroundColor: 'rgba(113, 114, 231, 0.7)', - lineTension: 0, + lineTension: 0 }, { label: "Einnahmen in €", - data: results.data2, + data: results.data[1], fill: true, backgroundColor: 'rgba(104, 216, 154, 0.8)', - lineTension: 0, + lineTension: 0 }] }, options: { @@ -31,7 +31,7 @@ $.ajax({ }, tooltips: { mode: 'index', - intersect: false, + intersect: false }, hover: { mode: 'nearest', @@ -50,7 +50,7 @@ $.ajax({ } }], yAxes: [{ - display: true, + display: true }] } } diff --git a/src/main/webapp/preview/js/shoping_times.js b/src/main/webapp/js/shoping_times.js similarity index 100% rename from src/main/webapp/preview/js/shoping_times.js rename to src/main/webapp/js/shoping_times.js diff --git a/src/main/webapp/preview/js/sold_articles.js b/src/main/webapp/js/sold_articles.js similarity index 100% rename from src/main/webapp/preview/js/sold_articles.js rename to src/main/webapp/js/sold_articles.js diff --git a/src/main/webapp/preview/js/top_articles.js b/src/main/webapp/js/top_articles.js similarity index 100% rename from src/main/webapp/preview/js/top_articles.js rename to src/main/webapp/js/top_articles.js diff --git a/src/main/webapp/preview/logoOrginal.gif b/src/main/webapp/logoOrginal.gif similarity index 100% rename from src/main/webapp/preview/logoOrginal.gif rename to src/main/webapp/logoOrginal.gif diff --git a/src/main/webapp/preview/index.html b/src/main/webapp/preview/index.html index 1095225..31a72e1 100644 --- a/src/main/webapp/preview/index.html +++ b/src/main/webapp/preview/index.html @@ -44,7 +44,7 @@
  • - +


    diff --git a/src/main/webapp/preview/login.html b/src/main/webapp/preview/login.html index 67dd914..8538999 100644 --- a/src/main/webapp/preview/login.html +++ b/src/main/webapp/preview/login.html @@ -18,7 +18,7 @@
    - +
    diff --git a/src/main/webapp/preview/registration.html b/src/main/webapp/preview/registration.html index 0dbe2f8..a8705ba 100644 --- a/src/main/webapp/preview/registration.html +++ b/src/main/webapp/preview/registration.html @@ -21,7 +21,7 @@
    - +
    diff --git a/src/main/webapp/upload-test.html b/src/main/webapp/upload-test.html deleted file mode 100644 index b57a823..0000000 --- a/src/main/webapp/upload-test.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -
    - - -
    - - \ No newline at end of file diff --git a/src/test/java/de/hsel/spm/baudas/analysis/ClusterTest.java b/src/test/java/de/hsel/spm/baudas/analysis/ClusterTest.java index 8eddd85..df3438d 100644 --- a/src/test/java/de/hsel/spm/baudas/analysis/ClusterTest.java +++ b/src/test/java/de/hsel/spm/baudas/analysis/ClusterTest.java @@ -29,7 +29,7 @@ class ClusterTest { AtomicReference>> results = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(2000), () -> results.set(cluster.getResult())); + assertTimeout(Duration.ofMillis(10000), () -> results.set(cluster.getResult())); assertEquals("m", results.get().get(0).get("Geschlecht")); } diff --git a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java index 7a02cf7..1915fa9 100644 --- a/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java +++ b/src/test/java/de/hsel/spm/baudas/analysis/WeekOverviewTest.java @@ -84,7 +84,7 @@ class WeekOverviewTest { AtomicReference>> result = new AtomicReference<>(); - assertTimeout(Duration.ofMillis(15), () -> result.set(overview.getResult())); + assertTimeout(Duration.ofMillis(30), () -> result.set(overview.getResult())); assertEquals(295688, result.get().get("Montag").getKey());