Explore: Uses new TimePicker from Grafana/UI (#17793)

* Wip: Intiail commit

* Refactor: Replaces TimePicker in Explore

* Refactor: Removes Angular TimePicker folder

* Refactor: Adds tests for getShiftedTimeRange

* Fix: Fixes invalid import to removed TimePicker

* Fix: Fixes dateTime tests

* Refactor: Reuses getShiftedTimeRange for both Explore and Dashboards

* Refactor: Shares getZoomedTimeRange between Explore and Dashboard
This commit is contained in:
Hugo Häggmark
2019-06-28 12:07:55 +02:00
committed by GitHub
parent 2379de53c4
commit ead4b1f5c7
27 changed files with 302 additions and 1032 deletions

View File

@@ -12,6 +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/ui/src/utils/moment_wrapper';
import { getZoomedTimeRange } from 'app/core/utils/timePicker';
export class TimeSrv {
time: any;
@@ -238,12 +239,7 @@ export class TimeSrv {
zoomOut(e: any, factor: number) {
const range = this.timeRange();
const timespan = range.to.valueOf() - range.from.valueOf();
const center = range.to.valueOf() - timespan / 2;
const to = center + (timespan * factor) / 2;
const from = center - (timespan * factor) / 2;
const { from, to } = getZoomedTimeRange(range, factor);
this.setTime({ from: toUtc(from), to: toUtc(to) });
}