diff --git a/mistraldashboard/action_executions/templates/action_executions/filtered.html b/mistraldashboard/action_executions/templates/action_executions/filtered.html
index bae249b..a654e97 100644
--- a/mistraldashboard/action_executions/templates/action_executions/filtered.html
+++ b/mistraldashboard/action_executions/templates/action_executions/filtered.html
@@ -8,6 +8,6 @@
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Action Executions of Task ID:") %}
- {{ action_execution_id }}
+ {{ task_id }}
{% endblock page_header %}
diff --git a/mistraldashboard/action_executions/urls.py b/mistraldashboard/action_executions/urls.py
index 0133baa..b6300b5 100644
--- a/mistraldashboard/action_executions/urls.py
+++ b/mistraldashboard/action_executions/urls.py
@@ -19,6 +19,7 @@ from django.conf.urls import url # noqa
from mistraldashboard.action_executions import views
ACTION_EXECUTIONS = r'^(?P[^/]+)/%s$'
+TASKS = r'^(?P[^/]+)/%s$'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
@@ -30,6 +31,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')
]
diff --git a/mistraldashboard/action_executions/views.py b/mistraldashboard/action_executions/views.py
index 647344d..6bb6865 100644
--- a/mistraldashboard/action_executions/views.py
+++ b/mistraldashboard/action_executions/views.py
@@ -164,7 +164,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 = (
diff --git a/mistraldashboard/api.py b/mistraldashboard/api.py
index d10f588..d69b0bf 100644
--- a/mistraldashboard/api.py
+++ b/mistraldashboard/api.py
@@ -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
diff --git a/mistraldashboard/executions/templates/executions/index_filtered_task.html b/mistraldashboard/executions/templates/executions/index_filtered_task.html
new file mode 100644
index 0000000..eb5ea3e
--- /dev/null
+++ b/mistraldashboard/executions/templates/executions/index_filtered_task.html
@@ -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:") %}
+
+ {{ task_execution_id }}
+
+{% endblock page_header %}
diff --git a/mistraldashboard/executions/urls.py b/mistraldashboard/executions/urls.py
index 78be001..8a8140b 100644
--- a/mistraldashboard/executions/urls.py
+++ b/mistraldashboard/executions/urls.py
@@ -19,10 +19,12 @@ from django.conf.urls import url # noqa
from mistraldashboard.executions import views
EXECUTIONS = r'^(?P[^/]+)/%s$'
+TASKS = r'^(?P[^/]+)/%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(),
diff --git a/mistraldashboard/executions/views.py b/mistraldashboard/executions/views.py
index 2e7ea54..f2bb907 100644
--- a/mistraldashboard/executions/views.py
+++ b/mistraldashboard/executions/views.py
@@ -124,6 +124,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")
diff --git a/mistraldashboard/tasks/tables.py b/mistraldashboard/tasks/tables.py
index 971b63c..e9adbed 100644
--- a/mistraldashboard/tasks/tables.py
+++ b/mistraldashboard/tasks/tables.py
@@ -49,12 +49,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])
diff --git a/mistraldashboard/tasks/templates/tasks/detail.html b/mistraldashboard/tasks/templates/tasks/detail.html
index aa7916f..714322d 100644
--- a/mistraldashboard/tasks/templates/tasks/detail.html
+++ b/mistraldashboard/tasks/templates/tasks/detail.html
@@ -58,7 +58,7 @@
- {% trans "Workflow Name" %}
-
-
{{ task.workflow_name }}
diff --git a/mistraldashboard/tasks/templates/tasks/filtered.html b/mistraldashboard/tasks/templates/tasks/filtered.html
index fffed02..a2a672f 100644
--- a/mistraldashboard/tasks/templates/tasks/filtered.html
+++ b/mistraldashboard/tasks/templates/tasks/filtered.html
@@ -8,6 +8,6 @@
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Tasks of Workflow Execution ID:") %}
- {{ task_id }}
+ {{ execution_id }}
{% endblock page_header %}
diff --git a/mistraldashboard/tasks/urls.py b/mistraldashboard/tasks/urls.py
index 52ac887..c1ae9b4 100644
--- a/mistraldashboard/tasks/urls.py
+++ b/mistraldashboard/tasks/urls.py
@@ -19,11 +19,14 @@ from django.conf.urls import url # noqa
from mistraldashboard.tasks import views
TASKS = r'^(?P[^/]+)/%s$'
+EXECUTIONS = r'^(?P[^/]+)/%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(),
diff --git a/mistraldashboard/tasks/views.py b/mistraldashboard/tasks/views.py
index fcda8c7..7543841 100644
--- a/mistraldashboard/tasks/views.py
+++ b/mistraldashboard/tasks/views.py
@@ -49,7 +49,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
@@ -62,22 +62,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',