From 89468525abf850cae722906501ef46ca2f4ae07f Mon Sep 17 00:00:00 2001 From: joethei Date: Wed, 29 May 2019 18:59:56 +0200 Subject: [PATCH] ~ fixed a few problems that sonarqube found #SPM32: add work development 2h --- README.md | 4 +-- .../de/hsel/spm/baudas/analysis/Analysis.java | 3 +- .../hsel/spm/baudas/analysis/Attribute.java | 2 ++ .../de/hsel/spm/baudas/analysis/Cluster.java | 7 +++-- .../spm/baudas/analysis/ShoppingCart.java | 7 +++-- .../spm/baudas/analysis/WeekOverview.java | 1 - .../spm/baudas/web/AuthorizationFilter.java | 3 +- .../spm/baudas/web/DatasetManagement.java | 26 ++++++++++++----- .../de/hsel/spm/baudas/web/ErrorCode.java | 1 - .../de/hsel/spm/baudas/web/LoginServlet.java | 1 + .../de/hsel/spm/baudas/web/LogoutServlet.java | 1 + .../de/hsel/spm/baudas/web/UploadServlet.java | 29 ++++++++++++++----- .../baudas/web/depiction/ClusterTable.java | 7 ++--- .../spm/baudas/web/depiction/Depiction.java | 5 ++-- .../web/depiction/SalesNumberChart.java | 2 +- .../web/depiction/ShoppingCartTable.java | 5 ++-- .../web/depiction/ShoppingTimesChart.java | 2 +- .../web/depiction/WeekOverviewChart.java | 2 +- src/main/webapp/js/clusters.js | 28 +++++++++++------- src/main/webapp/js/{cache.js => datasets.js} | 8 +++++ src/main/webapp/js/sales.js | 11 +++++-- src/main/webapp/js/shopping_cart.js | 10 ++++++- src/main/webapp/js/shopping_times.js | 8 +++++ src/main/webapp/js/upload.js | 10 ++++++- src/main/webapp/js/week_overview.js | 8 +++++ src/main/webapp/theming.jsp | 2 +- 26 files changed, 139 insertions(+), 54 deletions(-) rename src/main/webapp/js/{cache.js => datasets.js} (96%) diff --git a/README.md b/README.md index c7d50dd..ec8c82e 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ #Kundenkarten Analyse [![Build Status](https://teamcity.joethei.xyz/app/rest/builds/buildType:(id:Studium_Programmierung_Softwareprojektmanagement_SpmProd)/statusIcon)](https://tcstatus.joethei.space/dashboard/spm) -[![Quality Gate](https://sonarqube.joethei.xyz/api/project_badges/measure?project=Studium_Programmierung_Softwareprojektmanagement&metric=alert_status) -![Code Coverage](https://sonarqube.joethei.xyz/api/project_badges/measure?project=Studium_Programmierung_Softwareprojektmanagement&metric=coverage)](https://sonarqube.joethei.xyz/dashboard?id=Studium_Programmierung_Softwareprojektmanagement) +[![Quality Gate Status](https://sonarqube.joethei.xyz/api/project_badges/measure?project=de.hs-el.spm%3AbauDas-kundenkarten&metric=alert_status)](https://sonarqube.joethei.xyz/dashboard?id=de.hs-el.spm%3AbauDas-kundenkarten) + ## minimal Requirements diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java index 3723996..e91a931 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Analysis.java @@ -6,6 +6,7 @@ import weka.core.converters.CSVLoader; import java.io.File; import java.io.IOException; +import java.util.logging.Logger; /** * base interface for analysis. @@ -31,7 +32,7 @@ public interface Analysis { loader.setSource(file); return loader.getDataSet(); } catch (IOException e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "load", e); } return null; } diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Attribute.java b/src/main/java/de/hsel/spm/baudas/analysis/Attribute.java index 9d29e36..08558a2 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Attribute.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Attribute.java @@ -37,5 +37,7 @@ class Attribute { static final int GARDENING_TOOLS = 25; + private Attribute() { + } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java index 0608bd7..d5d974e 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java @@ -9,6 +9,7 @@ import weka.filters.unsupervised.attribute.Remove; import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.logging.Logger; /** * Cluster Analysis. @@ -46,7 +47,7 @@ public class Cluster implements Analysis>> { remove.setInputFormat(instances); instances = Filter.useFilter(instances, remove); } catch (Exception e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); } //creating a single cluster to get average, weka has no way to get that from a bigger one. @@ -59,7 +60,7 @@ public class Cluster implements Analysis>> { averageCentroids = averageMeans.getClusterCentroids(); } catch (Exception ex) { - ex.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex); } assert averageCentroids != null; @@ -77,7 +78,7 @@ public class Cluster implements Analysis>> { putIntoMap(centroids, count); } catch (Exception ex) { - ex.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", ex); } return result; } diff --git a/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java b/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java index f1277e1..da437e9 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/ShoppingCart.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.logging.Logger; /** * The shopping-cart analysis. @@ -45,7 +46,7 @@ public class ShoppingCart implements Analysis, List>> { nc.setInputFormat(instances); instances = Filter.useFilter(instances, nc); } catch (Exception e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); } @@ -55,7 +56,7 @@ public class ShoppingCart implements Analysis, List>> { num2nom.setInputFormat(instances); instances = Filter.useFilter(instances, num2nom); } catch (Exception e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); } Apriori model = new Apriori(); @@ -64,7 +65,7 @@ public class ShoppingCart implements Analysis, List>> { try { model.buildAssociations(instances); } catch (Exception e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "getResult", e); } for (int i = 0; i < model.getAssociationRules().getRules().size(); i++) { diff --git a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java index ee3dd19..f70bd45 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java @@ -21,7 +21,6 @@ public class WeekOverview implements Analysis> result; public WeekOverview(File file) { - instances = load(file); } diff --git a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java index 6d0b81c..c30d696 100644 --- a/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java +++ b/src/main/java/de/hsel/spm/baudas/web/AuthorizationFilter.java @@ -32,10 +32,9 @@ public class AuthorizationFilter implements Filter { * initialize this filter. * * @param filterConfig configuration - * @throws ServletException failed to initialize filter */ @Override - public void init(@NotNull FilterConfig filterConfig) throws ServletException { + public void init(@NotNull FilterConfig filterConfig) { this.context = filterConfig.getServletContext(); this.context.log("AuthorizationFilter initialized"); } diff --git a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java index 5cd4f69..95db76d 100644 --- a/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java +++ b/src/main/java/de/hsel/spm/baudas/web/DatasetManagement.java @@ -16,6 +16,8 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.logging.Logger; +import java.util.stream.Stream; /** * manages data about .csv files. @@ -45,8 +47,10 @@ public class DatasetManagement { if (files.get(session).size() >= 5) { SavedFile file = files.get(session).iterator().next(); - if (!get(file.getUuid()).delete()) { - System.err.println("failed to delete file " + file); + try { + Files.delete(get(file.getUuid()).toPath()); + } catch (IOException e) { + Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "add", e); } files.get(session).remove(file); } @@ -63,16 +67,19 @@ public class DatasetManagement { if (!files.containsKey(session)) return; for (SavedFile file : files.get(session)) { - if (!get(file.getUuid()).delete()) - System.err.println("failed to delete file " + file); + try { + Files.delete(get(file.getUuid()).toPath()); + } catch (IOException e) { + Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e); + } } files.remove(session); //deleting all files older than x days. int days = 30; - try { - Files.list(Paths.get("")).forEach(path -> { + try (Stream stream = Files.list(Paths.get(""))) { + stream.forEach(path -> { if (path.toFile().getName().endsWith("*.csv")) { long diff = new Date().getTime() - path.toFile().lastModified(); @@ -80,13 +87,13 @@ public class DatasetManagement { try { Files.delete(path); } catch (IOException e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", e); } } } }); } catch (IOException ex) { - ex.printStackTrace(); + Logger.getLogger("BauDas").throwing(DatasetManagement.class.getName(), "delete", ex); } } @@ -113,4 +120,7 @@ public class DatasetManagement { private static String getFileName(@NotNull UUID uuid) { return uuid + ".csv"; } + + private DatasetManagement() { + } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java b/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java index c293349..c5ff4ff 100644 --- a/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java +++ b/src/main/java/de/hsel/spm/baudas/web/ErrorCode.java @@ -27,7 +27,6 @@ public enum ErrorCode { */ public static boolean exists(String message) { for (ErrorCode code : values()) { - System.out.println(message + " == " + code.name()); if (code.name().equals(message)) return true; } diff --git a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java index de96b79..83baa02 100644 --- a/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/LoginServlet.java @@ -32,6 +32,7 @@ public class LoginServlet extends HttpServlet { * @param response response object * @throws IOException failed to initialize print writer */ + @Override protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws ServletException, IOException { String password = request.getParameter("password"); if (this.password.equals(password)) { diff --git a/src/main/java/de/hsel/spm/baudas/web/LogoutServlet.java b/src/main/java/de/hsel/spm/baudas/web/LogoutServlet.java index 302c2ca..c1c914a 100644 --- a/src/main/java/de/hsel/spm/baudas/web/LogoutServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/LogoutServlet.java @@ -27,6 +27,7 @@ public class LogoutServlet extends HttpServlet { * @param response response object * @throws IOException failed to initialize print writer */ + @Override protected void doGet(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); if (session != null) { diff --git a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java index 9616b2c..747a632 100644 --- a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java @@ -17,6 +17,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.util.logging.Logger; /** * saves uploaded files. @@ -62,45 +63,59 @@ public class UploadServlet extends HttpServlet { Part filePart = req.getPart("file"); if (filePart == null) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + error(resp, ErrorCode.FILE_NOT_FOUND); return; } if (filePart.getSubmittedFileName() == null) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + error(resp, ErrorCode.FILE_NOT_FOUND); return; } String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); if (fileName == null) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + error(resp, ErrorCode.FILE_NOT_FOUND); return; } InputStream inputStream = filePart.getInputStream(); if (inputStream == null) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.FILE_NOT_FOUND); + error(resp, ErrorCode.FILE_NOT_FOUND); return; } if (inputStream.available() == 0) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.EMPTY_FILE); + error(resp, ErrorCode.EMPTY_FILE); return; } if (!checkFormat(inputStream)) { - resp.sendRedirect("error.jsp?code=" + ErrorCode.INVALID_FORMAT); + error(resp, ErrorCode.INVALID_FORMAT); return; } else { inputStream = filePart.getInputStream(); } Path path = DatasetManagement.add(fileName, req.getSession().getId()); - if (!Files.exists(path)) { + if (!path.toFile().exists()) { Files.createFile(path); } Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING); } + + /** + * redirect to error page. + * + * @param response response object + * @param code error code + */ + private void error(@NotNull HttpServletResponse response, @NotNull ErrorCode code) { + try { + response.sendRedirect("error.jsp?code=" + code); + } catch (IOException e) { + Logger.getLogger("BauDas").throwing(getClass().getName(), "error", e); + } + } } \ No newline at end of file diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/ClusterTable.java b/src/main/java/de/hsel/spm/baudas/web/depiction/ClusterTable.java index aa3afb5..242cfc5 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/ClusterTable.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/ClusterTable.java @@ -26,7 +26,7 @@ import java.util.UUID; @WebServlet("/clusters") public class ClusterTable extends HttpServlet implements Depiction { - private static Map cache; + private static Map cache = new HashMap<>(); /** * returns formatted analysis result to HTTP GET request from supplied id. @@ -37,15 +37,14 @@ public class ClusterTable extends HttpServlet implements Depiction { */ @Override protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { - UUID uuid = setup(req, resp, cache); + UUID uuid = init(req, resp, cache); if (uuid == null) return; - Map> result = new HashMap<>(); File file = DatasetManagement.get(uuid); Cluster cluster = new Cluster(file); - result = cluster.getResult(); + Map> result = cluster.getResult(); PrintWriter out = resp.getWriter(); Gson gson = new Gson(); diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java b/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java index edca3ce..070edbd 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/Depiction.java @@ -11,6 +11,7 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; +import java.util.logging.Logger; import java.util.regex.Pattern; /** @@ -31,7 +32,7 @@ interface Depiction { * @return validated uuid */ @Nullable - default UUID setup(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Map cache) { + default UUID init(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Map cache) { try { request.setCharacterEncoding(StandardCharsets.UTF_8.name()); response.setCharacterEncoding(StandardCharsets.UTF_8.name()); @@ -50,7 +51,7 @@ interface Depiction { } return uuid; } catch (IOException e) { - e.printStackTrace(); + Logger.getLogger("BauDas").throwing(this.getClass().getName(), "init", e); } return null; } diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/SalesNumberChart.java b/src/main/java/de/hsel/spm/baudas/web/depiction/SalesNumberChart.java index 24eba0e..28d92f4 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/SalesNumberChart.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/SalesNumberChart.java @@ -42,7 +42,7 @@ public class SalesNumberChart extends HttpServlet implements Depiction { */ @Override protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { - UUID uuid = setup(req, resp, cache); + UUID uuid = init(req, resp, cache); if (uuid == null) return; File file = DatasetManagement.get(uuid); diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingCartTable.java b/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingCartTable.java index 311df27..9013ca6 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingCartTable.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingCartTable.java @@ -31,7 +31,7 @@ public class ShoppingCartTable extends HttpServlet implements Depiction { private static final long serialVersionUID = 5026732432605473505L; - private static Map cache; + private static Map cache = new HashMap<>(); /** * returns formatted analysis result to HTTP GET request from supplied id. @@ -40,8 +40,9 @@ public class ShoppingCartTable extends HttpServlet implements Depiction { * @param resp response object * @throws IOException failed to initialize print writer */ + @Override protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { - UUID uuid = setup(req, resp, cache); + UUID uuid = init(req, resp, cache); if (uuid == null) return; diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingTimesChart.java b/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingTimesChart.java index 615bf57..9ee5fdd 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingTimesChart.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/ShoppingTimesChart.java @@ -47,7 +47,7 @@ public class ShoppingTimesChart extends HttpServlet implements Depiction { */ @Override protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { - UUID uuid = setup(req, resp, cache); + UUID uuid = init(req, resp, cache); if (uuid == null) return; diff --git a/src/main/java/de/hsel/spm/baudas/web/depiction/WeekOverviewChart.java b/src/main/java/de/hsel/spm/baudas/web/depiction/WeekOverviewChart.java index d9d0cb0..55d258a 100644 --- a/src/main/java/de/hsel/spm/baudas/web/depiction/WeekOverviewChart.java +++ b/src/main/java/de/hsel/spm/baudas/web/depiction/WeekOverviewChart.java @@ -44,7 +44,7 @@ public class WeekOverviewChart extends HttpServlet implements Depiction { @Override protected void doGet(@NotNull HttpServletRequest req, @NotNull HttpServletResponse resp) throws IOException { - UUID uuid = setup(req, resp, cache); + UUID uuid = init(req, resp, cache); if (uuid == null) return; diff --git a/src/main/webapp/js/clusters.js b/src/main/webapp/js/clusters.js index a255cc6..ac9709f 100644 --- a/src/main/webapp/js/clusters.js +++ b/src/main/webapp/js/clusters.js @@ -1,30 +1,38 @@ +/** + * renders cluster analysis results as a table. + * + * @author Julian Hinxlage + * @version 0.1 + * @since 1.0 + */ + let cluster_result; function updateClusters(id) { - if(typeof id !== 'undefined') { + if (typeof id !== 'undefined') { request('clusters', id).then(function (data) { cluster_result = data; drawClusterTable(); }); - }else request('clusters').then(function(data) { + } else request('clusters').then(function (data) { cluster_result = data; drawClusterTable(); }); } -function drawClusterTable(){ +function drawClusterTable() { let table = document.getElementById("cluster_table"); - while(table.hasChildNodes()){ + while (table.hasChildNodes()) { table.removeChild(table.firstChild); } let row = $(""); row.append(""); row.append(""); - for (x in cluster_result){ - if(x == 0){ + for (let x in cluster_result) { + if (x == 0) { row.append("" + "Durchschnitt" + ""); - }else{ + } else { row.append("" + x + ""); } } @@ -44,12 +52,12 @@ function drawClusterTable(){ $("#cluster_table").append(row); } -function appendClusterTable(row, attrib){ +function appendClusterTable(row, attrib) { row.append(""); row.append(""); row.append("" + attrib + ""); - for (x in cluster_result){ - row.append($("" + cluster_result[x][attrib] +"")); + for (let x in cluster_result) { + row.append($("" + cluster_result[x][attrib] + "")); } row.append(""); } diff --git a/src/main/webapp/js/cache.js b/src/main/webapp/js/datasets.js similarity index 96% rename from src/main/webapp/js/cache.js rename to src/main/webapp/js/datasets.js index e474c4b..904b7f5 100644 --- a/src/main/webapp/js/cache.js +++ b/src/main/webapp/js/datasets.js @@ -1,3 +1,11 @@ +/** + * Dataset switching and listing. + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ + Chart.defaults.global.defaultFontColor = "black"; diff --git a/src/main/webapp/js/sales.js b/src/main/webapp/js/sales.js index 995a428..a506b62 100644 --- a/src/main/webapp/js/sales.js +++ b/src/main/webapp/js/sales.js @@ -1,3 +1,11 @@ +/** + * renders sales numbers as chart. + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ + let top_flop_result; @@ -13,8 +21,7 @@ let sales = new Chart($("#sales_chart"), { options: { responsive: true, title: { - display: false, - text: 'Top Flop Artikel' + display: false }, legend: { display: false diff --git a/src/main/webapp/js/shopping_cart.js b/src/main/webapp/js/shopping_cart.js index 70b7bb5..8dbcbc6 100644 --- a/src/main/webapp/js/shopping_cart.js +++ b/src/main/webapp/js/shopping_cart.js @@ -1,3 +1,11 @@ +/** + * renders shopping cart analysis results as a table. + * + * @author Karsten Eden + * @version 0.1 + * @since 1.0 + */ + let shopping_cart_result; function updateShoppingCartTable(id) { @@ -25,7 +33,7 @@ function drawShoppingCartTable(){ row.append(""); row.append(""); row.append(""); - for (x in shopping_cart_result){ + for (let x in shopping_cart_result){ row.append(""); row.append("" + shopping_cart_result[x].key + ""); row.append("" + shopping_cart_result[x].value + ""); diff --git a/src/main/webapp/js/shopping_times.js b/src/main/webapp/js/shopping_times.js index 1f29752..e13c90b 100644 --- a/src/main/webapp/js/shopping_times.js +++ b/src/main/webapp/js/shopping_times.js @@ -1,3 +1,11 @@ +/** + * renders shopping times analysis result as chart with day selection. + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ + let shopping_result; let shopping_chart = new Chart(document.getElementById("shopping_times_chart"), { diff --git a/src/main/webapp/js/upload.js b/src/main/webapp/js/upload.js index 11d344d..4c50324 100644 --- a/src/main/webapp/js/upload.js +++ b/src/main/webapp/js/upload.js @@ -1,3 +1,11 @@ +/** + * upload files and show loading modal + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ + let form = document.getElementById("upload"); form.onsubmit = function (event) { @@ -12,7 +20,7 @@ form.onsubmit = function (event) { loading.removeClass("hide"); $('.sidenav').sidenav('close'); loading.modal('open'); - } + }; xhr.upload.addEventListener("progress", function (event) { if (event.lengthComputable) { diff --git a/src/main/webapp/js/week_overview.js b/src/main/webapp/js/week_overview.js index c20f5b7..72198bf 100644 --- a/src/main/webapp/js/week_overview.js +++ b/src/main/webapp/js/week_overview.js @@ -1,3 +1,11 @@ +/** + * render week overview analysis result as chart. + * + * @author Johannes Theiner + * @version 0.1 + * @since 1.0 + */ + let week_result; let week_overview = new Chart($("#overview_chart"), { diff --git a/src/main/webapp/theming.jsp b/src/main/webapp/theming.jsp index d6dcc2f..b0267ea 100644 --- a/src/main/webapp/theming.jsp +++ b/src/main/webapp/theming.jsp @@ -5,7 +5,7 @@ - +