Просмотр исходного кода

AMBARI-3923.Stale configs on Clients don't affect on Start/Stop Components buttons. (akovalenko)

Aleksandr Kovalenko 11 лет назад
Родитель
Сommit
82bb2103db

+ 24 - 9
ambari-web/app/controllers/main/service/info/configs.js

@@ -1744,13 +1744,13 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
   restartComponents: function(e) {
     var commandName = "stop_component";
-    if(e.context) {
-      if(this.get('content.healthStatus') != 'green'){
+    if (e.context) {
+      if (!this.get('content.hostComponents').filterProperty('staleConfigs').findProperty('workStatus', 'STARTED')) {
         return;
       }
-    }else {
+    } else {
       commandName = "start_component";
-      if(this.get('content.healthStatus') != 'red'){
+      if (!this.get('content.hostComponents').filterProperty('staleConfigs').findProperty('workStatus', 'INSTALLED')) {
         return;
       }
     };
@@ -1764,16 +1764,31 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       onPrimary: function () {
         var selectedService = this.content.get('content.id');
         var hostComponents = App.HostComponent.find().filterProperty('service.id', selectedService).filterProperty('staleConfigs', true)
-        hostComponents.forEach(function(item){
-          var componentName = item.get('componentName');
-          var hostName = item.get('host.hostName');
+        hostComponents.forEach(function (item) {
+          var state = 'INSTALLED',
+              componentName = item.get('componentName'),
+              context = "Stop " + App.format.role(componentName),
+              hostName = item.get('host.hostName');
+
+          if (commandName === 'start_component') {
+            context = "Start " + App.format.role(componentName);
+            state = 'STARTED';
+            if (item.get('isClient')) {
+              //start components action includes install of clients
+              context = "Install " + App.format.role(componentName);
+              state = "INSTALLED";
+            }
+          } else if (item.get('isClient')) {
+            return false;
+          }
           App.ajax.send({
-            name: 'config.stale.'+commandName,
+            name: 'host.host_component.action',
             sender: this,
             data: {
               hostName: hostName,
               componentName: componentName,
-              displayName: App.format.role(componentName)
+              context: context,
+              state: state
             }
           });
         })

+ 0 - 38
ambari-web/app/utils/ajax.js

@@ -289,44 +289,6 @@ var urls = {
       }
     }
   },
-  'config.stale.stop_component': {
-    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
-    'mock': '',
-    'type': 'PUT',
-    'format': function (data) {
-      return {
-        data: JSON.stringify({
-          RequestInfo: {
-            "context": "Stop " + data.displayName
-          },
-          Body: {
-            "HostRoles": {
-              "state": "INSTALLED"
-            }
-          }
-        })
-      }
-    }
-  },
-  'config.stale.start_component': {
-    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
-    'mock': '',
-    'type': 'PUT',
-    'format': function (data) {
-      return {
-        data: JSON.stringify({
-          RequestInfo: {
-            "context": "Start " + data.displayName
-          },
-          Body: {
-            "HostRoles": {
-              "state": "STARTED"
-            }
-          }
-        })
-      }
-    }
-  },
   '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',

+ 4 - 4
ambari-web/app/views/main/host/summary.js

@@ -39,22 +39,22 @@ App.MainHostSummaryView = Em.View.extend({
   }.property('content.hostComponents.@each.staleConfigs'),
 
   stopComponentsIsDisabled: function () {
-    var staleComponents = this.get('sortedComponents').filterProperty('staleConfigs', true);
+    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs', true);
     if(!staleComponents.findProperty('workStatus','STARTED')){
       return true;
     } else {
       return false;
     }
-  }.property('sortedComponents.@each.workStatus'),
+  }.property('content.hostComponents.@each.workStatus', 'content.hostComponents.@each.staleConfigs'),
 
   startComponentsIsDisabled:function () {
-    var staleComponents = this.get('sortedComponents').filterProperty('staleConfigs', true);
+    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs', true);
     if(!staleComponents.findProperty('workStatus','INSTALLED')){
       return true;
     } else {
       return false;
     }
-  }.property('sortedComponents.@each.workStatus'),
+  }.property('content.hostComponents.@each.workStatus', 'content.hostComponents.@each.staleConfigs'),
 
   needToRestartMessage: function() {
     var componentsCount, word;

+ 2 - 2
ambari-web/app/views/main/service/info/configs.js

@@ -31,7 +31,7 @@ App.MainServiceInfoConfigsView = Em.View.extend({
 
 
   stopComponentsIsDisabled: function () {
-    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true).filterProperty('isClient', false);
+    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true);
     if (!staleComponents.findProperty('workStatus', 'STARTED')) {
       return true;
     } else {
@@ -40,7 +40,7 @@ App.MainServiceInfoConfigsView = Em.View.extend({
   }.property('controller.content.hostComponents.@each.workStatus', 'controller.content.hostComponents.@each.staleConfigs'),
 
   startComponentsIsDisabled: function () {
-    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true).filterProperty('isClient', false);
+    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true);
     if (!staleComponents.findProperty('workStatus', 'INSTALLED')) {
       return true;
     } else {