You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/04/30 16:44:37 UTC

ambari git commit: AMBARI-10867. Comparison and filtering issue (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 9eaacd3db -> b3ef40c69


AMBARI-10867. Comparison and filtering issue (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b3ef40c6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b3ef40c6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b3ef40c6

Branch: refs/heads/trunk
Commit: b3ef40c693e00bc411c0b9c10ea2ba5adb46c4fd
Parents: 9eaacd3
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Apr 30 17:42:48 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Apr 30 17:42:48 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/models/configs/section.js        | 10 ++-
 ambari-web/app/models/configs/sub_section.js    | 12 ++-
 ambari-web/app/models/configs/tab.js            | 12 ++-
 .../configs/service_config_layout_tab_view.js   | 89 +-------------------
 .../views/common/configs/service_config_view.js | 34 ++++++--
 .../configs/service_configs_by_category_view.js |  2 +-
 ambari-web/test/models/configs/section_test.js  | 43 ++++++++++
 .../test/models/configs/sub_section_test.js     | 32 +++++++
 .../common/configs/service_config_view_test.js  | 60 +++++++++++++
 9 files changed, 197 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/app/models/configs/section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/section.js b/ambari-web/app/models/configs/section.js
index 92909fb..8f45757 100644
--- a/ambari-web/app/models/configs/section.js
+++ b/ambari-web/app/models/configs/section.js
@@ -121,7 +121,15 @@ App.Section = DS.Model.extend({
    */
   isLastColumn: function () {
     return this.get('columnIndex') + this.get('columnSpan') == this.get('tab.columns');
-  }.property('columnIndex', 'columnSpan', 'tab.columns')
+  }.property('columnIndex', 'columnSpan', 'tab.columns'),
+
+  /**
+   * Determines if section is filtered out (all it's subsections should be hidden)
+   * @type {boolean}
+   */
+  isHiddenByFilter: function () {
+    return this.get('subSections').everyProperty('isHiddenByFilter', true);
+  }.property('subSections.@each.isHiddenByFilter')
 
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/app/models/configs/sub_section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/sub_section.js b/ambari-web/app/models/configs/sub_section.js
index 84f26bc..d500a65 100644
--- a/ambari-web/app/models/configs/sub_section.js
+++ b/ambari-web/app/models/configs/sub_section.js
@@ -141,7 +141,17 @@ App.SubSection = DS.Model.extend({
    */
   isLastColumn: function () {
     return this.get('columnIndex') + this.get('columnSpan') == this.get('section.sectionColumns');
-  }.property('columnIndex', 'columnSpan', 'section.sectionColumns')
+  }.property('columnIndex', 'columnSpan', 'section.sectionColumns'),
+
+  /**
+   * Determines if subsection is filtered by checking it own configs
+   * If there is no configs, subsection can't be hidden
+   * @type {boolean}
+   */
+  isHiddenByFilter: function () {
+    var configs = this.get('configs');
+    return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false;
+  }.property('configs.@each.isHiddenByFilter')
 });
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/app/models/configs/tab.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/tab.js b/ambari-web/app/models/configs/tab.js
index bf9f96e..d7c2156 100644
--- a/ambari-web/app/models/configs/tab.js
+++ b/ambari-web/app/models/configs/tab.js
@@ -45,7 +45,17 @@ App.Tab = DS.Model.extend({
    */
   headingClass: function() {
     return '.' + this.get('id');
-  }.property('id')
+  }.property('id'),
+
+  /**
+   * Determines if tab is filtered out (all it's sections should be hidden)
+   * If it's an Advanced Tab it can't be hidden
+   * @type {boolean}
+   */
+  isHiddenByFilter: function () {
+    return this.get('isAdvanced') ? false : this.get('sections').everyProperty('isHiddenByFilter', true);
+  }.property('isAdvanced', 'sections.@each.isHiddenByFilter')
+
 });
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/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 67bc419..b3d69ee 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
@@ -115,96 +115,13 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
     });
   },
 
