commit 1b4cb4c575c633c189c17e3ded1df67f190068ec
Author: Ondřej Váně <onry.vane@gmail.com>
Date:   Tue Jul 20 12:23:09 2021 +0200

    #4 Allow reparameterization in AP detail
    
    - added form to the AP detail page for editing treshold values
    - added method to the controller for saving new values

diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
index f9262bb..946b861 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import java.util.List;
 
@@ -104,4 +105,24 @@ public class AppController {
 
         return "configuration";
     }
+
+    @PostMapping("/anti-patterns/{id}")
+    public String antiPatternsPost(Model model,
+                                   @PathVariable Long id,
+                                   @RequestParam(value = "configValues", required = false) String[] configValues,
+                                   @RequestParam(value = "configNames", required = false) String[] configNames,
+                                   RedirectAttributes redirectAttrs) {
+
+        if (antiPatternService.saveNewConfiguration(configNames, configValues)) {
+            redirectAttrs.addFlashAttribute("successMessage", "All threshold values has been successfully saved.");
+        } else {
+            redirectAttrs.addFlashAttribute("errorMessage", "One or more configuration values are not in correct format");
+        }
+
+        model.addAttribute("antiPatterns", antiPatternService.antiPatternToModel(antiPatternService.getAntiPatternById(id)));
+
+        return "redirect:/anti-patterns/{id}";
+    }
+
+
 }
diff --git a/src/main/webapp/WEB-INF/templates/anti-pattern.html b/src/main/webapp/WEB-INF/templates/anti-pattern.html
index a49de92..c725e5f 100644
--- a/src/main/webapp/WEB-INF/templates/anti-pattern.html
+++ b/src/main/webapp/WEB-INF/templates/anti-pattern.html
@@ -23,6 +23,19 @@
 <div th:replace="fragments/navbar :: navBar"></div>
 <!-- ./Navigation bar imported -->
 
+<!-- Container for show error message -->
+<div class="container">
+    <div th:if="${errorMessage}" th:text="${errorMessage}" class="alert alert-danger" role="alert">
+    </div>
+</div>
+<!-- ./Container for show error message -->
+<!-- Container for show success message -->
+<div class="container">
+    <div th:if="${successMessage}" th:text="${successMessage}" class="alert alert-success" role="alert">
+    </div>
+</div>
+<!-- ./Container for show success message -->
+
 <!-- Card for anti pattern details-->
 <div class="card">
     <!-- Card header -->
@@ -68,14 +81,25 @@
 
         <!-- Anti pattern configuration form -->
         <h5>Anti Pattern configurations</h5>
-        <div th:each="config : ${antiPattern.configurations}" class="form-group">
-            <label th:text="${config.value.printName} + ':'" th:for="${config.value.name}"></label>
-            <input disabled type="text" class="form-control" th:id="${config.value.name}"
-                   th:value="${config.value.value}">
-            <small th:text="${config.value.description}" th:value="${config.value.name}"
-                   class="form-text text-muted"></small>
-        </div>
-        <!-- ./Anti pattern configuration form -->
+
+        <!-- Form for configuration values -->
+        <form action="#" th:action="@{/anti-patterns/} + ${antiPattern.id}" th:object="${antiPattern}" method="post">
+            <div th:each="config : ${antiPattern.configurations}" class="form-group">
+                <label th:text="${config.value.printName} + ':'"
+                       th:for="${config.value.name}"></label>
+                <input th:value="${config.value.value}" class="form-control" th:id="${config.value.name}"
+                       name="configValues">
+                <input th:value="${config.value.name}" style="display: none" class="form-control"
+                       name="configNames">
+                <small th:text="${config.value.description}" th:value="${config.value.name}"
+                       class="form-text text-muted"></small>
+            </div>
+            <div class="analyze-button-container">
+                <button type="submit" class="btn btn-primary btn-lg btn-block">Save configuration</button>
+            </div>
+            <!-- ./Anti pattern configuration form -->
+        </form>
+        <!-- ./Form for configuration values -->
     </div>
 </div>
 <!-- ./Card for anti pattern details-->
