Add global service configuration dialog
Change-Id: Id1dad3c61dc3b6749cd9b591e7c9ca53296ee31a
This commit is contained in:
parent
adc4a27baf
commit
1d56365d2e
@ -17,8 +17,9 @@ import logging
|
||||
import django.forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon.exceptions
|
||||
from tuskar_ui import api
|
||||
from tuskar_ui.infrastructure.overview import forms
|
||||
|
||||
from tuskar_ui.infrastructure.parameters import forms as parameters_forms
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -66,3 +67,30 @@ class EditPlan(forms.EditPlan):
|
||||
if not value:
|
||||
cleaned_data[key.replace('-flavor', '-count')] = 0
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class GlobalServiceConfig(horizon.forms.SelfHandlingForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(GlobalServiceConfig, self).__init__(*args, **kwargs)
|
||||
self.fields.update({
|
||||
k: v for (k, v) in
|
||||
parameters_forms.parameter_fields(self.request).iteritems()
|
||||
if '::' not in k
|
||||
})
|
||||
|
||||
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
|
||||
|
@ -24,7 +24,8 @@ urlpatterns = tuskar_urls.urlpatterns[1:]
|
||||
urlpatterns.extend(urls.patterns(
|
||||
'',
|
||||
urls.url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
urls.url(r'^config$', views.IndexView.as_view(), name='config'),
|
||||
urls.url(r'^config$', views.GlobalServiceConfigView.as_view(),
|
||||
name='config'),
|
||||
))
|
||||
|
||||
if settings.DEBUG:
|
||||
|
@ -18,6 +18,7 @@ import operator
|
||||
from django.core.urlresolvers import reverse
|
||||
import django.utils.text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon.forms
|
||||
from openstack_dashboard.api import base as api_base
|
||||
|
||||
from tuskar_ui import api
|
||||
@ -191,3 +192,12 @@ class IndexView(views.IndexView):
|
||||
'ajax_modal': True,
|
||||
}]
|
||||
return context
|
||||
|
||||
|
||||
class GlobalServiceConfigView(horizon.forms.ModalFormView):
|
||||
form_class = forms.GlobalServiceConfig
|
||||
template_name = "tuskar_boxes/overview/global_service_config.html"
|
||||
submit_label = _("Save Configuration")
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('horizon:infrastructure:overview:index')
|
||||
|
@ -0,0 +1,13 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block form_id %}configuration_form{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:infrastructure:overview:config' %}{% endblock %}
|
||||
{% block modal-header %}{% trans "Global Service Configuration" %}{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
<div class="form form-horizontal">
|
||||
{% include "horizon/common/_horizontal_fields.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,11 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Global Service Configuration" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Global Service Configuration") %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include "tuskar_boxes/overview/_global_service_config.html" %}
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user