فهرست منبع

Merge branch 'subsecond-influx' of https://github.com/abrander/grafana

Torkel Ödegaard 10 سال پیش
والد
کامیت
8f0269de76
2فایلهای تغییر یافته به همراه8 افزوده شده و 3 حذف شده
  1. 7 2
      public/app/components/kbn.js
  2. 1 1
      public/test/specs/kbn-format-specs.js

+ 7 - 2
public/app/components/kbn.js

@@ -81,11 +81,16 @@ function($, _, moment) {
     if(numminutes){
       return numminutes + 'm';
     }
-    var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
+    var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60);
     if(numseconds){
       return numseconds + 's';
     }
-    return 'less then a second'; //'just now' //or other string you like;
+    var nummilliseconds = Math.floor(seconds * 1000.0);
+    if(nummilliseconds){
+      return nummilliseconds + 'ms';
+    }
+
+    return 'less then a millisecond'; //'just now' //or other string you like;
   };
 
   kbn.to_percent = function(number,outof) {

+ 1 - 1
public/test/specs/kbn-format-specs.js

@@ -63,7 +63,7 @@ define([
     it('10m 1600 resolution', function() {
       var range = { from: kbn.parseDate('now-10m'), to: kbn.parseDate('now') };
       var str = kbn.calculateInterval(range, 1600, null);
-      expect(str).to.be('0.1s');
+      expect(str).to.be('100ms');
     });
 
     it('fixed user interval', function() {