From 30f84f65125dc6c90bc519333d7a75d62ac5259d Mon Sep 17 00:00:00 2001 From: David Cruciani Date: Thu, 8 Feb 2024 11:30:55 +0100 Subject: [PATCH] chg: [website] query page --- webiste/app/home.py | 20 ++++ webiste/app/session.py | 2 +- webiste/app/static/css/core.css | 1 - webiste/app/templates/history.html | 7 +- webiste/app/templates/home.html | 151 ++++++--------------------- webiste/app/templates/query.html | 162 +++++++++++++++++++++++++++++ webiste/app/templates/sidebar.html | 8 +- 7 files changed, 220 insertions(+), 131 deletions(-) create mode 100644 webiste/app/templates/query.html diff --git a/webiste/app/home.py b/webiste/app/home.py index 03dd0cd3..9a39535d 100644 --- a/webiste/app/home.py +++ b/webiste/app/home.py @@ -1,3 +1,4 @@ +import json from flask import Flask, Blueprint, render_template, request, jsonify from . import home_core as HomeModel from . import session as SessionModel @@ -14,6 +15,25 @@ home_blueprint = Blueprint( def home(): return render_template("home.html") +@home_blueprint.route("/query/") +def query(sid): + session = HomeModel.get_session(sid) + flag=False + if session: + flag = True + query_loc = session.query_enter + else: + for s in SessionModel.sessions: + if s.id == sid: + flag = True + query_loc = s.query + session=s + if flag: + return render_template("query.html", query=query_loc, sid=sid, input_query=session.input_query, modules=json.loads(session.glob_query)) + return render_template("404.html") + + + @home_blueprint.route("/get_modules") def get_modules(): """Return all modules available""" diff --git a/webiste/app/session.py b/webiste/app/session.py index 23caf261..0153a66f 100644 --- a/webiste/app/session.py +++ b/webiste/app/session.py @@ -154,7 +154,7 @@ class Session_class: histories = History.query.all() - while len(histories) > 3: + while len(histories) > 10: history = History.query.order_by(History.id).all() Session_db.query.filter_by(id=history[0].session_id).delete() History.query.filter_by(id=history[0].id).delete() diff --git a/webiste/app/static/css/core.css b/webiste/app/static/css/core.css index 59f0475d..05a1e7b8 100644 --- a/webiste/app/static/css/core.css +++ b/webiste/app/static/css/core.css @@ -37,7 +37,6 @@ div#searchbox { border: 1px solid #ccc; border-radius: 5px 0 0 5px; padding-left: .75em; - width: 80%; outline: none; } button#query { diff --git a/webiste/app/templates/history.html b/webiste/app/templates/history.html index b73aaaf6..9fb19032 100644 --- a/webiste/app/templates/history.html +++ b/webiste/app/templates/history.html @@ -5,7 +5,7 @@ {% extends 'base.html' %} {% block content %} -

History

+

History



@@ -13,13 +13,12 @@