Loki: Send current time range when fetching labels and values (#26622)

* Send current time range when fetching labels and values in Explore

* Pass range to Editors, in the same way as it was in Angular editors

* Remove unused imports

* Remove unused imports, props

* Update

* Update

* Update refresh condition

* Add comment
This commit is contained in:
Ivana Huckova
2020-07-30 18:04:20 +02:00
committed by GitHub
parent d88864f376
commit bf5d52c5c7
13 changed files with 63 additions and 110 deletions

View File

@@ -2,7 +2,7 @@
import React, { PureComponent } from 'react';
// Types
import { AbsoluteTimeRange, QueryEditorProps, PanelData } from '@grafana/data';
import { QueryEditorProps } from '@grafana/data';
import { InlineFormLabel } from '@grafana/ui';
import { LokiDatasource } from '../datasource';
import { LokiQuery } from '../types';
@@ -31,21 +31,6 @@ export class LokiQueryEditor extends PureComponent<Props, State> {
};
}
calcAbsoluteRange = (data: PanelData | undefined): AbsoluteTimeRange => {
if (data && data.request) {
const { range } = data.request;
return {
from: range.from.valueOf(),
to: range.to.valueOf(),
};
}
return {
from: Date.now() - 10000,
to: Date.now(),
};
};
onFieldChange = (query: LokiQuery, override?: any) => {
this.query.expr = query.expr;
};
@@ -63,7 +48,7 @@ export class LokiQueryEditor extends PureComponent<Props, State> {
};
render() {
const { datasource, query, data } = this.props;
const { datasource, query, data, range } = this.props;
const { legendFormat } = this.state;
return (
@@ -75,7 +60,7 @@ export class LokiQueryEditor extends PureComponent<Props, State> {
onRunQuery={this.onRunQuery}
history={[]}
data={data}
absoluteRange={this.calcAbsoluteRange(data)}
range={range}
/>
<div className="gf-form-inline">