ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject git commit: AMBARI-5975. Slider apps table not sorting/filtering properly along with other small fixes. Additional (alexantonenko)
Date Wed, 16 Jul 2014 17:59:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c13dad9a1 -> 442b7961c


AMBARI-5975. Slider apps table not sorting/filtering properly along with other small fixes.
Additional (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 442b7961c739da2e7fb82e6b49b10878faa8c777
Parents: c13dad9
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Jul 16 20:58:06 2014 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Jul 16 20:58:37 2014 +0300

----------------------------------------------------------------------
 .../resources/ui/app/templates/slider_apps.hbs  |  2 +-
 .../ui/app/views/common/filter_view.js          | 32 +++++++++++++++++++-
 .../resources/ui/app/views/common/table_view.js | 12 +++++---
 .../resources/ui/app/views/slider_apps_view.js  | 16 ++++++++--
 4 files changed, 53 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/442b7961/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
index 024e638..95820d0 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
@@ -92,4 +92,4 @@
     </div>
   </div>
 </div>
-{{outlet}}
\ No newline at end of file
+{{outlet}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/442b7961/contrib/views/slider/src/main/resources/ui/app/views/common/filter_view.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/views/common/filter_view.js b/contrib/views/slider/src/main/resources/ui/app/views/common/filter_view.js
index 315a349..9f8e6cc 100644
--- a/contrib/views/slider/src/main/resources/ui/app/views/common/filter_view.js
+++ b/contrib/views/slider/src/main/resources/ui/app/views/common/filter_view.js
@@ -76,7 +76,7 @@ var wrapperView = Ember.View.extend({
    * @return {Boolean}
    */
   isEmpty: function(){
-    if(this.get('value') === null){
+    if(this.get('value') === null || this.get('value') == this.get('defaultValue')){
       return true;
     }
     return this.get('value').toString() === this.get('emptyValue').toString();
@@ -288,6 +288,36 @@ module.exports = {
           return origin === compareValue;
         };
         break;
+      case 'date':
+        return function (rowValue, rangeExp) {
+          var match = false;
+          var timePassed = new Date().getTime() - rowValue;
+          switch (rangeExp) {
+            case 'Past 1 hour':
+              match = timePassed <= 3600000;
+              break;
+            case 'Past 1 Day':
+              match = timePassed <= 86400000;
+              break;
+            case 'Past 2 Days':
+              match = timePassed <= 172800000;
+              break;
+            case 'Past 7 Days':
+              match = timePassed <= 604800000;
+              break;
+            case 'Past 14 Days':
+              match = timePassed <= 1209600000;
+              break;
+            case 'Past 30 Days':
+              match = timePassed <= 2592000000;
+              break;
+            case 'Any':
+              match = true;
+              break;
+          }
+          return match;
+        };
+        break;
       case 'number':
         return function(rowValue, rangeExp){
           var compareChar = rangeExp.charAt(0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/442b7961/contrib/views/slider/src/main/resources/ui/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/views/common/table_view.js b/contrib/views/slider/src/main/resources/ui/app/views/common/table_view.js
index 1fdf0a7..cb78c88 100644
--- a/contrib/views/slider/src/main/resources/ui/app/views/common/table_view.js
+++ b/contrib/views/slider/src/main/resources/ui/app/views/common/table_view.js
@@ -298,8 +298,9 @@ App.TableView = Em.View.extend({
    * @param {Object} value
    * @param {String} type
    */
-  updateFilter: function (iColumn, value, type) {
+  updateFilter: function (iColumn, value, type, defaultValue) {
     var filterCondition = this.get('filterConditions').findProperty('iColumn', iColumn);
+    defaultValue = defaultValue ? defaultValue : "";
     if (filterCondition) {
       filterCondition.value = value;
     }
@@ -307,7 +308,8 @@ App.TableView = Em.View.extend({
       filterCondition = {
         iColumn: iColumn,
         value: value,
-        type: type
+        type: type,
+        defaultValue: defaultValue
       };
       this.get('filterConditions').push(filterCondition);
     }
@@ -357,7 +359,7 @@ App.TableView = Em.View.extend({
          var match = true;
         filterConditions.forEach(function (condition) {
           var filterFunc = filters.getFilterByType(condition.type, false);
-          if (match) {
+          if (match && condition.value != condition.defaultValue) {
             match = filterFunc(Em.get(item, assoc[condition.iColumn]), condition.value);
           }
         });
@@ -387,7 +389,7 @@ App.TableView = Em.View.extend({
     }
     var filtersUsed = false;
     filterConditions.forEach(function(filterCondition) {
-      if (filterCondition.value.toString() !== '') {
+      if (filterCondition.value.toString() !== '' && filterCondition.value.toString()
!== filterCondition.defaultValue.toString()) {
         filtersUsed = true;
       }
     });
@@ -406,4 +408,4 @@ App.TableView = Em.View.extend({
     });
   }
 
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/442b7961/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js b/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
index 53252b7..fd85061 100644
--- a/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
+++ b/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
@@ -21,7 +21,7 @@ var sort = require('views/common/sort_view');
 App.SliderAppsView = App.TableView.extend({
 
   statusList: [
-    "",
+    "All Status",
     App.SliderApp.Status.accepted,
     App.SliderApp.Status.failed,
     App.SliderApp.Status.finished,
@@ -102,12 +102,13 @@ App.SliderAppsView = App.TableView.extend({
 
   statusFilterView: filters.createSelectView({
     column: 1,
+    defaultValue: "All Status",
     fieldType: 'filter-input-width',
     content: function() {
       return this.get('parentView.statusList');
     }.property('parentView.statusList'),
     onChangeValue: function(){
-      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string',
this.get('defaultValue'));
     }
   }),
 
@@ -137,6 +138,17 @@ App.SliderAppsView = App.TableView.extend({
     type: 'number'
   }),
 
+  startFilterView: filters.createSelectView({
+    column: 4,
+    defaultValue: "All Dates",
+    fieldType: 'filter-input-width',
+    content: ['All Dates', 'Past 1 hour',  'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past
14 Days', 'Past 30 Days'],
+    onChangeValue: function(){
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'date',
this.get('defaultValue'));
+    },
+    type: 'date'
+  }),
+
   /**
    * associations between host property and column index
    * @type {Array}


Mime
View raw message