From d6862df8f0b0295210055901b9522b4c2c45ba14 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Thu, 11 Jan 2018 20:25:49 +0800 Subject: [PATCH] Task info page --- eosweb/core/main.py | 10 ++- eosweb/core/static/css/main.css | 11 ++++ .../templates/task/active_tasks_menu.html | 12 ++-- eosweb/core/templates/task/view.html | 66 +++++++++++++++++++ 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 eosweb/core/templates/task/view.html diff --git a/eosweb/core/main.py b/eosweb/core/main.py index 5e6c2e4..679f1be 100644 --- a/eosweb/core/main.py +++ b/eosweb/core/main.py @@ -208,9 +208,9 @@ def using_election(func): def election_admin(func): @functools.wraps(func) - def wrapped(election, **kwargs): + def wrapped(*args, **kwargs): if 'user' in flask.session and flask.session['user'].is_admin(): - return func(election, **kwargs) + return func(*args, **kwargs) else: return flask.Response('Administrator credentials required', 403) return wrapped @@ -341,6 +341,12 @@ def election_api_export_question(election, q_num, format): resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' return resp +@app.route('/task/') +@election_admin +def task_view(task_id): + task = Task.get_by_id(task_id) + return flask.render_template('task/view.html', task=task) + @app.route('/auditor') def auditor(): return flask.render_template('election/auditor.html') diff --git a/eosweb/core/static/css/main.css b/eosweb/core/static/css/main.css index 33bf464..c927b48 100644 --- a/eosweb/core/static/css/main.css +++ b/eosweb/core/static/css/main.css @@ -26,6 +26,17 @@ word-break: break-all; } +.monoout { + font-family: monospace; + white-space: pre-wrap; + overflow-y: scroll; + + padding: .78571429em 1em; + border: 1px solid rgba(34,36,38,.15); + color: rgba(0,0,0,.87); + border-radius: .28571429rem; +} + .superem { font-weight: bold; font-style: italic; diff --git a/eosweb/core/templates/task/active_tasks_menu.html b/eosweb/core/templates/task/active_tasks_menu.html index dde8f5e..ad0a46a 100644 --- a/eosweb/core/templates/task/active_tasks_menu.html +++ b/eosweb/core/templates/task/active_tasks_menu.html @@ -26,26 +26,26 @@ diff --git a/eosweb/core/templates/task/view.html b/eosweb/core/templates/task/view.html new file mode 100644 index 0000000..8d8a483 --- /dev/null +++ b/eosweb/core/templates/task/view.html @@ -0,0 +1,66 @@ +{% extends 'base.html' %} + +{# + Eos - Verifiable elections + Copyright © 2017-18 RunasSudo (Yingtong Li) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +#} + +{% block title %}{{ task.label }}{% endblock %} + +{% block content %} +

{{ task.label }}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Status{{ task.status.name|title }}
Strategy{{ task.run_strategy._name }}
Scheduled{% if task.run_at %}{{ task.run_at|pretty_date }}{% endif %}
Started{% if task.started_at %}{{ task.started_at|pretty_date }}{% endif %}
Exited{% if task.completed_at %}{{ task.completed_at|pretty_date }}{% endif %}
Messages + {% if task.messages %} +
{{ '\n'.join(task.messages) }}
+ {% endif %} +
Result + {% if task.result %} +
{{ eos.core.object.EosObject.to_json(eos.core.object.EosObject.serialise_and_wrap(task.result)) }}
+ {% endif %} +
+{% endblock %}