Repository: ambari Updated Branches: refs/heads/trunk 875bcfe4a -> 449818c67
AMBARI-11088. Integrate the API response change done for supporting multiple aggregation type for same metrics. (jaimin) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/449818c6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/449818c6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/449818c6 Branch: refs/heads/trunk Commit: 449818c6752eb3bdc9ba9da3255006385618ccb2 Parents: 875bcfe Author: Jaimin Jetly <jai...@hortonworks.com> Authored: Tue May 12 17:25:52 2015 -0700 Committer: Jaimin Jetly <jai...@hortonworks.com> Committed: Tue May 12 17:26:00 2015 -0700 ---------------------------------------------------------------------- .../app/mixins/common/widgets/widget_mixin.js | 32 +++++++++++++------- .../views/common/widget/graph_widget_view.js | 4 +++ 2 files changed, 25 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/449818c6/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 f307335..94fe63f 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -259,18 +259,28 @@ App.WidgetMixin = Ember.Mixin.create({ var metrics = []; if (this.get('content.metrics')) { this.get('content.metrics').forEach(function (_metric) { - var metric_path; - this.aggregatorFunc.forEach(function (_func) { - if (_metric.metric_path.endsWith(_func)) { - // truncate aggregator function suffixed at the end of the metric - metric_path = _metric.metric_path.substring(0, _metric.metric_path.indexOf(_func)); - } - }, this); - if (!metric_path) { - metric_path = _metric.metric_path; + var metric_path = _metric.metric_path; + var isAggregatorFunc = false; + var metric_data = Em.get(data, metric_path.replace(/\//g, '.')); + if (Em.isNone(metric_data)) { + this.aggregatorFunc.forEach(function (_item) { + if (metric_path.endsWith(_item) && !isAggregatorFunc) { + isAggregatorFunc = true; + var metricBeanProperty = metric_path.split("/").pop(); + var metricBean; + metric_path = metric_path.substring(0, metric_path.indexOf(metricBeanProperty)); + if (metric_path.endsWith("/")) { + metric_path = metric_path.slice(0, -1); + } + metricBean = Em.get(data, metric_path.replace(/\//g, '.')); + if (!Em.isNone(metricBean)) { + metric_data = metricBean[metricBeanProperty]; + } + } + }, this); } - if (!Em.isNone(Em.get(data, metric_path.replace(/\//g, '.')))) { - _metric.data = Em.get(data, metric_path.replace(/\//g, '.')); + if (!Em.isNone(metric_data)) { + _metric.data = metric_data; this.get('metrics').pushObject(_metric); } }, this); http://git-wip-us.apache.org/repos/asf/ambari/blob/449818c6/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 72da9dc51..f135636 100644 --- a/ambari-web/app/views/common/widget/graph_widget_view.js +++ b/ambari-web/app/views/common/widget/graph_widget_view.js @@ -135,6 +135,10 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, { return dataLinks[match][i][0]; }); var dataLinkPointValue = isPointNull ? null : Number(window.eval(beforeCompute)); + // expression resulting into `0/0` will produce NaN Object which is not a valid series data value for RickShaw graphs + if (isNaN(dataLinkPointValue)) { + dataLinkPointValue = 0; + } value.push([dataLinkPointValue, timestamp]); } }