From 3ad2cd053d39f745883254ba14cd769476ac1fd3 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Thu, 5 Oct 2017 10:20:00 -0600 Subject: [PATCH] Add Data Explorer InfluxQL query and location query synchronization --- ui/src/data_explorer/components/QueryMaker.js | 7 +--- .../data_explorer/containers/DataExplorer.js | 42 +++++++++++++++---- ui/src/utils/influxql.js | 3 ++ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ui/src/data_explorer/components/QueryMaker.js b/ui/src/data_explorer/components/QueryMaker.js index 12ee0317e..5b7fd4d46 100644 --- a/ui/src/data_explorer/components/QueryMaker.js +++ b/ui/src/data_explorer/components/QueryMaker.js @@ -2,19 +2,16 @@ import React, {PropTypes} from 'react' import QueryEditor from './QueryEditor' import SchemaExplorer from 'src/shared/components/SchemaExplorer' -import buildInfluxQLQuery from 'utils/influxql' +import {buildRawText} from 'utils/influxql' const rawTextBinder = (links, id, action) => text => action(links.queries, id, text) -const buildText = (q, timeRange) => - q.rawText || buildInfluxQLQuery(timeRange, q) || '' - const QueryMaker = ({source, actions, timeRange, activeQuery}) =>
{ this.setState({showWriteForm: false}) } @@ -56,12 +78,8 @@ class DataExplorer extends Component { writeLineProtocol, } = this.props - const {activeQueryIndex, showWriteForm} = this.state - const selectedDatabase = _.get( - queryConfigs, - [`${activeQueryIndex}`, 'database'], - null - ) + const {showWriteForm} = this.state + const selectedDatabase = _.get(queryConfigs, ['0', 'database'], null) return (
@@ -101,7 +119,7 @@ class DataExplorer extends Component { timeRange={timeRange} queryConfigs={queryConfigs} errorThrown={errorThrownAction} - activeQueryIndex={activeQueryIndex} + activeQueryIndex={0} editQueryStatus={queryConfigActions.editQueryStatus} views={VIS_VIEWS} /> @@ -121,6 +139,12 @@ DataExplorer.propTypes = { queries: string.isRequired, }).isRequired, }).isRequired, + router: shape({ + location: shape({ + search: string, + pathanme: string, + }), + }), queryConfigs: arrayOf(shape({})).isRequired, queryConfigActions: shape({ editQueryStatus: func.isRequired, @@ -181,4 +205,6 @@ const mapDispatchToProps = dispatch => { } } -export default connect(mapStateToProps, mapDispatchToProps)(DataExplorer) +export default connect(mapStateToProps, mapDispatchToProps)( + withRouter(DataExplorer) +) diff --git a/ui/src/utils/influxql.js b/ui/src/utils/influxql.js index d2ff2b1bb..71ba07f0a 100644 --- a/ui/src/utils/influxql.js +++ b/ui/src/utils/influxql.js @@ -199,3 +199,6 @@ export const buildQueriesForLayouts = (cell, source, timeRange, host) => { return {...query, host: source.links.proxy, text: queryText} }) } + +export const buildRawText = (q, timeRange) => + q.rawText || buildInfluxQLQuery(timeRange, q) || ''