Commit 04eefb84 by Torkel Ödegaard

fix(timepicker): fixed issue with timepicker and auto refresh and entering…

fix(timepicker): fixed issue with timepicker and auto refresh and entering manual time when timepicker dropdown is open, fixes #2897
parent 8789be76
...@@ -94,7 +94,7 @@ define([ ...@@ -94,7 +94,7 @@ define([
_.extend(this.time, time); _.extend(this.time, time);
// disable refresh if we have an absolute time // disable refresh if we have an absolute time
if (_.isString(time.to) && time.to.indexOf('now') === -1) { if (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);
} }
......
...@@ -32,11 +32,9 @@ export class TimePickerCtrl { ...@@ -32,11 +32,9 @@ export class TimePickerCtrl {
constructor(private $scope, private $rootScope, private timeSrv) { constructor(private $scope, private $rootScope, private timeSrv) {
$scope.ctrl = this; $scope.ctrl = this;
$rootScope.onAppEvent('refresh', () => this.init(), $scope);
$rootScope.onAppEvent('zoom-out', () => this.zoom(2), $scope); $rootScope.onAppEvent('zoom-out', () => this.zoom(2), $scope);
$rootScope.onAppEvent('dash-editor-hidden', () => { $rootScope.onAppEvent('refresh', () => this.init(), $scope);
this.isOpen = false; $rootScope.onAppEvent('dash-editor-hidden', () => this.isOpen = false, $scope);
}, $scope);
this.init(); this.init();
} }
...@@ -64,9 +62,14 @@ export class TimePickerCtrl { ...@@ -64,9 +62,14 @@ export class TimePickerCtrl {
this.rangeString = rangeUtil.describeTimeRange(timeRaw); this.rangeString = rangeUtil.describeTimeRange(timeRaw);
this.absolute = {fromJs: time.from.toDate(), toJs: time.to.toDate()}; this.absolute = {fromJs: time.from.toDate(), toJs: time.to.toDate()};
this.timeRaw = timeRaw;
this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>'; this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';
this.tooltip += this.dashboard.formatDate(time.to); this.tooltip += this.dashboard.formatDate(time.to);
// do not update time raw when dropdown is open
// as auto refresh will reset the from/to input fields
if (!this.isOpen) {
this.timeRaw = timeRaw;
}
} }
zoom(factor) { zoom(factor) {
...@@ -88,6 +91,7 @@ export class TimePickerCtrl { ...@@ -88,6 +91,7 @@ export class TimePickerCtrl {
} }
openDropdown() { openDropdown() {
this.init();
this.isOpen = true; this.isOpen = true;
this.timeOptions = rangeUtil.getRelativeTimesList(this.panel, this.rangeString); this.timeOptions = rangeUtil.getRelativeTimesList(this.panel, this.rangeString);
this.refresh = { this.refresh = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment