* Added 3 new action executions screens: index, overview, and update dialog * Added "type" attribute to task screens, followed by a corresponding link * Fixed breadcrumbs issue in detail screens following Horizon Newton change * Added state label design to detail screens * Added design to boolean fields * Screenshots: http://pho.to/AXApU Implements blueprint: mistral-dashboard-action-execution-screens Implements blueprint: dashboard-detail-screens-improvements Partially implements blueprint: refactor-execution-link-in-task-executions-screens Closes-Bug: #1642246 Change-Id: I4c270b2b23d548d4e1cb7e8507e804e44e27c88fchanges/88/401188/11
parent
1665e7c8a7
commit
2a54532154
@ -0,0 +1,102 @@
|
||||
# Copyright 2016 - Nokia.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import forms
|
||||
|
||||
from mistraldashboard import api
|
||||
from mistraldashboard.handle_errors import handle_errors
|
||||
|
||||
|
||||
class UpdateForm(forms.SelfHandlingForm):
|
||||
action_execution_id = forms.CharField(label=_("Action Execution ID"),
|
||||
widget=forms.HiddenInput(),
|
||||
required=False)
|
||||
output_source = forms.ChoiceField(
|
||||
label=_('Output'),
|
||||
help_text=_('Content for output. '
|
||||
'Select either file, raw content or Null value.'),
|
||||
choices=[('null', _('<null> (sends empty value)')),
|
||||
('file', _('File')),
|
||||
('raw', _('Direct Input'))],
|
||||
widget=forms.Select(
|
||||
attrs={'class': 'switchable',
|
||||
'data-slug': 'outputsource'}
|
||||
),
|
||||
required=False
|
||||
)
|
||||
output_upload = forms.FileField(
|
||||
label=_('Output File'),
|
||||
help_text=_('A local output to upload'),
|
||||
widget=forms.FileInput(
|
||||
attrs={'class': 'switched',
|
||||
'data-switch-on': 'outputsource',
|
||||
'data-outputsource-file': _('Output File')}
|
||||
),
|
||||
required=False
|
||||
)
|
||||
output_data = forms.CharField(
|
||||
label=_('Output Data'),
|
||||
help_text=_('The raw content for output'),
|
||||
widget=forms.widgets.Textarea(
|
||||
attrs={'class': 'switched',
|
||||
'data-switch-on': 'outputsource',
|
||||
'data-outputsource-raw': _('Output Data'),
|
||||
'rows': 4}
|
||||
),
|
||||
required=False
|
||||
)
|
||||
|
||||
state = forms.ChoiceField(
|
||||
label=_('State'),
|
||||
help_text=_('Select state to update'),
|
||||
choices=[('null', _('<null> (sends empty value)')),
|
||||
('SUCCESS', _('Success')),
|
||||
('ERROR', _('Error'))],
|
||||
widget=forms.Select(
|
||||
attrs={'class': 'switchable'}
|
||||
),
|
||||
required=False
|
||||
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(UpdateForm, self).clean()
|
||||
cleaned_data['output'] = None
|
||||
|
||||
if cleaned_data.get('output_upload'):
|
||||
files = self.request.FILES
|
||||
cleaned_data['output'] = files['output_upload'].read()
|
||||
elif cleaned_data.get('output_data'):
|
||||
cleaned_data['output'] = cleaned_data['output_data']
|
||||
elif cleaned_data.get('output_source') == 'null':
|
||||
cleaned_data['output'] = None
|
||||
|
||||
del cleaned_data['output_upload']
|
||||
del cleaned_data['output_data']
|
||||
del cleaned_data['output_source']
|
||||
|
||||
if cleaned_data['state'] == 'null':
|
||||
cleaned_data['state'] = None
|
||||
|
||||
return cleaned_data
|
||||
|
||||
@handle_errors(_("Unable to update Action Execution"), [])
|
||||
def handle(self, request, data):
|
||||
return api.action_execution_update(
|
||||
request,
|
||||
data['action_execution_id'],
|
||||
data['state'],
|
||||
data['output'],
|
||||
)
|
@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2016 - Nokia.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
from mistraldashboard import dashboard
|
||||
|
||||
|
||||
class Tasks(horizon.Panel):
|
||||
name = _("Action Executions")
|
||||
slug = 'action_executions'
|
||||
|
||||
|
||||
dashboard.MistralDashboard.register(Tasks)
|
@ -0,0 +1,182 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2016 - Nokia.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# 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.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
|
||||
from mistraldashboard import api
|
||||
import mistraldashboard.default.SmartCell as SmartCell
|
||||
from mistraldashboard.default import utils
|
||||
|
||||
SmartCell.init()
|
||||
|
||||
|
||||
class UpdateRow(tables.Row):
|
||||
ajax = True
|
||||
|
||||
def get_data(self, request, id):
|
||||
try:
|
||||
instance = api.action_execution_get(request, id)
|
||||
except Exception as e:
|
||||
msg = _("Unable to get action execution by ID %(id)s: %(e)s.") % {
|
||||
'id': id, 'e': str(e)
|
||||
}
|
||||
exceptions.handle(request, msg)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
class DeleteActionExecution(tables.DeleteAction):
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
u"Delete Action Execution",
|
||||
u"Delete Action Executions",
|
||||
count
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
u"Deleted Action Execution",
|
||||
u"Deleted Action Executions",
|
||||
count
|
||||
)
|
||||
|
||||
def delete(self, request, action_execution_id):
|
||||
api.action_execution_delete(request, action_execution_id)
|
||||
|
||||
|
||||
class UpdateActionExecution(tables.LinkAction):
|
||||
name = "updateAE"
|
||||
verbose_name = _("Update")
|
||||
url = "horizon:mistral:action_executions:update"
|
||||
classes = ("ajax-modal",)
|
||||
|
||||
|
||||
class TaskExecutionIDColumn(tables.Column):
|
||||
def get_link_url(self, datum):
|
||||
task_url = "horizon:mistral:tasks:detail"
|
||||
obj_id = datum.task_execution_id
|
||||
return reverse(task_url, args=[obj_id])
|
||||
|
||||
|
||||
class WorkflowNameColumn(tables.Column):
|
||||
def get_link_url(self, datum):
|
||||
workflow_url = "horizon:mistral:workflows:detail"
|
||||
obj_id = datum.workflow_name
|
||||
return reverse(workflow_url, args=[obj_id])
|
||||
|
||||
|
||||
class ActionExecutionsTable(tables.DataTable):
|
||||
|
||||
def getHoverHelp(data):
|
||||
if hasattr(data, 'state_info') and data.state_info:
|
||||
|
||||
return {'title': data.state_info}
|
||||
|
||||
STATE_STATUS_CHOICES = (
|
||||
("success", True),
|
||||
("error", False),
|
||||
("idle", None),
|
||||
("running", None),
|
||||
("canceled", None),
|
||||
)
|
||||
|
||||
id = tables.Column(
|
||||
"id",
|
||||
verbose_name=_("ID"),
|
||||
link="horizon:mistral:action_executions:detail"
|
||||
)
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name")
|
||||
)
|
||||
tags = tables.Column(
|
||||
"tags",
|
||||
verbose_name=_("Tags")
|
||||
)
|
||||
workflow_name = WorkflowNameColumn(
|
||||
"workflow_name",
|
||||
verbose_name=_("Workflow Name"),
|
||||
link=True
|
||||
)
|
||||
task_execution_id = TaskExecutionIDColumn(
|
||||
"task_execution_id",
|
||||
verbose_name=_("Task Execution ID"),
|
||||
link=True
|
||||
)
|
||||
task_name = tables.Column(
|
||||
"task_name",
|
||||
verbose_name=_("Task name")
|
||||
)
|
||||
description = tables.Column(
|
||||
"description",
|
||||
verbose_name=_("Description")
|
||||
)
|
||||
input = tables.Column(
|
||||
"",
|
||||
verbose_name=_("Input"),
|
||||
empty_value=_("View"),
|
||||
link="horizon:mistral:action_executions:input",
|
||||
link_classes=("ajax-modal",)
|
||||
)
|
||||
output = tables.Column(
|
||||
"",
|
||||
verbose_name=_("Output"),
|
||||
empty_value=_("View"),
|
||||
link="horizon:mistral:action_executions:output",
|
||||
link_classes=("ajax-modal",)
|
||||
)
|
||||
created_at = tables.Column(
|
||||
"created_at",
|
||||
verbose_name=_("Created at"),
|
||||
filters=[utils.humantime]
|
||||
)
|
||||
updated_at = tables.Column(
|
||||
"updated_at",
|
||||
verbose_name=_("Updated at"),
|
||||
filters=[utils.humantime]
|
||||
)
|
||||
accepted = tables.Column(
|
||||
"accepted",
|
||||
verbose_name=_("Accepted"),
|
||||
filters=[utils.booleanfield],
|
||||
)
|
||||
state = tables.Column(
|
||||
"state",
|
||||
status=True,
|
||||
status_choices=STATE_STATUS_CHOICES,
|
||||
verbose_name=_("State"),
|
||||
filters=[utils.label],
|
||||
cell_attributes_getter=getHoverHelp
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
name = "actionExecutions"
|
||||
verbose_name = _("Action Executions")
|
||||
status_columns = ["state"]
|
||||
row_class = UpdateRow
|
||||
table_actions = (
|
||||
tables.FilterAction,
|
||||
DeleteActionExecution
|
||||
)
|
||||
row_actions = (UpdateActionExecution, DeleteActionExecution)
|
@ -0,0 +1,17 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block modal-body-right %}
|
||||
<h3>{% trans "Description:" %}</h3>
|
||||
<p>
|
||||
{% trans "Enter new output and or state to update the corresponding Action Execution." %}
|
||||
</p>
|
||||
<p>
|
||||
{% trans "For more info refer to:" %}
|
||||
<br/>
|
||||
<a href="http://docs.openstack.org/developer/mistral/developer/webapi/v2.html#action-executions" target="_blank">
|
||||
{% trans "Mistral documentation - Action Executions" %}
|
||||
</a>
|
||||
|
||||
</p>
|
||||
{% endblock %}
|
@ -0,0 +1,96 @@
|
||||
<span class="mistral-wrapper detail-screen">
|
||||
{% extends 'mistral/default/base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Action Execution Details" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
<h1>
|
||||
{% trans "Action Execution Details" %}
|
||||
</h1>
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% load i18n sizeformat %}
|
||||
|
||||
<div class="detail">
|
||||
<h4>{% trans "Overview" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>{{ action_execution.name }}</dd>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>{{ action_execution.id }}</dd>
|
||||
{% if action_execution.description %}
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ action_execution.description }}</dd>
|
||||
{% endif %}
|
||||
<div class="line-space">
|
||||
<dt>{% trans "State" %}</dt>
|
||||
<dd>{{ action_execution.state }}</dd>
|
||||
</div>
|
||||
{% if action_execution.state_info %}
|
||||
<dt>{% trans "State Info" %}</dt>
|
||||
<dd>{{ action_execution.state_info }}</dd>
|
||||
{% endif %}
|
||||
<dt>{% trans "Accepted" %}</dt>
|
||||
<dd>{{ action_execution.accepted }}</dd>
|
||||
<dt>{% trans "Tags" %}</dt>
|
||||
<dd>{{ action_execution.tags }}</dd>
|
||||
<br/>
|
||||
<dt>{% trans "Creation Date" %}</dt>
|
||||
<dd>{{ action_execution.created_at|parse_isotime}}</dd>
|
||||
<dt>{% trans "Time Since Created" %}</dt>
|
||||
<dd>{{ action_execution.created_at|parse_isotime|timesince }}</dd>
|
||||
<br/>
|
||||
<dt>{% trans "Update Date" %}</dt>
|
||||
<dd>{{ action_execution.updated_at|parse_isotime}}</dd>
|
||||
<dt>{% trans "Time Since Updated" %}</dt>
|
||||
<dd>{{ action_execution.updated_at|parse_isotime|timesince }}</dd>
|
||||
<br/>
|
||||
<dt>{% trans "Input" %}</dt>
|
||||
<dd>{{ action_execution.input }}</dd>
|
||||
<dt>{% trans "Output" %}</dt>
|
||||
<dd>{{ action_execution.output }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{% if action_execution.workflow_url %}
|
||||
<div class="detail">
|
||||
<h4>{% trans "Workflow Execution" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>
|
||||
<a href="{{ action_execution.workflow_url }}"
|
||||
title="{{action_execution.workflow_name}} {% trans "overview" %}">
|
||||
{{ action_execution.workflow_name }}
|
||||
</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if action_execution.task_execution_url %}
|
||||
<div class="detail">
|
||||
<h4>{% trans "Task Execution" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Name" %}</dt>
|
||||
<dd>
|
||||
<a href="{{ action_execution.task_execution_url }}"
|
||||
title="{{action_execution.task_name}} {% trans "overview" %}">
|
||||
{{ action_execution.task_name }}
|
||||
</a>
|
||||
</dd>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>
|
||||
<a href="{{ action_execution.task_execution_url }}"
|
||||
title="{{ action_execution.task_execution_id }} {% trans "overview" %}">
|
||||
{{ action_execution.task_execution_id }}
|
||||
</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
</span>
|
@ -0,0 +1,13 @@
|
||||
{% extends 'mistral/default/table.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}
|
||||
{% trans "Action Executions" %}
|
||||
{{ task_id }}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Action Executions of Task ID:") %}
|
||||
<h3>
|
||||
{{ action_execution_id }}
|
||||
</h3>
|
||||
{% endblock page_header %}
|
@ -0,0 +1,9 @@
|
||||
{% extends 'mistral/default/table.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}
|
||||
{% trans "Action Executions" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Action Executions")%}
|
||||
{% endblock page_header %}
|
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'mistral/executions/_update.html' %}
|
||||
{% endblock %}
|
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2016 - Nokia.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.conf.urls import url # noqa
|
||||
|
||||
from mistraldashboard.action_executions import views
|
||||
|
||||
ACTION_EXECUTIONS = r'^(?P<action_execution_id>[^/]+)/%s$'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(ACTION_EXECUTIONS % 'detail', views.OverviewView.as_view(),
|
||||
name='detail'),
|
||||
url(ACTION_EXECUTIONS % 'input', views.CodeView.as_view(),
|
||||
{'column': 'input'}, name='input'),
|
||||
url(ACTION_EXECUTIONS % 'output', views.CodeView.as_view(),
|
||||
{'column': 'output'}, name='output'),
|
||||
url(ACTION_EXECUTIONS % 'update', views.UpdateView.as_view(),
|
||||
name='update'),
|
||||
url(ACTION_EXECUTIONS % 'task', views.FilteredByTaskView.as_view(),
|
||||
name='task')
|
||||
]
|
@ -0,0 +1,177 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2016 - Nokia.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# 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.action_executions import forms as action_execution_forms
|
||||
from mistraldashboard.action_executions import tables as mistral_tables
|
||||
from mistraldashboard import api
|
||||
from mistraldashboard.default import utils
|
||||
from mistraldashboard import forms as mistral_forms
|
||||
|
||||
|
||||
def get_single_action_execution_data(request, **kwargs):
|
||||
try:
|
||||
action_execution_id = kwargs['action_execution_id']
|
||||
action_execution = api.action_execution_get(
|
||||
request,
|
||||
action_execution_id
|
||||
)
|
||||
except Exception:
|
||||
msg = _('Unable to get action execution "%s".') % action_execution_id
|
||||
redirect = reverse('horizon:mistral:action_execution:index')
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
|
||||
return action_execution
|
||||
|
||||
|
||||
class OverviewView(generic.TemplateView):
|
||||
template_name = 'mistral/action_executions/detail.html'
|
||||
page_title = _("Action Execution Details")
|
||||
workflow_url = 'horizon:mistral:workflows:detail'
|
||||
task_execution_url = 'horizon:mistral:tasks:detail'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(OverviewView, self).get_context_data(**kwargs)
|
||||
action_execution = get_single_action_execution_data(
|
||||
self.request,
|
||||
**kwargs
|
||||
)
|
||||
if action_execution.workflow_name:
|
||||
action_execution.workflow_url = reverse(
|
||||
self.workflow_url,
|
||||
args=[action_execution.workflow_name])
|
||||
if action_execution.task_execution_id:
|
||||
action_execution.task_execution_url = reverse(
|
||||
self.task_execution_url,
|
||||
args=[action_execution.task_execution_id]
|
||||
)
|
||||
if action_execution.input:
|
||||
action_execution.input = utils.prettyprint(action_execution.input)
|
||||
if action_execution.output:
|
||||
action_execution.output = utils.prettyprint(
|
||||
action_execution.output
|
||||
)
|
||||
if action_execution.state:
|
||||
action_execution.state = utils.label(action_execution.state)
|
||||
if action_execution.accepted:
|
||||
action_execution.accepted = utils.booleanfield(
|
||||
action_execution.accepted
|
||||
)
|
||||
|
||||
breadcrumb = [(action_execution.id, reverse(
|
||||
'horizon:mistral:action_executions:detail',
|
||||
args=[action_execution.id]
|
||||
))]
|
||||
|
||||
context["custom_breadcrumb"] = breadcrumb
|
||||
context['action_execution'] = action_execution
|
||||
|
||||
return context
|
||||
|
||||
|
||||
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:action_executions:index")
|
||||
page_title = _("Code view")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CodeView, self).get_context_data(**kwargs)
|
||||
column = self.kwargs['column']
|
||||
action_execution = get_single_action_execution_data(
|
||||
self.request,
|
||||
**self.kwargs
|
||||
)
|
||||
io = {}
|
||||
|
||||
if column == 'input':
|
||||
io['name'] = _('Input')
|
||||
io['value'] = utils.prettyprint(action_execution.input)
|
||||
elif column == 'output':
|
||||
io['name'] = _('Output')
|
||||
io['value'] = (
|
||||
utils.prettyprint(action_execution.output)
|
||||
if action_execution.output
|
||||
else _("No available output yet")
|
||||
)
|
||||
|
||||
context['io'] = io
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
table_class = mistral_tables.ActionExecutionsTable
|
||||
template_name = 'mistral/action_executions/index.html'
|
||||
|
||||
def get_data(self):
|
||||
|
||||
return api.action_executions_list(self.request)
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
template_name = 'mistral/action_executions/update.html'
|
||||
modal_header = _("Update Action Execution")
|
||||
form_id = "update_action_execution"
|
||||
form_class = action_execution_forms.UpdateForm
|
||||
submit_label = _("Update")
|
||||
success_url = reverse_lazy("horizon:mistral:action_executions:index")
|
||||
submit_url = "horizon:mistral:action_executions:update"
|
||||
cancel_url = "horizon:mistral:action_executions:index"
|
||||
page_title = _("Update Action Execution")
|
||||
|
||||
def get_initial(self):
|
||||
return {"action_execution_id": self.kwargs["action_execution_id"]}
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
||||
context['submit_url'] = reverse(
|
||||
self.submit_url,
|
||||
args=[self.kwargs["action_execution_id"]]
|
||||
)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class FilteredByTaskView(tables.DataTableView):
|
||||
table_class = mistral_tables.ActionExecutionsTable
|
||||
template_name = 'mistral/action_executions/filtered.html'
|
||||
data = {}
|
||||
|
||||
def get_data(self, **kwargs):
|
||||
try:
|
||||
task_id = self.kwargs['action_execution_id']
|
||||
data = api.action_executions_list(self.request, task_id)
|
||||
except Exception:
|
||||
msg = (
|
||||
_('Unable to get action execution by task id "%s".') % task_id
|
||||
)
|
||||
redirect = reverse('horizon:mistral:action_executions:index')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
||||
return data
|
@ -0,0 +1,4 @@
|
||||
<span class="boolfield">
|
||||
<i class="{{ type.color }} {{ type.icon }}" aria-hidden="true"></i>
|
||||
{{ bool }}
|
||||
</span>
|
Loading…
Reference in new issue