mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixed refresh setting for absolute time
This commit is contained in:
parent
0ff5ff5dbe
commit
712a420217
public
@ -90,10 +90,15 @@ define([
|
||||
timer.cancel(this.refresh_timer);
|
||||
};
|
||||
|
||||
this.setTime = function(time) {
|
||||
this.setTime = function(time, enableRefresh) {
|
||||
_.extend(this.time, time);
|
||||
|
||||
if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) {
|
||||
// disable refresh if zoom in or zoom out
|
||||
if (!enableRefresh && 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) {
|
||||
this.setAutoRefresh(this.old_refresh);
|
||||
this.old_refresh = null;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ export class TimePickerCtrl {
|
||||
this.timeSrv.setAutoRefresh(this.refresh.value);
|
||||
}
|
||||
|
||||
this.timeSrv.setTime(this.timeRaw);
|
||||
this.timeSrv.setTime(this.timeRaw, true);
|
||||
this.$rootScope.appEvent('hide-dash-editor');
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,17 @@ define([
|
||||
expect(_dashboard.refresh).to.be('30s');
|
||||
});
|
||||
|
||||
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('10s');
|
||||
expect(_dashboard.refresh).to.be(false);
|
||||
ctx.service.setTime({from: '2011-01-01', to: 'now' });
|
||||
expect(_dashboard.refresh).to.be('10s');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user