m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-11-24 20:58:41 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-11-24 20:58:41 +0100
commit95ff5829c1010f50ae7b389717c3426d963861c8 (patch)
tree2327beb48d11e32c36823d0b86f04b8784650d34
parentbc208bbea11c4e0babdad30bd13a70ec7c3b70f1 (diff)
Add query uninstall backend
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java31
-rw-r--r--src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html4
2 files changed, 30 insertions, 5 deletions
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 80a331e..fe958ae 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/ClientController.java
@@ -61,8 +61,8 @@ public class ClientController {
return "queryForm";
}
- @PostMapping("/query")
- public String submitQuery(@ModelAttribute Query queryObject, Model model) {
+ @PostMapping("/installQuery")
+ public String installQuery(@ModelAttribute Query queryObject, Model model) {
boolean success = true;
try {
@@ -76,7 +76,32 @@ public class ClientController {
if (success) {
model.addAttribute(
"homeMessage",
- "Query submitted successfully");
+ "Query installed successfully");
+ } else {
+ model.addAttribute(
+ "homeMessage",
+ "Query submission failed with a remote exception");
+ }
+
+ return "home";
+ }
+
+ @PostMapping("/uninstallQuery")
+ public String uninstallQuery(@ModelAttribute Query queryObject, Model model) {
+ boolean success = true;
+
+ try {
+ this.api.uninstallQuery(queryObject.getName());
+ } catch (Exception e) {
+ success = false;
+ System.err.println("Client exception:");
+ e.printStackTrace();
+ }
+
+ if (success) {
+ model.addAttribute(
+ "homeMessage",
+ "Query uninstalled successfully");
} else {
model.addAttribute(
"homeMessage",
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html
index 08b4e89..f31ef6b 100644
--- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html
+++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html
@@ -12,7 +12,7 @@
<div th:replace="fragments/navbar :: navbar"></div>
<div id="installQueryForm">
<h2 class="display-7">Install query</h2>
- <form action="#" th:action="@{/query}" th:object="${queryObject}" method="post">
+ <form action="#" th:action="@{/installQuery}" th:object="${queryObject}" method="post">
<div class="form-group">
<label for="InstallQueryName1">Enter query name</label>
<input type="text" class="form-control" id="InstallQueryName1" rows="3" th:field="*{name}"/>
@@ -27,7 +27,7 @@
<div id="uninstallQueryForm">
<h2 class="display-7">Uninstall query</h2>
- <form action="#" th:action="@{/query}" th:object="${queryObject}" method="post">
+ <form action="#" th:action="@{/uninstallQuery}" th:object="${queryObject}" method="post">
<div class="form-group">
<label for="UninstallQueryName1">Enter query name</label>
<input type="text" class="form-control" id="UninstallQueryName1" rows="3" th:field="*{name}"/>