Repository: ambari
Updated Branches:
  refs/heads/trunk 65e60df31 -> 00f951fd5


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


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

Branch: refs/heads/trunk
Commit: 00f951fd54672f05d0af647a295b0a9a857675e4
Parents: 65e60df
Author: Alex Antonenko <[email protected]>
Authored: Thu Mar 13 04:46:28 2014 +0200
Committer: Alex Antonenko <[email protected]>
Committed: Thu Mar 13 04:46:28 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/main/jobs_controller.js     |  2 +-
 ambari-web/app/templates/main/jobs.hbs          |  8 +--
 ambari-web/app/views/common/filter_view.js      |  2 -
 ambari-web/app/views/common/sort_view.js        |  6 ++
 ambari-web/app/views/common/table_view.js       | 13 ++--
 ambari-web/app/views/main/jobs_view.js          | 69 ++++++++++++++++++--
 6 files changed, 83 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/controllers/main/jobs_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/jobs_controller.js 
b/ambari-web/app/controllers/main/jobs_controller.js
index 52e255f..afe4666 100644
--- a/ambari-web/app/controllers/main/jobs_controller.js
+++ b/ambari-web/app/controllers/main/jobs_controller.js
@@ -260,7 +260,7 @@ App.MainJobsController = Em.ArrayController.extend({
           var sortColumn = self.get('sortingColumn');
           if(sortColumn && 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.set('status', sortColumnStatus);
             self.set('content',sortColumn.get('parentView').get('content'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/templates/main/jobs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/jobs.hbs 
b/ambari-web/app/templates/main/jobs.hbs
index 28a7721..a03cc96 100644
--- a/ambari-web/app/templates/main/jobs.hbs
+++ b/ambari-web/app/templates/main/jobs.hbs
@@ -16,7 +16,7 @@
 * limitations under the License.
 }}
 
-{{#if controller.loaded}}
+
   <div id="jobs">
       <div class="jobs_head">
         <div>{{t menu.item.jobs}}</div>
@@ -26,7 +26,7 @@
       </div>
       <table id="jobs-table" class="table table-bordered table-striped">
           <thead>
-          {{#view view.sortView classNames="label-row" 
contentBinding="view.filteredContent"}}
+          {{#view view.sortView classNames="label-row" 
contentBinding="controller.content"}}
               <th></th>
               {{view view.parentView.idSort}}
               {{view view.parentView.userSort}}
@@ -50,7 +50,7 @@
                 <td class="no-data" {{bindAttr 
colspan="controller.columnsName.content.length"}}>{{t jobs.nothingToShow}}</td>
               </tr>
           {{else}}
-            {{#each job in view.pageContent}}
+            {{#each job in controller.content}}
               <tr>
                 <td>
                   {{#if job.failed}}
@@ -93,4 +93,4 @@
           </div>
       </div>
   </div>
-{{/if}}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/views/common/filter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/filter_view.js 
b/ambari-web/app/views/common/filter_view.js
index 0cb0471..ba1080a 100644
--- a/ambari-web/app/views/common/filter_view.js
+++ b/ambari-web/app/views/common/filter_view.js
@@ -59,7 +59,6 @@ var wrapperView = Ember.View.extend({
   },
 
   setValueOnApply: function() {
-    this.set('disabled', true);
     if(this.get('value') == null){
       this.set('value', '')
     }
@@ -235,7 +234,6 @@ module.exports = {
    * @param config parameters of <code>wrapperView</code>
    */
   createTextView : function(config){
-
     config.fieldType = config.fieldType || 'input-medium';
     config.filterView = textFieldView.extend({
       classNames : [ config.fieldType ]

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/views/common/sort_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/sort_view.js 
b/ambari-web/app/views/common/sort_view.js
index baadf33..3d970d6 100644
--- a/ambari-web/app/views/common/sort_view.js
+++ b/ambari-web/app/views/common/sort_view.js
@@ -31,6 +31,12 @@ var wrapperView = Em.View.extend({
 
   classNames: ['sort-wrapper'],
 
+  willInsertElement:function () {
+    if(this.get('parentView.tableFilteringComplete')){
+      this.get('parentView').set('filteringComplete', true);
+    }
+  },
+
   /**
    * Load sort statuses from local storage
    * Works only after finish filtering in the parent View

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js 
b/ambari-web/app/views/common/table_view.js
index 73e7797..faa56d5 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -29,6 +29,12 @@ App.TableView = Em.View.extend(App.UserPref, {
   filteringComplete: false,
 
   /**
+   * intermediary for filteringComplete
+   * @type {Boolean}
+   */
+  tableFilteringComplete: false,
+
+  /**
    * Loaded from local storage startIndex value
    * @type {Number}
    */
@@ -74,12 +80,7 @@ App.TableView = Em.View.extend(App.UserPref, {
     } else {
       this.clearFilters();
     }
-
-    Em.run.next(function() {
-      Em.run.next(function() {
-        self.set('filteringComplete', true);
-      });
-    });
+    self.set('tableFilteringComplete', true);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/00f951fd/ambari-web/app/views/main/jobs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/jobs_view.js 
b/ambari-web/app/views/main/jobs_view.js
index b78ce44..ba47b0f 100644
--- a/ambari-web/app/views/main/jobs_view.js
+++ b/ambari-web/app/views/main/jobs_view.js
@@ -33,6 +33,8 @@ App.MainJobsView = App.TableView.extend({
    */
   noDataToShow:true,
 
+  filterCondition:[],
+
   /*
    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"),
 
+  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() {
     var isIdFilterApplied = 
this.get('controller.filterObject.isIdFilterApplied');
     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];
         if(childOfChild){
-          childOfChild.set('disabled', isIdFilterApplied);
+          Em.run.next(function() {
+            childOfChild.set('disabled', 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,
   idSort: sort.fieldView.extend({
     column: 1,
@@ -148,7 +205,10 @@ App.MainJobsView = App.TableView.extend({
     fieldType: 'input-120',
     column: 3,
     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[2] = 'user';
     associations[3] = 'startTime';
+    associations[4] = 'endTime';
     return associations;
   }.property(),
 

Reply via email to