-  /**
-   * Mark isHiddenByFilter flag for configs, sub-sections, and tab
-   * @method filterEnhancedConfigs
-   */
-  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
-    this.get('parentView').pickActiveTab(this.get('parentView.tabs'));
-  }.observes('parentView.filter', 'parentView.columns.@each.selected'),
-
   didInsertElement: function () {
     this.set('dataIsReady', false);
     this._super();
     this.prepareConfigProperties();
-    this.filterEnhancedConfigs();
+    if (this.get('controller.isCompareMode')) {
+      this.get('parentView').filterEnhancedConfigs();
+    }
     this.set('dataIsReady', true);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/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 515cab6..31240a6 100644
--- a/ambari-web/app/views/common/configs/service_config_view.js
+++ b/ambari-web/app/views/common/configs/service_config_view.js
@@ -54,6 +54,7 @@ App.ServiceConfigView = Em.View.extend({
   }.property('controller.name', 'controller.selectedService'),
 
   showConfigHistoryFeature: false,
+
   toggleRestartMessageView: function () {
     this.$('.service-body').toggle('blind', 200);
     this.set('isRestartMessageCollapsed', !this.get('isRestartMessageCollapsed'));
@@ -115,14 +116,22 @@ App.ServiceConfigView = Em.View.extend({
 
   /**
    * Pick the first non hidden tab and make it active when there is no active tab
+   * @method pickActiveTab
    */
-  pickActiveTab : function (tabs) {
+  pickActiveTab: function (tabs) {
+    if (!tabs) return;
     var activeTab = tabs.findProperty('isActive', true);
-    if (!activeTab) {
-      var nonHiddenTabs = tabs.filter(function (tab) {
-        return !(tab.get('isHiddenByFilter') === true);
-      });
-      nonHiddenTabs.get('firstObject').set('isActive', true);
+    if (activeTab) {
+      if (activeTab.get('isHiddenByFilter')) {
+        activeTab.set('isActive', false);
+        this.pickActiveTab(tabs);
+      }
+    }
+    else {
+      var firstHotHiddenTab = tabs.filterProperty('isHiddenByFilter', false).get('firstObject');
+      if(firstHotHiddenTab) {
+        firstHotHiddenTab.set('isActive', true);
+      }
     }
   },
 
@@ -157,6 +166,17 @@ App.ServiceConfigView = Em.View.extend({
       }
       tab.set('sectionRows', sectionRows);
     }
-  }
+  },
+
+  /**
+   * Mark isHiddenByFilter flag for configs, sub-sections, and tab
+   * @method filterEnhancedConfigs
+   */
+  filterEnhancedConfigs: function () {
+    var self = this;
+    Em.run.next(function () {
+      self.pickActiveTab(self.get('tabs'));
+    });
+  }.observes('filter', 'columns.@each.selected', 'tabs.@each.isHiddenByFilter')
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index d9fb8f2..1b6adc2 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -235,7 +235,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
         }
 
         var searchString = config.get('defaultValue') + config.get('description') +
-          config.get('displayName') + config.get('name') + config.get('value');
+          config.get('displayName') + config.get('name') + config.get('value') + config.getWithDefault('stackConfigProperty.displayName', '');
 
         if (config.get('overrides')) {
           config.get('overrides').forEach(function (overriddenConf) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/test/models/configs/section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/section_test.js b/ambari-web/test/models/configs/section_test.js
index 208d664..1b72a11 100644
--- a/ambari-web/test/models/configs/section_test.js
+++ b/ambari-web/test/models/configs/section_test.js
@@ -40,4 +40,47 @@ describe('App.Section', function () {
 
   });
 
+  describe('#isHiddenByFilter', function () {
+
+    Em.A([
+        {
+          subSections: [],
+          m: 'no subsections',
+          e: true
+        },
+        {
+          subSections: [
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: false}, {isHiddenByFilter: false}]}),
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: false}, {isHiddenByFilter: false}]})
+          ],
+          m: 'no subsections are hidden',
+          e: false
+        },
+        {
+          subSections: [
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: true}, {isHiddenByFilter: true}]}),
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: false}, {isHiddenByFilter: false}]})
+          ],
+          m: 'one subsection is hidden',
+          e: false
+        },
+        {
+          subSections: [
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: true}, {isHiddenByFilter: true}]}),
+            App.SubSection.createRecord({configs: [{isHiddenByFilter: true}, {isHiddenByFilter: true}]})
+          ],
+          m: 'all subsections are hidden',
+          e: true
+        }
+      ]).forEach(function (test) {
+        it(test.m, function () {
+          model.reopen({
+            subSections: test.subSections
+          });
+          expect(model.get('isHiddenByFilter')).to.equal(test.e);
+        });
+      });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/test/models/configs/sub_section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/sub_section_test.js b/ambari-web/test/models/configs/sub_section_test.js
index b410071..ec8c626 100644
--- a/ambari-web/test/models/configs/sub_section_test.js
+++ b/ambari-web/test/models/configs/sub_section_test.js
@@ -42,4 +42,36 @@ describe('App.SubSection', function () {
 
   });
 
