Quellcode durchsuchen

AMBARI-6462. Filter should be cleared when user clicks on Hosts in the top bar.(xiwang)

Xi Wang vor 11 Jahren
Ursprung
Commit
fa1a119fff

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

@@ -766,6 +766,7 @@ module.exports = Em.Route.extend({
     if (!component.context)
       return;
     router.get('mainHostController').filterByComponent(component.context);
+    router.get('mainHostController').set('showFilterConditionsFirstLoad', true);
     router.transitionTo('hosts.index');
   },
   showDetails: function (router, event) {

+ 13 - 25
ambari-web/app/views/common/sort_view.js

@@ -191,34 +191,22 @@ var serverWrapperView = Em.View.extend({
     this.loadSortStatuses();
   },
 
+  /**
+   * Initialize and save sorting statuses: publicHostName sorting_asc
+   */
   loadSortStatuses: function () {
-    var statuses = App.db.getSortingStatuses(this.get('controller.name'));
+    var statuses = [];
     var childViews = this.get('childViews');
-    var self = this;
-    if (statuses) {
-      statuses.forEach(function (st) {
-        if (st.status !== 'sorting') {
-          self.get('childViews').findProperty('name', childViews.findProperty('name', st.name).get('name')).set('status', st.status);
-          self.saveSortStatuses();
-          self.get('controller').set('sortingColumn', childViews.findProperty('name', st.name));
-        } else {
-          childViews.findProperty('name', st.name).set('status', st.status);
-        }
-      });
-    } else {
-      // setup and save initial sort statuses when first login : publicHostName sorting_asc, used only once
-      var statuses = [];
-      childViews.forEach(function (childView) {
-        var sortStatus = (childView.get('name') == 'publicHostName' && childView.get('status') == 'sorting') ? 'sorting_asc' : childView.get('status');
-        statuses.push({
-          name: childView.get('name'),
-          status: sortStatus
-        });
-        childView.set('status', sortStatus);
+    childViews.forEach(function (childView) {
+      var sortStatus = (childView.get('name') == 'publicHostName' && childView.get('status') == 'sorting') ? 'sorting_asc' : childView.get('status');
+      statuses.push({
+        name: childView.get('name'),
+        status: sortStatus
       });
-      App.db.setSortingStatuses(self.get('controller.name'), statuses);
-      self.get('controller').set('sortingColumn', childViews.findProperty('name', 'publicHostName'));
-    }
+      childView.set('status', sortStatus);
+    });
+    App.db.setSortingStatuses(this.get('controller.name'), statuses);
+    this.get('controller').set('sortingColumn', childViews.findProperty('name', 'publicHostName'));
   },
 
   /**

+ 2 - 3
ambari-web/app/views/common/table_view.js

@@ -90,11 +90,10 @@ App.TableView = Em.View.extend(App.UserPref, {
     var name = this.get('controller.name');
     var self = this;
     var filterConditions = App.db.getFilterConditions(name);
-    if (filterConditions) {
+    if ((filterConditions && name != 'mainHostController') || (filterConditions && this.get('controller.showFilterConditionsFirstLoad'))) {
       this.set('filterConditions', filterConditions);
-
+      this.get('controller').set('showFilterConditionsFirstLoad', false);
       var childViews = this.get('childViews');
-
       filterConditions.forEach(function (condition, index, filteredConditions) {
         var view = !Em.isNone(condition.iColumn) && childViews.findProperty('column', condition.iColumn);
         if (view) {