فهرست منبع

AMBARI-5063. Filter and sorting preferences lost when visiting a Job (alexantonenko)

Alex Antonenko 11 سال پیش
والد
کامیت
00f951fd54

+ 1 - 1
ambari-web/app/controllers/main/jobs_controller.js

@@ -260,7 +260,7 @@ App.MainJobsController = Em.ArrayController.extend({
           var sortColumn = self.get('sortingColumn');
           var sortColumn = self.get('sortingColumn');
           if(sortColumn && sortColumn.get('status')){
           if(sortColumn && sortColumn.get('status')){
             var sortColumnStatus = sortColumn.get('status');
             var sortColumnStatus = sortColumn.get('status');
-            sortColumn.set('content', self.get('content'));
+            sortColumn.get('parentView').set('content', self.get('content'));
             sortColumn.get('parentView').sort(sortColumn, sortColumnStatus === "sorting_desc");
             sortColumn.get('parentView').sort(sortColumn, sortColumnStatus === "sorting_desc");
             sortColumn.set('status', sortColumnStatus);
             sortColumn.set('status', sortColumnStatus);
             self.set('content',sortColumn.get('parentView').get('content'));
             self.set('content',sortColumn.get('parentView').get('content'));

+ 4 - 4
ambari-web/app/templates/main/jobs.hbs

@@ -16,7 +16,7 @@
 * limitations under the License.
 * limitations under the License.
 }}
 }}
 
 
