Repository: ambari Updated Branches: refs/heads/trunk d7fcd258d -> 9b4c5a2e6
AMBARI-10262. Provide ability to filter enhanced configs (Richard Zang via srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9b4c5a2e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9b4c5a2e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9b4c5a2e Branch: refs/heads/trunk Commit: 9b4c5a2e6de047d36535e1b0ad96bd585f742e08 Parents: d7fcd25 Author: Srimanth Gunturi <[email protected]> Authored: Tue Mar 31 16:45:44 2015 -0700 Committer: Srimanth Gunturi <[email protected]> Committed: Tue Mar 31 16:45:44 2015 -0700 ---------------------------------------------------------------------- .../templates/common/configs/service_config.hbs | 8 +- .../configs/service_config_layout_tab.hbs | 7 +- .../configs/widgets/list_config_widget.hbs | 2 +- .../configs/widgets/slider_config_widget.hbs | 3 +- .../configs/service_config_layout_tab_view.js | 90 ++++++++++++++++++++ .../views/common/configs/service_config_view.js | 10 ++- 6 files changed, 111 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/templates/common/configs/service_config.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/service_config.hbs b/ambari-web/app/templates/common/configs/service_config.hbs index 26c7c2f..e2da5ee 100644 --- a/ambari-web/app/templates/common/configs/service_config.hbs +++ b/ambari-web/app/templates/common/configs/service_config.hbs @@ -91,7 +91,9 @@ {{#if view.supportsConfigLayout}} <ul class="nav nav-tabs"> {{#each tab in view.tabs}} - <li {{bindAttr class="tab.isActive:active" }}><a href="#" {{bindAttr data-target="tab.headingClass"}} data-toggle="tab">{{tab.displayName}}</a></li> + {{#unless tab.isHiddenByFilter}} + <li {{bindAttr class="tab.isActive:active" }}><a href="#" {{action "setActiveTab" tab target="view"}} {{bindAttr data-target="tab.headingClass"}} data-toggle="tab">{{tab.displayName}}</a></li> + {{/unless}} {{/each}} </ul> <div class="tab-content"> @@ -108,8 +110,8 @@ </div> {{/each}} {{else}} - {{! Render Enhanced Config Section }} - {{view App.ServiceConfigLayoutTabView contentBinding="tab"}} + {{! Render Enhanced Config Section }} + {{view App.ServiceConfigLayoutTabView contentBinding="tab"}} {{/if}} </div> {{/each}} http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/templates/common/configs/service_config_layout_tab.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/service_config_layout_tab.hbs b/ambari-web/app/templates/common/configs/service_config_layout_tab.hbs index 9e3d601..ecf2e23 100644 --- a/ambari-web/app/templates/common/configs/service_config_layout_tab.hbs +++ b/ambari-web/app/templates/common/configs/service_config_layout_tab.hbs @@ -15,19 +15,19 @@ * See the License for the specific language governing permissions and * limitations under the License. }} - +{{#unless tab.isHiddenByFilter}} <div class="section-layout-container"> <table class="config-section-table"> {{#each row in tab.sectionRows}} <tr> {{#each section in row}} - <td class="config-section" {{bindAttr colspan="section.columnSpan" rowspan="section.rowSpan"}}> + <td {{bindAttr class="section.isHiddenByFilter:invisible :config-section" colspan="section.columnSpan" rowspan="section.rowSpan"}}> <h3>{{section.displayName}}</h3> <table class="config-subsection-table"> {{#each subRow in section.subsectionRows}} <tr> {{#each subsection in subRow}} - <td class="config-subsection"> + <td {{bindAttr class="subsection.isHiddenByFilter:invisible :config-subsection"}}> {{#each config in subsection.configs}} {{#if config.view}} {{#unless config.isHiddenByFilter}} @@ -46,3 +46,4 @@ {{/each}} </table> </div> +{{/unless}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs index 8f6e5da..91ebd15 100644 --- a/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs @@ -16,7 +16,7 @@ * limitations under the License. }} -<div class="widget list-widget"> +<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget :list-widget"}}> {{view.configLabel}} <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown">{{view.displayVal}} <span class="caret"></span></a> http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs index 537c349..e4e7f24 100644 --- a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs @@ -16,7 +16,8 @@ * limitations under the License. }} -<div class="widget slider-widget"> + +<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget :slider-widget"}}> {{#if view.isOriginalSCP}} <p>{{formatWordBreak view.configLabel}}</p> {{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/views/common/configs/service_config_layout_tab_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js index a48dba9..866e9b6 100644 --- a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js +++ b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js @@ -103,6 +103,96 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, { }); }, + /** + * Mark isHiddenByFilter flag for configs, sub-sections, and tab + */ + filterEnhancedConfigs: function () { + var self = this; + this.get('content.sectionRows').forEach(function (row) { + row.forEach(function (section) { + section.get('subsectionRows').forEach(function (subRow) { + subRow.forEach(function (subsection) { + subsection.get('configs').forEach(function (config) { + $('.popover').remove(); + var filter = self.get('parentView.filter'); + var selectedFilters = self.get('parentView.columns').filterProperty('selected'); + + if (selectedFilters.length > 0 || filter.length > 0 || self.get('state') === 'inDOM') { + // process selected filters + var passesFilters = true; + selectedFilters.forEach(function (filter) { + if (config.get(filter.attributeName) !== filter.attributeValue) { + passesFilters = false; + } + }); + + if (!passesFilters) { + config.set('isHiddenByFilter', true); + return false; + } + + // process input filter + var searchString = config.get('defaultValue') + config.get('description') + + config.get('displayName') + config.get('name') + config.get('value'); + if (config.get('overrides')) { + config.get('overrides').forEach(function (overriddenConf) { + searchString += overriddenConf.get('value') + overriddenConf.get('group.name'); + }); + } + + if (filter != null && typeof searchString === "string") { + config.set('isHiddenByFilter', !(searchString.toLowerCase().indexOf(filter) > -1)); + } else { + config.set('isHiddenByFilter', false); + } + } + }); + // check subsection + var allConfigs = subsection.get('configs'); + var allHiddenConfigs = allConfigs.filterProperty('isHiddenByFilter'); + var configsLength = allConfigs.get('length'); + if (configsLength > 0 && configsLength == allHiddenConfigs.length) { + subsection.set('isHiddenByFilter', true); + } else { + subsection.set('isHiddenByFilter', false); + } + }); + }); + // check section + var allSubSections = section.get('subSections'); + var allHiddenSubSections = allSubSections.filterProperty('isHiddenByFilter'); + var subSectionsLength = allSubSections.get('length'); + if (subSectionsLength > 0 && subSectionsLength == allHiddenSubSections.length) { + section.set('isHiddenByFilter', true); + } else { + section.set('isHiddenByFilter', false); + } + }); + }); + // process show/hide state for tab + var tab = this.get('content'); + if (!tab.get('isAdvanced')) { + var allSections = tab.get('sections'); + var allHiddenSections = allSections.filterProperty('isHiddenByFilter'); + var sectionsLength = allSections.get('length'); + // if all sections in tab are hidden by filter, do not show the tab + if (sectionsLength > 0 && sectionsLength == allHiddenSections.length) { + tab.set('isHiddenByFilter', true); + tab.set('isActive', false); + } else { + tab.set('isHiddenByFilter', false); + } + } + // no more active tab? pick the first non hidden tab and make it active + var activeTab = this.get('parentView.tabs').findProperty('isActive', true); + if (!activeTab) { + var nonHiddenTabs = this.get('parentView.tabs').filter(function (tab) { + return !(tab.get('isHiddenByFilter') === true); + }); + nonHiddenTabs.get('firstObject').set('isActive', true); + } + }.observes('parentView.filter', '[email protected]'), + willInsertElement: function () { this._super(); this.prepareConfigProperties(); http://git-wip-us.apache.org/repos/asf/ambari/blob/9b4c5a2e/ambari-web/app/views/common/configs/service_config_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_config_view.js b/ambari-web/app/views/common/configs/service_config_view.js index 3f06e15..97d74f3 100644 --- a/ambari-web/app/views/common/configs/service_config_view.js +++ b/ambari-web/app/views/common/configs/service_config_view.js @@ -90,6 +90,14 @@ App.ServiceConfigView = Em.View.extend({ 'App.router.wizardStep7Controller.selectedConfigGroup.name' ), + setActiveTab: function (event) { + this.get('tabs').forEach(function (tab) { + tab.set('isActive', false); + }); + var currentTab = event.context; + currentTab.set('isActive', true); + }, + /** * Object that used for Twitter Bootstrap tabs markup. * @@ -100,8 +108,8 @@ App.ServiceConfigView = Em.View.extend({ return Em.A([]); } var tabs = App.Tab.find().filterProperty('serviceName', this.get('controller.selectedService.serviceName')); - // make first tab active this.processTabs(tabs); + // make first tab active tabs.get('firstObject').set('isActive', true); return tabs; }.property('controller.selectedService.serviceName'),
