ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhew...@apache.org
Subject ambari git commit: AMBARI-18449 Ambari create widget does not show what the error is (Vivek Ratnavel Subramanian via zhewang)
Date Mon, 26 Sep 2016 20:13:15 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk ee4e63a9a -> 69e8f6fa8


AMBARI-18449 Ambari create widget does not show what the error is (Vivek Ratnavel Subramanian
via zhewang)


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

Branch: refs/heads/trunk
Commit: 69e8f6fa89b5b2a4e6246e0e32b23c314a12df5c
Parents: ee4e63a
Author: Zhe (Joe) Wang <zhewang@apache.org>
Authored: Mon Sep 26 13:12:09 2016 -0700
Committer: Zhe (Joe) Wang <zhewang@apache.org>
Committed: Mon Sep 26 13:12:09 2016 -0700

----------------------------------------------------------------------
 .../service/widgets/create/step2_controller.js  | 26 ++++++++++++++++++++
 .../main/service/widgets/create/expression.hbs  | 10 ++++++--
 .../main/service/widgets/create/step2_graph.hbs |  6 ++++-
 .../service/widgets/create/step2_number.hbs     |  6 ++++-
 .../service/widgets/create/step2_template.hbs   |  6 ++++-
 .../service/widgets/create/expression_view.js   | 14 +++++++++--
 6 files changed, 61 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
