mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
[Shortcuts] Fixes shortcuts for moving time range backwards and forwards (#18305)
Closes #18159
This commit is contained in:
committed by
Leonard Gram
parent
21f702f7c9
commit
bcf28cb7a2
@@ -12,7 +12,7 @@ import { ITimeoutService, ILocationService } from 'angular';
|
||||
import { ContextSrv } from 'app/core/services/context_srv';
|
||||
import { DashboardModel } from '../state/DashboardModel';
|
||||
import { toUtc, dateTime, isDateTime } from '@grafana/data';
|
||||
import { getZoomedTimeRange } from 'app/core/utils/timePicker';
|
||||
import { getZoomedTimeRange, getShiftedTimeRange } from 'app/core/utils/timePicker';
|
||||
|
||||
export class TimeSrv {
|
||||
time: any;
|
||||
@@ -35,6 +35,7 @@ export class TimeSrv {
|
||||
this.time = { from: '6h', to: 'now' };
|
||||
|
||||
$rootScope.$on('zoom-out', this.zoomOut.bind(this));
|
||||
$rootScope.$on('shift-time', this.shiftTime.bind(this));
|
||||
$rootScope.$on('$routeUpdate', this.routeUpdated.bind(this));
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
@@ -243,6 +244,16 @@ export class TimeSrv {
|
||||
|
||||
this.setTime({ from: toUtc(from), to: toUtc(to) });
|
||||
}
|
||||
|
||||
shiftTime(e: any, direction: number) {
|
||||
const range = this.timeRange();
|
||||
const { from, to } = getShiftedTimeRange(direction, range);
|
||||
|
||||
this.setTime({
|
||||
from: toUtc(from),
|
||||
to: toUtc(to),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let singleton: TimeSrv;
|
||||
|
||||
Reference in New Issue
Block a user