Merge "Show task result when click the id"
This commit is contained in:
commit
a11b32a216
@ -67,6 +67,15 @@ def task_list(request, execution_id=None):
|
||||
return mistralclient(request).tasks.list(execution_id)
|
||||
|
||||
|
||||
def task_get(request, task_id=None):
|
||||
"""Get specific task.
|
||||
|
||||
:param task_id: Task ID
|
||||
"""
|
||||
|
||||
return mistralclient(request).tasks.get(task_id)
|
||||
|
||||
|
||||
@handle_errors(_("Unable to retrieve workflows."), [])
|
||||
def workflow_list(request):
|
||||
"""Returns all workflows."""
|
||||
|
@ -24,7 +24,10 @@ from mistraldashboard.default.utils import prettyprint
|
||||
|
||||
|
||||
class TaskTable(tables.DataTable):
|
||||
id = tables.Column("id", verbose_name=_("ID"))
|
||||
id = tables.Column(
|
||||
"id",
|
||||
verbose_name=_("ID"),
|
||||
link="horizon:mistral:tasks:result")
|
||||
name = tables.Column("name", verbose_name=_("Name"))
|
||||
|
||||
parameters = tables.Column(
|
||||
|
13
mistraldashboard/tasks/templates/tasks/result.html
Normal file
13
mistraldashboard/tasks/templates/tasks/result.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% 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 %}
|
@ -17,9 +17,12 @@
|
||||
from django.conf.urls import patterns # noqa
|
||||
from django.conf.urls import url # noqa
|
||||
|
||||
from mistraldashboard.tasks.views import IndexView
|
||||
from mistraldashboard.tasks import views
|
||||
|
||||
TASKS = r'^(?P<task_id>[^/]+)/%s$'
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(TASKS % 'result', views.ResultView.as_view(), name='result')
|
||||
)
|
||||
|
@ -14,12 +14,39 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
|
||||
from mistraldashboard import api
|
||||
from mistraldashboard.tasks.tables import TaskTable
|
||||
|
||||
|
||||
class ResultView(generic.TemplateView):
|
||||
template_name = 'mistral/tasks/result.html'
|
||||
page_title = _("Task Result")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ResultView, self).get_context_data(**kwargs)
|
||||
task = self.get_data(self.request, **kwargs)
|
||||
context['result'] = task.result
|
||||
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 IndexView(tables.DataTableView):
|
||||
table_class = TaskTable
|
||||
template_name = 'mistral/tasks/index.html'
|
||||
|
Loading…
Reference in New Issue
Block a user