Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 4b074fe9f -> a32cb2a26


AMBARI-11987. Create Gauge widget: Preview show 0% if the value is more than 
1.(XIWANG)


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

Branch: refs/heads/branch-2.1
Commit: a32cb2a26681d66d37e31fc2dfecb40494e24071
Parents: 4b074fe
Author: Xi Wang <[email protected]>
Authored: Wed Jun 17 17:55:38 2015 -0700
Committer: Xi Wang <[email protected]>
Committed: Thu Jun 18 10:38:59 2015 -0700

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  1 +
 .../app/styles/enhanced_service_dashboard.less  |  5 +++++
 .../templates/common/widget/gauge_widget.hbs    | 12 ++++++++---
 .../views/common/widget/gauge_widget_view.js    | 22 +++++++++++++++++++-
 4 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a32cb2a2/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 6d579d5..ec7d2ac 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2598,6 +2598,7 @@ Em.I18n.translations = {
   'widget.create.wizard.step2.body.template.invalid.msg':'Invalid expression 
name existed. Should use name "Expression#" with double curly braces.',
   'widget.create.wizard.step2.addExpression': 'Add Expression',
   'widget.create.wizard.step2.addDataset': 'Add data set',
+  'widget.create.wizard.step2.body.gauge.overflow.warning':'Overflowed! Gauge 
can only display number between 0 and 1.',
   'widget.create.wizard.step2.allComponents': 'All {0}s',
   'widget.create.wizard.step2.activeComponents': 'Active {0}',
   'widget.create.wizard.step2.noMetricFound': 'No metric found',

http://git-wip-us.apache.org/repos/asf/ambari/blob/a32cb2a2/ambari-web/app/styles/enhanced_service_dashboard.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/enhanced_service_dashboard.less 
b/ambari-web/app/styles/enhanced_service_dashboard.less
index 71c99d7..8745604 100644
--- a/ambari-web/app/styles/enhanced_service_dashboard.less
+++ b/ambari-web/app/styles/enhanced_service_dashboard.less
@@ -150,6 +150,11 @@
         .unavailable {
           padding-top: 30px;
         }
+        .overflow-warning {
+          font-size: 14px;
+          margin-left: 10px;
+          padding: 10px 20px;
+        }
       }
     }
     .red {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a32cb2a2/ambari-web/app/templates/common/widget/gauge_widget.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/widget/gauge_widget.hbs 
b/ambari-web/app/templates/common/widget/gauge_widget.hbs
index 9463c87..0bfb22f 100644
--- a/ambari-web/app/templates/common/widget/gauge_widget.hbs
+++ b/ambari-web/app/templates/common/widget/gauge_widget.hbs
@@ -32,9 +32,15 @@
     {{/isAccessible}}
     <div class="content">
       {{#if view.isUnavailable}}
-        <div class="grey unavailable">
-          {{t common.na}}
-        </div>
+        {{#if view.isOverflowed}}
+          <div class="alert alert-warning overflow-warning">
+            {{t widget.create.wizard.step2.body.gauge.overflow.warning}}
+          </div>
+        {{else}}
+          <div class="grey unavailable">
+            {{t common.na}}
+          </div>
+        {{/if}}
       {{else}}
         {{view view.chartView}}
       {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a32cb2a2/ambari-web/app/views/common/widget/gauge_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/widget/gauge_widget_view.js 
b/ambari-web/app/views/common/widget/gauge_widget_view.js
index a1cd24b..60d636d 100644
--- a/ambari-web/app/views/common/widget/gauge_widget_view.js
+++ b/ambari-web/app/views/common/widget/gauge_widget_view.js
@@ -33,10 +33,30 @@ App.GaugeWidgetView = Em.View.extend(App.WidgetMixin, {
   metrics: [],
 
   /**
+   * 1 - is maximum value of a gauge
+   * @type {number}
+   * @const
+   */
+  MAX_VALUE: 1,
+  /**
+   * 0 - is minimum value of a gauge
+   * @type {number}
+   * @const
+   */
+  MIN_VALUE: 0,
+
+  /**
    * @type {boolean}
    */
   isUnavailable: function () {
-    return isNaN(parseFloat(this.get('value')));
+    return isNaN(parseFloat(this.get('value'))) || this.get('isOverflowed');
+  }.property('value', 'isOverflowed'),
+
+  /**
+   * @type {boolean}
+   */
+  isOverflowed: function () {
+    return parseFloat(this.get('value')) > this.get('MAX_VALUE') || 
parseFloat(this.get('value')) < this.get('MIN_VALUE');
   }.property('value'),
 
   chartView: App.ChartPieView.extend({

Reply via email to