ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6441 Hosts page: the number of filtered hosts keeps flipping (unable to page; filtered hosts incorrect). (atkach)
Date Wed, 09 Jul 2014 17:54:24 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d3b8a5e9e -> 627e9261b


AMBARI-6441 Hosts page: the number of filtered hosts keeps flipping (unable to page; filtered
hosts incorrect). (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/627e9261
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/627e9261
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/627e9261

Branch: refs/heads/trunk
Commit: 627e9261bd33de123452fb52549820905dd96942
Parents: d3b8a5e
Author: atkach <atkach@hortonworks.com>
Authored: Wed Jul 9 20:54:05 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Jul 9 20:54:17 2014 +0300

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js | 33 ++++++++++++++------
 1 file changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/627e9261/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 6238658..7d21f1b 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -36,6 +36,8 @@ App.UpdateController = Em.Controller.extend({
    */
   hostsPreLoadKeys: ['host_components/HostRoles/component_name', 'host_components/HostRoles/stale_configs',
'host_components/HostRoles/maintenance_state'],
 
+  paginationKeys: ['page_size', 'from'],
+
   getUrl: function (testUrl, url) {
     return (App.get('testMode')) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName')
+ url;
   },
@@ -148,7 +150,7 @@ App.UpdateController = Em.Controller.extend({
   updateHost: function (callback, error) {
     var testUrl = App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hosts.json' : '/data/hosts/hosts.json',
       self = this,
-      p = '';
+      hostDetailsFilter = '';
     var realUrl = '/hosts?<parameters>fields=Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/total_mem,'
+
       'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,'
+
       'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,'
+
@@ -159,7 +161,7 @@ App.UpdateController = Em.Controller.extend({
     }
     else {
       if(App.router.get('currentState.name') == 'summary' && App.router.get('currentState.parentState.name')
== 'hostDetails') {
-        p = 'Hosts/host_name=' + App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/summary/)[1]
+ '&';
+        hostDetailsFilter = App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/summary/)[1];
         App.updater.updateInterval('updateHost', App.get('componentsUpdateInterval'));
       }
       else {
@@ -171,9 +173,19 @@ App.UpdateController = Em.Controller.extend({
       }
     }
     var mainHostController = App.router.get('mainHostController'),
-      viewProperties = mainHostController.getViewProperties(),
       sortProperties = mainHostController.getSortProperties();
-    this.get('queryParams').set('Hosts', mainHostController.getQueryParameters(true));
+    if (hostDetailsFilter) {
+      //if host details page opened then request info only of one displayed host
+      this.get('queryParams').set('Hosts', [
+        {
+          key: 'Hosts/host_name',
+          value: [hostDetailsFilter],
+          type: 'MULTIPLE'
+        }
+      ]);
+    } else {
+      this.get('queryParams').set('Hosts', mainHostController.getQueryParameters(true));
+    }
     var clientCallback = function (skipCall, queryParams) {
       if (skipCall) {
         //no hosts match filter by component
@@ -184,13 +196,16 @@ App.UpdateController = Em.Controller.extend({
         callback();
       }
       else {
-        var params = p + self.computeParameters(queryParams),
-          viewProps = self.computeParameters(viewProperties),
+        var params = self.computeParameters(queryParams),
+          paginationProps = self.computeParameters(queryParams.filter(function (param) {
+            return (this.get('paginationKeys').contains(param.key));
+          }, self)),
           sortProps = self.computeParameters(sortProperties);
-        if ((params.length + viewProps.length + sortProps.length) > 0) {
+
+        if ((params.length + paginationProps.length + sortProps.length) > 0) {
           realUrl = App.get('apiPrefix') + '/clusters/' + App.get('clusterName') +
             realUrl.replace('<parameters>', '') +
-            (viewProps.length > 0 ? '&' + viewProps.substring(0, viewProps.length
- 1) : '') +
+            (paginationProps.length > 0 ? '&' + paginationProps.substring(0, paginationProps.length
- 1) : '') +
             (sortProps.length > 0 ? '&' + sortProps.substring(0, sortProps.length
- 1) : '');
           App.HttpClient.get(realUrl, App.hostsMapper, {
             complete: callback,
@@ -263,7 +278,7 @@ App.UpdateController = Em.Controller.extend({
      * exclude pagination parameters as they were applied in previous call
      * to obtain hostnames of filtered hosts
      */
-    preLoadKeys.pushObjects(['page_size', 'from']);
+    preLoadKeys = preLoadKeys.concat(this.get('paginationKeys'));
 
     var itemTotal = parseInt(data.itemTotal);
     if (!isNaN(itemTotal)) {


Mime
View raw message