Start query editor with placeholder text
parent
20ca434e97
commit
1aa7b4770a
|
@ -52,7 +52,7 @@ const QueryBuilder = React.createClass({
|
||||||
|
|
||||||
handleAddRawQuery() {
|
handleAddRawQuery() {
|
||||||
const newIndex = this.props.queries.length
|
const newIndex = this.props.queries.length
|
||||||
this.props.actions.addQuery({rawText: `SELECT "fields" from "db"."rp"."measurement"`})
|
this.props.actions.addQuery({rawText: ''})
|
||||||
this.handleSetActiveQueryIndex(newIndex)
|
this.handleSetActiveQueryIndex(newIndex)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ const QueryBuilder = React.createClass({
|
||||||
query={q}
|
query={q}
|
||||||
onSelect={this.handleSetActiveQueryIndex}
|
onSelect={this.handleSetActiveQueryIndex}
|
||||||
onDelete={onDeleteQuery}
|
onDelete={onDeleteQuery}
|
||||||
queryTabText={q.rawText || buildInfluxQLQuery(timeRange, q) || `SELECT "fields" FROM "db"."rp"."measurement"`}
|
queryTabText={q.rawText || buildInfluxQLQuery(timeRange, q) || `Query ${i + 1}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -91,9 +91,9 @@ const QueryEditor = React.createClass({
|
||||||
|
|
||||||
renderQuery() {
|
renderQuery() {
|
||||||
const {query, timeRange} = this.props
|
const {query, timeRange} = this.props
|
||||||
const statement = query.rawText || buildInfluxQLQuery(timeRange, query) || `SELECT "fields" FROM "db"."rp"."measurement"`
|
const statement = query.rawText || buildInfluxQLQuery(timeRange, query) || `Select a database, measurement, and field below.`
|
||||||
|
|
||||||
if (!query.rawText) {
|
if (typeof query.rawText !== 'string') {
|
||||||
return (
|
return (
|
||||||
<div className="query-builder--query-preview">
|
<div className="query-builder--query-preview">
|
||||||
<pre><code>{statement}</code></pre>
|
<pre><code>{statement}</code></pre>
|
||||||
|
|
|
@ -29,7 +29,7 @@ const RawQueryEditor = React.createClass({
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.handleUpdate()
|
this.handleUpdate()
|
||||||
} else if (e.keyCode === ESCAPE) {
|
} else if (e.keyCode === ESCAPE) {
|
||||||
this.setState({value: this.props.query.rawText}, () => {
|
this.setState({value: this.state.value}, () => {
|
||||||
this.editor.blur()
|
this.editor.blur()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@ import _ from 'lodash'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
const {oneOfType, number, string, shape, arrayOf, func} = PropTypes
|
const {oneOfType, number, string, shape, arrayOf, func} = PropTypes
|
||||||
|
const emptyCells = {
|
||||||
|
columns: [],
|
||||||
|
values: [],
|
||||||
|
}
|
||||||
|
|
||||||
const CustomCell = React.createClass({
|
const CustomCell = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -39,10 +43,7 @@ const ChronoTable = React.createClass({
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
cellData: {
|
cellData: emptyCells,
|
||||||
columns: [],
|
|
||||||
values: [],
|
|
||||||
},
|
|
||||||
columnWidths: {},
|
columnWidths: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -54,6 +55,10 @@ const ChronoTable = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchCellData(query) {
|
async fetchCellData(query) {
|
||||||
|
if (!query.text) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({isLoading: true})
|
this.setState({isLoading: true})
|
||||||
const {onEditRawStatus} = this.props
|
const {onEditRawStatus} = this.props
|
||||||
// second param is db, we want to leave this blank
|
// second param is db, we want to leave this blank
|
||||||
|
@ -87,9 +92,15 @@ const ChronoTable = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (this.props.query.text !== nextProps.query.text) {
|
if (!this.props.query || !nextProps.query) {
|
||||||
this.fetchCellData(nextProps.query)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.query.text === nextProps.query.text) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fetchCellData(nextProps.query)
|
||||||
},
|
},
|
||||||
|
|
||||||
handleColumnResize(newColumnWidth, columnKey) {
|
handleColumnResize(newColumnWidth, columnKey) {
|
||||||
|
|
Loading…
Reference in New Issue