Forráskód Böngészése

AMBARI-15605 UI Changes To Expose Alert Repeat Tolerance Counts (zhewang)

Zhe (Joe) Wang 9 éve
szülő
commit
a2c6ea46f0

+ 1 - 1
ambari-web/app/controllers/global/update_controller.js

@@ -560,7 +560,7 @@ App.UpdateController = Em.Controller.extend({
     var realUrl = '/alerts?fields=' +
       'Alert/component_name,Alert/definition_id,Alert/definition_name,Alert/host_name,Alert/id,Alert/instance,' +
       'Alert/label,Alert/latest_timestamp,Alert/maintenance_state,Alert/original_timestamp,Alert/scope,' +
-      'Alert/service_name,Alert/state,Alert/text' +
+      'Alert/service_name,Alert/state,Alert/text,Alert/repeat_tolerance,Alert/repeat_tolerance_remaining' +
       '&Alert/state.in(CRITICAL,WARNING)&Alert/maintenance_state.in(OFF)&from=' + queryParams.from + '&page_size=' + queryParams.page_size;
     var url = this.getUrl(testUrl, realUrl);
 

+ 3 - 1
ambari-web/app/mappers/alert_instances_mapper.js

@@ -40,7 +40,9 @@ App.alertInstanceMapper = App.QuickDataMapper.create({
     maintenance_state: 'Alert.maintenance_state',
     instance: 'Alert.instance',
     state: 'Alert.state',
-    text: 'Alert.text'
+    text: 'Alert.text',
+    repeat_tolerance: 'Alert.repeat_tolerance',
+    repeat_tolerance_remaining: 'Alert.repeat_tolerance_remaining'
   },
 
   map: function(json) {

+ 1 - 0
ambari-web/app/messages.js

@@ -326,6 +326,7 @@ Em.I18n.translations = {
   'models.alert_instance.tiggered.verbose': "Occurred on {0} <br> Checked on {1}",
   'models.alert_definition.triggered.verbose': "Occurred on {0}",
   'models.alert_definition.triggered.checked': "Status Changed: {0}\nLast Checked: {1}",
+  'models.alert_definition.check.retry': "Retried {0} out of {1} alerts before sending notifications",
 
   'passiveState.turnOn':'Turn On Maintenance Mode',
   'passiveState.turnOff':'Turn Off Maintenance Mode',

+ 10 - 0
ambari-web/app/models/alerts/alert_instance.js

@@ -37,6 +37,8 @@ App.AlertInstance = DS.Model.extend({
   instance: DS.attr('string'),
   state: DS.attr('string'),
   text: DS.attr('string'),
+  repeatTolerance: DS.attr('number'),
+  repeatToleranceRemaining: DS.attr('number'),
   notification: DS.hasMany('App.AlertNotification'),
 
   /**
@@ -145,6 +147,14 @@ App.AlertInstance = DS.Model.extend({
     'DISABLED': 'icon-off'
   },
 
+  repeatToleranceReceived: function () {
+    return this.get('repeatTolerance') - this.get('repeatToleranceRemaining');
+  }.property('repeatToleranceRemaining', 'repeatTolerance'),
+
+  retryText: function () {
+    return this.get('state') === 'OK' ? '' : Em.I18n.t('models.alert_definition.check.retry').format(this.get('repeatToleranceReceived'), this.get('repeatTolerance'));
+  }.property('state','repeatToleranceRemaining', 'repeatTolerance'),
+
   /**
    * Define if definition serviceName is Ambari
    * Used in some logic in templates to distinguish definitions with Ambari serviceName

+ 1 - 4
ambari-web/app/templates/common/modal_popups/alerts_popup.hbs

@@ -43,10 +43,7 @@
                     </div>
                   </div>
                   <div class="status-col" {{bindAttr title="instance.lastTriggered"}}>
-                    {{template "templates/main/alerts/alert_instance/status"}}
-                    <span>
-                      <time>{{instance.lastTriggeredForFormatted}}</time>
-                    </span>
+                      {{view App.AlertInstanceStateView instanceBinding="instance"}}
                   </div>
               </div>
             </div>

+ 8 - 2
ambari-web/app/templates/main/alerts/alert_instance/status.hbs

@@ -22,5 +22,11 @@
   {{#if instance.isMaintenanceStateOn}}
     <span class="icon-medkit"></span>
   {{/if}}
-  {{instance.shortStateMsg}}
-</div>
+  <span rel="StateTooltip" {{bindAttr data-original-title="instance.retryText"}}>
+    {{instance.shortStateMsg}}
+  </span>
+</div>
+<time class="timeago"
+      rel="tooltip" {{bindAttr data-original-title="instance.statusChangedAndLastCheckedFormatted"}}>
+    {{instance.lastTriggeredForFormatted}}
+</time>

+ 1 - 5
ambari-web/app/templates/main/alerts/definition_details.hbs

@@ -212,11 +212,7 @@
                   {{/if}}
                 </td>
                 <td>
-                  {{template "templates/main/alerts/alert_instance/status"}}
-                  <time class="timeago"
-                        rel="tooltip" {{bindAttr data-original-title="instance.statusChangedAndLastCheckedFormatted"}}>
-                    {{instance.lastTriggeredForFormatted}}
-                  </time>
+                  {{view App.AlertInstanceStateView instanceBinding="instance"}}
                 </td>
                 <td>{{view view.parentView.lastDayCount hostNameBinding="instance.hostName"}}</td>
                 <td>

+ 16 - 0
ambari-web/app/views/main/alerts/definition_details_view.js

@@ -318,4 +318,20 @@ App.AlertInstanceServiceHostView = Em.View.extend({
    */
   showSeparator: Em.computed.and('instance.serviceDisplayName', 'instance.hostName')
 
+});
+
+App.AlertInstanceStateView = Em.View.extend({
+
+  templateName: require('templates/main/alerts/alert_instance/status'),
+
+  didInsertElement: function () {
+    App.tooltip(this.$("[rel='StateTooltip']"));
+    App.tooltip(this.$("[rel='tooltip']"));
+  },
+
+  willDestroyElement: function() {
+    this.$("[rel='StateTooltip']").remove();
+    this.$("[rel='tooltip']").remove();
+  }
+
 });