Просмотр исходного кода

AMBARI-12899 Heatmaps page request metrics when Ambari Metrics service is absent. (atkach)

Andrii Tkach 10 лет назад
Родитель
Сommit
cd3a55783d
1 измененных файлов с 37 добавлено и 1 удалено
  1. 37 1
      ambari-web/app/views/common/widget/heatmap_widget_view.js

+ 37 - 1
ambari-web/app/views/common/widget/heatmap_widget_view.js

@@ -33,6 +33,12 @@ App.HeatmapWidgetView = Em.View.extend(App.WidgetMixin, {
    */
   racks: [],
 
+  /**
+   * @type {$.ajax|null}
+   * @default null
+   */
+  activeRequest: null,
+
   onMetricsLoaded: function () {
     if (!this.get('isLoaded')) {
       this.set('controller.inputMaximum', this.get('content.properties.max_limit'));
@@ -40,6 +46,36 @@ App.HeatmapWidgetView = Em.View.extend(App.WidgetMixin, {
     this._super();
   },
 
+  willDestroyElement: function () {
+    if ($.isPlainObject(this.get('activeRequest'))) {
+      this.get('activeRequest').abort();
+      this.set('activeRequest', null);
+    }
+  },
+
+  getHostComponentsMetrics: function (request) {
+    var ajax = this._super(request);
+    this.set('activeRequest', ajax);
+    return ajax;
+  },
+
+  getHostsMetrics: function (request) {
+    var ajax = this._super(request);
+    this.set('activeRequest', ajax);
+    return ajax;
+  },
+
+  /**
+   * skip metrics loading if AMBARI METRICS service is not started
+   */
+  loadMetrics: function () {
+    if (App.Service.find('AMBARI_METRICS').get('isStarted')) {
+      this._super();
+    } else {
+      this.onMetricsLoaded();
+    }
+  },
+
   /**
    * draw widget
    */
@@ -65,7 +101,7 @@ App.HeatmapWidgetView = Em.View.extend(App.WidgetMixin, {
       App.loadTimer.finish('Heatmaps Page');
       App.loadTimer.finish('Service Heatmaps Page');
     }
-  },
+  }.observes('racks.@each.isLoaded'),
 
   /**
    * calculate value for heatmap widgets