Repository: ambari Updated Branches: refs/heads/trunk de06e8e08 -> bc55f2d4e
AMBARI-10830 Create/Edit widget wizard: Preview section should show real data. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bc55f2d4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bc55f2d4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bc55f2d4 Branch: refs/heads/trunk Commit: bc55f2d4e76bedeb79db44199fbf3e588329699c Parents: de06e8e Author: Andrii Tkach <atk...@hortonworks.com> Authored: Wed Apr 29 15:55:11 2015 +0300 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Wed Apr 29 15:55:11 2015 +0300 ---------------------------------------------------------------------- .../app/mixins/common/widgets/widget_mixin.js | 27 ++++++++++---------- .../views/common/widget/gauge_widget_view.js | 4 +-- .../main/service/widgets/create/wizard_view.js | 27 +++----------------- 3 files changed, 20 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/bc55f2d4/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 3a4d8f8..c9b2614 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -510,26 +510,27 @@ App.WidgetPreviewMixin = Ember.Mixin.create({ isLoaded: true, metrics: [], content: Em.Object.create({ - widgetName: 'mock-widget', + id: 1, values: [] }), drawWidget: function () { - this.loadMetrics(); this.get('content').setProperties({ 'values': this.get('controller.widgetValues'), 'properties': this.get('controller.widgetProperties'), - 'displayName': this.get('controller.widgetName') + 'widgetName': this.get('controller.widgetName'), + 'metrics': this.get('controller.widgetMetrics').map(function (metric) { + return { + "name": metric.name, + "service_name": metric.serviceName, + "component_name": metric.componentName, + "metric_path": metric.metricPath, + "host_component_criteria": metric.hostComponentCriteria, + "category": metric.category + } + }) }); + this.loadMetrics(); this._super(); }.observes('controller.widgetProperties', 'controller.widgetValues', 'controller.widgetMetrics', 'controller.widgetName'), - loadMetrics: function () { - var metrics = []; - this.get('controller.widgetMetrics').forEach(function (metric) { - metrics.push({ - name: metric.name, - data: this.get('MOCK_VALUE') - }); - }, this); - this.set('metrics', metrics); - } + onMetricsLoaded: Em.K }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/bc55f2d4/ambari-web/app/views/common/widget/gauge_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/widget/gauge_widget_view.js b/ambari-web/app/views/common/widget/gauge_widget_view.js index 3e951cb..4ce8ebb 100644 --- a/ambari-web/app/views/common/widget/gauge_widget_view.js +++ b/ambari-web/app/views/common/widget/gauge_widget_view.js @@ -59,8 +59,8 @@ App.GaugeWidgetView = Em.View.extend(App.WidgetMixin, { }.property('parentView.content.properties.error_threshold'), id: function() { - return this.get('parentView.content.widgetName'); - }.property('parentView.content.widgetName'), + return 'gauge-widget-' + this.get('parentView.content.id'); + }.property('parentView.content.id'), existCenterText: true, centerTextColor: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/bc55f2d4/ambari-web/app/views/main/service/widgets/create/wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/widgets/create/wizard_view.js b/ambari-web/app/views/main/service/widgets/create/wizard_view.js index 7741697..e39d494 100644 --- a/ambari-web/app/views/main/service/widgets/create/wizard_view.js +++ b/ambari-web/app/views/main/service/widgets/create/wizard_view.js @@ -28,32 +28,13 @@ App.WidgetWizardView = Em.View.extend(App.WizardMenuMixin, { previewWidgetClass: function () { switch (this.get('controller.content.widgetType')) { case 'GRAPH': - return App.GraphWidgetView.extend(App.WidgetPreviewMixin, { - MOCK_VALUE: function () { - var nowTime = App.dateTime(); - var mock = []; - - for (var i = 0; i < 240; i++) { - mock.push([ - 1, - (nowTime + (15 * i)) - ]) - } - return mock; - }.property() - }); + return App.GraphWidgetView.extend(App.WidgetPreviewMixin); case 'TEMPLATE': - return App.TemplateWidgetView.extend(App.WidgetPreviewMixin, { - MOCK_VALUE: 50 - }); + return App.TemplateWidgetView.extend(App.WidgetPreviewMixin); case 'NUMBER': - return App.NumberWidgetView.extend(App.WidgetPreviewMixin, { - MOCK_VALUE: 50 - }); + return App.NumberWidgetView.extend(App.WidgetPreviewMixin); case 'GAUGE': - return App.GaugeWidgetView.extend(App.WidgetPreviewMixin, { - MOCK_VALUE: 0.5 - }); + return App.GaugeWidgetView.extend(App.WidgetPreviewMixin); default: return Em.View; }