UI: Execution update - update description modal
* added table action button and a modal to update execution description Screenshots: http://pasteboard.co/2fTvPcAA.png http://pasteboard.co/2fTCIKAL.png http://pasteboard.co/2fTENJz7.png Partially implements blueprint: mistral-dashboard-executions-screen Change-Id: If0e096b674640e12a095607c333954719a5ad594
This commit is contained in:
parent
9eb73b650b
commit
143ad65de6
45
mistraldashboard/executions/forms.py
Normal file
45
mistraldashboard/executions/forms.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# 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 horizon import exceptions
|
||||||
|
from horizon import forms
|
||||||
|
from horizon import messages
|
||||||
|
|
||||||
|
from mistraldashboard import api
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDescriptionForm(forms.SelfHandlingForm):
|
||||||
|
execution_id = forms.CharField(label=_("Execution ID"),
|
||||||
|
widget=forms.HiddenInput(),
|
||||||
|
required=False)
|
||||||
|
description = forms.CharField(max_length=255,
|
||||||
|
label=_("Execution description"))
|
||||||
|
|
||||||
|
def handle(self, request, data):
|
||||||
|
try:
|
||||||
|
api.execution_update(
|
||||||
|
request,
|
||||||
|
data["execution_id"],
|
||||||
|
"description",
|
||||||
|
data["description"])
|
||||||
|
msg = _('Successfully updated execution description.')
|
||||||
|
messages.success(request, msg)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
msg = _('Failed to update execution description.')
|
||||||
|
redirect = reverse('horizon:mistral:executions:index')
|
||||||
|
exceptions.handle(request, msg, redirect=redirect)
|
@ -130,6 +130,13 @@ class ResumeExecution(tables.BatchAction):
|
|||||||
api.execution_update(request, obj_id, "state", "RUNNING")
|
api.execution_update(request, obj_id, "state", "RUNNING")
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDescription(tables.LinkAction):
|
||||||
|
name = "updateDescription"
|
||||||
|
verbose_name = _("Update Description")
|
||||||
|
url = "horizon:mistral:executions:update_description"
|
||||||
|
classes = ("ajax-modal",)
|
||||||
|
|
||||||
|
|
||||||
class ExecutionsTable(tables.DataTable):
|
class ExecutionsTable(tables.DataTable):
|
||||||
id = tables.Column(
|
id = tables.Column(
|
||||||
"id",
|
"id",
|
||||||
@ -185,5 +192,6 @@ class ExecutionsTable(tables.DataTable):
|
|||||||
name = "executions"
|
name = "executions"
|
||||||
verbose_name = _("Executions")
|
verbose_name = _("Executions")
|
||||||
table_actions = (DeleteExecution, tables.FilterAction)
|
table_actions = (DeleteExecution, tables.FilterAction)
|
||||||
row_actions = (DeleteExecution, PauseExecution,
|
row_actions = (DeleteExecution, UpdateDescription,
|
||||||
CancelExecution, ResumeExecution, DeleteExecution)
|
PauseExecution, CancelExecution,
|
||||||
|
ResumeExecution, DeleteExecution)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{% extends "horizon/common/_modal_form.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block modal-body-right %}
|
||||||
|
<h3>{% trans "Description:" %}</h3>
|
||||||
|
<p>{% trans "Enter execution description." %}</p>
|
||||||
|
{% endblock %}
|
@ -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_description.html' %}
|
||||||
|
{% endblock %}
|
@ -31,4 +31,7 @@ urlpatterns = patterns(
|
|||||||
{'column': 'output'}, name='output'),
|
{'column': 'output'}, name='output'),
|
||||||
url(EXECUTIONS % 'input', views.CodeView.as_view(),
|
url(EXECUTIONS % 'input', views.CodeView.as_view(),
|
||||||
{'column': 'input'}, name='input'),
|
{'column': 'input'}, name='input'),
|
||||||
|
url(EXECUTIONS % 'update_description',
|
||||||
|
views.UpdateDescriptionView.as_view(),
|
||||||
|
name='update_description'),
|
||||||
)
|
)
|
||||||
|
@ -26,6 +26,7 @@ from horizon import tables
|
|||||||
|
|
||||||
from mistraldashboard import api
|
from mistraldashboard import api
|
||||||
from mistraldashboard.default.utils import prettyprint
|
from mistraldashboard.default.utils import prettyprint
|
||||||
|
from mistraldashboard.executions.forms import UpdateDescriptionForm
|
||||||
from mistraldashboard.executions.tables import ExecutionsTable
|
from mistraldashboard.executions.tables import ExecutionsTable
|
||||||
from mistraldashboard import forms as mistral_forms
|
from mistraldashboard import forms as mistral_forms
|
||||||
|
|
||||||
@ -149,3 +150,27 @@ class CodeView(forms.ModalFormView):
|
|||||||
context['io'] = io
|
context['io'] = io
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDescriptionView(forms.ModalFormView):
|
||||||
|
template_name = 'mistral/executions/update_description.html'
|
||||||
|
modal_header = _("Update Execution Description")
|
||||||
|
form_id = "update_execution_description"
|
||||||
|
form_class = UpdateDescriptionForm
|
||||||
|
submit_label = _("Update")
|
||||||
|
success_url = reverse_lazy("horizon:mistral:executions:index")
|
||||||
|
submit_url = "horizon:mistral:executions:update_description"
|
||||||
|
cancel_url = "horizon:mistral:executions:index"
|
||||||
|
page_title = _("Update Execution Description")
|
||||||
|
|
||||||
|
def get_initial(self):
|
||||||
|
return {"execution_id": self.kwargs["execution_id"]}
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(UpdateDescriptionView, self).get_context_data(**kwargs)
|
||||||
|
context['submit_url'] = reverse(
|
||||||
|
self.submit_url,
|
||||||
|
args=[self.kwargs["execution_id"]]
|
||||||
|
)
|
||||||
|
|
||||||
|
return context
|
||||||
|
Loading…
Reference in New Issue
Block a user