Commit 8fe8313c authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fill results menu

parent 659c6bac
......@@ -33,6 +33,12 @@ app.config['SECRET_KEY'] = 'dsqdsq-255sdA-fHfg52-25Asd5'
app_data = config_reader.get_app_data()
@app.context_processor
def get_launched_results():
cookie = request.cookies.get("results")
return {"results": cookie.split("|") if cookie is not None else set()}
# Main
@app.route("/", methods=['GET'])
def main():
......@@ -121,7 +127,14 @@ def status(id_job):
# Results path
@app.route("/result/<id_res>", methods=['GET'])
def result(id_res):
return render_template("results.html", title=app_title, id=id_res, menu="results")
my_render = render_template("results.html", title=app_title, id=id_res, menu="results", current_result=id_res)
response = app.make_response(my_render)
cookie = request.cookies.get("results")
cookie = cookie.split("|") if cookie is not None else []
if id_res not in cookie:
cookie.insert(0, id_res)
response.set_cookie(key="results", value="|".join(cookie), path="/")
return response
# Get graph (ajax request)
......
......@@ -39,7 +39,18 @@
class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
{% block results %}
<li><a href="/run">Please run a job!</a></li>
{% set has_job = False %}
{% if current_result and current_result not in results %}
{% set has_job = True %}
<li><a href="/result/{{ current_result }}">{{ current_result }}</a></li>
{% endif %}
{% if results | length > 0 %}
{% for result in results %}
<li><a href="/result/{{ result }}">{{ result }}</a></li>
{% endfor %}
{% elif not has_job %}
<li><a href="/run">Please run a job!</a></li>
{% endif %}
{% endblock %}
</ul>
</li>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment