mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'refresh' of https://github.com/utkarshcmu/grafana into utkarshcmu-refresh
This commit is contained in:
commit
d80458ef81
@ -90,11 +90,11 @@ define([
|
|||||||
timer.cancel(this.refresh_timer);
|
timer.cancel(this.refresh_timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setTime = function(time) {
|
this.setTime = function(time, enableRefresh) {
|
||||||
_.extend(this.time, time);
|
_.extend(this.time, time);
|
||||||
|
|
||||||
// disable refresh if we have an absolute time
|
// disable refresh if zoom in or zoom out
|
||||||
if (moment.isMoment(time.to)) {
|
if (!enableRefresh && moment.isMoment(time.to)) {
|
||||||
this.old_refresh = this.dashboard.refresh || this.old_refresh;
|
this.old_refresh = this.dashboard.refresh || this.old_refresh;
|
||||||
this.setAutoRefresh(false);
|
this.setAutoRefresh(false);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ export class TimePickerCtrl {
|
|||||||
this.timeSrv.setAutoRefresh(this.refresh.value);
|
this.timeSrv.setAutoRefresh(this.refresh.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timeSrv.setTime(this.timeRaw);
|
this.timeSrv.setTime(this.timeRaw, true);
|
||||||
this.$rootScope.appEvent('hide-dash-editor');
|
this.$rootScope.appEvent('hide-dash-editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +78,20 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('setTime', function() {
|
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;
|
_dashboard.refresh = false;
|
||||||
|
|
||||||
ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
|
ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
|
||||||
expect(_dashboard.refresh).to.be(false);
|
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() {
|
it('should restore refresh after relative time range is set', function() {
|
||||||
_dashboard.refresh = '10s';
|
_dashboard.refresh = '10s';
|
||||||
ctx.service.setTime({from: moment([2011,1,1]), to: moment([2015,1,1])});
|
ctx.service.setTime({from: moment([2011,1,1]), to: moment([2015,1,1])});
|
||||||
|
Loading…
Reference in New Issue
Block a user