Repository: ambari Updated Branches: refs/heads/branch-2.1 d1acccc73 -> 773f67eca
AMBARI-12899 Heatmaps page request metrics when Ambari Metrics service is absent. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/773f67ec Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/773f67ec Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/773f67ec Branch: refs/heads/branch-2.1 Commit: 773f67eca4a3f627cd977d8c6c74617a7d8255c2 Parents: d1acccc Author: Andrii Tkach <[email protected]> Authored: Fri Aug 28 12:45:39 2015 +0300 Committer: Andrii Tkach <[email protected]> Committed: Fri Aug 28 12:45:39 2015 +0300 ---------------------------------------------------------------------- .../views/common/widget/heatmap_widget_view.js | 38 +++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/773f67ec/ambari-web/app/views/common/widget/heatmap_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/widget/heatmap_widget_view.js b/ambari-web/app/views/common/widget/heatmap_widget_view.js index bb39a04..972797a 100644 --- a/ambari-web/app/views/common/widget/heatmap_widget_view.js +++ b/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('[email protected]'), /** * calculate value for heatmap widgets