index 4e3ab91..8b1045a 100644
--- a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
@@ -138,6 +138,32 @@ App.WidgetWizardStep2Controller = Em.Controller.extend({
   },
 
   /**
+   * check whether any of the expressions is incomplete or invalid
+   * @returns {boolean}
+   */
+  isAnyExpressionInvalid: function() {
+    var isAnyExpressionInvalid = false;
+    switch (this.get('content.widgetType')) {
+      case "NUMBER":
+      case "GAUGE":
+      case "TEMPLATE":
+        isAnyExpressionInvalid = this.get('isSubmitDisabled') && this.get('expressions').someProperty('isEmpty',
false);
+        break;
+      case "GRAPH":
+        var dataSets = this.get('dataSets'),
+          isNotEmpty = false;
+        for (var i = 0; i < dataSets.length; i++) {
+          if (dataSets[i].get('expression.data').length > 0) {
+            isNotEmpty = true;
+            break;
+          }
+        }
+        isAnyExpressionInvalid = this.get('isSubmitDisabled') && isNotEmpty;
+    }
+    return isAnyExpressionInvalid;
+  }.property('isSubmitDisabled'),
+
+  /**
    * check whether data of graph widget is complete
    * @param dataSets
    * @returns {boolean} isComplete

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/templates/main/service/widgets/create/expression.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/widgets/create/expression.hbs b/ambari-web/app/templates/main/service/widgets/create/expression.hbs
index 826cb43..0ad08bf 100644
--- a/ambari-web/app/templates/main/service/widgets/create/expression.hbs
+++ b/ambari-web/app/templates/main/service/widgets/create/expression.hbs
@@ -33,8 +33,15 @@
     {{view App.AddNumberExpressionView valueBinding="view.numberValue" class="input-small"}}
     <button class="btn add-on" {{action addNumber target="view"}} {{bindAttr disabled="view.isNumberValueInvalid"}}>{{t
dashboard.widgets.wizard.step2.newNumber}}</button>
   </div>
-
 </div>
+{{#if view.isInvalid}}
+  <div class="alert alert-error">
+    Invalid expression!
+    {{#if view.isInvalidTextfield}}
+      Only numbers or operators are allowed in this field.
+    {{/if}}
+  </div>
+{{/if}}
 <div class="metric-field">
   {{#if view.expression.isRemovable}}
       <a {{action removeExpression view.expression target="controller"}} class="remove-link"><i
class="icon-trash"></i></a>
@@ -54,6 +61,5 @@
     </div>
     <div class="placeholder">{{t dashboard.widgets.wizard.step2.addMetrics}}</div>
   {{/if}}
-
 </div>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/templates/main/service/widgets/create/step2_graph.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/widgets/create/step2_graph.hbs b/ambari-web/app/templates/main/service/widgets/create/step2_graph.hbs
index 17e4790..483abd6 100644
--- a/ambari-web/app/templates/main/service/widgets/create/step2_graph.hbs
+++ b/ambari-web/app/templates/main/service/widgets/create/step2_graph.hbs
@@ -20,7 +20,11 @@
 <div class="alert alert-info">
   {{t widget.create.wizard.step2.body.text}}
 </div>
-
+{{#if isAnyExpressionInvalid}}
+  <div class="alert alert-error">
+    Expression is not complete or is invalid!
+  </div>
+{{/if}}
 {{#each dataSet in dataSets}}
   <fieldset>
     <h5>{{view Ember.TextField valueBinding="dataSet.label"}}</h5>

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/templates/main/service/widgets/create/step2_number.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/widgets/create/step2_number.hbs b/ambari-web/app/templates/main/service/widgets/create/step2_number.hbs
index 27fd7e4..13c4f4b 100644
--- a/ambari-web/app/templates/main/service/widgets/create/step2_number.hbs
+++ b/ambari-web/app/templates/main/service/widgets/create/step2_number.hbs
@@ -20,7 +20,11 @@
 <div class="alert alert-info">
   {{t widget.create.wizard.step2.body.text}}
 </div>
-
+{{#if isAnyExpressionInvalid}}
+  <div class="alert alert-error">
+    Expression is not complete or is invalid!
+  </div>
+{{/if}}
 {{#each expression in expressions}}
   {{view App.WidgetWizardExpressionView expressionBinding="expression"}}
 {{/each}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/templates/main/service/widgets/create/step2_template.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/widgets/create/step2_template.hbs b/ambari-web/app/templates/main/service/widgets/create/step2_template.hbs
index 6a8a469..c0faedc 100644
--- a/ambari-web/app/templates/main/service/widgets/create/step2_template.hbs
+++ b/ambari-web/app/templates/main/service/widgets/create/step2_template.hbs
@@ -33,7 +33,11 @@
 <div class="alert alert-info">
   {{t widget.create.wizard.step2.body.text}}
 </div>
-
+{{#if isAnyExpressionInvalid}}
+  <div class="alert alert-error">
+    Expression is not complete or is invalid!
+  </div>
+{{/if}}
 {{#each expression in expressions}}
   <h5>{{EXPRESSION_PREFIX}}{{expression.id}}</h5>
   {{view App.WidgetWizardExpressionView expressionBinding="expression"}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e8f6fa/ambari-web/app/views/main/service/widgets/create/expression_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/widgets/create/expression_view.js b/ambari-web/app/views/main/service/widgets/create/expression_view.js
index 32c664f..a12bf99 100644
--- a/ambari-web/app/views/main/service/widgets/create/expression_view.js
+++ b/ambari-web/app/views/main/service/widgets/create/expression_view.js
@@ -67,6 +67,11 @@ App.WidgetWizardExpressionView = Em.View.extend({
   isInvalid: false,
 
   /**
+   * @type {boolean}
+   */
+  isInvalidTextfield: false,
+
+  /**
    * contains value of number added to expression
    * @type {string}
    */
@@ -431,7 +436,8 @@ App.InputCursorTextfieldView = Ember.TextField.extend({
   validateInput: function () {
     var value = this.get('value');
     var parentView = this.get('parentView');
-    var isInvalid = false;
+    var isInvalid = false,
+      isInvalidTextfield = false;
 
     if (!number_utils.isPositiveNumber(value))  {
       if (value && parentView.get('OPERATORS').contains(value)) {
@@ -451,10 +457,12 @@ App.InputCursorTextfieldView = Ember.TextField.extend({
         this.set('value', '');
       } else if (value) {
         // invalid operator
-        isInvalid = true;
+        isInvalid = isInvalidTextfield = true;
       }
     }
     this.set('isInvalid', isInvalid);
+    this.set('parentView.isInvalid', isInvalid);
+    this.set('parentView.isInvalidTextfield', isInvalidTextfield);
   }.observes('value'),
 
   keyDown: function (event) {
@@ -479,6 +487,8 @@ App.InputCursorTextfieldView = Ember.TextField.extend({
       }));
       this.set('numberValue', "");
       this.set('isInvalid', false);
+      this.set('parentView.isInvalid', false);
+      this.set('parentView.isInvalidTextfield', false);
       this.set('value', '');
     }
   }


Mime
View raw message