Просмотр исходного кода

Enabled refresh interval for absolute time range

utkarshcmu 10 лет назад
Родитель
Сommit
0ff5ff5dbe
2 измененных файлов с 10 добавлено и 8 удалено
  1. 1 6
      public/app/features/dashboard/timeSrv.js
  2. 9 2
      public/test/specs/time_srv_specs.js

+ 1 - 6
public/app/features/dashboard/timeSrv.js

@@ -93,12 +93,7 @@ define([
     this.setTime = function(time) {
       _.extend(this.time, time);
 
-      // disable refresh if we have an absolute time
-      if (moment.isMoment(time.to)) {
-        this.old_refresh = this.dashboard.refresh || this.old_refresh;
-        this.setAutoRefresh(false);
-      }
-      else if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) {
+      if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) {
         this.setAutoRefresh(this.old_refresh);
         this.old_refresh = null;
       }

+ 9 - 2
public/test/specs/time_srv_specs.js

@@ -78,17 +78,24 @@ define([
     });
 
     describe('setTime', function() {
-      it('should return disable refresh for absolute times', function() {
+      it('should return disable refresh if refresh is disabled for any range', function() {
         _dashboard.refresh = false;
 
         ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
         expect(_dashboard.refresh).to.be(false);
       });
 
+      it('should restore refresh for absolute time range', function() {
+        _dashboard.refresh = '30s';
+
+        ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
+        expect(_dashboard.refresh).to.be('30s');
+      });
+
       it('should restore refresh after relative time range is set', function() {
         _dashboard.refresh = '10s';
         ctx.service.setTime({from: moment([2011,1,1]), to: moment([2015,1,1])});
-        expect(_dashboard.refresh).to.be(false);
+        expect(_dashboard.refresh).to.be('10s');
         ctx.service.setTime({from: '2011-01-01', to: 'now' });
         expect(_dashboard.refresh).to.be('10s');
       });