Browse Source

AMBARI-6456. Browsing to Hosts page doesn't show default sort order.(xiwang)

Xi Wang 11 years ago
parent
commit
959c0d0fe6
1 changed files with 15 additions and 3 deletions
  1. 15 3
      ambari-web/app/views/common/sort_view.js

+ 15 - 3
ambari-web/app/views/common/sort_view.js

@@ -193,10 +193,9 @@ var serverWrapperView = Em.View.extend({
 
   loadSortStatuses: function () {
     var statuses = App.db.getSortingStatuses(this.get('controller.name'));
-
+    var childViews = this.get('childViews');
+    var self = this;
     if (statuses) {
-      var childViews = this.get('childViews');
-      var self = this;
       statuses.forEach(function (st) {
         if (st.status !== 'sorting') {
           self.get('childViews').findProperty('name', childViews.findProperty('name', st.name).get('name')).set('status', st.status);
@@ -206,6 +205,19 @@ var serverWrapperView = Em.View.extend({
           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);
+      });
+      App.db.setSortingStatuses(self.get('controller.name'), statuses);
+      self.get('controller').set('sortingColumn', childViews.findProperty('name', 'publicHostName'));
     }
   },