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/19 19:52:00 UTC

svn commit: r1494711 - in /incubator/ambari/branches/branch-1.4.0/ambari-web/app: controllers/global/background_operations_controller.js controllers/main/service/item.js models/service.js templates/main/service/item.hbs views/main/service/item.js

Author: yusaku
Date: Wed Jun 19 17:52:00 2013
New Revision: 1494711

URL: http://svn.apache.org/r1494711
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/branches/branch-1.4.0/ambari-web/app/controllers/global/background_operations_controller.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/item.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/models/service.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/main/service/item.hbs
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/main/service/item.js

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/global/background_operations_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/global/background_operations_controller.js?rev=1494711&r1=1494710&r2=1494711&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/global/background_operations_controller.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/global/background_operations_controller.js Wed Jun 19 17:52:00 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/branches/branch-1.4.0/ambari-web/app/controllers/main/service/item.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/item.js?rev=1494711&r1=1494710&r2=1494711&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/item.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/item.js Wed Jun 19 17:52:00 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('isPending', true);
       self.startStopPopupPrimary(serviceHealth);
     });
   },
@@ -110,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);
   },
 
   /**
@@ -211,5 +213,46 @@ 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) {
+            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.set('isPending', false);
+        }
+        else {
+            this.set('isPending', true);
+        }
+
+    }.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/branches/branch-1.4.0/ambari-web/app/models/service.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/models/service.js?rev=1494711&r1=1494710&r2=1494711&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/models/service.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/models/service.js Wed Jun 19 17:52:00 2013
@@ -30,13 +30,6 @@ App.Service = DS.Model.extend({
   hostComponents: DS.hasMany('App.HostComponent'),
   serviceConfigsTemplate: App.config.get('preDefinedServiceConfigs'),
   runningHostComponents: null,
-  isStartDisabled: function () {
-    return !(this.get('healthStatus') == 'red');
-  }.property('healthStatus'),
-
-  isStopDisabled: function () {
-    return !(this.get('healthStatus') == 'green');
-  }.property('healthStatus'),
 
   // 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

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/main/service/item.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/main/service/item.hbs?rev=1494711&r1=1494710&r2=1494711&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/main/service/item.hbs (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/main/service/item.hbs Wed Jun 19 17:52:00 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}}

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/main/service/item.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/main/service/item.js?rev=1494711&r1=1494710&r2=1494711&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/main/service/item.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/main/service/item.js Wed Jun 19 17:52:00 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