Ver código fonte

AMBARI-2018. Hosts page: no filter selection is shown after clicking on "Alerts" filter, navigating away, and coming back to Hosts page. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1471783 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 anos atrás
pai
commit
a548101632

+ 3 - 0
CHANGES.txt

@@ -791,6 +791,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2018. Hosts page: no filter selection is shown after clicking on
+ "Alerts" filter, navigating away, and coming back to Hosts page. (yusaku)
+
  AMBARI-2016. Hide Maintenance pulldown if no operation can be performed.
  (yusaku)
 

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
ambari-web/app/assets/data/alerts/alerts.json


+ 0 - 22
ambari-web/app/controllers/main/host.js

@@ -50,28 +50,6 @@ App.MainHostController = Em.ArrayController.extend({
     return this.get('componentsForFilter').filterProperty('isClient', true);
   }.property('componentsForFilter'),
 
-  /**
-   * Is true if alets filter is active
-   */
-  filteredByAlerts:false,
-
-  /**
-   * Is true if Hosts page was opened by clicking on alerts count badge
-   */
-  comeWithAlertsFilter: false,
-
-  /**
-   * Enable or disable filtering by alets
-   */
-  filterByAlerts: function () {
-    if (App.router.get('currentState.name') == 'index') {
-      this.set('filteredByAlerts', !this.get('filteredByAlerts'));
-    } else {
-      App.router.transitionTo('hosts.index');
-      this.set('comeWithAlertsFilter', true);
-    }
-  },
-
   /**
    * Filter hosts by componentName of <code>component</code>
    * @param component App.HostComponent

+ 6 - 6
ambari-web/app/templates/main/host.hbs

@@ -22,17 +22,17 @@
     <div class="health-status-bar span8" >
       {{#each category in view.categories}}
         <span {{bindAttr class="category.itemClass"}}>
-          <span {{bindAttr class="category.healthStatusValue"}}> &nbsp;&nbsp;&nbsp; </span>
+        {{#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}}
-      <span class="label label-important">{{t hosts.host.alerts.st}}</span>
-      <span {{bindAttr class="controller.filteredByAlerts:active"}}>
-        <a href="#" {{action filterByAlerts target="controller"}}>{{t hosts.host.alerts.label}} ({{view.hostsWithAlertsCount}})</a>
-      </span>
     </div>
 
     {{#if App.isAdmin}}

+ 13 - 37
ambari-web/app/views/main/host.js

@@ -29,12 +29,6 @@ App.MainHostView = App.TableView.extend({
 
   didInsertElement:function () {
     this._super();
-    if (this.get('controller.comeWithAlertsFilter')) {
-      this.set('controller.comeWithAlertsFilter', false);
-      this.set('controller.filteredByAlerts', true);
-    } else {
-      this.set('controller.filteredByAlerts', false);
-    }
   },
 
   sortView: sort.wrapperView,
@@ -109,7 +103,10 @@ App.MainHostView = App.TableView.extend({
 
     hostsCount: function () {
       var statusString = this.get('healthStatusValue');
-      if (statusString == "") {
+      var alerts = this.get('alerts');
+      if(alerts){
+        return this.get('view.content').filterProperty('criticalAlertsCount').get('length');
+      } else if (statusString == "") {
         return this.get('view.content').get('length');
       } else {
         return this.get('view.content').filterProperty('healthClass', statusString ).get('length');
@@ -145,7 +142,8 @@ App.MainHostView = App.TableView.extend({
       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', last: true })
+      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: '', last: true, alerts: true })
     ];
 
     this.set('category', categories.get('firstObject'));
@@ -157,17 +155,15 @@ App.MainHostView = App.TableView.extend({
 
   selectCategory: function(event, context){
     this.set('category', event.context);
-    this.updateFilter(0, event.context.get('healthStatusValue'), 'string');
+    if(event.context.get('alerts')){
+      this.updateFilter(0, '', 'string');
+      this.updateFilter(7, '>0', 'number');
+    } else {
+      this.updateFilter(7, '', 'number');
+      this.updateFilter(0, event.context.get('healthStatusValue'), 'string');
+    }
   },
 
-  /**
-   * Deactivate Alerts filtering if some Health category is selected
-   */
-  deactivateAlertsFilter: function() {
-    if (this.get('category')) {
-      this.set('controller.filteredByAlerts', false);
-    }
-  }.observes('category'),
 
   /**
    * Count of the hosts with alerts
@@ -176,26 +172,6 @@ App.MainHostView = App.TableView.extend({
     return this.get('content.length') - this.get('content').filterProperty('criticalAlertsCount', 0).length;
   }.property('content.@each.criticalAlertsCount'),
 
-  /**
-   * Filter hosts by hosts with at least one alert
-   */
-  filterByAlerts:function() {
-    if (this.get('controller.filteredByAlerts')) {
-      this.updateFilter(0, '', 'string');
-      this.updateFilter(7, '>0', 'number');
-      this.get('categories').setEach('isActive', false);
-      this.set('category', false);
-    }
-    else {
-      this.updateFilter(7, '', 'number');
-      if (!this.get('category')) {
-        var category = this.get('categories').objectAt(0);
-        category.set('isActive', false);
-        this.set('category', category);
-      }
-    }
-  }.observes('controller.filteredByAlerts'),
-
 
   /**
    * Filter view for name column

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff