Browse Source

AMBARI-4949. Storm: When Nimbus is down, the graphs are shown with spinners that spin forever (page refresh shows "Loading..." bar). (Denys Buzhor via onechiporenko)

Oleg Nechiporenko 11 năm trước cách đây
mục cha
commit
c9466c7c01

+ 2 - 0
ambari-web/app/messages.js

@@ -193,6 +193,8 @@ Em.I18n.translations = {
   'common.hostLog.popup.outputLog.value': 'output-{0}.txt',
   'common.hostLog.popup.errorLog.value': 'errors-{0}.txt',
   'common.maintenance.task': ' Toggle Maintenance Mode',
+  'common.used': 'used',
+  'common.free': 'free',
   'passiveState.turnOn':'Turn On Maintenance Mode',
   'passiveState.turnOff':'Turn Off Maintenance Mode',
   'passiveState.turnOnFor':'Turn On Maintenance Mode for {0}',

+ 3 - 2
ambari-web/app/mixins/common/chart/storm_linear_time.js

@@ -44,8 +44,9 @@ App.StormLinearTimeChartMixin = Em.Mixin.create({
   getMappedStormData: function() {
     var seriesData = [];
     this.get('stormChartDefinition').forEach(function(item) {
-      seriesData.push(this.transformData(this.get('chartStormModel.' + item.value), item.name));
+      if (this.get('chartStormModel.' + item.value) || this.get('chartStormModel.' + item.value) == 0)
+        seriesData.push(this.transformData(this.get('chartStormModel.' + item.value), item.name));
     }, this);
-    return seriesData
+    return seriesData;
   }
 });

+ 4 - 4
ambari-web/app/templates/main/dashboard/service/storm.hbs

@@ -36,7 +36,7 @@
     {{t services.service.summary.storm.freeslots}}
   </td>
   <td>
-    {{view.service.freeSlots}} / {{view.service.totalSlots}} ({{view.freeSlotsPercentage}}% free)
+    {{formatNull view.service.freeSlots}} / {{formatNull view.service.totalSlots}} ({{formatNull view.freeSlotsPercentage empty="0"}}% {{t common.free}})
   </td>
 </tr>
 <tr>
@@ -44,7 +44,7 @@
     {{t services.service.summary.storm.tasks}}
   </td>
   <td>
-    {{view.service.totalTasks}}
+    {{formatNull view.service.totalTasks}}
   </td>
 </tr>
 <tr>
@@ -52,7 +52,7 @@
     {{t services.service.summary.storm.executors}}
   </td>
   <td>
-    {{view.service.totalExecutors}}
+    {{formatNull view.service.totalExecutors}}
   </td>
 </tr>
 <tr>
@@ -60,7 +60,7 @@
     {{t services.service.summary.storm.topologies}}
   </td>
   <td>
-    {{view.service.topologies}}
+    {{formatNull view.service.topologies}}
   </td>
 </tr>
 <tr>

+ 28 - 2
ambari-web/app/utils/helper.js

@@ -370,7 +370,6 @@ App.registerBoundHelper('pluralize', Em.View.extend({
     }
     return '';
   },
-
   /*
    * Detect for Em.I18n.t reference call
    * @params word {String}
@@ -386,7 +385,34 @@ App.registerBoundHelper('pluralize', Em.View.extend({
   }
   })
 );
-
+/**
+ * Return defined string instead of empty if value is null/undefined
+ * by default is `n/a`.
+ *
+ * @param empty {String} - value instead of empty string (not required)
+ *  can be used with Em.I18n pass value started with't:'
+ *
+ * Examples:
+ *
+ * default value will be returned
+ * {{formatNull service.someValue}}
+ *
+ * <code>empty<code> will be returned
+ * {{formatNull service.someValue empty="I'm empty"}}
+ *
+ * Em.I18n translation will be returned
+ * {{formatNull service.someValue empty="t:my.key.to.translate"
+ */
+App.registerBoundHelper('formatNull', Em.View.extend({
+  tagName: 'span',
+  template: Em.Handlebars.compile('{{view.result}}'),
+
+  result: function() {
+    var emptyValue = this.get('empty') ? this.get('empty') : Em.I18n.t('services.service.summary.notAvailable');
+    emptyValue = emptyValue.startsWith('t:') ? Em.I18n.t(emptyValue.substr(2, emptyValue.length)) : emptyValue;
+    return (this.get('content') || this.get('content') == 0) ? this.get('content') : emptyValue;
+  }.property('content')
+}));
 
 /**
  * Ambari overrides the default date transformer.