浏览代码

AMBARI-1313. Alert time jumps between 'less than a minute ago' and 'about a minute ago'. (srimanth via yusaku)

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

+ 3 - 0
CHANGES.txt

@@ -213,6 +213,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1313. Alert time jumps between 'less than a minute ago' and 'about a
+ minute ago'. (srimanth via yusaku) 
+
  AMBARI-1304. When switching jobs in timeline + tasks charts, blank charts show.
  (Arun Kandregula via yusaku) 
 

+ 12 - 1
ambari-web/app/models/alert.js

@@ -79,12 +79,23 @@ App.Alert = DS.Model.extend({
       }
       var prevSuffix = $.timeago.settings.strings.suffixAgo;
       $.timeago.settings.strings.suffixAgo = '';
-      var since = prefix + $.timeago(d);
+      var since = prefix + $.timeago(this.makeTimeAtleastMinuteAgo(d));
       $.timeago.settings.strings.suffixAgo = prevSuffix;
       return since;
     }
     return "";
   }.property('date', 'status'),
+  
+  makeTimeAtleastMinuteAgo: function(d){
+    var diff = new Date().getTime() - d.getTime();
+    if (diff < 60000) {
+      diff = 60000 - diff;
+      var newD = new Date(d.getTime() - diff );
+      //console.log("Making time more than 1 minute. New time=",newD,", Old time=",d);
+      return newD;
+    }
+    return d;
+  },
 
   /**
    * Provides more details about when this alert happened.