UI: Task & Execution screen refactored

* enhanced django template inheritance
* removed redundant template (html) files
* added link to task overview from execution overview
* when clicking task under execution main table,
  it now opens under task menu, which handles the logic
* same as above - when clicking execution under main tasks table

Screenshots:
http://pasteboard.co/23xFix0r.png
http://pasteboard.co/23jzE8JJ.png

Partially implements blueprint:tasks-screen-improvments
Partially implements blueprint: mistral-dashboard-executions-screen

Change-Id: Ibb4a8814b421b5dffcff264e7517a3b3ba29fdd7
This commit is contained in:
Gal Margalit 2015-11-10 15:41:19 +00:00
parent 359b941afd
commit d77840ff95
12 changed files with 117 additions and 112 deletions

View File

@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load i18n %}
{% block css %}
{% include "_stylesheets.html" %}

View File

@ -0,0 +1,5 @@
{% extends 'mistral/default/base.html' %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -61,7 +61,7 @@ class ExecutionsTable(tables.DataTable):
"task",
verbose_name=_("Tasks"),
empty_value=_("View"),
link="horizon:mistral:executions:tasks"
link="horizon:mistral:tasks:execution"
)
input = tables.Column(
@ -101,20 +101,3 @@ class ExecutionsTable(tables.DataTable):
verbose_name = _("Executions")
table_actions = (DeleteExecution, tables.FilterAction)
row_actions = (DeleteExecution,)
class TaskTable(tables.DataTable):
id = tables.Column("id", verbose_name=_("ID"))
name = tables.Column("name", verbose_name=_("Name"))
parameters = tables.Column("parameters", verbose_name=_("Parameters"))
output = tables.Column("output", verbose_name=_("Output"))
created_at = tables.Column("created_at", verbose_name=_("Created at"))
updated_at = tables.Column("updated_at", verbose_name=_("Updated at"))
state = tables.Column("state", verbose_name=_("State"), filters=[label])
class Meta(object):
name = "tasks"
verbose_name = _("Tasks")

View File

@ -34,6 +34,13 @@
{{ execution.workflow_name }}
</a>
</dd>
<dt>{% trans "Tasks" %}</dt>
<dd>
<a href="{{ task.url }}"
title="{% trans "View tasks" %}">
{% trans "view corresponding tasks" %}
</a>
</dd>
<br/>
<dt>{% trans "Creation Date" %}</dt>
<dd>{{ execution.created_at|parse_isotime}}</dd>

View File

@ -24,8 +24,9 @@ EXECUTIONS = r'^(?P<execution_id>[^/]+)/%s$'
urlpatterns = patterns(
'',
url(r'^$', views.IndexView.as_view(), name='index'),
url(EXECUTIONS % 'tasks', views.TaskView.as_view(), name='tasks'),
url(EXECUTIONS % 'detail', views.DetailView.as_view(), name='detail'),
url(EXECUTIONS % 'detail_task_id', views.DetailView.as_view(),
{'caller': 'task'}, name='detail_task_id'),
url(EXECUTIONS % 'output', views.CodeView.as_view(),
{'column': 'output'}, name='output'),
url(EXECUTIONS % 'input', views.CodeView.as_view(),

View File

@ -27,19 +27,46 @@ from horizon import tables
from mistraldashboard import api
from mistraldashboard.default.utils import prettyprint
from mistraldashboard.executions.tables import ExecutionsTable
from mistraldashboard.executions.tables import TaskTable
from mistraldashboard import forms as mistral_forms
def get_execution_data(request, execution_id):
try:
execution = api.execution_get(request, execution_id)
except Exception:
msg = _('Unable to get execution "%s".') % execution_id
redirect = reverse('horizon:mistral:executions:index')
exceptions.handle(request, msg, redirect=redirect)
def get_single_data(request, id, type="execution"):
"""Get Execution or Task data by ID.
return execution
:param request: Request data
:param id: Entity ID
:param type: Request dispatch flag, Default: Execution
"""
if type == "execution":
try:
execution = api.execution_get(request, id)
except Exception:
msg = _('Unable to get execution by its ID"%s".') % id
redirect = reverse('horizon:mistral:executions:index')
exceptions.handle(request, msg, redirect=redirect)
return execution
elif type == "task":
try:
task = api.task_get(request, id)
except Exception:
msg = _('Unable to get task by its ID "%s".') % id
redirect = reverse('horizon:mistral:tasks:index')
exceptions.handle(request, msg, redirect=redirect)
return task
elif type == "task_by_execution":
try:
task = api.task_list(request, id)[0]
except Exception:
msg = _('Unable to get task by Execution ID "%s".') % id
redirect = reverse('horizon:mistral:executions:index')
exceptions.handle(request, msg, redirect=redirect)
return task
class IndexView(tables.DataTableView):
@ -50,28 +77,50 @@ class IndexView(tables.DataTableView):
return api.execution_list(self.request)
class TaskView(tables.DataTableView):
table_class = TaskTable
template_name = 'mistral/executions/index.html'
def get_data(self):
return api.task_list(self.request, self.kwargs['execution_id'])
class DetailView(generic.TemplateView):
template_name = 'mistral/executions/detail.html'
page_title = _("Execution Overview")
workflow_url = 'horizon:mistral:workflows:detail'
task_url = 'horizon:mistral:tasks:execution'
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
execution = get_execution_data(self.request, kwargs['execution_id'])
task = {}
execution = {}
if 'caller' in kwargs:
if kwargs['caller'] == 'task':
kwargs['task_id'] = kwargs['execution_id']
del kwargs['execution_id']
task = get_single_data(
self.request,
kwargs['task_id'],
"task"
)
execution = get_single_data(
self.request,
task.workflow_execution_id,
)
else:
execution = get_single_data(
self.request,
kwargs['execution_id'],
)
task = get_single_data(
self.request,
self.kwargs['execution_id'],
"task_by_execution"
)
execution.workflow_url = reverse(self.workflow_url,
args=[execution.workflow_name])
execution.input = prettyprint(execution.input)
execution.output = prettyprint(execution.output)
execution.params = prettyprint(execution.params)
task.url = reverse(self.task_url, args=[execution.id])
context['execution'] = execution
context['task'] = task
return context
@ -87,8 +136,10 @@ class CodeView(forms.ModalFormView):
def get_context_data(self, **kwargs):
context = super(CodeView, self).get_context_data(**kwargs)
column = self.kwargs['column']
execution = get_execution_data(self.request,
self.kwargs['execution_id'])
execution = get_single_data(
self.request,
self.kwargs['execution_id'],
)
io = {}
if column == 'input':

View File

@ -35,7 +35,7 @@ class TaskTable(tables.DataTable):
workflow_execution_id = tables.Column(
"workflow_execution_id",
verbose_name=_("Workflow Execution ID"),
link="horizon:mistral:tasks:execution"
link="horizon:mistral:executions:detail_task_id"
)
result = tables.Column(
"",

View File

@ -1,39 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block page_header %}
<h1>
{% trans "Execution Overview " %}
</h1>
{% endblock page_header %}
{% block main %}
{% load i18n sizeformat %}
<div class="detail">
<h4>{% trans "Information" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
<dt>{% trans "ID" %}</dt>
<dd>{{ execution.id|default:_("None") }}</dd>
<dt>{% trans "Worflow Name" %}</dt>
<dd>{{ execution.workflow_name }}</dd>
<dt>{% trans "State" %}</dt>
<dd>{{ execution.state }}</dd>
{% if execution.description %}
<dt>{% trans "Description" %}</dt>
<dd>{{ execution.description }}</dd>
{% endif %}
<dt>{% trans "Created At" %}</dt>
<dd>{{ execution.created_at }}</dd>
<dt>{% trans "Updated At" %}</dt>
<dd>{{ execution.updated_at }}</dd>
<dt>{% trans "Params" %}</dt>
<dd>{{ execution.params }}</dd>
<dt>{% trans "Input" %}</dt>
<dd>{{ execution.input }}</dd>
<dt>{% trans "Output" %}</dt>
<dd>{{ execution.output }}</dd>
</dl>
</div>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends 'mistral/default/table.html' %}
{% load i18n %}
{% block title %}
{% trans "Tasks" %}
{{ task_id }}
{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Tasks of Workflow Execution ID:") %}
<h3>
{{ task_id }}
</h3>
{% endblock page_header %}

View File

@ -1,11 +1,9 @@
{% extends 'mistral/default/base.html' %}
{% extends 'mistral/default/table.html' %}
{% load i18n %}
{% block title %}{% trans "Tasks" %}{% endblock %}
{% block title %}
{% trans "Tasks" %}
{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Tasks") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -1,13 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Task Result" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Task Result") %}
{% endblock page_header %}
{% block main %}
<div class="detail">
<pre>{{ result }}</pre>
</div>
{% endblock %}

View File

@ -42,22 +42,20 @@ def get_single_task_data(request, **kwargs):
return task
class ExecutionView(generic.TemplateView):
template_name = 'mistral/tasks/execution.html'
page_title = _("Execution Overview")
class ExecutionView(tables.DataTableView):
table_class = TaskTable
template_name = 'mistral/tasks/filtered.html'
def get_context_data(self, **kwargs):
context = super(ExecutionView, self).get_context_data(**kwargs)
task = get_single_task_data(self.request, **kwargs)
execution = api.execution_get(self.request, task.workflow_execution_id)
execution.input = prettyprint(execution.input)
execution.output = prettyprint(execution.output)
execution.params = prettyprint(execution.params)
def get_data(self, **kwargs):
try:
execution_id = self.kwargs['task_id']
tasks = api.task_list(self.request, execution_id)
except Exception:
msg = _('Unable to get task by execution id "%s".') % execution_id
redirect = reverse('horizon:mistral:executions:index')
exceptions.handle(self.request, msg, redirect=redirect)
context['task'] = task
context['execution'] = execution
return context
return tasks
class OverviewView(generic.TemplateView):