Updated Branches:
  refs/heads/branch-1.4.2 bfedee144 -> ca1ef85b0

AMBARI-3920. List of hosts does not reflect deleted hosts. (onechiporenko)


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

Branch: refs/heads/branch-1.4.2
Commit: ca1ef85b0a3282dcb37e7db8fed5c9a436f84979
Parents: bfedee1
Author: Oleg Nechiporenko <[email protected]>
Authored: Fri Nov 29 12:35:42 2013 +0200
Committer: Oleg Nechiporenko <[email protected]>
Committed: Fri Nov 29 12:35:42 2013 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 54 ++++++++++----------
 ambari-web/app/utils/ajax.js                    |  9 ++++
 2 files changed, 35 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ca1ef85b/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 708b1dc..44f9722 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -926,7 +926,6 @@ App.MainHostDetailsController = Em.Controller.extend({
       }),
       onPrimary: function() {
         if (!this.get('enablePrimary')) return;
-        var dialogSelf = this;
         var allComponents = self.get('content.hostComponents');
         var deleteError = null;
         allComponents.forEach(function(component){
@@ -935,35 +934,37 @@ App.MainHostDetailsController = Em.Controller.extend({
           }
         });
         if (!deleteError) {
-          var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() 
+ '/hosts/' + self.get('content.hostName');
-          $.ajax({
-            type: 'DELETE',
-            url: url,
-            timeout: App.timeout,
-            async: false,
-            success: function (data) {
-              dialogSelf.hide();
-              App.router.get('updateController').updateAll();
-              App.router.transitionTo('hosts.index');
-            },
-            error: function (xhr, textStatus, errorThrown) {
-              console.log('Error deleting host component');
-              console.log(textStatus);
-              console.log(errorThrown);
-              dialogSelf.hide();
-              xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
-              App.ajax.defaultErrorHandler(xhr, url, 'DELETE', xhr.status);
+          App.ajax.send({
+            name: 'host.delete',
+            sender: this,
+            data: {
+              hostName: self.get('content.hostName')
             },
-            statusCode: require('data/statusCodes')
+            success: 'deleteHostSuccessCallback',
+            error: 'deleteHostErrorCallback'
           });
-        } else {
-          dialogSelf.hide();
+
+        }
+        else {
+          this.hide();
           deleteError.xhr.responseText = "{\"message\": \"" + 
deleteError.xhr.statusText + "\"}";
           App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, 
deleteError.method, deleteError.xhr.status);
         }
       },
-      onSecondary: function() {
+      deleteHostSuccessCallback: function(data) {
+        var dialogSelf = this;
+        App.router.get('updateController').updateHost(function(){
+          dialogSelf.hide();
+          App.router.transitionTo('hosts.index');
+        });
+      },
+      deleteHostErrorCallback: function (xhr, textStatus, errorThrown, opt) {
+        console.log('Error deleting host.');
+        console.log(textStatus);
+        console.log(errorThrown);
+        xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
         this.hide();
+        App.ajax.defaultErrorHandler(xhr, opt.url, 'DELETE', xhr.status);
       }
     })
   },
@@ -980,7 +981,7 @@ App.MainHostDetailsController = Em.Controller.extend({
       if(!staleComponents.findProperty('workStatus','INSTALLED')){
         return;
       }
-    };
+    }
     var content = this;
     return App.ModalPopup.show({
       primary: Em.I18n.t('ok'),
@@ -1002,12 +1003,9 @@ App.MainHostDetailsController = Em.Controller.extend({
               displayName: App.format.role(componentName)
             }
           });
-        })
+        });
         this.hide();
         App.router.get('backgroundOperationsController').showPopup();
-      },
-      onSecondary: function () {
-        this.hide();
       }
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/ca1ef85b/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index b7e9da0..1603627 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -295,6 +295,15 @@ var urls = {
       }
     }
   },
+  'host.delete': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}',
+    'mock': '',
+    'type': 'DELETE',
+    'format': function (data) {
+      return {
+        async: false
+      }
+    }
   'service.metrics.flume.channel_fill_percent': {
     'real': 
'/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
     'mock': '/data/services/metrics/flume/channelFillPct.json',

Reply via email to