add: [website] history collapse for query page

main
David Cruciani 2024-02-20 10:10:02 +01:00
parent 8a1f6b1f46
commit 02fb2da389
No known key found for this signature in database
GPG Key ID: 8690CDE1E3994B9B
8 changed files with 70 additions and 9 deletions

View File

@ -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/<sid>", methods=["GET"])
def save_history(sid):
return HistoryModel.save_history_core(sid)

View File

@ -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:

View File

@ -6,11 +6,6 @@ body {
background-color: #fbfbfb;
}
/* @media (min-width: 991.98px) {
main {
padding-left: 200px;
}
} */
span#goTop, span#project-version{
position: fixed;

View File

@ -0,0 +1,16 @@
export default {
name: "History_view",
delimiters: ['[[', ']]'],
props: {
history: Object,
},
template: `
<li><a :href="'/query/'+history.uuid" :title="'Attribute: \\n' +history.input+ '\\n\\nModules: \\n' + history.modules">[[history.query]]</a></li>
<ul>
<template v-for="child in history.children">
<history_view :history="child"></history_view>
</template>
</ul>
`
}

View File

@ -1,4 +1,4 @@
import {display_toast} from './toaster.js'
import {display_toast} from '../toaster.js'
export default {
name: "History_view",
delimiters: ['[[', ']]'],

View File

@ -33,7 +33,6 @@
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='css/jquery-ui.css') }}">
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='css/core.css') }}">
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='css/sidebar.css') }}">
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='css/select2-bootstrap-5-theme.min.css') }}">
</head>

View File

@ -85,7 +85,7 @@
<script type="module">
const { createApp, ref, onMounted, nextTick, defineComponent} = Vue
import {display_toast, message_list} from '/static/js/toaster.js'
import history_view from '/static/js/history_view.js'
import history_view from '/static/js/history/history_view.js'
createApp({
delimiters: ['[[', ']]'],
components: {

View File

@ -48,6 +48,30 @@
<br/>
<button class="btn btn-outline-primary" style="position: fixed; right: 0px; top: 50%" title="Session history" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">
<i class="fa-solid fa-bars"></i>
</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasScrolling" aria-labelledby="offcanvasScrollingLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasScrollingLabel">Current History query</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div style="margin-left: 18px;">
<a class="btn btn-secondary btn-sm" href="/history_session">Complete view</a>
</div>
<div class="offcanvas-body">
<ul>
<li><a :href="'/query/'+history.uuid" :title="'Attribute: \n' +history.input+ '\n\nModules: \n' + history.modules">[[history.query]]</a></li>
<ul>
<template v-for="child in history.children">
<history_view :history="child"></history_view>
</template>
</ul>
</ul>
</div>
</div>
<!-- Results Part -->
<hr>
<ul class="nav nav-tabs" style="margin-bottom: 10px;">
@ -183,8 +207,12 @@
<script type="module">
const { createApp, ref, onMounted, nextTick, defineComponent} = Vue
import {message_list} from '/static/js/toaster.js'
import history_view from '/static/js/history/history_tree_query.js'
createApp({
delimiters: ['[[', ']]'],
components: {
history_view
},
setup() {
const is_searching = ref(false)
@ -194,6 +222,7 @@
const progress = ref(0)
const status_site = ref()
const tab_list = ref("json")
const history = ref({})
function actionQuery(){
@ -258,8 +287,15 @@
}
}
async function get_history_session(){
let res = await fetch("/get_current_query_history")
let loc = await res.json()
history.value = loc
}
onMounted(() => {
actionQuery()
get_history_session()
})
return {
@ -269,6 +305,7 @@
is_searching,
modules_res,
tab_list,
history,
generateCoreFormatUI,
active_tab
}