You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/06/07 20:20:53 UTC

svn commit: r1490769 - in /incubator/ambari/trunk/ambari-web/app: controllers/main/service/item.js models/service.js templates/main/service/item.hbs

Author: yusaku
Date: Fri Jun  7 18:20:53 2013
New Revision: 1490769

URL: http://svn.apache.org/r1490769
Log:
AMBARI-2259. Start/Stop button may stay enabled for 30-40 seconds after it has been clicked. (Oleg Nechiporenko via yusaku)

Modified:
    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/templates/main/service/item.hbs

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=1490769&r1=1490768&r2=1490769&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 Fri Jun  7 18:20:53 2013
@@ -89,7 +89,7 @@ App.MainServiceItemController = Em.Contr
     }
     var self = this;
     App.showConfirmationPopup(function() {
-      self.set('content.isPending', true);
+      self.set('isPending', true);
       self.startStopPopupPrimary(serviceHealth);
     });
   },
@@ -112,8 +112,8 @@ App.MainServiceItemController = Em.Contr
         'state': serviceHealth
       }
     });
-    this.set('content.isStopDisabled',true);
-    this.set('content.isStartDisabled',true);
+    this.set('isStopDisabled',true);
+    this.set('isStartDisabled',true);
   },
 
   /**
@@ -222,27 +222,40 @@ App.MainServiceItemController = Em.Contr
     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;
-                                }
+        if(backgroundOperations.length>0) {
+            for (var i = 0; i < backgroundOperations.length; i++) {
+                var hosts = backgroundOperations[i].hosts;
+                for (var j = 0; j < hosts.length; j++) {
+                    var logTasks = hosts[j].logTasks;
+                    for (var k = 0; k < logTasks.length; k++) {
+                        var service = service_components.findProperty('component_name', logTasks[k].Tasks.role);
+                        if (service && serviceName == service.service_name) {
+                            if (logTasks[k].Tasks.status == 'PENDING' || logTasks[k].Tasks.status == 'IN_PROGRESS' || logTasks[k].Tasks.status == 'QUEUED') {
+                                this.set('isPending', true);
+                                return;
                             }
                         }
-                    }, this)
-                }, this)
-            }, this)
+                    }
+                }
+            }
+            this.set('isPending', false);
         }
         else {
-            this.set('content.isPending', true);
+            this.set('isPending', true);
         }
-    }.observes('App.router.backgroundOperationsController.serviceTimestamp')
+
+    }.observes('App.router.backgroundOperationsController.serviceTimestamp'),
+
+  isStartDisabled: function () {
+    if(this.get('isPending')) return true;
+    return !(this.get('content.healthStatus') == 'red');
+  }.property('content.healthStatus','isPending'),
+
+  isStopDisabled: function () {
+    if(this.get('isPending')) return true;
+    return !(this.get('content.healthStatus') == 'green');
+  }.property('content.healthStatus','isPending'),
+
+  isPending:true
 
 })
\ 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=1490769&r1=1490768&r2=1490769&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/service.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/service.js Fri Jun  7 18:20:53 2013
@@ -30,17 +30,7 @@ App.Service = DS.Model.extend({
   hostComponents: DS.hasMany('App.HostComponent'),
   serviceConfigsTemplate: App.config.get('preDefinedServiceConfigs'),
   runningHostComponents: null,
-  isStartDisabled: function () {
-    if(this.get('isPending')) return true;
-    return !(this.get('healthStatus') == 'red');
-  }.property('healthStatus','isPending'),
-
-  isStopDisabled: function () {
-    if(this.get('isPending')) return true;
-    return !(this.get('healthStatus') == 'green');
-  }.property('healthStatus','isPending'),
 
-  isPending:true,
   // 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
   // only once after the run loop.  This is because Ember invokes the computed property every time

Modified: incubator/ambari/trunk/ambari-web/app/templates/main/service/item.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/service/item.hbs?rev=1490769&r1=1490768&r2=1490769&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/service/item.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/service/item.hbs Fri Jun  7 18:20:53 2013
@@ -28,19 +28,19 @@
       <ul class="dropdown-menu">
         <!-- dropdown menu links -->
         {{#each option in view.maintenance}}
-        <li {{bindAttr class="controller.content.isStopDisabled:disabled"}}>
+        <li {{bindAttr class="controller.isStopDisabled:disabled"}}>
           <a {{action "doAction" option target="controller" href=true}}>{{option.label}}</a>
         </li>
         {{/each}}
       </ul>
     </div>
   {{/if}}
-  <a href="javascript:void(null)" {{bindAttr class=":btn controller.content.isStartDisabled:disabled:btn-success" }}
+  <a href="javascript:void(null)" {{bindAttr class=":btn controller.isStartDisabled:disabled:btn-success" }}
      data-toggle="modal" {{action "startService" target="controller"}}>
     <i class="icon-play"></i>
     {{t services.service.start}}
   </a>
-  <a href="javascript:void(null)" {{bindAttr class=":btn controller.content.isStopDisabled:disabled:btn-danger" }}
+  <a href="javascript:void(null)" {{bindAttr class=":btn controller.isStopDisabled:disabled:btn-danger" }}
      data-toggle="modal" {{action "stopService" target="controller"}}>
     <i class="icon-stop icon-white"></i>
     {{t services.service.stop}}