Added Advanced configuration form
Change-Id: I17bdbc12a0655221184b9dfa9386b077371837d2
This commit is contained in:
parent
1897d28726
commit
bd9f148e49
@ -37,6 +37,7 @@ class IndexView(horizon.tables.MultiTableView):
|
||||
'name': _("New Flavor"),
|
||||
'url': reverse('horizon:infrastructure:flavors:create'),
|
||||
'icon': 'fa-plus',
|
||||
'ajax_modal': True,
|
||||
}
|
||||
context['header_actions'] = [create_action]
|
||||
context['flavors_count'] = self.get_flavors_count()
|
||||
|
@ -42,6 +42,7 @@ class IndexView(infrastructure_views.ItemCountMixin,
|
||||
'name': _('Register Nodes'),
|
||||
'url': reverse('horizon:infrastructure:nodes:register'),
|
||||
'icon': 'fa-plus',
|
||||
'ajax_modal': True,
|
||||
}
|
||||
context['header_actions'] = [register_action]
|
||||
return context
|
||||
|
@ -98,7 +98,43 @@ class ServiceConfig(horizon.forms.SelfHandlingForm):
|
||||
pass
|
||||
|
||||
|
||||
class EditServiceConfig(horizon.forms.SelfHandlingForm):
|
||||
class AdvancedEditServiceConfig(ServiceConfig):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AdvancedEditServiceConfig, self).__init__(*args, **kwargs)
|
||||
|
||||
plan = api.tuskar.Plan.get_the_plan(self.request)
|
||||
parameters = plan.parameter_list(include_key_parameters=False)
|
||||
|
||||
for p in parameters:
|
||||
if p.hidden:
|
||||
self.fields[p.name] = django.forms.CharField(
|
||||
required=False,
|
||||
widget=django.forms.PasswordInput(render_value=True),
|
||||
label=name_with_tooltip(p))
|
||||
else:
|
||||
self.fields[p.name] = django.forms.CharField(
|
||||
required=False,
|
||||
label=name_with_tooltip(p))
|
||||
|
||||
def handle(self, request, data):
|
||||
plan = api.tuskar.Plan.get_the_plan(self.request)
|
||||
|
||||
try:
|
||||
plan.patch(request, plan.uuid, data)
|
||||
except Exception as e:
|
||||
horizon.exceptions.handle(
|
||||
request,
|
||||
_("Unable to update the service configuration."))
|
||||
LOG.exception(e)
|
||||
return False
|
||||
else:
|
||||
horizon.messages.success(
|
||||
request,
|
||||
_("Service configuration updated."))
|
||||
return True
|
||||
|
||||
|
||||
class SimpleEditServiceConfig(horizon.forms.SelfHandlingForm):
|
||||
virt_type = django.forms.ChoiceField(
|
||||
label=_("Deployment Type"),
|
||||
choices=VIRT_TYPE_CHOICES,
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% load url from future %}
|
||||
|
||||
{% block form_id %}configuration_form{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:infrastructure:parameters:service_configuration' %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:infrastructure:parameters:simple_service_configuration' %}{% endblock %}
|
||||
|
||||
{% block modal_id %}provision_modal{% endblock %}
|
||||
{% block modal-header %}{% trans "Service Configuration" %}{% endblock %}
|
@ -0,0 +1,82 @@
|
||||
{% extends "infrastructure/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
{% block title %}{% trans "Advanced Service Configuration" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include 'horizon/common/_items_count_domain_page_header.html' with title=_('Advanced Service Configuration') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<form id="{% block form_id %}{{ form_id }}{% endblock %}"
|
||||
name="{% block form_name %}{% endblock %}"
|
||||
autocomplete="{% block autocomplete %}{% if form.no_autocomplete %}off{% endif %}{% endblock %}"
|
||||
class="{% block form_class %}{% endblock %} form-horizontal"
|
||||
action="{% block form_action %}{{ submit_url }}{% endblock %}"
|
||||
method="{% block form-method %}POST{% endblock %}"
|
||||
{% block form_validation %}{% endblock %}
|
||||
{% if add_to_field %}data-add-to-field="{{ add_to_field }}"{% endif %} {% block form_attrs %}{% endblock %}>{% csrf_token %}
|
||||
<div class="col-sm-12 page_form_actions">
|
||||
<div class="pull-right">
|
||||
<a href="{% block cancel_url %}{{ cancel_url }}{% endblock %}"
|
||||
class="btn btn-default cancel">
|
||||
{{ cancel_label }}
|
||||
</a>
|
||||
<input class="btn btn-primary" type="submit" value="{{ submit_label }}">
|
||||
</div>
|
||||
</div>
|
||||
{% include 'horizon/common/_form_errors.html' with form=form %}
|
||||
<div class="col-md-2">
|
||||
<ul class="nav nav-pills nav-stacked nav-arrow" role="tablist">
|
||||
<li class="active"><a href="#global" role="tab" data-toggle="tab">{% trans "Global" %}</a></li>
|
||||
<li><a href="#controller" role="tab" data-toggle="tab">{% trans "Controller" %}</a></li>
|
||||
<li><a href="#compute" role="tab" data-toggle="tab">{% trans "Compute" %}</a></li>
|
||||
<li><a href="#block-storage" role="tab" data-toggle="tab">{% trans "Block Storage" %}</a></li>
|
||||
<li><a href="#object-storage" role="tab" data-toggle="tab">{% trans "Object Storage" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<div class="tab-content panel panel-default configuration-panel">
|
||||
<div class="tab-pane active" id="global">
|
||||
{% for field in form.global_fieldset %}
|
||||
{% include 'horizon/common/_horizontal_field.html' with field=field %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="tab-pane" id="controller">
|
||||
{% for field in form.controller_fieldset %}
|
||||
{% include 'horizon/common/_horizontal_field.html' with field=field %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="tab-pane" id="compute">
|
||||
{% for field in form.compute_fieldset %}
|
||||
{% include 'horizon/common/_horizontal_field.html' with field=field %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="tab-pane" id="block-storage">
|
||||
{% for field in form.block_storage_fieldset %}
|
||||
{% include 'horizon/common/_horizontal_field.html' with field=field %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="tab-pane" id="object-storage">
|
||||
{% for field in form.object_storage_fieldset %}
|
||||
{% include 'horizon/common/_horizontal_field.html' with field=field %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(window.$ || window.addHorizonLoadEvent)(function () {
|
||||
$(document).tooltip('hide'); // prevent horizon from adding tooltip
|
||||
$('a.help-icon').click(function () {
|
||||
return false;
|
||||
}).popover({
|
||||
trigger: 'focus',
|
||||
placement: 'right'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -1,11 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Service Configuration" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Service Configuration") %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include "infrastructure/parameters/_service_config.html" %}
|
||||
{% endblock %}
|
@ -0,0 +1,11 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Simple Service Configuration" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Simple Service Configuration") %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include "infrastructure/parameters/_simple_service_config.html" %}
|
||||
{% endblock %}
|
@ -25,8 +25,10 @@ from tuskar_ui.test.test_data import tuskar_data
|
||||
|
||||
INDEX_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:parameters:index')
|
||||
SERVICE_CONFIG_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:parameters:service_configuration')
|
||||
SIMPLE_SERVICE_CONFIG_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:parameters:simple_service_configuration')
|
||||
ADVANCED_SERVICE_CONFIG_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:parameters:advanced_service_configuration')
|
||||
|
||||
TEST_DATA = utils.TestDataContainer()
|
||||
tuskar_data.data(TEST_DATA)
|
||||
@ -50,7 +52,7 @@ class ParametersTest(test.BaseAdminViewTests):
|
||||
|
||||
self.assertTemplateUsed(res, 'infrastructure/parameters/index.html')
|
||||
|
||||
def test_service_config_get(self):
|
||||
def test_simple_service_config_get(self):
|
||||
plan = api.tuskar.Plan(self.tuskarclient_plans.first())
|
||||
role = api.tuskar.Role(self.tuskarclient_roles.first())
|
||||
with contextlib.nested(
|
||||
@ -59,11 +61,36 @@ class ParametersTest(test.BaseAdminViewTests):
|
||||
patch('tuskar_ui.api.tuskar.Plan.get_role_by_name',
|
||||
return_value=role),
|
||||
):
|
||||
res = self.client.get(SERVICE_CONFIG_URL)
|
||||
res = self.client.get(SIMPLE_SERVICE_CONFIG_URL)
|
||||
self.assertTemplateUsed(
|
||||
res, 'infrastructure/parameters/service_config.html')
|
||||
res, 'infrastructure/parameters/simple_service_config.html')
|
||||
|
||||
def test_service_config_post(self):
|
||||
def test_advanced_service_config_post(self):
|
||||
plan = api.tuskar.Plan(self.tuskarclient_plans.first())
|
||||
roles = [api.tuskar.Role(role)
|
||||
for role in self.tuskarclient_roles.list()]
|
||||
parameters = [api.tuskar.Parameter(p, plan=self)
|
||||
for p in plan.parameters]
|
||||
|
||||
data = {p.name: unicode(p.value) for p in parameters}
|
||||
|
||||
with contextlib.nested(
|
||||
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
|
||||
return_value=plan),
|
||||
patch('tuskar_ui.api.tuskar.Plan.role_list',
|
||||
return_value=roles),
|
||||
patch('tuskar_ui.api.tuskar.Plan.parameter_list',
|
||||
return_value=parameters),
|
||||
patch('tuskar_ui.api.tuskar.Plan.patch',
|
||||
return_value=plan),
|
||||
) as (get_the_plan, role_list, parameter_list, plan_patch):
|
||||
res = self.client.post(ADVANCED_SERVICE_CONFIG_URL, data)
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
plan_patch.assert_called_once_with(ANY, plan.uuid, data)
|
||||
|
||||
def test_simple_service_config_post(self):
|
||||
plan = api.tuskar.Plan(self.tuskarclient_plans.first())
|
||||
roles = [api.tuskar.Role(role) for role in
|
||||
self.tuskarclient_roles.list()]
|
||||
@ -85,7 +112,7 @@ class ParametersTest(test.BaseAdminViewTests):
|
||||
patch('tuskar_ui.api.tuskar.Plan.get_role_by_name',
|
||||
return_value=roles[0]),
|
||||
) as (get_the_plan, plan_patch, get_role_by_name):
|
||||
res = self.client.post(SERVICE_CONFIG_URL, data)
|
||||
res = self.client.post(SIMPLE_SERVICE_CONFIG_URL, data)
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
|
@ -20,7 +20,10 @@ from tuskar_ui.infrastructure.parameters import views
|
||||
urlpatterns = urls.patterns(
|
||||
'',
|
||||
urls.url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
urls.url(r'^service-config$',
|
||||
views.ServiceConfigView.as_view(),
|
||||
name='service_configuration'),
|
||||
urls.url(r'^simple-service-config$',
|
||||
views.SimpleServiceConfigView.as_view(),
|
||||
name='simple_service_configuration'),
|
||||
urls.url(r'^advanced-service-config$',
|
||||
views.AdvancedServiceConfigView.as_view(),
|
||||
name='advanced_service_configuration'),
|
||||
)
|
||||
|
@ -22,11 +22,11 @@ from tuskar_ui import api
|
||||
from tuskar_ui.infrastructure.parameters import forms
|
||||
|
||||
|
||||
class ServiceConfigView(horizon.forms.ModalFormView):
|
||||
form_class = forms.EditServiceConfig
|
||||
class SimpleServiceConfigView(horizon.forms.ModalFormView):
|
||||
form_class = forms.SimpleEditServiceConfig
|
||||
success_url = reverse_lazy('horizon:infrastructure:parameters:index')
|
||||
submit_label = _("Save Configuration")
|
||||
template_name = "infrastructure/parameters/service_config.html"
|
||||
template_name = "infrastructure/parameters/simple_service_config.html"
|
||||
|
||||
def get_initial(self):
|
||||
plan = api.tuskar.Plan.get_the_plan(self.request)
|
||||
@ -61,6 +61,7 @@ class ServiceConfigView(horizon.forms.ModalFormView):
|
||||
|
||||
class IndexView(horizon.forms.ModalFormView):
|
||||
form_class = forms.ServiceConfig
|
||||
form_id = "service_config"
|
||||
template_name = "infrastructure/parameters/index.html"
|
||||
|
||||
def get_initial(self):
|
||||
@ -71,11 +72,36 @@ class IndexView(horizon.forms.ModalFormView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(IndexView, self).get_context_data(**kwargs)
|
||||
edit_action = {
|
||||
'name': _('Edit Configuration'),
|
||||
advanced_edit_action = {
|
||||
'name': _('Advanced Configuration'),
|
||||
'url': reverse('horizon:infrastructure:parameters:'
|
||||
'service_configuration'),
|
||||
'advanced_service_configuration'),
|
||||
'icon': 'fa-pencil',
|
||||
'ajax_modal': False,
|
||||
}
|
||||
context['header_actions'] = [edit_action]
|
||||
simplified_edit_action = {
|
||||
'name': _('Simplified Configuration'),
|
||||
'url': reverse('horizon:infrastructure:parameters:'
|
||||
'simple_service_configuration'),
|
||||
'icon': 'fa-pencil-square-o',
|
||||
'ajax_modal': True,
|
||||
}
|
||||
context['header_actions'] = [advanced_edit_action,
|
||||
simplified_edit_action]
|
||||
return context
|
||||
|
||||
|
||||
class AdvancedServiceConfigView(IndexView):
|
||||
form_class = forms.AdvancedEditServiceConfig
|
||||
form_id = "advanced_service_config"
|
||||
success_url = reverse_lazy('horizon:infrastructure:parameters:index')
|
||||
submit_label = _("Save Configuration")
|
||||
submit_url = reverse_lazy('horizon:infrastructure:parameters:'
|
||||
'advanced_service_configuration')
|
||||
template_name = "infrastructure/parameters/advanced_service_config.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AdvancedServiceConfigView,
|
||||
self) .get_context_data(**kwargs)
|
||||
context['header_actions'] = []
|
||||
return context
|
||||
|
@ -248,7 +248,7 @@ ul.nav-arrow {
|
||||
}
|
||||
|
||||
.configuration-panel {
|
||||
padding: 15px 15px 15px 30px !important;
|
||||
padding: 15px 0 0px 30px !important;
|
||||
border: none;
|
||||
border-left: 1px solid $border-color;
|
||||
border-radius: 0;
|
||||
@ -266,3 +266,7 @@ ul.nav-arrow {
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.page_form_actions {
|
||||
margin-top: -3.4em;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% for action in header_actions %}
|
||||
<a href="{{ action.url }}"
|
||||
title="{{ action.name }}"
|
||||
class="btn btn-default btn-lg btn-no-border ajax-modal">
|
||||
class="btn btn-default btn-lg btn-no-border {% if action.ajax_modal %}ajax-modal{% endif %}">
|
||||
<span class="fa {{ action.icon }}"></span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user