Author: yusaku
Date: Mon Jun  3 19:12:11 2013
New Revision: 1489109

URL: http://svn.apache.org/r1489109
Log:
AMBARI-2259. Start/Stop button stays enabled for atleast 30-40 seconds after 
its been clicked already. (Oleg Nechiporenko via yusaku)

Modified:
    
incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js
    incubator/ambari/trunk/ambari-web/app/models/service.js
    incubator/ambari/trunk/ambari-web/app/views/main/service/item.js

Modified: 
incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js?rev=1489109&r1=1489108&r2=1489109&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
 (original)
+++ 
incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
 Mon Jun  3 19:12:11 2013
@@ -39,6 +39,7 @@ App.BackgroundOperationsController = Em.
    */
   startPolling: function(){
     if(this.get('isWorking')){
+      this.requestMostRecent();
       App.updater.run(this, 'requestMostRecent', 'isWorking', 
App.bgOperationsUpdateInterval);
     }
   }.observes('isWorking'),

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js?rev=1489109&r1=1489108&r2=1489109&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js 
(original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js Mon 
Jun  3 19:12:11 2013
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var service_components = require('data/service_components');
 
 App.MainServiceItemController = Em.Controller.extend({
   name: 'mainServiceItemController',
@@ -88,6 +89,7 @@ App.MainServiceItemController = Em.Contr
     }
     var self = this;
     App.showConfirmationPopup(function() {
+      self.set('content.isPending', true);
       self.startStopPopupPrimary(serviceHealth);
     });
   },
@@ -214,5 +216,33 @@ App.MainServiceItemController = Em.Contr
     if (methodName) {
       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')
+
 })
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-web/app/models/service.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/service.js?rev=1489109&r1=1489108&r2=1489109&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/service.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/service.js Mon Jun  3 19:12:11 
2013
@@ -31,13 +31,16 @@ App.Service = DS.Model.extend({
   serviceConfigsTemplate: App.config.get('preDefinedServiceConfigs'),
   runningHostComponents: null,
   isStartDisabled: function () {
+    if(this.get('isPending')) return true;
     return !(this.get('healthStatus') == 'red');
-  }.property('healthStatus'),
+  }.property('healthStatus','isPending'),
 
   isStopDisabled: function () {
+    if(this.get('isPending')) return true;
     return !(this.get('healthStatus') == 'green');
-  }.property('healthStatus'),
+  }.property('healthStatus','isPending'),
 
+  isPending:true,
   // Instead of making healthStatus a computed property that listens on 
[email protected],
   // 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

Modified: incubator/ambari/trunk/ambari-web/app/views/main/service/item.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/service/item.js?rev=1489109&r1=1489108&r2=1489109&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/service/item.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/service/item.js Mon Jun  3 
19:12:11 2013
@@ -70,5 +70,9 @@ App.MainServiceItemView = Em.View.extend
   }.property('maintenance'),
   hasConfigTab: function(){
     return this.get("controller.content.isConfigurable");
-  }.property('controller.content.isConfigurable')
+  }.property('controller.content.isConfigurable'),
+
+  didInsertElement: function () {
+    this.get('controller').setStartStopState();
+  }
 });
\ No newline at end of file


Reply via email to