Get new dbs, rps, meas, fields etc when selecting a new source
parent
6230ddc512
commit
ae364f5018
|
@ -257,9 +257,20 @@ class CellEditorOverlay extends Component {
|
||||||
return (selected && selected.text) || 'No sources'
|
return (selected && selected.text) || 'No sources'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSource = () => {
|
||||||
|
const {source, sources} = this.props
|
||||||
|
const query = _.get(this.state.queriesWorkingDraft, 0, false)
|
||||||
|
|
||||||
|
if (!query || !query.source) {
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
|
||||||
|
const querySource = sources.find(s => s.id === query.source.id)
|
||||||
|
return querySource || source
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
source,
|
|
||||||
onCancel,
|
onCancel,
|
||||||
templates,
|
templates,
|
||||||
timeRange,
|
timeRange,
|
||||||
|
@ -330,7 +341,7 @@ class CellEditorOverlay extends Component {
|
||||||
onSetYAxisBoundMax={this.handleSetYAxisBoundMax}
|
onSetYAxisBoundMax={this.handleSetYAxisBoundMax}
|
||||||
/>
|
/>
|
||||||
: <QueryMaker
|
: <QueryMaker
|
||||||
source={source}
|
source={this.getSource()}
|
||||||
templates={templates}
|
templates={templates}
|
||||||
queries={queriesWorkingDraft}
|
queries={queriesWorkingDraft}
|
||||||
actions={queryActions}
|
actions={queryActions}
|
||||||
|
|
|
@ -13,7 +13,7 @@ const buildText = q =>
|
||||||
q.rawText || buildInfluxQLQuery(q.range || TEMPLATE_RANGE, q) || ''
|
q.rawText || buildInfluxQLQuery(q.range || TEMPLATE_RANGE, q) || ''
|
||||||
|
|
||||||
const QueryMaker = ({
|
const QueryMaker = ({
|
||||||
source: {links},
|
source,
|
||||||
actions,
|
actions,
|
||||||
queries,
|
queries,
|
||||||
timeRange,
|
timeRange,
|
||||||
|
@ -39,7 +39,7 @@ const QueryMaker = ({
|
||||||
query={buildText(activeQuery)}
|
query={buildText(activeQuery)}
|
||||||
config={activeQuery}
|
config={activeQuery}
|
||||||
onUpdate={rawTextBinder(
|
onUpdate={rawTextBinder(
|
||||||
links,
|
source.links,
|
||||||
activeQuery.id,
|
activeQuery.id,
|
||||||
actions.editRawTextAsync
|
actions.editRawTextAsync
|
||||||
)}
|
)}
|
||||||
|
@ -49,6 +49,7 @@ const QueryMaker = ({
|
||||||
query={activeQuery}
|
query={activeQuery}
|
||||||
actions={actions}
|
actions={actions}
|
||||||
onAddQuery={onAddQuery}
|
onAddQuery={onAddQuery}
|
||||||
|
source={source}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
: <EmptyQuery onAddQuery={onAddQuery} />}
|
: <EmptyQuery onAddQuery={onAddQuery} />}
|
||||||
|
|
|
@ -14,6 +14,17 @@ const DatabaseList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
query: shape({}).isRequired,
|
query: shape({}).isRequired,
|
||||||
onChooseNamespace: func.isRequired,
|
onChooseNamespace: func.isRequired,
|
||||||
|
querySource: shape({
|
||||||
|
links: shape({
|
||||||
|
proxy: string.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultProps() {
|
||||||
|
return {
|
||||||
|
source: null,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
|
@ -31,8 +42,23 @@ const DatabaseList = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
this.getDbRp()
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (_.isEqual(prevProps.querySource, this.props.querySource)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getDbRp()
|
||||||
|
},
|
||||||
|
|
||||||
|
getDbRp() {
|
||||||
const {source} = this.context
|
const {source} = this.context
|
||||||
const proxy = source.links.proxy
|
const {querySource} = this.props
|
||||||
|
const proxy =
|
||||||
|
_.get(querySource, ['links', 'proxy'], null) || source.links.proxy
|
||||||
|
|
||||||
showDatabases(proxy).then(resp => {
|
showDatabases(proxy).then(resp => {
|
||||||
const {errors, databases} = showDatabasesParser(resp.data)
|
const {errors, databases} = showDatabasesParser(resp.data)
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, {PropTypes, Component} from 'react'
|
import React, {PropTypes, Component} from 'react'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
import FieldListItem from 'src/data_explorer/components/FieldListItem'
|
import FieldListItem from 'src/data_explorer/components/FieldListItem'
|
||||||
import GroupByTimeDropdown from 'src/data_explorer/components/GroupByTimeDropdown'
|
import GroupByTimeDropdown from 'src/data_explorer/components/GroupByTimeDropdown'
|
||||||
|
@ -26,7 +27,8 @@ class FieldList extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const {database, measurement, retentionPolicy} = this.props.query
|
const {querySource, query} = this.props
|
||||||
|
const {database, measurement, retentionPolicy} = query
|
||||||
const {
|
const {
|
||||||
database: prevDB,
|
database: prevDB,
|
||||||
measurement: prevMeas,
|
measurement: prevMeas,
|
||||||
|
@ -39,7 +41,8 @@ class FieldList extends Component {
|
||||||
if (
|
if (
|
||||||
database === prevDB &&
|
database === prevDB &&
|
||||||
measurement === prevMeas &&
|
measurement === prevMeas &&
|
||||||
retentionPolicy === prevRP
|
retentionPolicy === prevRP &&
|
||||||
|
_.isEqual(prevProps.querySource, querySource)
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -58,14 +61,12 @@ class FieldList extends Component {
|
||||||
_getFields = () => {
|
_getFields = () => {
|
||||||
const {database, measurement, retentionPolicy} = this.props.query
|
const {database, measurement, retentionPolicy} = this.props.query
|
||||||
const {source} = this.context
|
const {source} = this.context
|
||||||
const proxySource = source.links.proxy
|
const {querySource} = this.props
|
||||||
|
|
||||||
showFieldKeys(
|
const proxy =
|
||||||
proxySource,
|
_.get(querySource, ['links', 'proxy'], null) || source.links.proxy
|
||||||
database,
|
|
||||||
measurement,
|
showFieldKeys(proxy, database, measurement, retentionPolicy).then(resp => {
|
||||||
retentionPolicy
|
|
||||||
).then(resp => {
|
|
||||||
const {errors, fieldSets} = showFieldKeysParser(resp.data)
|
const {errors, fieldSets} = showFieldKeysParser(resp.data)
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
console.error('Error parsing fields keys: ', errors)
|
console.error('Error parsing fields keys: ', errors)
|
||||||
|
@ -171,6 +172,11 @@ FieldList.propTypes = {
|
||||||
applyFuncsToField: func.isRequired,
|
applyFuncsToField: func.isRequired,
|
||||||
isKapacitorRule: bool,
|
isKapacitorRule: bool,
|
||||||
isInDataExplorer: bool,
|
isInDataExplorer: bool,
|
||||||
|
querySource: shape({
|
||||||
|
links: shape({
|
||||||
|
proxy: string.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FieldList
|
export default FieldList
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, {PropTypes} from 'react'
|
import React, {PropTypes} from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
import {showMeasurements} from 'shared/apis/metaQuery'
|
import {showMeasurements} from 'shared/apis/metaQuery'
|
||||||
import showMeasurementsParser from 'shared/parsing/showMeasurements'
|
import showMeasurementsParser from 'shared/parsing/showMeasurements'
|
||||||
|
@ -19,6 +20,11 @@ const MeasurementList = React.createClass({
|
||||||
onChooseTag: func.isRequired,
|
onChooseTag: func.isRequired,
|
||||||
onToggleTagAcceptance: func.isRequired,
|
onToggleTagAcceptance: func.isRequired,
|
||||||
onGroupByTag: func.isRequired,
|
onGroupByTag: func.isRequired,
|
||||||
|
querySource: shape({
|
||||||
|
links: shape({
|
||||||
|
proxy: string.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
|
@ -36,6 +42,12 @@ const MeasurementList = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDefaultProps() {
|
||||||
|
return {
|
||||||
|
querySource: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (!this.props.query.database) {
|
if (!this.props.query.database) {
|
||||||
return
|
return
|
||||||
|
@ -45,13 +57,16 @@ const MeasurementList = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const {query} = this.props
|
const {query, querySource} = this.props
|
||||||
|
|
||||||
if (!query.database) {
|
if (!query.database) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevProps.query.database === query.database) {
|
if (
|
||||||
|
prevProps.query.database === query.database &&
|
||||||
|
_.isEqual(prevProps.querySource, querySource)
|
||||||
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +196,11 @@ const MeasurementList = React.createClass({
|
||||||
|
|
||||||
_getMeasurements() {
|
_getMeasurements() {
|
||||||
const {source} = this.context
|
const {source} = this.context
|
||||||
const proxy = source.links.proxy
|
const {querySource} = this.props
|
||||||
|
|
||||||
|
const proxy =
|
||||||
|
_.get(querySource, ['links', 'proxy'], null) || source.links.proxy
|
||||||
|
|
||||||
showMeasurements(proxy, this.props.query.database).then(resp => {
|
showMeasurements(proxy, this.props.query.database).then(resp => {
|
||||||
const {errors, measurementSets} = showMeasurementsParser(resp.data)
|
const {errors, measurementSets} = showMeasurementsParser(resp.data)
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ const actionBinder = (id, action) => item => action(id, item)
|
||||||
const SchemaExplorer = ({
|
const SchemaExplorer = ({
|
||||||
query,
|
query,
|
||||||
query: {id},
|
query: {id},
|
||||||
|
source,
|
||||||
actions: {
|
actions: {
|
||||||
chooseTag,
|
chooseTag,
|
||||||
groupByTag,
|
groupByTag,
|
||||||
|
@ -24,17 +25,22 @@ const SchemaExplorer = ({
|
||||||
<div className="query-builder">
|
<div className="query-builder">
|
||||||
<DatabaseList
|
<DatabaseList
|
||||||
query={query}
|
query={query}
|
||||||
|
querySource={source}
|
||||||
onChooseNamespace={actionBinder(id, chooseNamespace)}
|
onChooseNamespace={actionBinder(id, chooseNamespace)}
|
||||||
/>
|
/>
|
||||||
<MeasurementList
|
<MeasurementList
|
||||||
|
source={source}
|
||||||
query={query}
|
query={query}
|
||||||
|
querySource={source}
|
||||||
onChooseTag={actionBinder(id, chooseTag)}
|
onChooseTag={actionBinder(id, chooseTag)}
|
||||||
onGroupByTag={actionBinder(id, groupByTag)}
|
onGroupByTag={actionBinder(id, groupByTag)}
|
||||||
onChooseMeasurement={actionBinder(id, chooseMeasurement)}
|
onChooseMeasurement={actionBinder(id, chooseMeasurement)}
|
||||||
onToggleTagAcceptance={actionBinder(id, toggleTagAcceptance)}
|
onToggleTagAcceptance={actionBinder(id, toggleTagAcceptance)}
|
||||||
/>
|
/>
|
||||||
<FieldList
|
<FieldList
|
||||||
|
source={source}
|
||||||
query={query}
|
query={query}
|
||||||
|
querySource={source}
|
||||||
onToggleField={actionBinder(id, toggleFieldWithGroupByInterval)}
|
onToggleField={actionBinder(id, toggleFieldWithGroupByInterval)}
|
||||||
onFill={actionBinder(id, fill)}
|
onFill={actionBinder(id, fill)}
|
||||||
onGroupByTime={actionBinder(id, groupByTime)}
|
onGroupByTime={actionBinder(id, groupByTime)}
|
||||||
|
@ -60,6 +66,7 @@ SchemaExplorer.propTypes = {
|
||||||
fill: func.isRequired,
|
fill: func.isRequired,
|
||||||
editRawTextAsync: func.isRequired,
|
editRawTextAsync: func.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
|
source: shape({}),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SchemaExplorer
|
export default SchemaExplorer
|
||||||
|
|
Loading…
Reference in New Issue