浏览代码

AMBARI-1172. Alert status change does not change time for the alerts. (srimanth via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1438855 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父节点
当前提交
40c564ad53
共有 2 个文件被更改,包括 52 次插入4 次删除
  1. 3 0
      CHANGES.txt
  2. 49 4
      ambari-web/app/mappers/alerts_mapper.js

+ 3 - 0
CHANGES.txt

@@ -151,6 +151,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1172. Alert status change does not change time for the alerts.
+ (srimanth via yusaku) 
+
  AMBARI-1264. Service graphs refresh with spinners. (yusaku)
 
  AMBARI-1257. Separator missing in between Oozie and ZooKeeper. (yusaku)

+ 49 - 4
ambari-web/app/mappers/alerts_mapper.js

@@ -48,8 +48,22 @@ App.alertsMapper = App.QuickDataMapper.create({
         this.update(alerts);
       } else {
         var result = [];
-        alerts.forEach(function (item) {
-          result.push(this.parseIt(item, this.config));
+        alerts.forEach(function(item){
+          var applyConfig = jQuery.extend({}, this.config);
+          if (item.current_state && item.last_hard_state && item.current_state != item.last_hard_state) {
+            switch (item.current_state) {
+              case "0":
+                applyConfig['date'] = 'last_time_ok';
+                break;
+              case "1":
+                applyConfig['date'] = 'last_time_warning';
+                break;
+              case "2":
+                applyConfig['date'] = 'last_time_critical';
+                break;
+            }
+          }
+          result.push(this.parseIt(item, applyConfig));
         }, this);
         App.store.loadMany(this.get('model'), result);
       }
@@ -65,11 +79,42 @@ App.alertsMapper = App.QuickDataMapper.create({
     alerts.forEach(function(item){
       var existAlert = titleToAlertMap[item.service_type + item.service_description + item.plugin_output];
       if (existAlert == null) {
-        newRecords.push(this.parseIt(item, this.config));
+        var applyConfig = jQuery.extend({}, this.config);
+        if (item.current_state && item.last_hard_state && item.current_state != item.last_hard_state) {
+          switch (item.current_state) {
+            case "0":
+              applyConfig['date'] = 'last_time_ok';
+              break;
+            case "1":
+              applyConfig['date'] = 'last_time_warning';
+              break;
+            case "2":
+              applyConfig['date'] = 'last_time_critical';
+              break;
+          }
+        }
+        newRecords.push(this.parseIt(item, applyConfig));
       } else {
         // update record
         existAlert.set('serviceType', item.service_type);
-        existAlert.set('date', DS.attr.transforms.date.from(item.last_hard_state_change));
+        if (item.current_state && item.last_hard_state && item.current_state != item.last_hard_state) {
+          switch (item.current_state) {
+            case "0":
+              existAlert.set('date', DS.attr.transforms.date.from(item.last_time_ok));
+              break;
+            case "1":
+              existAlert.set('date', DS.attr.transforms.date.from(item.last_time_warning));
+              break;
+            case "2":
+              existAlert.set('date', DS.attr.transforms.date.from(item.last_time_critical));
+              break;
+            default:
+              existAlert.set('date', DS.attr.transforms.date.from(item.last_hard_state_change));
+              break;
+          }
+        }else{
+          existAlert.set('date', DS.attr.transforms.date.from(item.last_hard_state_change));
+        }
         existAlert.set('status', item.current_state);
         existAlert.set('message', item.plugin_output);
         existAlert.set('lastHardStateChange', item.last_hard_state_change);