浏览代码

AMBARI-4923. Exiting Add Hosts Wizard during deploy causes Hosts table to break - then the wizard got stuck trying to add already-added host (alexantonenko)

Alex Antonenko 11 年之前
父节点
当前提交
5aa5d90da1
共有 2 个文件被更改,包括 31 次插入9 次删除
  1. 2 0
      ambari-web/app/messages.js
  2. 29 9
      ambari-web/app/routes/add_host_routes.js

+ 2 - 0
ambari-web/app/messages.js

@@ -1512,6 +1512,8 @@ Em.I18n.translations = {
   'hosts.cant.do.popup.runningList.body.end':'To delete this host, you must first stop all the running components listed above. ' +
     'If this host has a DataNode, it should be decommissioned first to prevent data loss.',
   'hosts.add.header':'Add Host Wizard',
+  'hosts.add.exit.header':'Exit',
+  'hosts.add.exit.body':'Do you really want to exit Add Host Wizard?',
   'hosts.assignRack':'Assign Rack',
   'hosts.passiveMode.popup':'Are you sure you want to <b>Turn {0} Maintenance Mode</b> for {1}?',
 

+ 29 - 9
ambari-web/app/routes/add_host_routes.js

@@ -21,9 +21,22 @@ var App = require('app');
 module.exports = App.WizardRoute.extend({
   route: '/host/add',
 
+  clearData: function (router) {
+    App.router.get('updateController').set('isWorking', true);
+    App.clusterStatus.setClusterStatus({
+      clusterName: App.router.get('content.cluster.name'),
+      clusterState: 'DEFAULT',
+      wizardControllerName: App.router.get('addHostController.name'),
+      localdb: App.db.data
+    });
+    router.transitionTo('hosts.index');
+  },
+
   enter: function (router) {
     console.log('in /host/add:enter');
 
+    var self = this;
+
     Ember.run.next(function () {
       var addHostController = router.get('addHostController');
       App.router.get('updateController').set('isWorking', false);
@@ -43,15 +56,22 @@ module.exports = App.WizardRoute.extend({
           router.transitionTo('hosts.index');
         },
         onClose: function() {
-          this.hide();
-          App.router.get('updateController').set('isWorking', true);
-          App.clusterStatus.setClusterStatus({
-            clusterName: App.router.get('content.cluster.name'),
-            clusterState: 'DEFAULT',
-            wizardControllerName: App.router.get('addHostController.name'),
-            localdb: App.db.data
-          });
-          router.transitionTo('hosts.index');
+          if (addHostController.get('currentStep') == '6') {
+            App.ModalPopup.show({
+              header: Em.I18n.t('hosts.add.exit.header'),
+              body: Em.I18n.t('hosts.add.exit.body'),
+              onPrimary: function () {
+                this.hide();
+                addHostController.finish();
+                App.router.get('updateController').set('isWorking', true);
+                self.clearData(router);
+                location.reload();
+              }
+            });
+          } else {
+            this.hide();
+            self.clearData(router);
+          }
         },
         didInsertElement: function(){
           this.fitHeight();