You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2017/07/07 07:38:53 UTC

[1/3] ambari git commit: AMBARI-21388. Can't delete hosts components via bulk-menu (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 8e719f794 -> 7029e7fa0


AMBARI-21388. Can't delete hosts components via bulk-menu (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 7029e7fa0c3e2ebd8e6eea7eef1f965234018586
Parents: ac5eaae
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon Jul 3 15:35:28 2017 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Jul 7 10:38:45 2017 +0300

----------------------------------------------------------------------
 .../main/host/bulk_operations_controller.js          | 15 +++++++--------
 ambari-web/app/messages.js                           |  4 ++--
 .../main/host/delete_hosts_result_popup.hbs          |  8 ++++++--
 3 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7029e7fa/ambari-web/app/controllers/main/host/bulk_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/bulk_operations_controller.js b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
index b921cd5..34d61d8 100644
--- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js
+++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
@@ -717,6 +717,7 @@ App.BulkOperationsController = Em.Controller.extend({
 
       didInsertElement: function() {
         this.set('expanded', hostsToDelete.length <= minShown);
+        this._super();
       },
 
       onPrimary: function() {
@@ -763,6 +764,8 @@ App.BulkOperationsController = Em.Controller.extend({
         name: 'host.host_component.delete_components',
         sender: self,
         data: {
+          hostNames,
+          componentName: operationData.componentName,
           data: JSON.stringify({
             RequestInfo: {
               query: 'HostRoles/host_name.in(' + hostNames.join(',') + ')&HostRoles/component_name.in(' + operationData.componentName + ')'
@@ -783,7 +786,7 @@ App.BulkOperationsController = Em.Controller.extend({
     var undeletableHosts = [];
     if (arg1 == "error") {
       var request = arg0;
-      var params = arg4;
+      let params = arg4;
       var response = JSON.parse(request.responseText);
       var host = Ember.Object.create({
         error: {
@@ -797,7 +800,7 @@ App.BulkOperationsController = Em.Controller.extend({
       undeletableHosts.push(host);
     } else {
       var data = arg0;
-      var params = arg2;
+      let params = arg2;
       if (data) {
         data.deleteResult.forEach(function (host) {
           if (host.deleted) {
@@ -812,12 +815,7 @@ App.BulkOperationsController = Em.Controller.extend({
           }
         });
       } else {
-        var host = {
-          deleted: {
-            key: params.hosts[0]
-          }
-        };
-        deletedHosts.push(host);
+        deletedHosts.pushObjects(params.hostNames.map(hostName => ({deleted: {key: `${hostName}/${params.componentName}`}})));
       }
     }
 
@@ -831,6 +829,7 @@ App.BulkOperationsController = Em.Controller.extend({
         message: Em.I18n.t('hosts.bulkOperation.delete.component.dryRun.message').format(undeletableHosts.length),
         undeletableHosts: undeletableHosts,
         deletedHosts: deletedHosts.sortProperty('deleted.key'),
+        deleteComponents: true,
         onToggleHost: function (host) {
           host.contexts[0].toggleProperty('isCollapsed');
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7029e7fa/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5e1d08f..f75d801 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2597,8 +2597,8 @@ Em.I18n.translations = {
   'hosts.bulkOperation.confirmation.delete.component.minimum.body': 'At least {0} {1} should be installed in the cluster.',
   'hosts.bulkOperation.confirmation.delete.component.nothingToDo.body': '{0} are neither installed on selected hosts nor in the states that can be deleted.',
   'hosts.bulkOperation.confirmation.delete.component.skip':'The following hosts are skipped as {0} on them are not in the states that can be deleted.',
-  'hosts.bulkOperation.delete.component.result.header':'Delete Hosts',
-  'hosts.bulkOperation.delete.component.result.body': 'The following hosts were deleted successfully:',
+  'hosts.bulkOperation.delete.component.result.header':'Delete Components',
+  'hosts.bulkOperation.delete.component.result.body': 'The following components were deleted successfully:',
   'hosts.bulkOperation.delete.component.dryRun.message':'There are <strong>{0} host(s)</strong> that cannot be deleted (expand for reason):',
 
   'hosts.selectHostsDialog.title': 'Select Configuration Group Hosts',

http://git-wip-us.apache.org/repos/asf/ambari/blob/7029e7fa/ambari-web/app/templates/main/host/delete_hosts_result_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/delete_hosts_result_popup.hbs b/ambari-web/app/templates/main/host/delete_hosts_result_popup.hbs
index eb6f89c..2e074bc 100644
--- a/ambari-web/app/templates/main/host/delete_hosts_result_popup.hbs
+++ b/ambari-web/app/templates/main/host/delete_hosts_result_popup.hbs
@@ -16,7 +16,11 @@
 * limitations under the License.
 }}
 {{#if view.deletedHosts}}
-  <p>{{t hosts.bulkOperation.deleteHosts.result.body}}</p>
+  {{#if view.deleteComponents}}
+    <p>{{t hosts.bulkOperation.delete.component.result.body}}</p>
+  {{else}}
+    <p>{{t hosts.bulkOperation.deleteHosts.result.body}}</p>
+  {{/if}}
 {{/if}}
 
 {{#each deletedHost in view.deletedHosts}}
@@ -39,4 +43,4 @@
       </div>
     </div>
   {{/each}}
-{{/if}}
\ No newline at end of file
+{{/if}}


[2/3] ambari git commit: AMBARI-21385. Selected hosts are not dropped event if some of the selected hosts was deleted (alexantonenko)

Posted by al...@apache.org.
AMBARI-21385. Selected hosts are not dropped event if some of the selected hosts was deleted (alexantonenko)


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

Branch: refs/heads/trunk
Commit: ac5eaae59673740a43b56b54978948e73cd71a54
Parents: f17d317
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Jun 30 17:52:42 2017 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Jul 7 10:38:45 2017 +0300

----------------------------------------------------------------------
 .../main/host/bulk_operations_controller.js           | 11 +++++++++--
 ambari-web/app/controllers/main/host/details.js       |  2 +-
 ambari-web/app/mappers/hosts_mapper.js                |  2 +-
 ambari-web/app/utils/db.js                            | 14 ++++++++++----
 ambari-web/app/views/main/host.js                     |  8 +++-----
 ambari-web/test/views/main/host_test.js               |  4 ++--
 6 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/ambari-web/app/controllers/main/host/bulk_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/bulk_operations_controller.js b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
index b053fc3..b921cd5 100644
--- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js
+++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
@@ -450,13 +450,20 @@ App.BulkOperationsController = Em.Controller.extend({
         }
       }),
 
-      onPrimary: function () {
+      completeDelete() {
+        if (arg1 !== 'error') {
+          App.db.unselectHosts(arg2.hosts);
+        }
         location.reload();
+      },
+
+      onPrimary: function () {
+        this.completeDelete();
         this._super();
       },
 
       onClose: function () {
-        location.reload();
+        this.completeDelete();
         this._super();
       }
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 6f34dfe..382b09d 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -2678,7 +2678,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
         var popup = this;
         var completeCallback = function () {
           var remainingHosts = App.db.getSelectedHosts('mainHostController').removeObject(self.get('content.hostName'));
-          App.db.setSelectedHosts('mainHostController', remainingHosts);
+          App.db.setSelectedHosts(remainingHosts);
           popup.hide();
         };
         self.doDeleteHost(completeCallback);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/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 203cd67..e536269 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -103,7 +103,7 @@ App.hostsMapper = App.QuickDataMapper.create({
       var cacheServices = App.cache['services'];
       var currentServiceComponentsMap = App.get('componentConfigMapper').buildServiceComponentMap(cacheServices);
       var newHostComponentsMap = {};
-      var selectedHosts = App.db.getSelectedHosts('mainHostController');
+      var selectedHosts = App.db.getSelectedHosts();
       var clusterName = App.get('clusterName');
       var advancedHostComponents = [];
       var hostComponentLogs = [];

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index e41b9c0..eddd7ef 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -221,10 +221,16 @@ App.db.setSortingStatuses = function (name, sortingConditions) {
   App.db.set('app.tables.sortingConditions', name, sortingConditions);
 };
 
-App.db.setSelectedHosts = function (name, selectedHosts) {
-  App.db.set('app.tables.selectedItems', name, selectedHosts);
+App.db.setSelectedHosts = function (selectedHosts) {
+  App.db.set('app.tables.selectedItems', 'mainHostController', selectedHosts);
 };
 
+App.db.unselectHosts = function (hostsToUnselect = []) {
+  let selectedHosts = App.db.getSelectedHosts();
+  selectedHosts = selectedHosts.filter(host => hostsToUnselect.indexOf(host) === -1);
+  App.db.setSelectedHosts(selectedHosts);
+}
+
 App.db.setHosts = function (hostInfo) {
   App.db.set('Installer', 'hostInfo', hostInfo);
 };
@@ -405,8 +411,8 @@ App.db.getSortingStatuses = function (name) {
   return name ? App.db.get('app.tables.sortingConditions', name): null;
 };
 
-App.db.getSelectedHosts = function (name) {
-  return App.db.get('app.tables.selectedItems', name) || [];
+App.db.getSelectedHosts = function () {
+  return App.db.get('app.tables.selectedItems', 'mainHostController') || [];
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js
index 6a8dcf2..78eb82b 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -246,8 +246,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
     }
     this.combineSelectedFilter();
     //10 is an index of selected column
-    var controllerName = this.get('controller.name');
-    App.db.setSelectedHosts(controllerName, this.get('selectedHosts'));
+    App.db.setSelectedHosts(this.get('selectedHosts'));
 
     this.addObserver('selectAllHosts', this, this.toggleAllHosts);
   },
@@ -255,8 +254,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
    * combine selected hosts on page with selected hosts which are filtered out but added to cluster
    */
   combineSelectedFilter: function () {
-    var controllerName = this.get('controller.name');
-    var previouslySelectedHosts = App.db.getSelectedHosts(controllerName);
+    var previouslySelectedHosts = App.db.getSelectedHosts();
     var selectedHosts = [];
     var hostsOnPage = this.get('pageContent').mapProperty('hostName');
     selectedHosts = this.get('pageContent').filterProperty('selected').mapProperty('hostName');
@@ -306,7 +304,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
   clearSelection: function() {
     this.get('pageContent').setEach('selected', false);
     this.set('selectAllHosts', false);
-    App.db.setSelectedHosts(this.get('controller.name'), []);
+    App.db.setSelectedHosts([]);
     this.get('selectedHosts').clear();
     this.filterSelected();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/ac5eaae5/ambari-web/test/views/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host_test.js b/ambari-web/test/views/main/host_test.js
index e0eb9bc..15bdab2 100644
--- a/ambari-web/test/views/main/host_test.js
+++ b/ambari-web/test/views/main/host_test.js
@@ -523,7 +523,7 @@ describe('App.MainHostView', function () {
     it("App.db.setSelectedHosts should be called", function() {
       view.set('selectedHosts', []);
       view.updateCheckedFlags();
-      expect(App.db.setSelectedHosts.calledWith('ctrl1', [])).to.be.true;
+      expect(App.db.setSelectedHosts.calledWith([])).to.be.true;
     });
 
     it("addObserver should be called", function() {
@@ -620,7 +620,7 @@ describe('App.MainHostView', function () {
     });
 
     it("App.db.setSelectedHosts should be called", function() {
-      expect(App.db.setSelectedHosts.calledWith('ctrl1', [])).to.be.true;
+      expect(App.db.setSelectedHosts.calledWith([])).to.be.true;
     });
 
     it("filterSelected should be called", function() {


[3/3] ambari git commit: AMBARI-21384. Message for deleted hosts is confusing (alexantonenko)

Posted by al...@apache.org.
AMBARI-21384. Message for deleted hosts is confusing (alexantonenko)


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

Branch: refs/heads/trunk
Commit: f17d317b725012ccc687ee070b1e1dbc604e8d12
Parents: 8e719f7
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Jun 30 17:42:53 2017 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Jul 7 10:38:45 2017 +0300

----------------------------------------------------------------------
 .../app/controllers/main/host/bulk_operations_controller.js    | 6 +++---
 ambari-web/app/messages.js                                     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f17d317b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/bulk_operations_controller.js b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
index 92ae12e..b053fc3 100644
--- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js
+++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
@@ -444,7 +444,7 @@ App.BulkOperationsController = Em.Controller.extend({
         templateName: require('templates/main/host/delete_hosts_result_popup'),
         message: Em.I18n.t('hosts.bulkOperation.deleteHosts.dryRun.message').format(undeletableHosts.length),
         undeletableHosts: undeletableHosts,
-        deletedHosts: deletedHosts,
+        deletedHosts: deletedHosts.sortProperty('deleted.key'),
         onToggleHost: function (host) {
           host.contexts[0].toggleProperty('isCollapsed');
         }
@@ -823,7 +823,7 @@ App.BulkOperationsController = Em.Controller.extend({
         templateName: require('templates/main/host/delete_hosts_result_popup'),
         message: Em.I18n.t('hosts.bulkOperation.delete.component.dryRun.message').format(undeletableHosts.length),
         undeletableHosts: undeletableHosts,
-        deletedHosts: deletedHosts,
+        deletedHosts: deletedHosts.sortProperty('deleted.key'),
         onToggleHost: function (host) {
           host.contexts[0].toggleProperty('isCollapsed');
         }
@@ -1295,4 +1295,4 @@ App.BulkOperationsController = Em.Controller.extend({
     return hostNamesSkipped;
   }
 
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/f17d317b/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index e88ec42..5e1d08f 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2593,7 +2593,7 @@ Em.I18n.translations = {
   'hosts.bulkOperation.deleteHosts.confirmation.body.msg3': 'To completely delete the hosts, first stop ambari-agent on them.',
   'hosts.bulkOperation.deleteHosts.confirmation.body.msg4': 'If the hosts were hosting a Zookeeper Server, the Zookeeper Service should be restarted. Go to the <i>Services</i> page.',
   'hosts.bulkOperation.deleteHosts.result.header':'Delete Hosts',
-  'hosts.bulkOperation.deleteHosts.result.body': 'The following hosts were deleted successfully:',
+  'hosts.bulkOperation.deleteHosts.result.body': 'The following hosts and host components were deleted successfully:',
   'hosts.bulkOperation.confirmation.delete.component.minimum.body': 'At least {0} {1} should be installed in the cluster.',
   'hosts.bulkOperation.confirmation.delete.component.nothingToDo.body': '{0} are neither installed on selected hosts nor in the states that can be deleted.',
   'hosts.bulkOperation.confirmation.delete.component.skip':'The following hosts are skipped as {0} on them are not in the states that can be deleted.',