ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject git commit: AMBARI-3920. List of hosts does not reflect deleted hosts. (onechiporenko)
Date Thu, 28 Nov 2013 16:55:45 GMT
Updated Branches:
  refs/heads/trunk b7d29d1cf -> 3b292002c


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/3b292002
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3b292002
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3b292002

Branch: refs/heads/trunk
Commit: 3b292002c91b248a28e613aba81107294052ef8d
Parents: b7d29d1
Author: Oleg Nechiporenko <cv_github@yahoo.com>
Authored: Thu Nov 28 18:53:14 2013 +0200
Committer: Oleg Nechiporenko <cv_github@yahoo.com>
Committed: Thu Nov 28 18:55:39 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/ambari/blob/3b292002/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 4707316..f4c48ba 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'),
@@ -1017,12 +1018,9 @@ App.MainHostDetailsController = Em.Controller.extend({
               state: state
             }
           });
-        })
+        });
         this.hide();
         App.router.get('backgroundOperationsController').showPopup();
-      },
-      onSecondary: function () {
-        this.hide();
       }
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b292002/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index a0def3f..1175844 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -279,6 +279,16 @@ var urls = {
       }
     }
   },
+  'host.delete': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}',
+    'mock': '',
+    'type': 'DELETE',
+    'format': function (data) {
+      return {
+        async: false
+      }
+    }
+  },
   'config.stale.stop_component': {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
     'mock': '',


Mime
View raw message