Repository: ambari Updated Branches: refs/heads/trunk c22791cbd -> 272095e04
AMBARI-10929 Adjusting time range in zoomed-in graph widget does not work. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/272095e0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/272095e0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/272095e0 Branch: refs/heads/trunk Commit: 272095e049537c78abbc7540d7e9cc2ab28da79f Parents: c22791c Author: Andrii Tkach <[email protected]> Authored: Tue May 5 15:00:44 2015 +0300 Committer: Andrii Tkach <[email protected]> Committed: Tue May 5 15:00:44 2015 +0300 ---------------------------------------------------------------------- .../app/mixins/common/widgets/widget_mixin.js | 12 ++++++-- .../views/common/widget/graph_widget_view.js | 29 ++++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/272095e0/ambari-web/app/mixins/common/widgets/widget_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js index 676be85..4bace6b 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -45,6 +45,11 @@ App.WidgetMixin = Ember.Mixin.create({ CLONE_SUFFIX: '(Copy)', /** + * @type {number|null} + */ + timeoutId: null, + + /** * common metrics container * @type {Array} */ @@ -108,7 +113,7 @@ App.WidgetMixin = Ember.Mixin.create({ }); } } - }, + }.observes('customTimeRange'), /** * get data formatted for request @@ -332,9 +337,10 @@ App.WidgetMixin = Ember.Mixin.create({ var self = this; this.set('isLoaded', true); this.drawWidget(); - setTimeout(function () { + clearTimeout(this.get('timeoutId')); + this.set('timeoutId', setTimeout(function () { self.loadMetrics(); - }, App.contentUpdateInterval); + }, App.contentUpdateInterval)); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/272095e0/ambari-web/app/views/common/widget/graph_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/widget/graph_widget_view.js b/ambari-web/app/views/common/widget/graph_widget_view.js index 9388f4c..a0a9e8e 100644 --- a/ambari-web/app/views/common/widget/graph_widget_view.js +++ b/ambari-web/app/views/common/widget/graph_widget_view.js @@ -28,18 +28,24 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, { metrics: [], /** - * 3600000 ms in 1 hour + * 3600 sec in 1 hour * @const */ - TIME_FACTOR: 3600000, + TIME_FACTOR: 3600, /** - * value in ms + * custom time range, set when graph opened in popup + * @type {number|null} + */ + customTimeRange: null, + + /** + * value in seconds * @type {number} */ timeRange: function () { - return parseInt(this.get('content.properties.time_range')) * this.get('TIME_FACTOR'); - }.property('content.properties.time_range'), + return this.get('customTimeRange') || parseInt(this.get('content.properties.time_range')) * this.get('TIME_FACTOR'); + }.property('content.properties.time_range', 'customTimeRange'), /** * value in ms @@ -213,7 +219,7 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, { */ addTimeProperties: function (metricPaths) { var toSeconds = Math.round(App.dateTime() / 1000); - var fromSeconds = toSeconds - (this.get('timeRange')/1000); + var fromSeconds = toSeconds - this.get('timeRange'); var step = this.get('timeStep'); var result = []; @@ -234,6 +240,17 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, { inWidget: true, /** + * set custom time range for graph widget + */ + setTimeRange: function () { + if (this.get('isPopup')) { + this.set('parentView.customTimeRange', this.get('timeUnitSeconds')); + } else { + this.set('parentView.customTimeRange', null); + } + }.observes('isPopup', 'timeUnitSeconds'), + + /** * graph height * @type {number} */
