Kaynağa Gözat

AMBARI-12452. Template widget type should show n/a if no data available.(xiwang)

Xi Wang 10 yıl önce
ebeveyn
işleme
1157dac6d1

+ 1 - 1
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);
         }

+ 1 - 1
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}}

+ 2 - 2
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>');
     });
   });