Task info page

This commit is contained in:
Yingtong Li 2018-01-11 20:25:49 +08:00
parent 65aa81844b
commit d6862df8f0
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
4 changed files with 91 additions and 8 deletions

View File

@ -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/<task_id>')
@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')

View File

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

View File

@ -26,26 +26,26 @@
<div class="menu">
<div class="header">Active tasks</div>
{% for task in eos.core.tasks.TaskScheduler.active_tasks() %}
<div class="item">
<a class="item" href="{{ url_for('task_view', task_id=task._id) }}">
{{ task.label }}
<br><small><i class="wait icon"></i> started {{ task.started_at|pretty_date }}</small>
</div>
</a>
{% endfor %}
<div class="divider"></div>
<div class="header">Pending tasks</div>
{% for task in eos.core.tasks.TaskScheduler.pending_tasks() %}
<div class="item">
<a class="item" href="{{ url_for('task_view', task_id=task._id) }}">
{{ task.label }}
<br><small><i class="wait icon"></i> due {{ task.run_at|pretty_date }}</small>
</div>
</a>
{% endfor %}
<div class="divider"></div>
<div class="header">Recently completed tasks</div>
{% for task in eos.core.tasks.TaskScheduler.completed_tasks(3) %}
<div class="item">
<a class="item" href="{{ url_for('task_view', task_id=task._id) }}">
{% if task.status.is_error() %}<i class="warning sign icon"></i> {% endif %}{{ task.label }}
<br><small><i class="wait icon"></i> completed {{ task.completed_at|pretty_date }}</small>
</div>
</a>
{% endfor %}
</div>
</div>

View File

@ -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 <http://www.gnu.org/licenses/>.
#}
{% block title %}{{ task.label }}{% endblock %}
{% block content %}
<h1>{{ task.label }}</h1>
<table class="ui celled definition table">
<tbody>
<tr>
<td>Status</td>
<td>{{ task.status.name|title }}</td>
</tr>
<tr>
<td>Strategy</td>
<td>{{ task.run_strategy._name }}</td>
</tr>
<tr>
<td>Scheduled</td>
<td>{% if task.run_at %}{{ task.run_at|pretty_date }}{% endif %}</td>
</tr>
<tr>
<td>Started</td>
<td>{% if task.started_at %}{{ task.started_at|pretty_date }}{% endif %}</td>
</tr>
<tr>
<td>Exited</td>
<td>{% if task.completed_at %}{{ task.completed_at|pretty_date }}{% endif %}</td>
</tr>
<tr>
<td>Messages</td>
<td>
{% if task.messages %}
<div class="monoout" style="max-height: 10em;">{{ '\n'.join(task.messages) }}</div>
{% endif %}
</td>
</tr>
<tr>
<td>Result</td>
<td>
{% if task.result %}
<div class="monoout" style="max-height: 3em;">{{ eos.core.object.EosObject.to_json(eos.core.object.EosObject.serialise_and_wrap(task.result)) }}</div>
{% endif %}
</td>
</tr>
</tbody>
</table>
{% endblock %}