mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user