浏览代码

AMBARI-7359. Move Wizard should be disabled for single node cluster. (akovalenko)

Aleksandr Kovalenko 10 年之前
父节点
当前提交
24f0b47e52
共有 2 个文件被更改,包括 52 次插入45 次删除
  1. 1 0
      ambari-web/app/messages.js
  2. 51 45
      ambari-web/app/routes/reassign_master_routes.js

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

@@ -1459,6 +1459,7 @@ Em.I18n.translations = {
   'services.service.config_groups.switchGroupTextFull':'Switch to \'{0}\' host config group',
   'services.service.config_groups.switchGroupTextShort':'Switch to \'{0}\'',
   'services.reassign.closePopup':'Move {0} wizard is in progress. You must allow the wizard to complete for Ambari to be in usable state. If you choose to quit, you must follow manual instructions to complete or revert move {0} wizard as documented in the Ambari User Guide. Are you sure you want to exit the wizard?',
+  'services.reassign.error.fewHosts':'You must have at least 2 hosts in your cluster to run Move Wizard.',
 
   'services.reassign.step1.header':'Get Started',
   'services.reassign.step1.message1': 'This wizard will walk you through moving {0}.<br/>',

+ 51 - 45
ambari-web/app/routes/reassign_master_routes.js

@@ -34,56 +34,62 @@ module.exports = App.WizardRoute.extend({
 
   enter: function (router) {
     console.log('in /service/reassign:enter');
-    var context = this;
-    Em.run.next(function () {
-      var reassignMasterController = router.get('reassignMasterController');
-      App.router.get('updateController').set('isWorking', false);
-      var popup = App.ModalPopup.show({
-        classNames: ['full-width-modal'],
-        header: Em.I18n.t('services.reassign.header'),
-        bodyClass: App.ReassignMasterView.extend({
-          controller: reassignMasterController
-        }),
-        primary: Em.I18n.t('form.cancel'),
-        showFooter: false,
-        secondary: null,
+    if (App.router.get('mainHostController.hostsCountMap.TOTAL') > 1) {
+      var context = this;
+      Em.run.next(function () {
+        var reassignMasterController = router.get('reassignMasterController');
+        App.router.get('updateController').set('isWorking', false);
+        var popup = App.ModalPopup.show({
+          classNames: ['full-width-modal'],
+          header: Em.I18n.t('services.reassign.header'),
+          bodyClass: App.ReassignMasterView.extend({
+            controller: reassignMasterController
+          }),
+          primary: Em.I18n.t('form.cancel'),
+          showFooter: false,
+          secondary: null,
 
-        onPrimary: function () {
-          this.hide();
-          App.router.get('updateController').set('isWorking', true);
-          App.router.transitionTo('main.services.index');
-        },
-        onClose: function () {
-          var reassignMasterController = router.get('reassignMasterController');
-          var currStep = reassignMasterController.get('currentStep');
+          onPrimary: function () {
+            this.hide();
+            App.router.get('updateController').set('isWorking', true);
+            App.router.transitionTo('main.services.index');
+          },
+          onClose: function () {
+            var reassignMasterController = router.get('reassignMasterController');
+            var currStep = reassignMasterController.get('currentStep');
 
-          if (parseInt(currStep) > 3) {
-            var self = this;
-            App.showConfirmationPopup(function(){
-              router.get('reassignMasterWizardStep' + currStep + 'Controller').removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
-              context.leaveWizard(router,self);
-            }, Em.I18n.t('services.reassign.closePopup').format(reassignMasterController.get('content.reassign.display_name')));
-          } else {
-            context.leaveWizard(router,this);
+            if (parseInt(currStep) > 3) {
+              var self = this;
+              App.showConfirmationPopup(function () {
+                router.get('reassignMasterWizardStep' + currStep + 'Controller').removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
+                context.leaveWizard(router, self);
+              }, Em.I18n.t('services.reassign.closePopup').format(reassignMasterController.get('content.reassign.display_name')));
+            } else {
+              context.leaveWizard(router, this);
+            }
+          },
+          didInsertElement: function () {
+            this.fitHeight();
+          }
+        });
+        reassignMasterController.set('popup', popup);
+        reassignMasterController.loadSecurityEnabled();
+        reassignMasterController.loadComponentToReassign();
+        var currentClusterStatus = App.clusterStatus.get('value');
+        if (currentClusterStatus) {
+          switch (currentClusterStatus.clusterState) {
+            case 'REASSIGN_MASTER_INSTALLING' :
+              reassignMasterController.setCurrentStep(currentClusterStatus.localdb.ReassignMaster.currentStep);
+              break;
           }
-        },
-        didInsertElement: function () {
-          this.fitHeight();
         }
+        router.transitionTo('step' + reassignMasterController.get('currentStep'));
       });
-      reassignMasterController.set('popup', popup);
-      reassignMasterController.loadSecurityEnabled();
-      reassignMasterController.loadComponentToReassign();
-      var currentClusterStatus = App.clusterStatus.get('value');
-      if (currentClusterStatus) {
-        switch (currentClusterStatus.clusterState) {
-          case 'REASSIGN_MASTER_INSTALLING' :
-            reassignMasterController.setCurrentStep(currentClusterStatus.localdb.ReassignMaster.currentStep);
-            break;
-        }
-      }
-      router.transitionTo('step' + reassignMasterController.get('currentStep'));
-    });
+    } else {
+      App.showAlertPopup(Em.I18n.t('common.error'), Em.I18n.t('services.reassign.error.fewHosts'), function () {
+        router.transitionTo('main.services.index');
+      })
+    }
   },
 
   step1: Em.Route.extend({