فهرست منبع

AMBARI-6355 cause host page hang with range filter. (atkach)

atkach 11 سال پیش
والد
کامیت
9a85b8b7c9

+ 13 - 4
ambari-web/app/controllers/global/update_controller.js

@@ -168,7 +168,11 @@ App.UpdateController = Em.Controller.extend({
     this.get('queryParams').set('Hosts', App.router.get('mainHostController').getQueryParameters());
     var clientCallback = function (skipCall, queryParams) {
       if (skipCall) {
-        App.hostsMapper.map({items: []});
+        //no hosts match filter by component
+        App.hostsMapper.map({
+          items: [],
+          itemTotal: '0'
+        });
         callback();
       } else {
         var hostsUrl = self.getComplexUrl(testUrl, realUrl, queryParams);
@@ -226,14 +230,19 @@ App.UpdateController = Em.Controller.extend({
     var preLoadKeys = this.get('hostsPreLoadKeys');
     var queryParams = this.get('queryParams.Hosts');
     var hostNames = data.items.mapProperty('Hosts.host_name');
+    var skipCall = hostNames.length === 0;
+
+    /**
+     * exclude pagination parameters as they were applied in previous call
+     * to obtain hostnames of filtered hosts
+     */
+    preLoadKeys.pushObjects(['page_size', 'from']);
 
     var itemTotal = parseInt(data.itemTotal);
-    if (!isNaN(itemTotal) && itemTotal!==undefined && itemTotal!==null) {
+    if (!isNaN(itemTotal)) {
       App.router.set('mainHostController.filteredCount', itemTotal);
-      App.router.set('mainHostController.setFilteredCount', false);
     }
 
-    var skipCall = hostNames.length === 0;
     if (skipCall) {
       params.callback(skipCall);
     } else {

+ 0 - 4
ambari-web/app/controllers/main/host.js

@@ -27,10 +27,6 @@ App.MainHostController = Em.ArrayController.extend({
   clearFilters: null,
 
   filteredCount: 0,
-
-  // either set <code>filteredCount</code> property in hosts mapper, or it will be set in <code>getHostByHostComponentsSuccessCallback</code>
-  setFilteredCount: true,
-
   resetStartIndex: false,
   /**
    * flag responsible for updating status counters of hosts

+ 1 - 6
ambari-web/app/mappers/hosts_mapper.js

@@ -107,14 +107,9 @@ App.hostsMapper = App.QuickDataMapper.create({
       App.store.commit();
       App.store.loadMany(App.HostComponent, components);
       App.store.loadMany(App.Host, hostsWithFullInfo);
-
-      // check if <code>mainHostController.filteredCount</code> is already set in <code>getHostByHostComponentsSuccessCallback</code>
-      var setFilteredCount = App.router.get('mainHostController.setFilteredCount');
       var itemTotal = parseInt(json.itemTotal);
-      if (setFilteredCount && !isNaN(itemTotal) && itemTotal!==undefined && itemTotal!==null) {
+      if (!isNaN(itemTotal)) {
         App.router.set('mainHostController.filteredCount', itemTotal);
-      } else {
-        App.router.set('mainHostController.setFilteredCount', true);
       }
     }
     console.timeEnd('App.hostsMapper execution time');