ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-12621 FE: Going to a service heatmap makes a call to old heatmap first. (atkach)
Date Wed, 05 Aug 2015 11:57:55 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 9798b2265 -> 858545d63


AMBARI-12621 FE: Going to a service heatmap makes a call to old heatmap first. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/858545d6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/858545d6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/858545d6

Branch: refs/heads/branch-2.1
Commit: 858545d63b6c1713dd11913f780164a77363501c
Parents: 9798b22
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Mon Aug 3 17:39:33 2015 +0300
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Wed Aug 5 14:52:12 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  1 +
 .../app/controllers/main/charts/heatmap.js      | 13 ++--
 .../app/mixins/common/widgets/widget_section.js |  7 +++
 ambari-web/app/routes/main.js                   |  5 +-
 ambari-web/app/views/main/charts/heatmap.js     |  7 ++-
 .../test/views/main/charts/heatmap_test.js      | 63 ++++++++++++++++++++
 6 files changed, 85 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 5e4112b..9eecf89 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -239,6 +239,7 @@ var files = ['test/init_model_test',
   'test/views/main/host/details/host_component_views/nodemanager_view_test',
   'test/views/main/host/details/host_component_views/regionserver_view_test',
   'test/views/main/host/details/host_component_views/tasktracker_view_test',
+  'test/views/main/charts/heatmap_test',
   'test/views/main/charts/heatmap/heatmap_host_test',
   'test/views/main/service/item_test',
   'test/views/main/service/info/config_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/app/controllers/main/charts/heatmap.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/charts/heatmap.js b/ambari-web/app/controllers/main/charts/heatmap.js
index 9586071..f54c1b0 100644
--- a/ambari-web/app/controllers/main/charts/heatmap.js
+++ b/ambari-web/app/controllers/main/charts/heatmap.js
@@ -68,15 +68,15 @@ App.MainChartsHeatmapController = Em.Controller.extend(App.WidgetSectionMixin,
{
 
 
   /**
-   * This function is called from the binded view of the controller
+   * This function is called from the bound view of the controller
    */
   loadPageData: function () {
     var self = this;
-    this.loadRacks().done(function (data) {
-      self.set('isLoaded', true);
-      self.loadRacksSuccessCallback(data);
+
+    this.loadRacks().always(function () {
       self.resetPageData();
       self.getAllHeatMaps().done(function (allHeatmapData) {
+        self.set('isLoaded', true);
         allHeatmapData.items.forEach(function (_allHeatmapData) {
           self.get('allHeatmaps').pushObject(_allHeatmapData.WidgetInfo);
         });
@@ -93,7 +93,7 @@ App.MainChartsHeatmapController = Em.Controller.extend(App.WidgetSectionMixin,
{
    * @return {Array}
    */
   categorizeByServiceName: function(allHeatmaps) {
-  var categories = [];
+    var categories = [];
     allHeatmaps.forEach(function(_heatmap){
     var serviceNames = JSON.parse(_heatmap.metrics).mapProperty('service_name').uniq();
       serviceNames.forEach(function(_serviceName){
@@ -150,7 +150,8 @@ App.MainChartsHeatmapController = Em.Controller.extend(App.WidgetSectionMixin,
{
       sender: this,
       data: {
         urlParams: urlParams
-      }
+      },
+      success: 'loadRacksSuccessCallback'
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/app/mixins/common/widgets/widget_section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_section.js b/ambari-web/app/mixins/common/widgets/widget_section.js
index e486d66..81d9f70 100644
--- a/ambari-web/app/mixins/common/widgets/widget_section.js
+++ b/ambari-web/app/mixins/common/widgets/widget_section.js
@@ -263,5 +263,12 @@ App.WidgetSectionMixin = Ember.Mixin.create({
         data: data
       }
     });
+  },
+
+  /**
+   * After closing widget section, layout should be reset
+   */
+  clearActiveWidgetLayout: function () {
+    this.set('activeWidgetLayout', {});
   }
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 3e9f5fe..60567d0 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -700,10 +700,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
           router.get('mainController').dataLoading().done(function () {
             var item = router.get('mainServiceItemController.content');
             if (item.get('isLoaded')) {
-              router.get('mainServiceInfoHeatmapController').loadRacks().done(function (data)
{
-                router.get('mainServiceInfoHeatmapController').loadRacksSuccessCallback(data);
-                router.get('mainServiceItemController').connectOutlet('mainServiceInfoHeatmap',
item);
-              });
+              router.get('mainServiceItemController').connectOutlet('mainServiceInfoHeatmap',
item);
             } else {
               item.set('routeToHeatmaps', true);
               router.transitionTo('services.index');

http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/app/views/main/charts/heatmap.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/charts/heatmap.js b/ambari-web/app/views/main/charts/heatmap.js
index e5561d8..87b98b7 100644
--- a/ambari-web/app/views/main/charts/heatmap.js
+++ b/ambari-web/app/views/main/charts/heatmap.js
@@ -26,5 +26,10 @@ App.MainChartsHeatmapView = Em.View.extend({
   },
   dropdownView: Em.View.extend({
     templateName: require('templates/main/charts/heatmap_dropdown')
-  })
+  }),
+
+  willDestroyElement: function () {
+    this._super();
+    this.get('controller').clearActiveWidgetLayout();
+  }
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/858545d6/ambari-web/test/views/main/charts/heatmap_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/charts/heatmap_test.js b/ambari-web/test/views/main/charts/heatmap_test.js
new file mode 100644
index 0000000..60df2eb
--- /dev/null
+++ b/ambari-web/test/views/main/charts/heatmap_test.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/charts/heatmap');
+
+describe('App.MainChartsHeatmapView', function () {
+
+  var view;
+
+  beforeEach(function () {
+    view = App.MainChartsHeatmapView.create({
+      controller: Em.Object.create({
+        clearActiveWidgetLayout: Em.K,
+        loadPageData: Em.K
+      })
+    });
+  });
+
+
+  describe("#didInsertElement()", function () {
+    beforeEach(function () {
+      sinon.spy(view.get('controller'), 'loadPageData');
+    });
+    afterEach(function () {
+      view.get('controller').loadPageData.restore();
+    });
+    it("", function () {
+      view.didInsertElement();
+      expect(view.get('controller').loadPageData.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#willDestroyElement()", function () {
+    beforeEach(function () {
+      sinon.spy(view.get('controller'), 'clearActiveWidgetLayout');
+    });
+    afterEach(function () {
+      view.get('controller').clearActiveWidgetLayout.restore();
+    });
+    it("", function () {
+      view.willDestroyElement();
+      expect(view.get('controller').clearActiveWidgetLayout.calledOnce).to.be.true;
+    });
+  });
+
+});
\ No newline at end of file


Mime
View raw message