Pārlūkot izejas kodu

AMBARI-10139. Service alerts popup: status label has redundant tooltip (alexantonenko)

Alex Antonenko 10 gadi atpakaļ
vecāks
revīzija
30bd08b510

+ 9 - 0
ambari-web/app/models/alert_instance.js

@@ -117,6 +117,15 @@ App.AlertInstance = DS.Model.extend({
     return triggeredFor;
     return triggeredFor;
   }.property('originalTimestamp'),
   }.property('originalTimestamp'),
 
 
+  /**
+  * escaped '<' and '>' special characters.
+  * @type {string}
+  */  
+  escapeSpecialCharactersFromTooltip: function () {
+    var displayedText = this.get('text');
+    return  displayedText.replace(/[<>]/g, '');
+  }.property('text'),
+
   /**
   /**
    * Formatted lastChecked and lastTriggered timestamp
    * Formatted lastChecked and lastTriggered timestamp
    * @returns {string}
    * @returns {string}

+ 3 - 3
ambari-web/app/templates/main/host/host_alerts.hbs

@@ -52,15 +52,15 @@
             <a href="#" {{action routeToAlertDefinition alertInstance.definitionId target="controller"}}>{{alertInstance.label}}</a>
             <a href="#" {{action routeToAlertDefinition alertInstance.definitionId target="controller"}}>{{alertInstance.label}}</a>
           </td>
           </td>
           <td>{{{alertInstance.status}}} <time class="timeago" {{bindAttr data-original-title="alertInstance.statusChangedAndLastCheckedFormatted"}}>{{alertInstance.lastTriggeredForFormatted}}</time></td>
           <td>{{{alertInstance.status}}} <time class="timeago" {{bindAttr data-original-title="alertInstance.statusChangedAndLastCheckedFormatted"}}>{{alertInstance.lastTriggeredForFormatted}}</time></td>
-          <td><span class="alert-text" {{bindAttr data-original-title="alertInstance.text"}} class="alert-text">{{alertInstance.text}}</span></td>
+          <td><span class="alert-text" {{bindAttr data-original-title="alertInstance.escapeSpecialCharactersFromTooltip"}} class="alert-text">{{alertInstance.text}}</span></td>
         </tr>
         </tr>
       {{/each}}
       {{/each}}
     {{else}}
     {{else}}
       <tr>
       <tr>
-        <td class="first"></td>
-        <td colspan="3">
+        <td class="first">
           {{t alerts.table.noAlerts}}
           {{t alerts.table.noAlerts}}
         </td>
         </td>
+        <td colspan="3"></td>
       </tr>
       </tr>
     {{/if}}
     {{/if}}
     </tbody>
     </tbody>

+ 1 - 1
ambari-web/app/templates/main/service/info/service_alert_popup.hbs

@@ -29,7 +29,7 @@
               {{alert.latestText}}
               {{alert.latestText}}
             </div>
             </div>
           </div>
           </div>
-          <div class="span5 status-col" rel="alert-status-tooltip" {{bindAttr title="alert.lastTriggered"}}>
+          <div class="span5 status-col" rel="alert-status-tooltip" >
             <span class="timeago" {{bindAttr data-original-title="alert.lastTriggeredVerboseDisplay"}}>
             <span class="timeago" {{bindAttr data-original-title="alert.lastTriggeredVerboseDisplay"}}>
               <span class="status-icon">{{{alert.status}}}</span>
               <span class="status-icon">{{{alert.status}}}</span>
               <time>{{alert.lastTriggeredForFormatted}}</time>
               <time>{{alert.lastTriggeredForFormatted}}</time>

+ 3 - 1
ambari-web/app/views/main/alert_definitions_view.js

@@ -56,7 +56,6 @@ App.MainAlertDefinitionsView = App.TableView.extend({
     Em.run.next(function () {
     Em.run.next(function () {
       self.set('isInitialRendering', false);
       self.set('isInitialRendering', false);
       self.tooltipsUpdater();
       self.tooltipsUpdater();
-      self.addObserver('pageContent.length', self, 'tooltipsUpdater');
     });
     });
   },
   },
 
 
@@ -494,6 +493,7 @@ App.MainAlertDefinitionsView = App.TableView.extend({
     if (this.get('paginationLeftClass') === 'paginate_previous') {
     if (this.get('paginationLeftClass') === 'paginate_previous') {
       this._super();
       this._super();
     }
     }
+    this.tooltipsUpdater();
   },
   },
 
 
   /**
   /**
@@ -504,6 +504,7 @@ App.MainAlertDefinitionsView = App.TableView.extend({
     if (this.get('paginationRightClass') === 'paginate_next') {
     if (this.get('paginationRightClass') === 'paginate_next') {
       this._super();
       this._super();
     }
     }
+    this.tooltipsUpdater();
   },
   },
 
 
   /**
   /**
@@ -520,6 +521,7 @@ App.MainAlertDefinitionsView = App.TableView.extend({
     if (!this.get('isInitialRendering')) {
     if (!this.get('isInitialRendering')) {
       this._super(iColumn, value, type);
       this._super(iColumn, value, type);
     }
     }
+    this.tooltipsUpdater();
   }
   }
 
 
 });
 });

+ 10 - 0
ambari-web/test/models/alert_instance_test.js

@@ -81,4 +81,14 @@ describe('App.AlertInstance', function () {
 
 
   });
   });
 
 
+  describe('#escapeSpecialCharactersFromTooltip', function () {
+    it('it Should Display Alert Without special characters "<" and ">"', function () {
+
+      model.set('text', '<urlopen error [Errno 111] Connection refused>');
+      var resultedText = model.get('escapeSpecialCharactersFromTooltip');
+
+      expect(resultedText).to.equal('urlopen error [Errno 111] Connection refused');
+    });
+  });
+
 });
 });