-{{#if controller.loaded}}
+
   <div id="jobs">
   <div id="jobs">
       <div class="jobs_head">
       <div class="jobs_head">
         <div>{{t menu.item.jobs}}</div>
         <div>{{t menu.item.jobs}}</div>
@@ -26,7 +26,7 @@
       </div>
       </div>
       <table id="jobs-table" class="table table-bordered table-striped">
       <table id="jobs-table" class="table table-bordered table-striped">
           <thead>
           <thead>
-          {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
+          {{#view view.sortView classNames="label-row" contentBinding="controller.content"}}
               <th></th>
               <th></th>
               {{view view.parentView.idSort}}
               {{view view.parentView.idSort}}
               {{view view.parentView.userSort}}
               {{view view.parentView.userSort}}
@@ -50,7 +50,7 @@
                 <td class="no-data" {{bindAttr colspan="controller.columnsName.content.length"}}>{{t jobs.nothingToShow}}</td>
                 <td class="no-data" {{bindAttr colspan="controller.columnsName.content.length"}}>{{t jobs.nothingToShow}}</td>
               </tr>
               </tr>
           {{else}}
           {{else}}
-            {{#each job in view.pageContent}}
+            {{#each job in controller.content}}
               <tr>
               <tr>
                 <td>
                 <td>
                   {{#if job.failed}}
                   {{#if job.failed}}
@@ -93,4 +93,4 @@
           </div>
           </div>
       </div>
       </div>
   </div>
   </div>
-{{/if}}
+

+ 0 - 2
ambari-web/app/views/common/filter_view.js

@@ -59,7 +59,6 @@ var wrapperView = Ember.View.extend({
   },
   },
 
 
   setValueOnApply: function() {
   setValueOnApply: function() {
-    this.set('disabled', true);
     if(this.get('value') == null){
     if(this.get('value') == null){
       this.set('value', '')
       this.set('value', '')
     }
     }
@@ -235,7 +234,6 @@ module.exports = {
    * @param config parameters of <code>wrapperView</code>
    * @param config parameters of <code>wrapperView</code>
    */
    */
   createTextView : function(config){
   createTextView : function(config){
-
     config.fieldType = config.fieldType || 'input-medium';
     config.fieldType = config.fieldType || 'input-medium';
     config.filterView = textFieldView.extend({
     config.filterView = textFieldView.extend({
       classNames : [ config.fieldType ]
       classNames : [ config.fieldType ]

+ 6 - 0
ambari-web/app/views/common/sort_view.js

@@ -31,6 +31,12 @@ var wrapperView = Em.View.extend({
 
 
   classNames: ['sort-wrapper'],
   classNames: ['sort-wrapper'],
 
 
+  willInsertElement:function () {
+    if(this.get('parentView.tableFilteringComplete')){
+      this.get('parentView').set('filteringComplete', true);
+    }
+  },
+
   /**
   /**
    * Load sort statuses from local storage
    * Load sort statuses from local storage
    * Works only after finish filtering in the parent View
    * Works only after finish filtering in the parent View

+ 7 - 6
ambari-web/app/views/common/table_view.js

@@ -28,6 +28,12 @@ App.TableView = Em.View.extend(App.UserPref, {
    */
    */
   filteringComplete: false,
   filteringComplete: false,
 
 
+  /**
+   * intermediary for filteringComplete
+   * @type {Boolean}
+   */
+  tableFilteringComplete: false,
+
   /**
   /**
    * Loaded from local storage startIndex value
    * Loaded from local storage startIndex value
    * @type {Number}
    * @type {Number}
@@ -74,12 +80,7 @@ App.TableView = Em.View.extend(App.UserPref, {
     } else {
     } else {
       this.clearFilters();
       this.clearFilters();
     }
     }
-
-    Em.run.next(function() {
-      Em.run.next(function() {
-        self.set('filteringComplete', true);
-      });
-    });
+    self.set('tableFilteringComplete', true);
   },
   },
 
 
   /**
   /**

+ 65 - 4
ambari-web/app/views/main/jobs_view.js

@@ -33,6 +33,8 @@ App.MainJobsView = App.TableView.extend({
    */
    */
   noDataToShow:true,
   noDataToShow:true,
 
 
+  filterCondition:[],
+
   /*
   /*
    If no jobs to display set noDataToShow to true, else set emptyData to false.
    If no jobs to display set noDataToShow to true, else set emptyData to false.
    */
    */
@@ -44,19 +46,74 @@ App.MainJobsView = App.TableView.extend({
     }
     }
   }.observes("controller.content.length"),
   }.observes("controller.content.length"),
 
 
+  willInsertElement: function () {
+    var self = this;
+    var name = this.get('controller.name');
+    var colPropAssoc = this.get('colPropAssoc');
+    var filterConditions = App.db.getFilterConditions(name);
+    if (filterConditions) {
+      this.set('filterConditions', filterConditions);
+      var childViews = this.get('childViews');
+
+      filterConditions.forEach(function(condition) {
+        var view = childViews.findProperty('column', condition.iColumn);
+        if (view) {
+          //self.get('controller.filterObject').set(colPropAssoc[condition.iColumn], condition.value);
+          view.set('value', condition.value);
+          if(view.get('setPropertyOnApply')){
+            view.setValueOnApply();
+          }
+          Em.run.next(function() {
+            view.showClearFilter();
+          });
+        }
+      });
+    } else {
+      this.clearFilters();
+    }
+    this.onApplyIdFilter();
+    this.set('tableFilteringComplete', true);
+  },
+
+  didInsertElement: function () {
+    if(!this.get('controller.sortingColumn')){
+      var columns = this.get('childViews')[0].get('childViews')
+      if(columns && columns.findProperty('name', 'startTime')){
+        columns.findProperty('name','startTime').set('status', 'sorting_desc');
+        this.get('controller').set('sortingColumn', columns.findProperty('name','startTime'))
+      }
+    }
+  },
+
   onApplyIdFilter: function() {
   onApplyIdFilter: function() {
     var isIdFilterApplied = this.get('controller.filterObject.isIdFilterApplied');
     var isIdFilterApplied = this.get('controller.filterObject.isIdFilterApplied');
     this.get('childViews').forEach(function(childView) {
     this.get('childViews').forEach(function(childView) {
-      if (childView['clearFilter'] && childView.get('column') != 0) {
-        childView.clearFilter();
+      if (childView['clearFilter'] && childView.get('column') != 1) {
+        if(isIdFilterApplied){
+          childView.clearFilter();
+        }
         var childOfChild = childView.get('childViews')[0];
         var childOfChild = childView.get('childViews')[0];
         if(childOfChild){
         if(childOfChild){
-          childOfChild.set('disabled', isIdFilterApplied);
+          Em.run.next(function() {
+            childOfChild.set('disabled', isIdFilterApplied);
+          })
         }
         }
       }
       }
     });
     });
   }.observes('controller.filterObject.isIdFilterApplied'),
   }.observes('controller.filterObject.isIdFilterApplied'),
 
 
+  saveFilter: function () {
+    if(this.get('tableFilteringComplete')){
+      this.updateFilter(1, this.get('controller.filterObject.id'), 'string');
+      this.updateFilter(2, this.get('controller.filterObject.user'), 'string');
+      this.updateFilter(4, this.get('controller.filterObject.windowEnd'), 'date');
+    }
+  }.observes(
+      'controller.filterObject.id',
+      'controller.filterObject.user',
+      'controller.filterObject.windowEnd'
+  ),
+
   sortView: sort.wrapperView,
   sortView: sort.wrapperView,
   idSort: sort.fieldView.extend({
   idSort: sort.fieldView.extend({
     column: 1,
     column: 1,
@@ -148,7 +205,10 @@ App.MainJobsView = App.TableView.extend({
     fieldType: 'input-120',
     fieldType: 'input-120',
     column: 3,
     column: 3,
     content: ['Any', 'Past 1 hour',  'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days', 'Custom'],
     content: ['Any', 'Past 1 hour',  'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days', 'Custom'],
-    valueBinding: "controller.filterObject.startTime"
+    valueBinding: "controller.filterObject.startTime",
+    onChangeValue: function () {
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'date');
+    }
   }),
   }),
 
 
   /**
   /**
@@ -159,6 +219,7 @@ App.MainJobsView = App.TableView.extend({
     associations[1] = 'id';
     associations[1] = 'id';
     associations[2] = 'user';
     associations[2] = 'user';
     associations[3] = 'startTime';
     associations[3] = 'startTime';
+    associations[4] = 'endTime';
     return associations;
     return associations;
   }.property(),
   }.property(),