Преглед изворни кода

AMBARI-9216 Versions: multiple issues with versions in Hosts pages. (ababiichuk)

aBabiichuk пре 10 година
родитељ
комит
e9ecb672a3

+ 3 - 0
ambari-web/app/controllers/global/cluster_controller.js

@@ -286,6 +286,9 @@ App.ClusterController = Em.Controller.extend({
       self.updateLoadStatus('stackComponents');
       updater.updateServices(function () {
         self.updateLoadStatus('services');
+        //force clear filters  for hosts page to load all data
+        App.db.setFilterConditions('mainHostController', null);
+
         updater.updateHost(function () {
           self.updateLoadStatus('hosts');
         });

+ 11 - 3
ambari-web/app/controllers/main/host.js

@@ -57,6 +57,7 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
     return this.get('dataSource').filterProperty('isRequested');
   }.property('dataSource.@each.isRequested'),
 
+  allHostStackVersions: App.HostStackVersion.find(),
   /**
    * filterProperties support follow types of filter:
    * MATCH - match of RegExp
@@ -123,8 +124,13 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
       type: 'MULTIPLE'
     },
     {
-      name: 'stackVersions',
-      key: 'stack_versions/HostStackVersions',
+      name: 'repositoryVersion',
+      key: 'stack_versions/repository_versions/RepositoryVersions/repository_version',
+      type: 'EQUAL'
+    },
+    {
+      name: 'hostStackVersionState',
+      key: 'stack_versions/HostStackVersions/state',
       type: 'EQUAL'
     }
   ],
@@ -931,7 +937,9 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
     associations[8] = 'componentsWithStaleConfigsCount';
     associations[9] = 'componentsInPassiveStateCount';
     associations[10] = 'selected';
-    associations[11] = 'stackVersions.repoVersion';
+    associations[11] = 'hostStackVersion';
+    associations[12] = 'repositoryVersion';
+    associations[13] = 'hostStackVersionState';
     return associations;
   }.property()
 

+ 2 - 0
ambari-web/app/messages.js

@@ -1976,6 +1976,7 @@ Em.I18n.translations = {
   'hosts.host.serviceNotAvailable': 'Service not available on this host',
 
   'hosts.host.menu.stackVersions': 'Versions',
+  'hosts.host.stackVersions.table.allVersions': 'All Versions',
   'hosts.host.stackVersions.table.noVersions': 'No versions',
   'hosts.host.stackVersions.table.filteredInfo': '{0} of {1} versions showing',
   'hosts.host.stackVersions.status.init': 'Uninstalled',
@@ -1983,6 +1984,7 @@ Em.I18n.translations = {
   'hosts.host.stackVersions.status.install_failed': 'Install Failed',
   'hosts.host.stackVersions.status.installing': 'Installing',
   'hosts.host.stackVersions.status.current': 'Current',
+  'hosts.host.stackVersions.status.out_of_sync': 'Out of sync',
 
   'hosts.host.metrics.dataUnavailable':'Data Unavailable',
   'hosts.host.metrics.cpu':'CPU Usage',

+ 20 - 0
ambari-web/app/mixins/common/table_server_view_mixin.js

@@ -67,6 +67,26 @@ App.TableServerViewMixin = Em.Mixin.create({
   }.property('filteredContent'),
   /**
    * compute applied filters and run content update from server
+   * @param filterObjects
+   */
+  updateFilters: function(filterObjects) {
+    this.set('controller.resetStartIndex', false);
+    filterObjects.forEach(function(filterObject) {
+      this.saveFilterConditions(filterObject.iColumn, filterObject.value, filterObject.type, false);
+    }, this);
+    if (!this.get('filteringComplete')) {
+      clearTimeout(this.get('timeOut'));
+      this.set('timeOut', setTimeout(function () {
+        self.updateFilters(filterObjects);
+      }, this.get('filterWaitingTime')));
+    } else {
+      clearTimeout(this.get('timeOut'));
+      this.set('controller.resetStartIndex', true);
+      this.refresh();
+    }
+  },
+  /**
+   * compute applied filter and run content update from server
    * @param iColumn
    * @param value
    * @param type

+ 12 - 21
ambari-web/app/views/main/host.js

@@ -598,8 +598,9 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
      * @returns {String}
      */
     currentVersion: function() {
-      var repoVersion = this.get('content.stackVersions').findProperty('isCurrent');
-      return repoVersion.get('repoVersion') + " (" + repoVersion.get('displayStatus') + ")";
+      var currentRepoVersion = this.get('content.stackVersions').findProperty('isCurrent');
+      var version = currentRepoVersion ? currentRepoVersion : this.get('content.stackVersions').filterProperty('isCurrent', false)[0];
+      return version.get('repoVersion') + " (" + version.get('displayStatus') + ")";
     }.property('content.stackVersions'),
 
     /**
@@ -1019,26 +1020,28 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
       value: [],
 
       versionSelectView: filters.createSelectView({
+        column: 12,
         classNames: ['notActive'],
         fieldType: 'filter-input-width',
         content: function () {
           return  [
             {
               value: '',
-              label: Em.I18n.t('common.all')
+              label: Em.I18n.t('hosts.host.stackVersions.table.allVersions')
             }
-          ].concat(App.HostStackVersion.find().mapProperty('version').uniq().map(function (version) {
+          ].concat(this.get('controller.allHostStackVersions').mapProperty('repoVersion').uniq().map(function (version) {
             return {
               value: version,
               label: version
             }
           }));
-        }.property('App.router.clusterController.isLoaded'),
+        }.property('App.router.clusterController.isLoaded', 'controller.allHostStackVersions.length'),
         onChangeValue: function () {
           this.set('parentView.selectedVersion', this.get('value'));
         }
       }),
       statusSelectView: filters.createSelectView({
+        column: 13,
         classNames: ['notActive'],
         fieldType: 'filter-input-width',
         content: function () {
@@ -1065,19 +1068,10 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
         this._super();
         var self = this;
         var filterProperties = [];
-        if (this.get('selectedVersion')) {
-          filterProperties.push({
-            property: 'version',
-            value: this.get('selectedVersion')
-          });
-        }
-        if (this.get('selectedStatus')) {
-          filterProperties.push({
-            property: 'state',
-            value: this.get('selectedStatus')
-          });
-        }
-        self.set('value', filterProperties);
+        var filters = [];
+        filters.pushObject({ iColumn: 12, value: this.get('selectedVersion')});
+        filters.pushObject({ iColumn: 13, value: this.get('selectedStatus')});
+        this.get('parentView.parentView').updateFilters(filters);
       },
       /**
        * Clear filter to initial state
@@ -1089,9 +1083,6 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
         });
       }
     }),
-    onChangeValue: function () {
-      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'sub-resource');
-    },
     clearFilter: function () {
       this._super();
       this.get('childViews').forEach(function (view) {

+ 1 - 1
ambari-web/app/views/main/host/stack_versions_view.js

@@ -118,7 +118,7 @@ App.MainHostStackVersionsView = App.TableView.extend({
       return [
         {
           value: '',
-          label: Em.I18n.t('common.all')
+          label: Em.I18n.t('hosts.host.stackVersions.table.allVersions')
         }
       ].concat(this.get('parentView.content').mapProperty('repoVersion').uniq().map(function (version) {
         return {