Skip to content

Commit

Permalink
add: [website] history collapse for query page
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCruciani committed Feb 20, 2024
1 parent 8a1f6b1 commit 02fb2da
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 9 deletions.
6 changes: 6 additions & 0 deletions website/app/history/history.py
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion website/app/history/history_core.py
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions website/app/static/css/core.css
Expand Up @@ -6,11 +6,6 @@ body {
background-color: #fbfbfb;
}

/* @media (min-width: 991.98px) {
main {
padding-left: 200px;
}
} */

span#goTop, span#project-version{
position: fixed;
Expand Down
16 changes: 16 additions & 0 deletions website/app/static/js/history/history_tree_query.js
@@ -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>
`
}
@@ -1,4 +1,4 @@
import {display_toast} from './toaster.js'
import {display_toast} from '../toaster.js'
export default {
name: "History_view",
delimiters: ['[[', ']]'],
Expand Down
1 change: 0 additions & 1 deletion website/app/templates/base.html
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion website/app/templates/history_session.html
Expand Up @@ -85,7 +85,7 @@ <h5 class="mb-1">[[his.query]]</h5>
<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: {
Expand Down
37 changes: 37 additions & 0 deletions website/app/templates/query.html
Expand Up @@ -48,6 +48,30 @@ <h4>Modules:</h4>

<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;">
Expand Down Expand Up @@ -183,8 +207,12 @@ <h6>Attributes #[[key_attr+1]]</h6>
<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)

Expand All @@ -194,6 +222,7 @@ <h6>Attributes #[[key_attr+1]]</h6>
const progress = ref(0)
const status_site = ref()
const tab_list = ref("json")
const history = ref({})


function actionQuery(){
Expand Down Expand Up @@ -258,8 +287,15 @@ <h6>Attributes #[[key_attr+1]]</h6>
}
}

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 {
Expand All @@ -269,6 +305,7 @@ <h6>Attributes #[[key_attr+1]]</h6>
is_searching,
modules_res,
tab_list,
history,
generateCoreFormatUI,
active_tab
}
Expand Down

0 comments on commit 02fb2da

Please sign in to comment.