+ working version
Signed-off-by: Johannes Theiner <j.theiner@live.de> #SPM-11: add work h development
This commit is contained in:
parent
24d68319b9
commit
c34639bd3a
|
@ -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<String> labels = new ArrayList<>();
|
||||
|
||||
List<String> data1 = new ArrayList<>();
|
||||
List<String> data2 = new ArrayList<>();
|
||||
|
||||
for(Map.Entry<String, Map.Entry<Double, Integer>> entry : overview.getResult().entrySet()) {
|
||||
labels.add(entry.getKey());
|
||||
data1.add(entry.getValue().getKey().toString());
|
||||
data2.add(entry.getValue().getValue().toString());
|
||||
}
|
||||
|
||||
List<String> definedOrder = // define your custom order
|
||||
Arrays.asList("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
|
||||
|
||||
Comparator<String> comparator = Comparator.comparingInt(definedOrder::indexOf);
|
||||
labels.sort(comparator);
|
||||
|
||||
List<List<String>> data = new ArrayList<>();
|
||||
data.add(data1);
|
||||
data.add(data2);
|
||||
|
||||
Result result = new Result(labels, data);
|
||||
|
||||
out.print(gson.toJson(result));
|
||||
}
|
||||
}
|
|
@ -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<String> labels;
|
||||
private List<List<String>> data;
|
||||
}
|
|
@ -56,6 +56,6 @@ public class Upload extends HttpServlet {
|
|||
|
||||
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
resp.sendRedirect("index.jsf");
|
||||
resp.sendRedirect("index.jsp");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<!--Anfang Skriptbereich-->
|
||||
|
||||
<!--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 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://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||
<script type="text/javascript" src="js/materialize_components.js"></script>
|
||||
|
||||
<script src="js/overview.js"></script>
|
||||
<script src="js/shoping_times.js"></script>
|
||||
<script src="js/sold_articles.js"></script>
|
||||
<script src="js/top_articles.js"></script>
|
||||
<script src="js/flop_articles.js"></script>
|
||||
|
||||
<!--Ende Skriptbereich-->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,94 @@
|
|||
<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||
<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>BauDas</title>
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<!--Import materialize.css-->
|
||||
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" 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" />
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
|
||||
</head>
|
||||
<body class="blue-grey lighten-5">
|
||||
<!--Navbar-->
|
||||
<div class="navbar-fixed">
|
||||
<nav class="nav-extended blue-grey lighten-3 white-text row">
|
||||
<a href="#" class="brand-logo hide-on-small-and-down center">BauDas</a>
|
||||
<!--Navbar Tabs-->
|
||||
<div class="nav-content col 12 ">
|
||||
<ul class="tabs tabs-transparent blue-grey lighten-3 white-text">
|
||||
<li class="tab"><a class="active" href="#analysis"><i class="material-icons left">poll</i>Analyse</a></li>
|
||||
<li class="tab"><a href="#marketing"><i class="material-icons left">public</i>Marketing</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--Navbar Items-->
|
||||
<div class="nav-wrapper col 2 right">
|
||||
<ul class="right hide-on-med-and-down">
|
||||
<li><a data-target="slide-out" class="sidenav-trigger show-on-large"><i class="material-icons left">menu</i>Menü</a></li><!--Sidenav-->
|
||||
<li><a href="login.html"><i class="material-icons left">person_outline</i>Logout</a></li><!--Logout-->
|
||||
</ul>
|
||||
<ul class="right">
|
||||
<li><a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a></li><!--Sidenav-->
|
||||
<li><a href="login.html" class="sidenav-trigger"><i class="material-icons">person_outline</i></a></li><!--Logout-->
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!--Sidenav Content-->
|
||||
<ul id="slide-out" class="sidenav">
|
||||
<li><div class="user-view">
|
||||
<div class="background">
|
||||
<img style="width: 100%" src="logoOrginal.gif">
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
</div></li>
|
||||
<li><div class="divider"></div></li>
|
||||
<li><div class="input-field container">
|
||||
<label>Gruppenauswahl</label>
|
||||
<br>
|
||||
<select>
|
||||
<option value="0">alle</option>
|
||||
<option value="1">Gruppe 1</option>
|
||||
<option value="2">Gruppe 2</option>
|
||||
<option value="3">Gruppe 3</option>
|
||||
</select>
|
||||
</div></li>
|
||||
<li><div class="input-field container">
|
||||
<label>Datensatzauswahl</label>
|
||||
<br>
|
||||
<select>
|
||||
<option value="0">aktuell</option>
|
||||
<option value="1">Datensatz 1</option>
|
||||
<option value="2">Datensatz 2</option>
|
||||
<option value="3">Datensatz 3</option>
|
||||
<option value="4">Datensatz 4</option>
|
||||
<option value="5">Datensatz 5</option>
|
||||
</select>
|
||||
<br>
|
||||
</div></li>
|
||||
<li><div class="divider"></div></li>
|
||||
<li><form action="upload" method="post" enctype="multipart/form-data">
|
||||
<br>
|
||||
<div class="file-field input-field container">
|
||||
<div class="btn blue-grey lighten-2">
|
||||
<span>File</span>
|
||||
<input type="file" name="file">
|
||||
</div>
|
||||
<div class="file-path-wrapper">
|
||||
<input class="file-path validate" type="text" placeholder="Datei hochladen">
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn blue-grey waves-effect waves-light" type="submit" name="action">Hochladen<i class="material-icons right">file_upload</i>
|
||||
</button>
|
||||
</form></li>
|
||||
</ul>
|
|
@ -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()); %>
|
||||
|
||||
<!--Cards-->
|
||||
<!--Analyse-Cards-->
|
||||
<div id="analysis" class="row container">
|
||||
<!--Übersicht-->
|
||||
<div class="col s12 m12">
|
||||
<div id="overview" class="card white">
|
||||
<div class="center">
|
||||
<span class="card-title center">Übersicht</span>
|
||||
</div>
|
||||
<div class="card-action center">
|
||||
<a href="#">Tagesübersicht</a>
|
||||
<a href="#">Wochenübersicht</a>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div>
|
||||
<canvas id="overview_chart" width="1000" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Einkaufszeiten-->
|
||||
<div class="col s12 m6">
|
||||
<div id="shoping_times" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title">Einkaufszeiten</span>
|
||||
</div>
|
||||
<div class="center">
|
||||
<div class="input-field col s12">
|
||||
<select>
|
||||
<option value="0">Montag</option>
|
||||
<option value="1">Dienstag</option>
|
||||
<option value="2">Mittwoch</option>
|
||||
<option value="3">Donnerstag</option>
|
||||
<option value="4">Freitag</option>
|
||||
<option value="5">Samstag</option>
|
||||
<option value="6">Sonntag</option>
|
||||
</select>
|
||||
<label>Wochentag</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<canvas id="shoping_times_chart" width="1000" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Verkaufte Artikel-->
|
||||
<div class="col s12 m6">
|
||||
<div id="sold_articles" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Verkaufte Artikel</span>
|
||||
</div>
|
||||
<div class="center">
|
||||
<div class="input-field col s12">
|
||||
<select>
|
||||
<option value="0">Artikel 1</option>
|
||||
<option value="1">Artikel 2</option>
|
||||
<option value="2">Artikel 3</option>
|
||||
</select>
|
||||
<label>Artikel</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<canvas id="sold_articles_cake" width="1000" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Top Artikel-->
|
||||
<div class="col s12 m6">
|
||||
<div id="top_articles" class="card white">
|
||||
<div class="center">
|
||||
<span class="card-title center">Top Artikel</span>
|
||||
</div>
|
||||
<div class="card-action center">
|
||||
<a href="#">Umsatz</a>
|
||||
<a href="#">Stückzahl</a>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div>
|
||||
<canvas id="top_articles_chart" width="1000" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--Flop Artikel-->
|
||||
<div class="col s12 m6">
|
||||
<div id="flop_articles" class="card white">
|
||||
<div class="center">
|
||||
<span class="card-title center">Flop Artikel</span>
|
||||
</div>
|
||||
<div class="card-action center">
|
||||
<a href="#">Umsatz</a>
|
||||
<a href="#">Stückzahl</a>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<div>
|
||||
<canvas id="flop_articles_chart" width="1000" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Warenkorbanlyse-->
|
||||
<div id="shopping_card_analysis" class="col s12 m6">
|
||||
<div class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Warenkorbanalyse</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Gruppenübersicht-->
|
||||
<div class="col s12 m6">
|
||||
<div id="group_overview" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Gruppenübersicht</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Marketing-Cards-->
|
||||
<div id="marketing" class="row container">
|
||||
|
||||
<div class="col s12 m6">
|
||||
<div id="marketing_tip_1" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Marketingmaßnahme 1</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m6">
|
||||
<div id="marketing_tip_2" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Marketingmaßnahme 2</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m6">
|
||||
<div id="marketing_tip_3" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Marketingmaßnahme 3</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m6">
|
||||
<div id="marketing_tip_4" class="card white">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<span class="card-title center">Marketingmaßnahme 4</span>
|
||||
</div>
|
||||
<div>
|
||||
<p>Coming Soon</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%@include file="footer.jsp"%>
|
|
@ -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
|
||||
}]
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
@ -44,7 +44,7 @@
|
|||
<ul id="slide-out" class="sidenav">
|
||||
<li><div class="user-view">
|
||||
<div class="background">
|
||||
<img style="width: 100%" src="logoOrginal.gif">
|
||||
<img style="width: 100%" src="../logoOrginal.gif">
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="card white col s6 push-s3">
|
||||
<div class="card-content">
|
||||
<div class="center">
|
||||
<img style="width: 50%" src="logoOrginal.gif">
|
||||
<img style="width: 50%" src="../logoOrginal.gif">
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="row">
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
<div class="card-content">
|
||||
<div>
|
||||
<img style="width: 100%" src="logoOrginal.gif">
|
||||
<img style="width: 100%" src="../logoOrginal.gif">
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="row">
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<form action="upload" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="file">
|
||||
<button type="submit">
|
||||
Hochladen
|
||||
</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -29,7 +29,7 @@ class ClusterTest {
|
|||
AtomicReference<Map<Integer, Map<String, String>>> 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"));
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class WeekOverviewTest {
|
|||
|
||||
AtomicReference<Map<String, Map.Entry<Double, Integer>>> 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());
|
||||
|
|
Loading…
Reference in New Issue