Commit 5e7d4bea by Erik Sundell

get intervals from explore function

parent b36db6ac
......@@ -897,6 +897,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
onRemoveQueryRow={this.onRemoveQueryRow}
transactions={queryTransactions}
exploreEvents={this.exploreEvents}
range={range}
/>
<main className="m-t-2">
<ErrorBoundary>
......
import React, { PureComponent } from 'react';
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
import { Emitter } from 'app/core/utils/emitter';
import { getIntervals } from 'app/core/utils/explore';
import { DataQuery } from 'app/types';
import { RawTimeRange } from 'app/types/series';
import 'app/features/plugins/plugin_loader';
import { getTimeSrv } from 'app/features/dashboard/time_srv';
interface QueryEditorProps {
datasource: any;
......@@ -11,6 +14,7 @@ interface QueryEditorProps {
onQueryChange?: (value: DataQuery, override?: boolean) => void;
initialQuery: DataQuery;
exploreEvents: Emitter;
range: RawTimeRange;
}
export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
......@@ -22,7 +26,9 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
return;
}
const { datasource, initialQuery, exploreEvents } = this.props;
const { datasource, initialQuery, exploreEvents, range } = this.props;
this.initTimeSrv(range);
const loader = getAngularLoader();
const template = '<plugin-component type="query-ctrl"> </plugin-component>';
const target = { datasource: datasource.name, ...initialQuery };
......@@ -42,8 +48,7 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
getNextQueryLetter: x => '',
},
hideEditorRowActions: true,
interval: '1m',
intervalMs: 60000,
...getIntervals(range, datasource, null), // Possible to get resolution?
},
};
......@@ -56,6 +61,16 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
}
}
initTimeSrv(range) {
const timeSrv = getTimeSrv();
timeSrv.init({
time: range,
refresh: false,
getTimezone: () => 'utc',
timeRangeUpdated: () => console.log('refreshDashboard!'),
});
}
render() {
return <div ref={element => (this.element = element)} style={{ width: '100%' }} />;
}
......
......@@ -7,6 +7,7 @@ import { Emitter } from 'app/core/utils/emitter';
import QueryEditor from './QueryEditor';
import QueryTransactionStatus from './QueryTransactionStatus';
import { DataSource, DataQuery } from 'app/types';
import { RawTimeRange } from 'app/types/series';
function getFirstHintFromTransactions(transactions: QueryTransaction[]): QueryHint {
const transaction = transactions.find(qt => qt.hints && qt.hints.length > 0);
......@@ -30,6 +31,7 @@ interface QueryRowCommonProps {
history: HistoryItem[];
transactions: QueryTransaction[];
exploreEvents: Emitter;
range: RawTimeRange;
}
type QueryRowProps = QueryRowCommonProps &
......@@ -84,7 +86,7 @@ class QueryRow extends PureComponent<QueryRowProps> {
};
render() {
const { datasource, history, initialQuery, transactions, exploreEvents } = this.props;
const { datasource, history, initialQuery, transactions, exploreEvents, range } = this.props;
const transactionWithError = transactions.find(t => t.error !== undefined);
const hint = getFirstHintFromTransactions(transactions);
const queryError = transactionWithError ? transactionWithError.error : null;
......@@ -116,6 +118,7 @@ class QueryRow extends PureComponent<QueryRowProps> {
onExecuteQuery={this.onExecuteQuery}
initialQuery={initialQuery}
exploreEvents={exploreEvents}
range={range}
/>
)}
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment