mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix: url did not update correctly when closing settings view by using ESC key, fixes #8869
This commit is contained in:
parent
cff1c37064
commit
2d2800e710
@ -25,7 +25,6 @@ function ($, angular, coreModule) {
|
||||
function hideEditorPane(hideToShowOtherView) {
|
||||
if (editorScope) {
|
||||
editorScope.dismiss(hideToShowOtherView);
|
||||
scope.appEvent('dash-editor-hidden');
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +60,15 @@ function ($, angular, coreModule) {
|
||||
var urlParams = $location.search();
|
||||
if (options.editview === urlParams.editview) {
|
||||
delete urlParams.editview;
|
||||
$location.search(urlParams);
|
||||
|
||||
// even though we always are in apply phase here
|
||||
// some angular bug is causing location search updates to
|
||||
// not happen always so this is a hack fix or that
|
||||
setTimeout(function() {
|
||||
$rootScope.$apply(function() {
|
||||
$location.search(urlParams);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -129,10 +129,13 @@ class TimeSrv {
|
||||
}
|
||||
|
||||
// update url
|
||||
var params = this.$location.search();
|
||||
if (interval) {
|
||||
var params = this.$location.search();
|
||||
params.refresh = interval;
|
||||
this.$location.search(params);
|
||||
} else if (params.refresh) {
|
||||
delete params.refresh;
|
||||
this.$location.search(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<label class="small">From:</label>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-28">
|
||||
<input type="text" class="gf-form-input input-large" ng-model="ctrl.timeRaw.from" input-datetime>
|
||||
<input type="text" class="gf-form-input input-large" ng-model="ctrl.editTimeRaw.from" input-datetime>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<button class="btn gf-form-btn btn-primary" type="button" ng-click="openFromPicker=!openFromPicker">
|
||||
@ -22,7 +22,7 @@
|
||||
<label class="small">To:</label>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-28">
|
||||
<input type="text" class="gf-form-input input-large" ng-model="ctrl.timeRaw.to" input-datetime>
|
||||
<input type="text" class="gf-form-input input-large" ng-model="ctrl.editTimeRaw.to" input-datetime>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<button class="btn gf-form-btn btn-primary" type="button" ng-click="openToPicker=!openToPicker">
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user