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-13219 Not all hosts displayed on hosts page. (atkach)
Date Thu, 24 Sep 2015 10:17:47 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 8d9430a77 -> 678dbca89


AMBARI-13219 Not all hosts displayed on hosts page. (atkach)


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

Branch: refs/heads/branch-2.1
Commit: 678dbca89d1b6ab2f7f129358b1433aef251e7b8
Parents: 8d9430a
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Thu Sep 24 13:17:37 2015 +0300
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Thu Sep 24 13:17:37 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host.js         |  1 -
 ambari-web/app/mappers/hosts_mapper.js          | 10 +++---
 .../details/host_components/decommissionable.js |  1 +
 ambari-web/app/views/main/host/details.js       |  5 +--
 .../decommissionable_test.js                    | 34 ++++++++++++++++++++
 5 files changed, 44 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/678dbca8/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index 4a0a418..7ffd89e 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -24,7 +24,6 @@ var hostsManagement = require('utils/hosts');
 App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
   name: 'mainHostController',
 
-  dataSource: App.Host.find(),
   clearFilters: null,
 
   filteredCount: 0,

http://git-wip-us.apache.org/repos/asf/ambari/blob/678dbca8/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index 733160e..ed9ef26 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -182,15 +182,17 @@ App.hostsMapper = App.QuickDataMapper.create({
 
 
       for (var k = 0; k < advancedHostComponents.length; k++) {
-        var id = advancedHostComponents[k];
-        if (componentsIdMap[id]) componentsIdMap[id].display_name_advanced = App.HostComponent.find(id).get('displayNameAdvanced');
-      };
+        var key = advancedHostComponents[k];
+        if (componentsIdMap[key]) componentsIdMap[key].display_name_advanced = App.HostComponent.find(key).get('displayNameAdvanced');
+      }
+
       App.store.commit();
       if (stackUpgradeSupport) {
         App.store.loadMany(App.HostStackVersion, stackVersions);
       }
       App.store.loadMany(App.HostComponent, components);
-      if (App.router.get('currentState.parentState.name') != 'hostDetails') {
+      //"itemTotal" present only for Hosts page request
+      if (!Em.isNone(json.itemTotal)) {
         App.Host.find().clear();
       }
       App.store.loadMany(App.Host, hostsWithFullInfo);

http://git-wip-us.apache.org/repos/asf/ambari/blob/678dbca8/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
index 8dae252..b99cea7 100644
--- a/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
+++ b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
@@ -143,6 +143,7 @@ App.Decommissionable = Em.Mixin.create({
    * Get desired_admin_state status from server
    */
   getDesiredAdminState: function () {
+    if (Em.isNone(this.get('content'))) return null;
     return App.ajax.send({
       name: 'host.host_component.slave_desired_admin_state',
       sender: this,

http://git-wip-us.apache.org/repos/asf/ambari/blob/678dbca8/ambari-web/app/views/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details.js b/ambari-web/app/views/main/host/details.js
index 3113135..ea60181 100644
--- a/ambari-web/app/views/main/host/details.js
+++ b/ambari-web/app/views/main/host/details.js
@@ -58,12 +58,13 @@ App.MainHostDetailsView = Em.View.extend({
   }.property('controller.content','isActive', 'controller.content.isNotHeartBeating'),
   didInsertElement: function() {
     var self = this;
+    var host = self.get('content');
 
-    this.set('isLoaded', App.Host.find(this.get('content.id')).get('isLoaded'));
+    this.set('isLoaded', App.Host.find(host.get('id')).get('isLoaded'));
     App.router.get('updateController').updateHost(function () {
       self.set('isLoaded', true);
       App.tooltip($("[rel='HealthTooltip']"));
-      if (!self.get('content.isLoaded')) {
+      if (!host.get('isLoaded')) {
         //if host is not existed then route to list of hosts
         App.router.transitionTo('main.hosts.index');
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/678dbca8/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
index 659cfbd..7c02870 100644
--- a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
@@ -220,4 +220,38 @@ describe('App.Decommissionable', function() {
 
   });
 
+  describe("#getDesiredAdminState()", function() {
+    beforeEach(function () {
+      sinon.stub(App.ajax, 'send', Em.K);
+    });
+    afterEach(function () {
+      App.ajax.send.restore();
+    });
+    it("content is null", function() {
+      hostComponentView = Em.View.create(App.Decommissionable, {
+        content: null
+      });
+      hostComponentView.getDesiredAdminState();
+      expect(App.ajax.send.called).to.be.false;
+    });
+    it("content is correct", function() {
+      hostComponentView = Em.View.create(App.Decommissionable, {
+        content: Em.Object.create({
+          hostName: 'host1',
+          componentName: 'C1'
+        })
+      });
+      hostComponentView.getDesiredAdminState();
+      expect(App.ajax.send.calledWith({
+        name: 'host.host_component.slave_desired_admin_state',
+        sender: hostComponentView,
+        data: {
+          hostName: 'host1',
+          componentName: 'C1'
+        },
+        success: 'getDesiredAdminStateSuccessCallback',
+        error: 'getDesiredAdminStateErrorCallback'
+      })).to.be.true;
+    });
+  });
 });


Mime
View raw message