Commit 5e7d4bea by Erik Sundell

get intervals from explore function

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