Merge "Task table - type column would refer to workflow executions accordingly"

This commit is contained in:
Jenkins 2017-01-24 10:48:22 +00:00 committed by Gerrit Code Review
commit ba7c0111b8
12 changed files with 112 additions and 19 deletions

View File

@ -8,6 +8,6 @@
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Action Executions of Task ID:") %}
<h3>
{{ action_execution_id }}
{{ task_id }}
</h3>
{% endblock page_header %}

View File

@ -17,6 +17,7 @@ from django.conf.urls import url # noqa
from mistraldashboard.action_executions import views
ACTION_EXECUTIONS = r'^(?P<action_execution_id>[^/]+)/%s$'
TASKS = r'^(?P<task_id>[^/]+)/%s$'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
@ -28,6 +29,6 @@ urlpatterns = [
{'column': 'output'}, name='output'),
url(ACTION_EXECUTIONS % 'update', views.UpdateView.as_view(),
name='update'),
url(ACTION_EXECUTIONS % 'task', views.FilteredByTaskView.as_view(),
url(TASKS % 'task', views.FilteredByTaskView.as_view(),
name='task')
]

View File

@ -162,7 +162,7 @@ class FilteredByTaskView(tables.DataTableView):
def get_data(self, **kwargs):
try:
task_id = self.kwargs['action_execution_id']
task_id = self.kwargs['task_id']
data = api.action_executions_list(self.request, task_id)
except Exception:
msg = (

View File

@ -48,7 +48,7 @@ def mistralclient(request):
@handle_errors(_("Unable to retrieve list"), [])
def pagination_list(entity, request, marker='', sort_keys='', sort_dirs='asc',
paginate=False, reversed_order=False):
paginate=False, reversed_order=False, selector=None):
"""Retrieve a listing of specific entity and handles pagination.
:param entity: Requested entity (String)
@ -59,6 +59,7 @@ def pagination_list(entity, request, marker='', sort_keys='', sort_dirs='asc',
:param paginate: If true will perform pagination based on settings.
Default:False
:param reversed_order: flag to reverse list. Default:False
:param selector: additional selector to allow further server filtering
"""
limit = getattr(settings, 'API_RESULT_LIMIT', 1000)
@ -73,8 +74,21 @@ def pagination_list(entity, request, marker='', sort_keys='', sort_dirs='asc',
sort_dirs = 'desc' if sort_dirs == 'asc' else 'asc'
api = mistralclient(request)
entities_iter = getattr(api, entity).list(
marker, limit, sort_keys, sort_dirs
entities_iter = (
getattr(api, entity).list(
selector,
marker=marker,
limit=limit,
sort_keys=sort_keys,
sort_dirs=sort_dirs
) if selector else (
getattr(api, entity).list(
marker=marker,
limit=limit,
sort_keys=sort_keys,
sort_dirs=sort_dirs
)
)
)
has_prev_data = has_more_data = False

View File

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

View File

@ -17,10 +17,12 @@ from django.conf.urls import url # noqa
from mistraldashboard.executions import views
EXECUTIONS = r'^(?P<execution_id>[^/]+)/%s$'
TASKS = r'^(?P<task_execution_id>[^/]+)/%s$'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(EXECUTIONS % 'detail', views.DetailView.as_view(), name='detail'),
url(TASKS % 'tasks', views.TasksView.as_view(), name='tasks'),
url(EXECUTIONS % 'detail_task_id', views.DetailView.as_view(),
{'caller': 'task'}, name='detail_task_id'),
url(EXECUTIONS % 'output', views.CodeView.as_view(),

View File

@ -122,6 +122,63 @@ class IndexView(tables.DataTableView):
return executions
class TasksView(tables.DataTableView):
table_class = mistral_tables.ExecutionsTable
template_name = 'mistral/executions/index_filtered_task.html'
def has_prev_data(self, table):
return self._prev
def has_more_data(self, table):
return self._more
def get_data(self):
executions = []
prev_marker = self.request.GET.get(
mistral_tables.ExecutionsTable._meta.prev_pagination_param,
None
)
if prev_marker is not None:
sort_dir = 'asc'
marker = prev_marker
else:
sort_dir = 'desc'
marker = self.request.GET.get(
mistral_tables.ExecutionsTable._meta.pagination_param,
None
)
try:
executions, self._more, self._prev = api.pagination_list(
entity="executions",
request=self.request,
marker=marker,
sort_dirs=sort_dir,
paginate=True,
selector=self.kwargs['task_execution_id']
)
if prev_marker is not None:
executions = sorted(
executions,
key=lambda execution: getattr(
execution, 'created_at'
),
reverse=True
)
except Exception:
self._prev = False
self._more = False
msg = (
_('Unable to retrieve executions list of the requested task.')
)
exceptions.handle(self.request, msg)
return executions
class DetailView(generic.TemplateView):
template_name = 'mistral/executions/detail.html'
page_title = _("Execution Overview")

View File

@ -47,12 +47,11 @@ class TypeColumn(tables.Column):
obj_id = datum.id
url = ""
action_execution_url = "horizon:mistral:action_executions:task"
workflow_execution_url = "horizon:mistral:executions:tasks"
if datum.type == "ACTION":
url = action_execution_url
# todo: add missing link to workflow execution
# once available in python mistral client API
# elif datum.type = "WORKFLOW":
# url= "horizon:mistral:workflow:task"
elif datum.type == "WORKFLOW":
url = workflow_execution_url
return reverse(url, args=[obj_id])

View File

@ -58,7 +58,7 @@
<dl class="dl-horizontal">
<dt>{% trans "Workflow Name" %}</dt>
<dd>
<a href="{{ task.workflow_url }}"
<a href="{{ task.workflow_detail_url }}"
title="{{task.workflow_name}} {% trans "overview" %}">
{{ task.workflow_name }}
</a>

View File

@ -8,6 +8,6 @@
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Tasks of Workflow Execution ID:") %}
<h3>
{{ task_id }}
{{ execution_id }}
</h3>
{% endblock page_header %}

View File

@ -17,11 +17,14 @@ from django.conf.urls import url # noqa
from mistraldashboard.tasks import views
TASKS = r'^(?P<task_id>[^/]+)/%s$'
EXECUTIONS = r'^(?P<execution_id>[^/]+)/%s$'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(TASKS % 'detail', views.OverviewView.as_view(), name='detail'),
url(TASKS % 'execution', views.ExecutionView.as_view(), name='execution'),
url(EXECUTIONS % 'execution',
views.ExecutionView.as_view(),
name='execution'),
url(TASKS % 'result', views.CodeView.as_view(),
{'column': 'result'}, name='result'),
url(TASKS % 'published', views.CodeView.as_view(),

View File

@ -47,7 +47,7 @@ class ExecutionView(tables.DataTableView):
def get_data(self, **kwargs):
try:
execution_id = self.kwargs['task_id']
execution_id = self.kwargs['execution_id']
tasks = api.task_list(self.request, execution_id)
except Exception:
msg = _('Unable to get task by execution id "%s".') % execution_id
@ -60,22 +60,31 @@ class ExecutionView(tables.DataTableView):
class OverviewView(generic.TemplateView):
template_name = 'mistral/tasks/detail.html'
page_title = _("Task Details")
workflow_url = 'horizon:mistral:workflows:detail'
workflow_detail_url = 'horizon:mistral:workflows:detail'
workflow_execution_tasks_url = 'horizon:mistral:executions:tasks'
execution_url = 'horizon:mistral:executions:detail'
action_execution_url = 'horizon:mistral:action_executions:task'
def get_context_data(self, **kwargs):
context = super(OverviewView, self).get_context_data(**kwargs)
task = get_single_task_data(self.request, **kwargs)
task.workflow_url = reverse(self.workflow_url,
args=[task.workflow_name])
task.workflow_detail_url = reverse(self.workflow_detail_url,
args=[task.workflow_name])
task.execution_url = reverse(self.execution_url,
args=[task.workflow_execution_id])
task.result = utils.prettyprint(task.result)
task.published = utils.prettyprint(task.published)
task.state = utils.label(task.state)
if task.type and task.type == "ACTION":
task.type_url = reverse(self.action_execution_url, args=[task.id])
if task.type == "ACTION":
task.type_url = reverse(
self.action_execution_url,
args=[task.id]
)
elif task.type == "WORKFLOW":
task.type_url = reverse(
self.workflow_execution_tasks_url,
args=[task.id]
)
breadcrumb = [(task.id, reverse(
'horizon:mistral:tasks:detail',