mistral-dashboard Execution enhancements

* fixed main table:
  a. execution id now refers to overview screen
  b. task refer to corresponding task
* added execution overview screen
* removed duplicate string from prettyprint, shortage should be done on client side, (we don't use it atm)

* Screenshots:
http://i57.tinypic.com/2817r5c.png
http://i58.tinypic.com/23uydmo.png

Partially implements blueprint: mistral-dashboard-executions-screen

Change-Id: I4c580e21299aaccf4cf012c88d2d4c0d91de5710
This commit is contained in:
Gal Margalit 2015-08-13 10:59:59 +00:00
parent d908e62639
commit 5058e9e7c7
5 changed files with 82 additions and 8 deletions

View File

@ -1,9 +1,3 @@
{% if short %}
<div class="codeblock" tabindex="-1"> <div class="codeblock" tabindex="-1">
<pre lang="json" class="short">{{ short }}</pre>
<pre lang="json" class="full">{{ full }}</pre> <pre lang="json" class="full">{{ full }}</pre>
{% else %} </div>
<div class="codeblock">
<pre lang="json" class="short">{{ full }}</pre>
{% endif %}
</div>

View File

@ -50,11 +50,18 @@ class ExecutionsTable(tables.DataTable):
id = tables.Column( id = tables.Column(
"id", "id",
verbose_name=_("ID"), verbose_name=_("ID"),
link="horizon:mistral:executions:tasks" 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",
verbose_name=_("Task"),
empty_value=_("View"),
link="horizon:mistral:executions:tasks"
)
input = tables.Column( input = tables.Column(
"input", "input",
verbose_name=_("Input"), verbose_name=_("Input"),

View File

@ -0,0 +1,38 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Execution Overview" %}{% endblock %}
{% block page_header %}
<h1>
{% trans "Execution Overview: " %}
{{ execution.id|default:_("None") }}
</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 "State" %}</dt>
<dd>{{ execution.state }}</dd>
{% if execution.description %}
<dt>{% trans "Description" %}</dt>
<dd>{{ execution.description }}</dd>
{% endif %}
<dt>{% trans "Worflow Name" %}</dt>
<dd>{{ execution.workflow_name }}</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

@ -20,10 +20,13 @@ from django.conf.urls import url # noqa
from mistraldashboard.executions.views import IndexView from mistraldashboard.executions.views import IndexView
from mistraldashboard.executions.views import TaskView from mistraldashboard.executions.views import TaskView
from mistraldashboard.executions import views
EXECUTIONS = r'^(?P<execution_id>[^/]+)/%s$' EXECUTIONS = r'^(?P<execution_id>[^/]+)/%s$'
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url(r'^$', IndexView.as_view(), name='index'), url(r'^$', IndexView.as_view(), name='index'),
url(EXECUTIONS % 'tasks', TaskView.as_view(), name='tasks'), url(EXECUTIONS % 'tasks', TaskView.as_view(), name='tasks'),
url(EXECUTIONS % 'detail', views.DetailView.as_view(), name='detail'),
) )

View File

@ -14,9 +14,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from django.views import generic
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tables from horizon import tables
from mistraldashboard import api from mistraldashboard import api
from mistraldashboard.default.utils import prettyprint
from mistraldashboard.executions.tables import ExecutionsTable from mistraldashboard.executions.tables import ExecutionsTable
from mistraldashboard.executions.tables import TaskTable from mistraldashboard.executions.tables import TaskTable
@ -35,3 +42,28 @@ class TaskView(tables.DataTableView):
def get_data(self): def get_data(self):
return api.task_list(self.request, self.kwargs['execution_id']) return api.task_list(self.request, self.kwargs['execution_id'])
class DetailView(generic.TemplateView):
template_name = 'mistral/executions/detail.html'
page_title = _("Execution Overview")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
execution = self.get_data(self.request, **kwargs)
execution.input = prettyprint(execution.input)
execution.output = prettyprint(execution.output)
execution.params = prettyprint(execution.params)
context['execution'] = execution
return context
def get_data(self, request, **kwargs):
try:
execution_id = kwargs['execution_id']
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(self.request, msg, redirect=redirect)
return execution