|
|
@@ -18,11 +18,11 @@ export class TimePickerCtrl {
|
|
|
panel: any;
|
|
|
absolute: any;
|
|
|
timeRaw: any;
|
|
|
+ editTimeRaw: any;
|
|
|
tooltip: string;
|
|
|
rangeString: string;
|
|
|
timeOptions: any;
|
|
|
refresh: any;
|
|
|
- isOpen: boolean;
|
|
|
isUtc: boolean;
|
|
|
firstDayOfWeek: number;
|
|
|
|
|
|
@@ -32,18 +32,18 @@ export class TimePickerCtrl {
|
|
|
|
|
|
$rootScope.onAppEvent('shift-time-forward', () => this.move(1), $scope);
|
|
|
$rootScope.onAppEvent('shift-time-backward', () => this.move(-1), $scope);
|
|
|
- $rootScope.onAppEvent('refresh', () => this.init(), $scope);
|
|
|
- $rootScope.onAppEvent('dash-editor-hidden', () => this.isOpen = false, $scope);
|
|
|
- this.init();
|
|
|
- }
|
|
|
+ $rootScope.onAppEvent('refresh', this.onRefresh.bind(this), $scope);
|
|
|
|
|
|
- init() {
|
|
|
+ // init options
|
|
|
this.panel = this.dashboard.timepicker;
|
|
|
-
|
|
|
_.defaults(this.panel, TimePickerCtrl.defaults);
|
|
|
-
|
|
|
this.firstDayOfWeek = moment.localeData().firstDayOfWeek();
|
|
|
|
|
|
+ // init time stuff
|
|
|
+ this.onRefresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ onRefresh() {
|
|
|
var time = angular.copy(this.timeSrv.timeRange());
|
|
|
var timeRaw = angular.copy(time.raw);
|
|
|
|
|
|
@@ -65,12 +65,7 @@ export class TimePickerCtrl {
|
|
|
this.absolute = {fromJs: time.from.toDate(), toJs: time.to.toDate()};
|
|
|
this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';
|
|
|
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;
|
|
|
- }
|
|
|
+ this.timeRaw = timeRaw;
|
|
|
}
|
|
|
|
|
|
zoom(factor) {
|
|
|
@@ -101,8 +96,8 @@ export class TimePickerCtrl {
|
|
|
}
|
|
|
|
|
|
openDropdown() {
|
|
|
- this.init();
|
|
|
- this.isOpen = true;
|
|
|
+ this.onRefresh();
|
|
|
+ this.editTimeRaw = this.timeRaw;
|
|
|
this.timeOptions = rangeUtil.getRelativeTimesList(this.panel, this.rangeString);
|
|
|
this.refresh = {
|
|
|
value: this.dashboard.refresh,
|
|
|
@@ -125,16 +120,16 @@ export class TimePickerCtrl {
|
|
|
this.timeSrv.setAutoRefresh(this.refresh.value);
|
|
|
}
|
|
|
|
|
|
- this.timeSrv.setTime(this.timeRaw);
|
|
|
+ this.timeSrv.setTime(this.editTimeRaw);
|
|
|
this.$rootScope.appEvent('hide-dash-editor');
|
|
|
}
|
|
|
|
|
|
absoluteFromChanged() {
|
|
|
- this.timeRaw.from = this.getAbsoluteMomentForTimezone(this.absolute.fromJs);
|
|
|
+ this.editTimeRaw.from = this.getAbsoluteMomentForTimezone(this.absolute.fromJs);
|
|
|
}
|
|
|
|
|
|
absoluteToChanged() {
|
|
|
- this.timeRaw.to = this.getAbsoluteMomentForTimezone(this.absolute.toJs);
|
|
|
+ this.editTimeRaw.to = this.getAbsoluteMomentForTimezone(this.absolute.toJs);
|
|
|
}
|
|
|
|
|
|
getAbsoluteMomentForTimezone(jsDate) {
|