Pārlūkot izejas kodu

AMBARI-7309 UI should issue separate requests for starting service and disabling MM. (ababiichuk)

aBabiichuk 11 gadi atpakaļ
vecāks
revīzija
34ffd774c4

+ 24 - 12
ambari-web/app/controllers/main/service/item.js

@@ -157,20 +157,34 @@ App.MainServiceItemController = Em.Controller.extend({
 
     return App.showConfirmationFeedBackPopup(function(query, runMmOperation) {
       self.set('isPending', true);
-      self.startStopPopupPrimary(serviceHealth, query, runMmOperation);
+      self.startStopWithMmode(serviceHealth, query, runMmOperation);
     }, bodyMessage);
   },
 
-  startStopPopupPrimary: function (serviceHealth, query, runMmOperation) {
-    var requestInfo = "";
-    var turnOnMM = "ON";
-    if (serviceHealth == "STARTED") {
-      turnOnMM = "OFF";
-      requestInfo = App.BackgroundOperationsController.CommandContexts.START_SERVICE.format(this.get('content.serviceName'));
+
+  startStopWithMmode: function(serviceHealth, query, runMmOperation) {
+    var self = this;
+    if (runMmOperation) {
+      if (serviceHealth == "STARTED") {
+        this.startStopPopupPrimary(serviceHealth, query).complete(function() {
+          batchUtils.turnOnOffPassiveRequest("OFF", Em.I18n.t('passiveState.turnOff'), self.get('content.serviceName').toUpperCase());
+        });
+      } else {
+        batchUtils.turnOnOffPassiveRequest("ON", Em.I18n.t('passiveState.turnOn'), this.get('content.serviceName').toUpperCase()).complete(function() {
+          self.startStopPopupPrimary(serviceHealth, query);
+        })
+      }
     } else {
-      requestInfo = App.BackgroundOperationsController.CommandContexts.STOP_SERVICE.format(this.get('content.serviceName'));
+      this.startStopPopupPrimary(serviceHealth, query);
     }
 
+  },
+
+  startStopPopupPrimary: function (serviceHealth, query) {
+    var requestInfo = (serviceHealth == "STARTED")
+        ? App.BackgroundOperationsController.CommandContexts.START_SERVICE.format(this.get('content.serviceName'))
+        : App.BackgroundOperationsController.CommandContexts.STOP_SERVICE.format(this.get('content.serviceName'));
+
     var data = {
       'context': requestInfo,
       'serviceName': this.get('content.serviceName').toUpperCase(),
@@ -179,10 +193,8 @@ App.MainServiceItemController = Em.Controller.extend({
       },
       'query': query
     };
-    if (runMmOperation) {
-      data.ServiceInfo.maintenance_state = turnOnMM;
-    }
-    App.ajax.send({
+
+    return App.ajax.send({
       'name': 'common.service.update',
       'sender': this,
       'success': 'startStopPopupSuccessCallback',

+ 1 - 1
ambari-web/app/utils/batch_scheduled_requests.js

@@ -266,7 +266,7 @@ module.exports = {
   },
 
   turnOnOffPassiveRequest: function(state, message, serviceName, callback) {
-    App.ajax.send({
+    return App.ajax.send({
       'name': 'common.service.passive',
       'sender': {
         'successCallback': callback || defaultSuccessCallback,