AMBARI-12452. Template widget type should show n/a if no data available.(xiwang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ad2092cd Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ad2092cd Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ad2092cd Branch: refs/heads/branch-2.1 Commit: ad2092cd70853246fcc2eeaa3f783db63a5c3bea Parents: d4a26cc Author: Xi Wang <xiw...@apache.org> Authored: Fri Jul 17 15:18:51 2015 -0700 Committer: Xi Wang <xiw...@apache.org> Committed: Tue Jul 21 11:28:43 2015 -0700 ---------------------------------------------------------------------- ambari-web/app/mixins/common/widgets/widget_mixin.js | 4 ++-- ambari-web/app/templates/common/widget/template_widget.hbs | 2 +- ambari-web/test/mixins/common/widget_mixin_test.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ad2092cd/ambari-web/app/mixins/common/widgets/widget_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js index ac2c6e3..c07e23e 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -406,7 +406,7 @@ App.WidgetMixin = Ember.Mixin.create({ value.computedValue = value.value.replace(this.get('EXPRESSION_REGEX'), function (match) { var float = parseFloat(computeExpression[match]); if (isNaN(float)) { - return computeExpression[match] || ""; + return computeExpression[match] || "<span class=\"grey\">n/a</span>"; } else { return String((float % 1 !== 0) ? float.toFixed(2) : float); } @@ -751,4 +751,4 @@ App.WidgetLoadAggregator = Em.Object.create({ })(bulks[id]); } } -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ad2092cd/ambari-web/app/templates/common/widget/template_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/widget/template_widget.hbs b/ambari-web/app/templates/common/widget/template_widget.hbs index ba323ca..508c07b 100644 --- a/ambari-web/app/templates/common/widget/template_widget.hbs +++ b/ambari-web/app/templates/common/widget/template_widget.hbs @@ -30,7 +30,7 @@ <i class="icon-edit"></i> </a> {{/isAccessible}} - <div {{bindAttr class="view.contentColor :content"}}>{{view.displayValue}}</div> + <div {{bindAttr class="view.contentColor :content"}}>{{{view.displayValue}}}</div> {{#if view.content.description}} <div class="hidden-description"> {{view.content.description}} http://git-wip-us.apache.org/repos/asf/ambari/blob/ad2092cd/ambari-web/test/mixins/common/widget_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js index f0f663c..e8416d9 100644 --- a/ambari-web/test/mixins/common/widget_mixin_test.js +++ b/ambari-web/test/mixins/common/widget_mixin_test.js @@ -294,7 +294,7 @@ describe('App.WidgetMixin', function () { value: '${a}' }]); mixinObject.calculateValues(); - expect(mixinObject.get('content.values')[0].computedValue).to.be.empty; + expect(mixinObject.get('content.values')[0].computedValue).to.equal('<span class="grey">n/a</span>'); }); it("value is null", function () { this.mock.returns({'${a}': null}); @@ -302,7 +302,7 @@ describe('App.WidgetMixin', function () { value: '${a}' }]); mixinObject.calculateValues(); - expect(mixinObject.get('content.values')[0].computedValue).to.be.empty; + expect(mixinObject.get('content.values')[0].computedValue).to.equal('<span class="grey">n/a</span>'); }); });