From 5dcdf0ab716c9edefb448a4b12e8225bd921c8e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= <mag.grodzinska@gmail.com>
Date: Sat, 11 Jan 2020 19:00:13 +0100
Subject: Split attrib chart and adding zones

---
 .../mimuw/cloudatlas/client/ClientController.java  | 20 ++++++++-----
 src/main/resources/application.properties          |  2 +-
 .../cloudatlas/client/templates/attribChart.html   | 20 ++-----------
 .../client/templates/fragments/navbar.html         |  3 ++
 .../mimuw/cloudatlas/client/templates/home.html    |  2 --
 .../cloudatlas/client/templates/zoneForm.html      | 33 ++++++++++++++++++++++
 6 files changed, 52 insertions(+), 28 deletions(-)
 create mode 100644 src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/zoneForm.html

(limited to 'src/main')

diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
index 0715af5..210505d 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
@@ -24,7 +24,8 @@ import java.util.*;
  * /attribs - GET - displays attribute submission form
  * /attribs - POST - posts attribute submission data
  * /values - GET - displays attributes values
- * /values - POST - posts zone change data
+ * /zones - GET - displays zone change data
+ * /zones - POST - posts zone change data
  * /attribNumValues - REST API to get numerical attribute values
  * /attribAllValues - REST API to get all attribute values
  */
@@ -325,9 +326,6 @@ public class ClientController {
 
     @GetMapping("/values")
     public String valuesPage(Model model) {
-        model.addAttribute("availableZones", getAvailableZonesString());
-        model.addAttribute("currentZone", "Current zone: " + this.currentZoneName);
-        model.addAttribute("zoneName", new DataStringInput());
         return "attribChart";
     }
 
@@ -439,13 +437,21 @@ public class ClientController {
         return processAttribValues(getValuesTable(false));
     }
 
-    @PostMapping("/values")
-    public String valuesPage(@ModelAttribute DataStringInput zoneName, Model model) {
+    @GetMapping("/zones")
+    public String zonesGetPage(Model model) {
+        model.addAttribute("availableZones", getAvailableZonesString());
+        model.addAttribute("currentZone", "Current zone: " + this.currentZoneName);
+        model.addAttribute("zoneName", new DataStringInput());
+        return "zoneForm";
+    }
+
+    @PostMapping("/zones")
+    public String zonesPostPage(@ModelAttribute DataStringInput zoneName, Model model) {
         this.currentZoneName = zoneName.getString();
         this.attributes.clear();
         model.addAttribute("currentZone", "Current zone: " + this.currentZoneName);
         model.addAttribute("availableZones", getAvailableZonesString());
         model.addAttribute("zoneName", new DataStringInput());
-        return "attribChart";
+        return "zoneForm";
     }
 }
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index ee983e2..2bd3b7e 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,7 +1,7 @@
 server.port=8082
 spring.application.name=CloudAtlas Client
 
-spring.thymeleaf.cache=true
+spring.thymeleaf.cache=false
 spring.thymeleaf.enabled=true
 spring.thymeleaf.prefix=classpath:/pl/edu/mimuw/cloudatlas/client/templates/
 spring.thymeleaf.suffix=.html
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
index bfb306c..8da8798 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html
@@ -4,10 +4,8 @@
 <head>
     <meta charset="UTF-8">
     <title>Attributes chart</title>
-    <link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" as="script">
-    <link rel="preload" href="https://www.gstatic.com/charts/loader.js" as="script">
     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
-    <script async defer type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
+    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
     <script type="text/javascript">
         google.charts.load('current', {'packages':['corechart', 'table', 'controls', 'charteditor']});
@@ -119,20 +117,7 @@
 
 <div th:replace="fragments/navbar :: navbar"></div>
 
-<h4 th:text="${currentZone}" class="d-flex justify-content-center mt-2"></h4>
-<div id="zoneAttribForm" class="d-flex justify-content-center mt-2">
-    <form action="#" th:action="@{/values}" th:object="${zoneName}" method="post">
-        <div class="form-group">
-            <label for="ZoneName1">Change zone name</label>
-            <input type="text" class="form-control" id="ZoneName1" rows="3" th:field="*{string}"/>
-            <small id="passwordHelpBlock" class="form-text text-muted" th:text="${availableZones}">
-            </small>
-        </div>
-        <button type="submit" class="btn btn-primary">Submit</button>
-    </form>
-</div>
-
-<div id="programmatic_dashboard_div" class="d-flex flex-column justify-content-center mt-5">
+<div id="programmatic_dashboard_div" class="d-flex flex-column justify-content-center">
     <h4 class="d-flex justify-content-center mt-2">Attribute values</h4>
     <div id="programmatic_control_div" class="d-flex justify-content-center mt-3"></div>
     <div id="programmatic_chart_div" class="d-flex justify-content-center mt-1"></div>
@@ -140,7 +125,6 @@
 </div>
 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
 
 </body>
 
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/fragments/navbar.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/fragments/navbar.html
index ca83cbb..7d28176 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/fragments/navbar.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/fragments/navbar.html
@@ -32,6 +32,9 @@
                 <li class="nav-item">
                     <a class="nav-link" href="/values">Values</a>
                 </li>
+                <li class="nav-item">
+                    <a class="nav-link" href="/zones">Zones</a>
+                </li>
             </ul>
         </div>
     </nav>
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
index 043ac76..47b19af 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/home.html
@@ -6,8 +6,6 @@
     <meta charset="UTF-8">
     <title>CloudAtlas Client - home</title>
     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
-    <link rel="preload" href="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" as="script">
-    <link rel="preload" href="https://www.gstatic.com/charts/loader.js" as="script">
 </head>
 
 <body>
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/zoneForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/zoneForm.html
new file mode 100644
index 0000000..4c55e50
--- /dev/null
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/zoneForm.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+
+<head>
+    <meta charset="UTF-8">
+    <title>Contacts query form</title>
+    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
+</head>
+
+<body>
+
+<div th:replace="fragments/navbar :: navbar"></div>
+
+<h4 th:text="${currentZone}" class="d-flex justify-content-center mt-2"></h4>
+<div id="zoneAttribForm" class="d-flex justify-content-center mt-2">
+    <form action="#" th:action="@{/zones}" th:object="${zoneName}" method="post">
+        <div class="form-group">
+            <label for="ZoneName1">Change zone name</label>
+            <input type="text" class="form-control" id="ZoneName1" rows="3" th:field="*{string}"/>
+            <small id="passwordHelpBlock" class="form-text text-muted" th:text="${availableZones}">
+            </small>
+        </div>
+        <button type="submit" class="btn btn-primary">Submit</button>
+    </form>
+</div>
+
+<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
+<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
+
+</body>
+
+</html>
-- 
cgit v1.2.3