+  describe('#isHiddenByFilter', function () {
+
+    Em.A([
+        {
+          configs: [],
+          e: false,
+          m: 'Can\'t be hidden if there is no configs'
+        },
+        {
+          configs: [{isHiddenByFilter: true}, {isHiddenByFilter: true}],
+          e: true,
+          m: 'All configs are hidden'
+        },
+        {
+          configs: [{isHiddenByFilter: false}, {isHiddenByFilter: true}],
+          e: false,
+          m: 'Some configs are hidden'
+        },
+        {
+          configs: [{isHiddenByFilter: false}, {isHiddenByFilter: false}],
+          e: false,
+          m: 'No configs are hidden'
+        }
+    ]).forEach(function (test) {
+        it(test.m, function () {
+          model.set('configs', test.configs);
+          expect(model.get('isHiddenByFilter')).to.equal(test.e);
+        })
+      });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3ef40c6/ambari-web/test/views/common/configs/service_config_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_view_test.js b/ambari-web/test/views/common/configs/service_config_view_test.js
index bb127cb..f02b8ff 100644
--- a/ambari-web/test/views/common/configs/service_config_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_view_test.js
@@ -81,4 +81,64 @@ describe('App.ServiceConfigView', function () {
     });
   });
 
+  describe('#pickActiveTab', function () {
+
+    Em.A([
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: false, name: 'settings', isHiddenByFilter: false}),
+            Em.Object.create({isAdvanced: true, isActive: false, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `settings` active (1)',
+          e: 'settings'
+        },
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: false, name: 'settings', isHiddenByFilter: true}),
+            Em.Object.create({isAdvanced: true, isActive: false, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `advanced` active (1)',
+          e: 'advanced'
+        },
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: true, name: 'settings', isHiddenByFilter: false}),
+            Em.Object.create({isAdvanced: true, isActive: false, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `settings` active (2)',
+          e: 'settings'
+        },
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: true, name: 'settings', isHiddenByFilter: true}),
+            Em.Object.create({isAdvanced: true, isActive: false, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `advanced` active (2)',
+          e: 'advanced'
+        },
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: false, name: 'settings', isHiddenByFilter: false}),
+            Em.Object.create({isAdvanced: true, isActive: false, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `settings` active (3)',
+          e: 'settings'
+        },
+        {
+          tabs: [
+            Em.Object.create({isAdvanced: false, isActive: false, name: 'settings', isHiddenByFilter: false}),
+            Em.Object.create({isAdvanced: true, isActive: true, name: 'advanced', isHiddenByFilter: false})
+          ],
+          m: 'Should make `advanced` active (3)',
+          e: 'advanced'
+        }
+    ]).forEach(function (test) {
+        it(test.m, function () {
+          view.pickActiveTab(test.tabs);
+          expect(test.tabs.findProperty('name', test.e).get('isActive')).to.be.true;
+        });
+      });
+
+  });
+
 });