Browse Source

AMBARI-2259. Start/Stop button stays enabled for atleast 30-40 seconds after its been clicked already. (Oleg Nechiporenko via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1489109 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
571a9bc251

+ 1 - 0
ambari-web/app/controllers/global/background_operations_controller.js

@@ -39,6 +39,7 @@ App.BackgroundOperationsController = Em.Controller.extend({
    */
    */
   startPolling: function(){
   startPolling: function(){
     if(this.get('isWorking')){
     if(this.get('isWorking')){
+      this.requestMostRecent();
       App.updater.run(this, 'requestMostRecent', 'isWorking', App.bgOperationsUpdateInterval);
       App.updater.run(this, 'requestMostRecent', 'isWorking', App.bgOperationsUpdateInterval);
     }
     }
   }.observes('isWorking'),
   }.observes('isWorking'),

+ 31 - 1
ambari-web/app/controllers/main/service/item.js

@@ -17,6 +17,7 @@
  */
  */
 
 
 var App = require('app');
 var App = require('app');
+var service_components = require('data/service_components');
 
 
 App.MainServiceItemController = Em.Controller.extend({
 App.MainServiceItemController = Em.Controller.extend({
   name: 'mainServiceItemController',
   name: 'mainServiceItemController',
@@ -88,6 +89,7 @@ App.MainServiceItemController = Em.Controller.extend({
     }
     }
     var self = this;
     var self = this;
     App.showConfirmationPopup(function() {
     App.showConfirmationPopup(function() {
+      self.set('content.isPending', true);
       self.startStopPopupPrimary(serviceHealth);
       self.startStopPopupPrimary(serviceHealth);
     });
     });
   },
   },
@@ -214,5 +216,33 @@ App.MainServiceItemController = Em.Controller.extend({
     if (methodName) {
     if (methodName) {
       this[methodName](context);
       this[methodName](context);
     }
     }
-  }
+    },
+
+
+    setStartStopState: function () {
+        var serviceName = this.get('content.serviceName');
+        var backgroundOperations = App.router.get('backgroundOperationsController.services');
+        if (backgroundOperations.length > 0) {
+            this.set('content.isPending', false);
+            backgroundOperations.forEach(function (services) {
+                services.hosts.forEach(function (hosts) {
+                    hosts.logTasks.forEach(function (logTasks) {
+                        var service = service_components.findProperty('component_name', logTasks.Tasks.role);
+                        if (service) {
+                            if (serviceName == service.service_name) {
+                                if (logTasks.Tasks.status == 'PENDING' || logTasks.Tasks.status == 'IN_PROGRESS') {
+                                    this.set('content.isPending', true);
+                                    return true;
+                                }
+                            }
+                        }
+                    }, this)
+                }, this)
+            }, this)
+        }
+        else {
+            this.set('content.isPending', true);
+        }
+    }.observes('App.router.backgroundOperationsController.serviceTimestamp')
+
 })
 })

+ 5 - 2
ambari-web/app/models/service.js

@@ -31,13 +31,16 @@ App.Service = DS.Model.extend({
   serviceConfigsTemplate: App.config.get('preDefinedServiceConfigs'),
   serviceConfigsTemplate: App.config.get('preDefinedServiceConfigs'),
   runningHostComponents: null,
   runningHostComponents: null,
   isStartDisabled: function () {
   isStartDisabled: function () {
+    if(this.get('isPending')) return true;
     return !(this.get('healthStatus') == 'red');
     return !(this.get('healthStatus') == 'red');
-  }.property('healthStatus'),
+  }.property('healthStatus','isPending'),
 
 
   isStopDisabled: function () {
   isStopDisabled: function () {
+    if(this.get('isPending')) return true;
     return !(this.get('healthStatus') == 'green');
     return !(this.get('healthStatus') == 'green');
-  }.property('healthStatus'),
+  }.property('healthStatus','isPending'),
 
 
+  isPending:true,
   // Instead of making healthStatus a computed property that listens on hostComponents.@each.workStatus,
   // Instead of making healthStatus a computed property that listens on hostComponents.@each.workStatus,
   // we are creating a separate observer _updateHealthStatus.  This is so that healthStatus is updated
   // we are creating a separate observer _updateHealthStatus.  This is so that healthStatus is updated
   // only once after the run loop.  This is because Ember invokes the computed property every time
   // only once after the run loop.  This is because Ember invokes the computed property every time

+ 5 - 1
ambari-web/app/views/main/service/item.js

@@ -70,5 +70,9 @@ App.MainServiceItemView = Em.View.extend({
   }.property('maintenance'),
   }.property('maintenance'),
   hasConfigTab: function(){
   hasConfigTab: function(){
     return this.get("controller.content.isConfigurable");
     return this.get("controller.content.isConfigurable");
-  }.property('controller.content.isConfigurable')
+  }.property('controller.content.isConfigurable'),
+
+  didInsertElement: function () {
+    this.get('controller').setStartStopState();
+  }
 });
 });