You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/06/26 23:32:05 UTC

svn commit: r1497112 - in /incubator/ambari/branches/branch-1.2.5/ambari-web/app: templates/main/host.hbs views/common/table_view.js views/main/host.js

Author: yusaku
Date: Wed Jun 26 21:32:05 2013
New Revision: 1497112

URL: http://svn.apache.org/r1497112
Log:
AMBARI-2492. "All" filter should be linked when any filter applied. (Oleg Nechiporenko via yusaku)

Modified:
    incubator/ambari/branches/branch-1.2.5/ambari-web/app/templates/main/host.hbs
    incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/common/table_view.js
    incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/main/host.js

Modified: incubator/ambari/branches/branch-1.2.5/ambari-web/app/templates/main/host.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.5/ambari-web/app/templates/main/host.hbs?rev=1497112&r1=1497111&r2=1497112&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.5/ambari-web/app/templates/main/host.hbs (original)
+++ incubator/ambari/branches/branch-1.2.5/ambari-web/app/templates/main/host.hbs Wed Jun 26 21:32:05 2013
@@ -19,22 +19,25 @@
 <div id="hosts">
 
   <div class="box-header row">
-    <div class="health-status-bar pull-left" >
+    <div class="health-status-bar pull-left">
+      <div class="pull-left"><span {{bindAttr class="view.filtersUsed::active"}}><a {{action clearFilters target="view"}} href="#">{{t common.all}} ({{content.length}})</a></span>&nbsp;</div>
       {{view view.alertFilter}}
       {{#view view.statusFilter categoriesBinding="view.categories"}}
-      {{#each category in view.categories}}
-        <span {{bindAttr class="category.itemClass"}}>
-        {{#if category.alerts}}
-            <span class="label label-important">{{t hosts.host.alerts.st}}</span>
-        {{else}}
-            <span {{bindAttr class="category.healthStatusValue"}}> &nbsp;&nbsp;&nbsp; </span>
-        {{/if}}
-          <a {{action selectCategory category target="view"}} href="#">
-            {{category.label}}
-          </a>
-        </span>
-        {{#unless category.last}}|{{/unless}}
-      {{/each}}
+        {{#each category in view.categories}}
+          {{#if category.isVisible}}
+            |
+            <span {{bindAttr class="category.itemClass"}}>
+            {{#if category.alerts}}
+                <span class="label label-important">{{t hosts.host.alerts.st}}</span>
+            {{else}}
+                <span {{bindAttr class="category.healthStatusValue"}}> &nbsp;&nbsp;&nbsp; </span>
+            {{/if}}
+              <a {{action selectCategory category target="view"}} href="#">
+                {{category.label}}
+              </a>
+            </span>
+          {{/if}}
+        {{/each}}
       {{/view}}
     </div>
 

Modified: incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/common/table_view.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/common/table_view.js?rev=1497112&r1=1497111&r2=1497112&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/common/table_view.js (original)
+++ incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/common/table_view.js Wed Jun 26 21:32:05 2013
@@ -189,6 +189,7 @@ App.TableView = Em.View.extend({
       this.get('filterConditions').push(filterCondition);
     }
     this.saveFilterConditions();
+    this.filtersUsedCalc();
     this.filter();
   },
 
@@ -256,6 +257,31 @@ App.TableView = Em.View.extend({
     } else {
       this.set('filteredContent', content.toArray());
     }
-  }.observes('content')
+  }.observes('content'),
+
+  filtersUsed: false,
+
+  filtersUsedCalc: function() {
+    var filterConditions = this.get('filterConditions');
+    if (!filterConditions.length) {
+      this.set('filtersUsed', false);
+    }
+    var filtersUsed = false;
+    filterConditions.forEach(function(filterCondition) {
+      if (filterCondition.value.toString() !== '') {
+        filtersUsed = true;
+      }
+    });
+    this.set('filtersUsed', filtersUsed);
+  },
+
+  clearFilters: function() {
+    this.set('filterConditions', []);
+    this.get('_childViews').forEach(function(childView) {
+      if (childView['clearFilter']) {
+        childView.clearFilter();
+      }
+    });
+  }
 
 });

Modified: incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/main/host.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/main/host.js?rev=1497112&r1=1497111&r2=1497112&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/main/host.js (original)
+++ incubator/ambari/branches/branch-1.2.5/ambari-web/app/views/main/host.js Wed Jun 26 21:32:05 2013
@@ -112,7 +112,6 @@ App.MainHostView = App.TableView.extend(
       } else {
         return this.get('view.content').filterProperty('healthClass', statusString ).get('length');
       }
-
     }.property('view.content.@each.healthClass'),
 
     label: function () {
@@ -131,12 +130,12 @@ App.MainHostView = App.TableView.extend(
     });
 
     var categories = [
-      self.categoryObject.create({value: Em.I18n.t('common.all'), healthStatusValue: '', isActive: true}),
-      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.green'), healthStatusValue: 'health-status-LIVE'}),
-      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.red'), healthStatusValue: 'health-status-DEAD-RED'}),
-      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.orange'), healthStatusValue: 'health-status-DEAD-ORANGE'}),
-      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.yellow'), healthStatusValue: 'health-status-DEAD-YELLOW'}),
-      self.categoryObject.create({value: Em.I18n.t('hosts.host.alerts.label'), healthStatusValue: 'health-status-WITH-ALERTS', last: true, alerts: true })
+      self.categoryObject.create({value: Em.I18n.t('common.all'), healthStatusValue: '', isActive: true, isVisible: false}),
+      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.green'), healthStatusValue: 'health-status-LIVE', isVisible: true}),
+      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.red'), healthStatusValue: 'health-status-DEAD-RED', isVisible: true}),
+      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.orange'), healthStatusValue: 'health-status-DEAD-ORANGE', isVisible: true}),
+      self.categoryObject.create({value: Em.I18n.t('hosts.host.healthStatusCategory.yellow'), healthStatusValue: 'health-status-DEAD-YELLOW', isVisible: true}),
+      self.categoryObject.create({value: Em.I18n.t('hosts.host.alerts.label'), healthStatusValue: 'health-status-WITH-ALERTS', last: true, alerts: true, isVisible: true })
     ];
 
     return categories;
@@ -170,6 +169,11 @@ App.MainHostView = App.TableView.extend(
         this.get('parentView').updateFilter(7, '', 'number');
         this.get('parentView').updateFilter(0, category.get('healthStatusValue'), 'string');
       }
+    },
+    clearFilter: function() {
+      this.get('categories').setEach('isActive', false);
+      this.set('value', '');
+      this.showClearFilter();
     }
   }),