From 02fb2da3893fc639fb1b8ea24b1ba9c6c54a161a Mon Sep 17 00:00:00 2001 From: David Cruciani Date: Tue, 20 Feb 2024 10:10:02 +0100 Subject: [PATCH] add: [website] history collapse for query page --- website/app/history/history.py | 6 +++ website/app/history/history_core.py | 10 ++++- website/app/static/css/core.css | 5 --- .../static/js/history/history_tree_query.js | 16 ++++++++ .../static/js/{ => history}/history_view.js | 2 +- website/app/templates/base.html | 1 - website/app/templates/history_session.html | 2 +- website/app/templates/query.html | 37 +++++++++++++++++++ 8 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 website/app/static/js/history/history_tree_query.js rename website/app/static/js/{ => history}/history_view.js (98%) diff --git a/website/app/history/history.py b/website/app/history/history.py index f05a969..f5e91f3 100644 --- a/website/app/history/history.py +++ b/website/app/history/history.py @@ -35,6 +35,12 @@ def get_history_session(): return histories return {} +@history_blueprint.route("/get_current_query_history", methods=["GET"]) +def get_current_query_history(): + """Get current query history""" + return HistoryModel.get_current_query_history() + + @history_blueprint.route("/save_history/", methods=["GET"]) def save_history(sid): return HistoryModel.save_history_core(sid) diff --git a/website/app/history/history_core.py b/website/app/history/history_core.py index 44fc062..1d92438 100644 --- a/website/app/history/history_core.py +++ b/website/app/history/history_core.py @@ -30,7 +30,7 @@ def get_history_session(): # If current query have no children then don't display it # It's already save in history # Only parent-child tree structure is in flask session - current_query_value = sess.get(sess.get("current_query")) + current_query_value = sess.get(current_query) if current_query_value and current_query_value["children"]: loc_list.append(current_query_value) for q in sess: @@ -43,6 +43,14 @@ def get_history_session(): return loc_list +def get_current_query_history(): + current_query = sess.get("current_query") + if current_query: + current_query_value = sess.get(current_query) + if current_query_value and current_query_value["children"]: + return current_query_value + return {} + def get_history_session_uuid(history_uuid): for q in sess: diff --git a/website/app/static/css/core.css b/website/app/static/css/core.css index ca7e4f9..3735d35 100644 --- a/website/app/static/css/core.css +++ b/website/app/static/css/core.css @@ -6,11 +6,6 @@ body { background-color: #fbfbfb; } -/* @media (min-width: 991.98px) { - main { - padding-left: 200px; - } -} */ span#goTop, span#project-version{ position: fixed; diff --git a/website/app/static/js/history/history_tree_query.js b/website/app/static/js/history/history_tree_query.js new file mode 100644 index 0000000..022a3b5 --- /dev/null +++ b/website/app/static/js/history/history_tree_query.js @@ -0,0 +1,16 @@ +export default { + name: "History_view", + delimiters: ['[[', ']]'], + props: { + history: Object, + }, + + template: ` +
  • [[history.query]]
  • + + ` +} \ No newline at end of file diff --git a/website/app/static/js/history_view.js b/website/app/static/js/history/history_view.js similarity index 98% rename from website/app/static/js/history_view.js rename to website/app/static/js/history/history_view.js index 77270b0..cc066c7 100644 --- a/website/app/static/js/history_view.js +++ b/website/app/static/js/history/history_view.js @@ -1,4 +1,4 @@ -import {display_toast} from './toaster.js' +import {display_toast} from '../toaster.js' export default { name: "History_view", delimiters: ['[[', ']]'], diff --git a/website/app/templates/base.html b/website/app/templates/base.html index 3bf7926..0cfb01d 100644 --- a/website/app/templates/base.html +++ b/website/app/templates/base.html @@ -33,7 +33,6 @@ - diff --git a/website/app/templates/history_session.html b/website/app/templates/history_session.html index 478a2b8..2e6a7a2 100644 --- a/website/app/templates/history_session.html +++ b/website/app/templates/history_session.html @@ -85,7 +85,7 @@