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/21 13:42:43 UTC

ambari git commit: AMBARI-10624. Not apparent where the error is in Customize Services page (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk c3e0771e4 -> c97446c58


AMBARI-10624. Not apparent where the error is in Customize Services page (onechiporenko)


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

Branch: refs/heads/trunk
Commit: c97446c5860f16261a0a19214c5a17c7cc23d4a4
Parents: c3e0771
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Apr 21 14:21:33 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Apr 21 14:21:33 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  2 +
 .../controllers/main/service/info/configs.js    | 10 +++++
 .../app/controllers/wizard/step7_controller.js  | 10 +++++
 ambari-web/app/models/configs/section.js        | 10 +++++
 ambari-web/app/models/configs/sub_section.js    | 10 +++++
 ambari-web/app/models/configs/tab.js            | 10 +++++
 ambari-web/app/models/service_config.js         |  2 +-
 .../templates/common/configs/service_config.hbs | 15 ++++++-
 .../common/configs/service_config_wizard.hbs    | 15 ++++++-
 .../main/service/info/config_test.js            | 19 +++++++++
 .../test/controllers/wizard/step7_test.js       | 21 ++++++++-
 ambari-web/test/models/configs/section_test.js  | 43 +++++++++++++++++++
 .../test/models/configs/sub_section_test.js     | 45 ++++++++++++++++++++
 13 files changed, 208 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 0e576bc..27aaf95 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -286,6 +286,8 @@ var files = ['test/init_model_test',
   'test/models/user_test',
   'test/models/host_stack_version_test',
   'test/models/upgrade_entity_test',
+  'test/models/configs/sub_section_test',
+  'test/models/configs/section_test',
   'test/models/configs/service_config_version_test',
   'test/models/configs/config_property_test',
   'test/routes/views_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 3628a7a..c6fc874 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -173,6 +173,16 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   loadedClusterSiteToTagMap: {},
 
   /**
+   * Number of errors in the configs in the selected service
+   * @type {number}
+   */
+  errorsCount: function () {
+    return this.get('selectedService.configs').filter(function (config) {
+      return Em.isNone(config.get('widget'));
+    }).filterProperty('isValid', false).length;
+  }.property('selectedService.configs.@each.isValid'),
+
+  /**
    * Determines if Save-button should be disabled
    * Disabled if some configs have invalid values or save-process currently in progress
    * @type {boolean}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 4eaa119..a0b58c4 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -133,6 +133,16 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
   }.property('isAdvancedConfigLoaded', 'isAppliedConfigLoaded'),
 
   /**
+   * Number of errors in the configs in the selected service
+   * @type {number}
+   */
+  errorsCount: function () {
+    return this.get('selectedService.configs').filter(function (config) {
+      return Em.isNone(config.get('widget'));
+    }).filterProperty('isValid', false).length;
+  }.property('selectedService.configs.@each.isValid'),
+
+  /**
    * Should Next-button be disabled
    * @type {bool}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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 ee40b63..56bcf58 100644
--- a/ambari-web/app/models/configs/section.js
+++ b/ambari-web/app/models/configs/section.js
@@ -30,6 +30,16 @@ App.Section = DS.Model.extend({
   sectionRows: DS.attr('number', {defaultValue: 1}),
   subSections: DS.hasMany('App.SubSection'),
   tab: DS.belongsTo('App.Tab'),
+
+  /**
+   * Number of the errors in all subsections in the current section
+   * @type {number}
+   */
+  errorsCount: function () {
+    var errors = this.get('subSections').mapProperty('errorsCount');
+    return errors.length ? errors.reduce(Em.sum) : 0;
+  }.property('subSections.@each.errorsCount'),
+
   isFirstRow: function () {
     return this.get('rowIndex') == 0;
   }.property(),

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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 d7099ac..1767b5d 100644
--- a/ambari-web/app/models/configs/sub_section.js
+++ b/ambari-web/app/models/configs/sub_section.js
@@ -29,6 +29,16 @@ App.SubSection = DS.Model.extend({
   columnSpan: DS.attr('number', {defaultValue: 1}),
   section: DS.belongsTo('App.Section'),
   configProperties: DS.hasMany('App.StackConfigProperty'),
+  configs: [],
+
+  /**
+   * Number of the errors in all configs
+   * @type {number}
+   */
+  errorsCount: function () {
+    return this.get('configs').filterProperty('isValid', false).length;
+  }.property('configs.@each.isValid'),
+
   isFirstRow: function () {
     return this.get('rowIndex') == 0;
   }.property(),

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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 1396f34..bf9f96e 100644
--- a/ambari-web/app/models/configs/tab.js
+++ b/ambari-web/app/models/configs/tab.js
@@ -27,6 +27,16 @@ App.Tab = DS.Model.extend({
   isAdvanced: DS.attr('boolean', {defaultValue: false}),
   serviceName: DS.attr('string'),
   sections: DS.hasMany('App.Section'),
+
+  /**
+   * Number of the errors in all sections in the current tab
+   * @type {number}
+   */
+  errorsCount: function () {
+    var errors = this.get('sections').mapProperty('errorsCount');
+    return errors.length ? errors.reduce(Em.sum) : 0;
+  }.property('sections.@each.errorsCount'),
+
   /**
    * Class name used for tab switching
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 3913fb4..8798e5a 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -40,7 +40,7 @@ App.ServiceConfig = Ember.Object.extend({
     });
     configs.forEach(function (item) {
       var category = configCategories.findProperty('name', item.get('category'));
-      if (category && !item.get('isValid') && item.get('isVisible')) {
+      if (category && !item.get('isValid') && item.get('isVisible') && !item.get('widget')) {
         category.incrementProperty('nonSlaveErrorCount');
         masterErrors++;
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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 ecbe283..4c7a1f0 100644
--- a/ambari-web/app/templates/common/configs/service_config.hbs
+++ b/ambari-web/app/templates/common/configs/service_config.hbs
@@ -92,7 +92,20 @@
     <ul class="nav nav-tabs">
       {{#each tab in view.tabs}}
         {{#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>
+          <li {{bindAttr class="tab.isActive:active" }}>
+            <a href="#" {{action "setActiveTab" tab target="view"}} {{bindAttr data-target="tab.headingClass"}} data-toggle="tab">
+              {{tab.displayName}}
+                {{#if tab.isAdvanced}}
+                  {{#if controller.errorsCount}}
+                  <span class="badge badge-important">{{controller.errorsCount}}</span>
+                {{/if}}
+              {{else}}
+                {{#if tab.errorsCount}}
+                  <span class="badge badge-important">{{tab.errorsCount}}</span>
+                {{/if}}
+              {{/if}}
+            </a>
+          </li>
         {{/unless}}
       {{/each}}
     </ul>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/app/templates/common/configs/service_config_wizard.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/service_config_wizard.hbs b/ambari-web/app/templates/common/configs/service_config_wizard.hbs
index f464a78..cba158b 100644
--- a/ambari-web/app/templates/common/configs/service_config_wizard.hbs
+++ b/ambari-web/app/templates/common/configs/service_config_wizard.hbs
@@ -51,7 +51,20 @@
 {{#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>
+      <li {{bindAttr class="tab.isActive:active" }}>
+        <a href="#" {{bindAttr data-target="tab.headingClass"}} data-toggle="tab">
+          {{tab.displayName}}
+          {{#if tab.isAdvanced}}
+            {{#if controller.errorsCount}}
+              <span class="badge badge-important">{{controller.errorsCount}}</span>
+            {{/if}}
+          {{else}}
+            {{#if tab.errorsCount}}
+              <span class="badge badge-important">{{tab.errorsCount}}</span>
+            {{/if}}
+          {{/if}}
+        </a>
+      </li>
     {{/each}}
   </ul>
   <div class="tab-content">

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 26ec8de..e1d93c3 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1305,4 +1305,23 @@ describe("App.MainServiceInfoConfigsController", function () {
 
   });
 
+  describe('#errorsCount', function () {
+
+    it('should ignore configs with widgets (enhanced configs)', function () {
+
+      mainServiceInfoConfigsController.reopen({selectedService: {
+        configs: [
+          Em.Object.create({widget: Em.View, isValid: false}),
+          Em.Object.create({widget: Em.View, isValid: true}),
+          Em.Object.create({isValid: true}),
+          Em.Object.create({isValid: false})
+        ]
+      }});
+
+      expect(mainServiceInfoConfigsController.get('errorsCount')).to.equal(1);
+
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 4705d10..a37170b 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1952,4 +1952,23 @@ describe('App.InstallerStep7Controller', function () {
     });
   });
 
-});
+  describe('#errorsCount', function () {
+
+    it('should ignore configs with widgets (enhanced configs)', function () {
+
+      installerStep7Controller.reopen({selectedService: {
+        configs: [
+          Em.Object.create({widget: Em.View, isValid: false}),
+          Em.Object.create({widget: Em.View, isValid: true}),
+          Em.Object.create({isValid: true}),
+          Em.Object.create({isValid: false})
+        ]
+      }});
+
+      expect(installerStep7Controller.get('errorsCount')).to.equal(1);
+
+    });
+
+  });
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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
new file mode 100644
index 0000000..208d664
--- /dev/null
+++ b/ambari-web/test/models/configs/section_test.js
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var App = require('app');
+var model;
+
+describe('App.Section', function () {
+
+  beforeEach(function () {
+    model = App.Section.createRecord();
+  });
+
+  describe('#errorsCount', function () {
+
+    beforeEach(function () {
+      model.reopen({subSections: [
+        App.SubSection.createRecord({configs: [{isValid: true}, {isValid: false}]}),
+        App.SubSection.createRecord({configs: [{isValid: true}, {isValid: false}]})
+      ]});
+    });
+
+    it('should use subsections.@each.errorsCount', function () {
+      expect(model.get('errorsCount')).to.equal(2);
+    });
+
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/c97446c5/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
new file mode 100644
index 0000000..b410071
--- /dev/null
+++ b/ambari-web/test/models/configs/sub_section_test.js
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var App = require('app');
+var model;
+
+describe('App.SubSection', function () {
+
+  beforeEach(function () {
+    model = App.SubSection.createRecord();
+  });
+
+  describe('#errorsCount', function () {
+
+    beforeEach(function () {
+      model.set('configs', [
+        {isValid: false},
+        {isValid: true},
+        {isValid: false},
+        {isValid: true}
+      ]);
+    });
+
+    it('should use configs.@each.isValid', function () {
+      expect(model.get('errorsCount')).to.equal(2);
+    });
+
+  });
+
+});