Files
grafana/public/app/features/scenes/core/SceneTimeRange.tsx
Torkel Ödegaard 156ed4b56c VizPanel: Support panel migrations and state changes (#58501)
* VizPanel: Make it more real

* Updates

* Progress on query runner and max data points from width

* Updated

* Update

* Tests

* Fixed issue with migration

* Moving VizPanel

* Fixed migration issue due to pluginVersion not being set

* Update public/app/features/scenes/querying/SceneQueryRunner.test.ts

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>

* Some minor review fixes

* Added expect

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
2022-11-21 15:31:01 +01:00

38 lines
1013 B
TypeScript

import { getDefaultTimeRange, getTimeZone, TimeRange, UrlQueryMap } from '@grafana/data';
import { SceneObjectBase } from './SceneObjectBase';
import { SceneObjectWithUrlSync, SceneTimeRangeState } from './types';
export class SceneTimeRange extends SceneObjectBase<SceneTimeRangeState> implements SceneObjectWithUrlSync {
public constructor(state: Partial<SceneTimeRangeState> = {}) {
super({
...getDefaultTimeRange(),
timeZone: getTimeZone(),
...state,
});
}
public onTimeRangeChange = (timeRange: TimeRange) => {
this.setState(timeRange);
};
public onRefresh = () => {
// TODO re-eval time range
this.setState({ ...this.state });
};
public onIntervalChanged = (_: string) => {};
/** These url sync functions are only placeholders for something more sophisticated */
public getUrlState() {
return {
from: this.state.raw.from,
to: this.state.raw.to,
} as any;
}
public updateFromUrl(values: UrlQueryMap) {
// TODO
}
}