diff options
author | Tzu-Mainn Chen <tzumainn@redhat.com> | 2014-10-03 22:03:15 +0000 |
---|---|---|
committer | Tzu-Mainn Chen <tzumainn@redhat.com> | 2014-10-06 12:44:58 +0000 |
commit | 1f8b5e33afa1c701d155a23661018e4b2e6569ea (patch) | |
tree | e7c8c4628ba96b2779e92d930cb78163a2aa0c2e | |
parent | 7008d862835a08fe087ed4b8f952f89183465832 (diff) | |
download | tuskar-ui-1f8b5e33afa1c701d155a23661018e4b2e6569ea.tar.gz |
Changed service configuration table to multiple tabs
Change-Id: Icd1125f6b8edddf48b3ab87de27e0247b6cdd9b7
4 files changed, 68 insertions, 14 deletions
diff --git a/tuskar_ui/infrastructure/parameters/tables.py b/tuskar_ui/infrastructure/parameters/tables.py index d41db819..a0b671f8 100644 --- a/tuskar_ui/infrastructure/parameters/tables.py +++ b/tuskar_ui/infrastructure/parameters/tables.py @@ -17,9 +17,6 @@ from horizon import tables class ParametersTable(tables.DataTable): - role = tables.Column(lambda param: - param.role.name if param.role else _('General'), - verbose_name=_("Role")) name = tables.Column('stripped_name', verbose_name=_("Parameter Name")) value = tables.Column('value', diff --git a/tuskar_ui/infrastructure/parameters/tabs.py b/tuskar_ui/infrastructure/parameters/tabs.py new file mode 100644 index 00000000..3290dcd4 --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/tabs.py @@ -0,0 +1,62 @@ +# 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.datastructures import SortedDict +from django.utils.translation import ugettext_lazy as _ +from horizon import tabs + +from tuskar_ui import api +from tuskar_ui.infrastructure.parameters import tables + + +class ParametersTab(tabs.TableTab): + table_classes = (tables.ParametersTable,) + template_name = "horizon/common/_detail_table.html" + + def __init__(self, group, request, name, slug, parameters): + self.name = name + self.slug = slug + self.parameters = parameters + super(ParametersTab, self).__init__(group, request) + + def get_parameters_data(self): + return self.parameters + + +class ParametersTabs(tabs.TabGroup): + slug = "parameters" + tabs = () + sticky = True + template_name = "horizon/common/_items_count_tab_group.html" + + def __init__(self, request, **kwargs): + super(ParametersTabs, self).__init__(request, **kwargs) + plan = api.tuskar.Plan.get_the_plan(request) + params = plan.parameter_list(include_key_parameters=False) + tab_instances = [] + general_params = [p for p in params if p.role is None] + if general_params: + tab_instances.append(( + 'global', + ParametersTab(self, request, + _('Global'), 'global', general_params), + )) + for role in plan.role_list: + role_params = [p for p in params + if p.role and p.role.uuid == role.uuid] + if role_params: + tab_instances.append(( + role.name, + ParametersTab(self, request, + role.name.title(), role.name, role_params), + )) + self._tabs = SortedDict(tab_instances) diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html index 325bc8db..c33cf07f 100644 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html +++ b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html @@ -1,5 +1,6 @@ {% extends 'infrastructure/base.html' %} {% load i18n %} +{% load url from future %} {% block title %}{% trans 'Service Configuration' %}{% endblock %} {% block page_header %} @@ -15,9 +16,7 @@ {% trans 'Edit Configuration' %} </a> </div> - <div class="no-table-title"> - {{ table.render }} - </div> + {{ tab_group.render }} </div> </div> diff --git a/tuskar_ui/infrastructure/parameters/views.py b/tuskar_ui/infrastructure/parameters/views.py index 734e7b7d..29f1edae 100644 --- a/tuskar_ui/infrastructure/parameters/views.py +++ b/tuskar_ui/infrastructure/parameters/views.py @@ -14,11 +14,11 @@ from django.core.urlresolvers import reverse_lazy import horizon.forms -from horizon import tables as horizon_tables +from horizon import tabs as horizon_tabs from tuskar_ui import api from tuskar_ui.infrastructure.parameters import forms -from tuskar_ui.infrastructure.parameters import tables +from tuskar_ui.infrastructure.parameters import tabs class ServiceConfigView(horizon.forms.ModalFormView): @@ -40,10 +40,6 @@ class ServiceConfigView(horizon.forms.ModalFormView): 'snmp_password': snmp_password} -class IndexView(horizon_tables.DataTableView): - table_class = tables.ParametersTable +class IndexView(horizon_tabs.TabbedTableView): + tab_group_class = tabs.ParametersTabs template_name = "infrastructure/parameters/index.html" - - def get_data(self): - plan = api.tuskar.Plan.get_the_plan(self.request) - return plan.parameter_list(include_key_parameters=False) |