瀏覽代碼

AMBARI-10537. Service Actions menu: after page refresh, slaves rolling restart and download configs items appear with delay (alexantonenko)

Alex Antonenko 10 年之前
父節點
當前提交
34e60b07ff

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

@@ -407,6 +407,7 @@ App.UpdateController = Em.Controller.extend({
     };
     };
     App.HttpClient.get(servicesUrl, App.serviceMetricsMapper, {
     App.HttpClient.get(servicesUrl, App.serviceMetricsMapper, {
       complete: function () {
       complete: function () {
+        App.set('router.mainServiceItemController.isServicesInfoLoaded', App.get('router.clusterController.isLoaded'));
         callback();
         callback();
       }
       }
     });
     });

+ 2 - 0
ambari-web/app/controllers/main/service/item.js

@@ -45,6 +45,8 @@ App.MainServiceItemController = Em.Controller.extend({
     }
     }
   },
   },
 
 
+  isServicesInfoLoaded: false,
+
   initHosts: function() {
   initHosts: function() {
     if (App.get('components.masters').length !== 0) {
     if (App.get('components.masters').length !== 0) {
       var self = this;
       var self = this;

+ 1 - 0
ambari-web/app/routes/main.js

@@ -614,6 +614,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         route: '/summary',
         route: '/summary',
         connectOutlets: function (router, context) {
         connectOutlets: function (router, context) {
           var item = router.get('mainServiceItemController.content');
           var item = router.get('mainServiceItemController.content');
+          router.get('updateController').updateServiceMetric(Em.K);
           //if service is not existed then route to default service
           //if service is not existed then route to default service
           if (item.get('isLoaded')) {
           if (item.get('isLoaded')) {
             router.get('mainServiceItemController').connectOutlet('mainServiceInfoSummary', item);
             router.get('mainServiceItemController').connectOutlet('mainServiceInfoSummary', item);

+ 0 - 4
ambari-web/app/views/main/service/info/summary.js

@@ -526,10 +526,6 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, {
     return gangliaUrl;
     return gangliaUrl;
   }.property('App.router.clusterController.gangliaUrl', 'service.serviceName'),
   }.property('App.router.clusterController.gangliaUrl', 'service.serviceName'),
 
 
-  willInsertElement: function () {
-    App.router.get('updateController').updateServiceMetric(Em.K);
-  },
-
   didInsertElement: function () {
   didInsertElement: function () {
     var svcName = this.get('service.serviceName');
     var svcName = this.get('service.serviceName');
     var isMetricsSupported = svcName != 'STORM' || App.get('isStormMetricsSupported');
     var isMetricsSupported = svcName != 'STORM' || App.get('isStormMetricsSupported');

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

@@ -96,7 +96,7 @@ App.MainServiceItemView = Em.View.extend({
   isMaintenanceSet: false,
   isMaintenanceSet: false,
 
 
   observeMaintenance: function() {
   observeMaintenance: function() {
-    if (!this.get('isMaintenanceSet')) {
+    if (!this.get('isMaintenanceSet') && this.get('controller.isServicesInfoLoaded')) {
       this.observeMaintenanceOnce();
       this.observeMaintenanceOnce();
     }
     }
     Em.run.once(this, 'clearIsMaintenanceSet');
     Em.run.once(this, 'clearIsMaintenanceSet');
@@ -257,12 +257,14 @@ App.MainServiceItemView = Em.View.extend({
     this.addObserver('controller.isStopDisabled', this, 'observeMaintenance');
     this.addObserver('controller.isStopDisabled', this, 'observeMaintenance');
     this.addObserver('controller.isClientsOnlyService', this, 'observeMaintenance');
     this.addObserver('controller.isClientsOnlyService', this, 'observeMaintenance');
     this.addObserver('controller.content.isRestartRequired', this, 'observeMaintenance');
     this.addObserver('controller.content.isRestartRequired', this, 'observeMaintenance');
+    this.addObserver('controller.isServicesInfoLoaded', this, 'observeMaintenance');
   },
   },
 
 
   willDestroyElement: function() {
   willDestroyElement: function() {
     this.removeObserver('controller.isStopDisabled', this, 'observeMaintenance');
     this.removeObserver('controller.isStopDisabled', this, 'observeMaintenance');
     this.removeObserver('controller.isClientsOnlyService', this, 'observeMaintenance');
     this.removeObserver('controller.isClientsOnlyService', this, 'observeMaintenance');
     this.removeObserver('controller.content.isRestartRequired', this, 'observeMaintenance');
     this.removeObserver('controller.content.isRestartRequired', this, 'observeMaintenance');
+    this.removeObserver('controller.isServicesInfoLoaded', this, 'observeMaintenance');
   },
   },
   service:function () {
   service:function () {
     var svc = this.get('controller.content');
     var svc = this.get('controller.content');

+ 50 - 0
ambari-web/test/views/main/service/item_test.js

@@ -66,6 +66,56 @@ describe('App.MainServiceItemView', function () {
 
 
   describe('#observeMaintenance', function () {
   describe('#observeMaintenance', function () {
 
 
+    var cases = [
+      {
+        isMaintenanceSet: true,
+        isServicesInfoLoaded: true,
+        observeMaintenanceOnceCallCount: 0,
+        title: 'actions array set, services info loaded'
+      },
+      {
+        isMaintenanceSet: true,
+        isServicesInfoLoaded: false,
+        observeMaintenanceOnceCallCount: 0,
+        title: 'actions array set, services info not loaded'
+      },
+      {
+        isMaintenanceSet: false,
+        isServicesInfoLoaded: true,
+        observeMaintenanceOnceCallCount: 1,
+        title: 'actions array not set, services info loaded'
+      },
+      {
+        isMaintenanceSet: false,
+        isServicesInfoLoaded: false,
+        observeMaintenanceOnceCallCount: 0,
+        title: 'actions array not set, services info not loaded'
+      }
+    ];
+
+    beforeEach(function () {
+      sinon.stub(view, 'observeMaintenanceOnce', Em.K);
+    });
+
+    afterEach(function () {
+      view.observeMaintenanceOnce.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.setProperties({
+          'isMaintenanceSet': item.isMaintenanceSet,
+          'controller.isServicesInfoLoaded': item.isServicesInfoLoaded
+        });
+        view.observeMaintenance();
+        expect(view.observeMaintenanceOnce.callCount).to.equal(item.observeMaintenanceOnceCallCount);
+      });
+    });
+
+  });
+
+  describe('#observeMaintenanceOnce', function () {
+
     var mastersExcludedCommands = {
     var mastersExcludedCommands = {
         NAMENODE: ["DECOMMISSION", "REBALANCEHDFS"],
         NAMENODE: ["DECOMMISSION", "REBALANCEHDFS"],
         RESOURCEMANAGER: ["DECOMMISSION", "REFRESHQUEUES"],
         RESOURCEMANAGER: ["DECOMMISSION", "REFRESHQUEUES"],