Преглед изворни кода

AMBARI-2848. UI display label issues in Heatmaps. (xiwang via yusaku)

Yusaku Sako пре 11 година
родитељ
комит
436394607e

+ 2 - 2
ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js

@@ -126,7 +126,7 @@ App.MainChartHeatmapMetric = Em.Object.extend({
       var from = this.formatLegendNumber(c * delta);
       var to = this.formatLegendNumber((c + 1) * delta);
       if ($.trim(labelSuffix) == 'ms') {
-      	var label = date.timingFormat(from) + " - " + date.timingFormat(to);
+      	var label = date.timingFormat(from, 'zeroValid') + " - " + date.timingFormat(to, 'zeroValid');
       } else {
 	      var label = from + labelSuffix + " - " + to + labelSuffix;
       }
@@ -142,7 +142,7 @@ App.MainChartHeatmapMetric = Em.Object.extend({
     to = this.formatLegendNumber(max);
 
     if ($.trim(labelSuffix) == 'ms') {
-      var label = date.timingFormat(from) + " - " + date.timingFormat(to);
+      var label = date.timingFormat(from, 'zeroValid') + " - " + date.timingFormat(to, 'zeroValid');
     } else {
       var label = from + labelSuffix + " - " + to + labelSuffix;
     }

+ 3 - 1
ambari-web/app/utils/date.js

@@ -65,10 +65,12 @@ module.exports = {
    * 1000000 ms = 16.66 mins
    * 3500000 secs = 58.33 mins
    * @param time
+   * @param zeroValid, for the case to show 0 when time is 0, not null
    * @return string formatted date
    */
-  timingFormat:function (time) {
+  timingFormat:function (time, /* optional */ zeroValid) {
     var intTime  = parseInt(time);
+    if (zeroValid && intTime == 0) return 0 + '';
     if (!intTime) return null;
     var timeStr = intTime.toString();
     var lengthOfNumber = timeStr.length;