diff --git a/mistraldashboard/executions/templates/executions/_code.html b/mistraldashboard/default/templates/default/_code.html similarity index 84% rename from mistraldashboard/executions/templates/executions/_code.html rename to mistraldashboard/default/templates/default/_code.html index e7417c6..639da65 100644 --- a/mistraldashboard/executions/templates/executions/_code.html +++ b/mistraldashboard/default/templates/default/_code.html @@ -5,10 +5,8 @@ {% endblock %} {% block modal-body %} -
-
+
{{ io.value }} -
{% endblock %} diff --git a/mistraldashboard/executions/tables.py b/mistraldashboard/executions/tables.py index 144d76e..47281b7 100644 --- a/mistraldashboard/executions/tables.py +++ b/mistraldashboard/executions/tables.py @@ -52,7 +52,10 @@ class ExecutionsTable(tables.DataTable): link="horizon:mistral:executions:detail" ) - workflow_name = tables.Column("workflow_name", verbose_name=_("Workflow")) + workflow_name = tables.Column( + "workflow_name", + verbose_name=_("Workflow") + ) task = tables.Column( "task", diff --git a/mistraldashboard/executions/urls.py b/mistraldashboard/executions/urls.py index 47c2c39..d16aae6 100644 --- a/mistraldashboard/executions/urls.py +++ b/mistraldashboard/executions/urls.py @@ -17,17 +17,14 @@ from django.conf.urls import patterns # noqa from django.conf.urls import url # noqa -from mistraldashboard.executions.views import IndexView -from mistraldashboard.executions.views import TaskView - from mistraldashboard.executions import views EXECUTIONS = r'^(?P[^/]+)/%s$' urlpatterns = patterns( '', - url(r'^$', IndexView.as_view(), name='index'), - url(EXECUTIONS % 'tasks', TaskView.as_view(), name='tasks'), + 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 % 'output', views.CodeView.as_view(), {'column': 'output'}, name='output'), diff --git a/mistraldashboard/executions/views.py b/mistraldashboard/executions/views.py index 1e5137e..16051fe 100644 --- a/mistraldashboard/executions/views.py +++ b/mistraldashboard/executions/views.py @@ -26,9 +26,9 @@ from horizon import tables from mistraldashboard import api from mistraldashboard.default.utils import prettyprint -from mistraldashboard.executions import forms as mistral_forms 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): @@ -76,7 +76,7 @@ class DetailView(generic.TemplateView): class CodeView(forms.ModalFormView): - template_name = 'mistral/executions/code.html' + template_name = 'mistral/default/code.html' modal_header = _("Code view") form_id = "code_view" form_class = mistral_forms.EmptyForm diff --git a/mistraldashboard/executions/forms.py b/mistraldashboard/forms.py similarity index 100% rename from mistraldashboard/executions/forms.py rename to mistraldashboard/forms.py diff --git a/mistraldashboard/tasks/tables.py b/mistraldashboard/tasks/tables.py index 69c22b4..b19692f 100644 --- a/mistraldashboard/tasks/tables.py +++ b/mistraldashboard/tasks/tables.py @@ -26,14 +26,31 @@ class TaskTable(tables.DataTable): id = tables.Column( "id", verbose_name=_("ID"), - link="horizon:mistral:tasks:detail") - name = tables.Column("name", verbose_name=_("Name")) - + link="horizon:mistral:tasks:detail" + ) + name = tables.Column( + "name", + verbose_name=_("Name") + ) workflow_execution_id = tables.Column( "workflow_execution_id", verbose_name=_("Workflow Execution ID"), link="horizon:mistral:tasks:execution" ) + result = tables.Column( + "", + verbose_name=_("Result"), + empty_value=_("View"), + link="horizon:mistral:tasks:result", + link_classes=("ajax-modal",) + ) + published = tables.Column( + "", + verbose_name=_("Published"), + empty_value=_("View"), + link="horizon:mistral:tasks:published", + link_classes=("ajax-modal",) + ) created_at = tables.Column( "created_at", verbose_name=_("Created at"), diff --git a/mistraldashboard/tasks/templates/tasks/detail.html b/mistraldashboard/tasks/templates/tasks/detail.html index a8fa494..08f9c28 100644 --- a/mistraldashboard/tasks/templates/tasks/detail.html +++ b/mistraldashboard/tasks/templates/tasks/detail.html @@ -1,41 +1,65 @@ {% extends 'base.html' %} {% load i18n %} -{% load i18n sizeformat %} {% block title %}{% trans "Task Details" %}{% endblock %} {% block page_header %}

- {% trans "Task Details: " %} - {{ task.name}} + {% trans "Task Details" %}

{% endblock page_header %} {% block main %} -
-
-

{% trans "Task Overview" %}

-
-
-
{% trans "ID" %}
-
{{ task.id }}
-
{% trans "Name" %}
-
{{ task.name }}
-
{% trans "WorkFlow Name" %}
-
{{ task.workflow_name }}
-
{% trans "WorkFlow Execution Id" %}
-
{{ task.workflow_execution_id }}
-
{% trans "Result" %}
-
{{ task.result }}
-
{% trans "Created At" %}
-
{{ task.created_at }}
-
{% trans "Updated At" %}
-
{{ task.updated_at }}
-
{% trans "Published" %}
-
{{ task.published }}
-
{% trans "State" %}
-
{{ task.state }}
-
-
+
+

{% trans "Overview" %}

+
+
+
{% trans "Name" %}
+
{{ task.name }}
+
{% trans "ID" %}
+
{{ task.id }}
+ {% if task.state_info %} +
{% trans "State Info" %}
+
{{ task.state_info }}
+ {% endif %} +
{% trans "State" %}
+
{{ task.state }}
+
+
{% trans "Creation Date" %}
+
{{ task.created_at|parse_isotime }}
+
{% trans "Time Since Created" %}
+
{{ task.created_at|parse_isotime|timesince }}
+
+
{% trans "Update Date" %}
+
{{ task.updated_at|parse_isotime }}
+
{% trans "Time Since Updated" %}
+
{{ task.updated_at|parse_isotime|timesince }}
+
+
{% trans "Result" %}
+
{{ task.result }}
+
{% trans "Published" %}
+
{{ task.published }}
+
+
+ +
+

{% trans "Workflow" %}

+
+
+
{% trans "Workflow Name" %}
+
+ + {{ task.workflow_name }} + +
+
{% trans "Workflow Execution ID" %}
+
+ + {{ task.workflow_execution_id }} + +
+
{% endblock %} diff --git a/mistraldashboard/tasks/urls.py b/mistraldashboard/tasks/urls.py index 5f4d67b..8fe0f99 100644 --- a/mistraldashboard/tasks/urls.py +++ b/mistraldashboard/tasks/urls.py @@ -26,4 +26,8 @@ urlpatterns = patterns( 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(TASKS % 'result', views.CodeView.as_view(), + {'column': 'result'}, name='result'), + url(TASKS % 'published', views.CodeView.as_view(), + {'column': 'published'}, name='published'), ) diff --git a/mistraldashboard/tasks/views.py b/mistraldashboard/tasks/views.py index 952890c..83a6b31 100644 --- a/mistraldashboard/tasks/views.py +++ b/mistraldashboard/tasks/views.py @@ -15,25 +15,40 @@ # limitations under the License. from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse_lazy + from django.utils.translation import ugettext_lazy as _ from django.views import generic - from horizon import exceptions +from horizon import forms from horizon import tables from mistraldashboard import api from mistraldashboard.default.utils import prettyprint +from mistraldashboard import forms as mistral_forms from mistraldashboard.tasks.tables import TaskTable +def get_single_task_data(request, **kwargs): + try: + task_id = kwargs['task_id'] + task = api.task_get(request, task_id) + except Exception: + msg = _('Unable to get task "%s".') % task_id + redirect = reverse('horizon:mistral:tasks:index') + exceptions.handle(request, msg, redirect=redirect) + + return task + + class ExecutionView(generic.TemplateView): template_name = 'mistral/tasks/execution.html' page_title = _("Execution Overview") def get_context_data(self, **kwargs): context = super(ExecutionView, self).get_context_data(**kwargs) - task = self.get_data(self.request, **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) @@ -44,39 +59,52 @@ class ExecutionView(generic.TemplateView): return context - def get_data(self, request, **kwargs): - try: - task_id = kwargs['task_id'] - task = api.task_get(request, task_id) - except Exception: - msg = _('Unable to get task "%s".') % task_id - redirect = reverse('horizon:mistral:tasks:index') - exceptions.handle(self.request, msg, redirect=redirect) - - return task - class OverviewView(generic.TemplateView): template_name = 'mistral/tasks/detail.html' page_title = _("Task Details") + workflow_url = 'horizon:mistral:workflows:detail' + execution_url = 'horizon:mistral:executions:detail' def get_context_data(self, **kwargs): context = super(OverviewView, self).get_context_data(**kwargs) - task = self.get_data(self.request, **kwargs) + task = get_single_task_data(self.request, **kwargs) + task.workflow_url = reverse(self.workflow_url, + args=[task.workflow_name]) + task.execution_url = reverse(self.execution_url, + args=[task.workflow_execution_id]) task.result = prettyprint(task.result) + task.published = prettyprint(task.published) context['task'] = task + return context - def get_data(self, request, **kwargs): - try: - task_id = kwargs['task_id'] - task = api.task_get(request, task_id) - except Exception: - msg = _('Unable to get task "%s".') % task_id - redirect = reverse('horizon:mistral:tasks:index') - exceptions.handle(self.request, msg, redirect=redirect) - return task +class CodeView(forms.ModalFormView): + template_name = 'mistral/default/code.html' + modal_header = _("Code view") + form_id = "code_view" + form_class = mistral_forms.EmptyForm + cancel_label = "OK" + cancel_url = reverse_lazy("horizon:mistral:tasks:index") + page_title = _("Code view") + + def get_context_data(self, **kwargs): + context = super(CodeView, self).get_context_data(**kwargs) + column = self.kwargs['column'] + task = get_single_task_data(self.request, **self.kwargs) + io = {} + + if column == 'result': + io['name'] = _('Result') + io['value'] = task.result = prettyprint(task.result) + elif column == 'published': + io['name'] = _('Published') + io['value'] = task.published = prettyprint(task.published) + + context['io'] = io + + return context class IndexView(tables.DataTableView):