浏览代码

AMBARI-4592. Host Details page: When heartbeat is lost, Client action pulldown should be disabled. (onechiporenko)

Oleg Nechiporenko 11 年之前
父节点
当前提交
49bcf0fa03

+ 2 - 2
ambari-web/app/models/host.js

@@ -185,11 +185,11 @@ App.Host = DS.Model.extend({
   }.property('memory'),
 
   /**
-   * Return true if the host has not sent heartbeat within the last 180 seconds
+   * Return true if the host <code>healthStatus</code> is UNKNOWN
    * @returns {bool}
    */
   isNotHeartBeating : function() {
-    return (App.testMode) ? false : ((new Date()).getTime() - this.get('lastHeartBeatTime')) > 180 * 1000;
+    return (App.testMode) ? false : (this.get('healthStatus') === "UNKNOWN");
   }.property('lastHeartBeatTime'),
 
   /**

+ 1 - 1
ambari-web/app/templates/main/host/summary.hbs

@@ -77,7 +77,7 @@
             <div class="span5 row">
               {{#if App.isAdmin}}
                 <div class="btn-group pull-right">
-                  <button id="add_component" data-toggle="dropdown" {{bindAttr class=":btn :dropdown-toggle"}}>
+                  <button id="add_component" data-toggle="dropdown" {{bindAttr class=":btn :dropdown-toggle controller.content.isNotHeartBeating:disabled"}}>
                     {{t common.installed}}
                     <span class="caret pull-right"></span>
                   </button>

+ 4 - 2
ambari-web/test/models/host_test.js

@@ -51,7 +51,9 @@ describe('App.Host', function () {
       last_heart_beat_time: (new Date()).getTime()
     }
   ];
-  App.set('testMode', false);
+  before(function() {
+    App.set('testMode', false);
+  });
   App.store.loadMany(App.Host, data);
 
   describe('#diskUsedFormatted', function () {
@@ -109,7 +111,7 @@ describe('App.Host', function () {
     });
     it('host3 - false', function () {
       var host = App.Host.find().findProperty('hostName', 'host3');
-      expect(host.get('isNotHeartBeating')).to.equal(false);
+      expect(host.get('isNotHeartBeating')).to.equal(true);
     });
   });