From 4446260c102c63f07a88e87aa106ec195b68ed0f Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 8 Jan 2020 10:47:59 +0100
Subject: [PATCH 1/4] Change the way how the dismiss feature is added to
toasts.
---
app/templates/base.html.j2 | 10 +++++++++-
app/templates/corpora/analyse_corpus.html.j2 | 16 ++++++++++++++--
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2
index 6a8e50d9..7a544dfc 100644
--- a/app/templates/base.html.j2
+++ b/app/templates/base.html.j2
@@ -192,8 +192,16 @@
entry.parentNode.classList.add("active");
}
}
+ var toast;
+ var toastActionElement
{% for message in get_flashed_messages() %}
- M.toast({"html": '{{ message }}'});
+ toast = M.toast({"html": `{{ message }}`});
+ toastActionElement = toast.el.querySelector(".toast-action[data-action='close']");
+ if (toastActionElement) {
+ toastActionElement.addEventListener("click", function() {
+ toast.dismiss();
+ });
+ }
{% endfor %}
for (toastActionElement of document.querySelectorAll(".toast-action[data-action='close']")) {
toastActionElement.addEventListener("click", function(event) {
diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2
index 0f656aec..c1f20bc2 100644
--- a/app/templates/corpora/analyse_corpus.html.j2
+++ b/app/templates/corpora/analyse_corpus.html.j2
@@ -217,7 +217,13 @@
socket.emit("corpus_analysis", queryData);
queryLoadingElement.classList.remove("hide");
queryResultsTableElement.classList.add("hide");
- M.toast({html: "Query has been sent!"});
+ let toast = M.toast({"html": `Query has been sent!`});
+ let toastActionElement = toast.el.querySelector(".toast-action[data-action='close']");
+ if (toastActionElement) {
+ toastActionElement.addEventListener("click", function() {
+ toast.dismiss();
+ });
+ }
});
socket.on("corpus_analysis", function(message) {
@@ -234,7 +240,13 @@
if (message === null) {
queryResultsTableElement.classList.add("hide");
- M.toast({"html": "No results for this query!", "classes": "red"});
+ let toast = M.toast({"classes": "red", "html": `No results for this query!`});
+ let toastActionElement = toast.el.querySelector(".toast-action[data-action='close']");
+ if (toastActionElement) {
+ toastActionElement.addEventListener("click", function() {
+ toast.dismiss();
+ });
+ }
return;
}
From 2308ed9a8726552353e00e6ae524f3982d652fc5 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 8 Jan 2020 13:20:56 +0100
Subject: [PATCH 2/4] Add missing ";"
---
app/templates/base.html.j2 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2
index 7a544dfc..31fa5c2e 100644
--- a/app/templates/base.html.j2
+++ b/app/templates/base.html.j2
@@ -193,7 +193,7 @@
}
}
var toast;
- var toastActionElement
+ var toastActionElement;
{% for message in get_flashed_messages() %}
toast = M.toast({"html": `{{ message }}`});
toastActionElement = toast.el.querySelector(".toast-action[data-action='close']");
From 49f07e0ac59da01a48ea1244d9fa3447cbcb0d2c Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 8 Jan 2020 15:18:03 +0100
Subject: [PATCH 3/4] Add gunicorn to requirements.txt
---
requirements.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/requirements.txt b/requirements.txt
index f68e78f9..b0483a78 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,6 +7,7 @@ Flask-SocketIO
Flask-SQLAlchemy
Flask-Table
Flask-WTF
+gunicorn
jsonpatch
psycopg2
redis
From 44054a51c3efa53c094cfc34e2beb7dbf03f42cb Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 8 Jan 2020 16:02:28 +0100
Subject: [PATCH 4/4] Remove gunicorn from requirements.txt
---
requirements.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index b0483a78..f68e78f9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,7 +7,6 @@ Flask-SocketIO
Flask-SQLAlchemy
Flask-Table
Flask-WTF
-gunicorn
jsonpatch
psycopg2
redis