Remove MultiTable
parent
afde7fcf69
commit
3a4c955474
|
@ -1,94 +0,0 @@
|
||||||
import React, {PropTypes} from 'react'
|
|
||||||
import Table from './Table'
|
|
||||||
import classNames from 'classnames'
|
|
||||||
|
|
||||||
const {
|
|
||||||
arrayOf,
|
|
||||||
bool,
|
|
||||||
func,
|
|
||||||
number,
|
|
||||||
shape,
|
|
||||||
string,
|
|
||||||
} = PropTypes
|
|
||||||
|
|
||||||
const MultiTable = React.createClass({
|
|
||||||
propTypes: {
|
|
||||||
queries: arrayOf(shape({
|
|
||||||
host: arrayOf(string.isRequired).isRequired,
|
|
||||||
text: string.isRequired,
|
|
||||||
})),
|
|
||||||
height: number,
|
|
||||||
onEditRawStatus: func.isRequired,
|
|
||||||
activeQueryIndex: number,
|
|
||||||
onSetActiveQueryIndex: func.isRequired,
|
|
||||||
},
|
|
||||||
|
|
||||||
getActiveQuery() {
|
|
||||||
const {queries, activeQueryIndex} = this.props
|
|
||||||
const activeQuery = queries[activeQueryIndex]
|
|
||||||
const defaultQuery = queries[0]
|
|
||||||
|
|
||||||
return activeQuery || defaultQuery
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{this.renderTabs()}
|
|
||||||
{this.renderTable()}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTable() {
|
|
||||||
const {height, onEditRawStatus} = this.props
|
|
||||||
const query = this.getActiveQuery()
|
|
||||||
const noQuery = !query || !query.text
|
|
||||||
if (noQuery) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Table key={query.text} query={query} height={height} onEditRawStatus={onEditRawStatus} />
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTabs() {
|
|
||||||
const {queries, onSetActiveQueryIndex} = this.props
|
|
||||||
return (
|
|
||||||
<div className="multi-table__tabs">
|
|
||||||
{queries.map((q, i) => {
|
|
||||||
return (
|
|
||||||
<TabItem
|
|
||||||
isActive={this.getActiveQuery().id === q.id}
|
|
||||||
key={q.id}
|
|
||||||
query={q}
|
|
||||||
onSelect={() => onSetActiveQueryIndex(i)}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const TabItem = React.createClass({
|
|
||||||
propTypes: {
|
|
||||||
query: shape({
|
|
||||||
text: string.isRequired,
|
|
||||||
id: string.isRequired,
|
|
||||||
host: arrayOf(string.isRequired).isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
onSelect: func.isRequired,
|
|
||||||
isActive: bool.isRequired,
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {isActive, onSelect} = this.props
|
|
||||||
return (
|
|
||||||
<div className={classNames("multi-table__tab", {active: isActive})} onClick={onSelect}>
|
|
||||||
{"Query"}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export default MultiTable
|
|
|
@ -3,6 +3,7 @@ import React, {PropTypes} from 'react'
|
||||||
import QueryEditor from './QueryEditor'
|
import QueryEditor from './QueryEditor'
|
||||||
import QueryTabItem from './QueryTabItem'
|
import QueryTabItem from './QueryTabItem'
|
||||||
import SimpleDropdown from 'src/shared/components/SimpleDropdown'
|
import SimpleDropdown from 'src/shared/components/SimpleDropdown'
|
||||||
|
import buildInfluxQLQuery from 'utils/influxql'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
arrayOf,
|
arrayOf,
|
||||||
|
@ -98,7 +99,7 @@ const QueryBuilder = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderQueryTabList() {
|
renderQueryTabList() {
|
||||||
const {queries, activeQueryIndex, onDeleteQuery} = this.props
|
const {queries, activeQueryIndex, onDeleteQuery, timeRange} = this.props
|
||||||
return (
|
return (
|
||||||
<div className="query-builder--tabs">
|
<div className="query-builder--tabs">
|
||||||
<div className="query-builder--tabs-heading">
|
<div className="query-builder--tabs-heading">
|
||||||
|
@ -106,15 +107,6 @@ const QueryBuilder = React.createClass({
|
||||||
{this.renderAddQuery()}
|
{this.renderAddQuery()}
|
||||||
</div>
|
</div>
|
||||||
{queries.map((q, i) => {
|
{queries.map((q, i) => {
|
||||||
let queryTabText
|
|
||||||
if (q.rawText) {
|
|
||||||
queryTabText = 'Query Editor'
|
|
||||||
} else if (q.measurement && q.fields.length !== 0) {
|
|
||||||
queryTabText = `${q.measurement}.${q.fields[0].field}`
|
|
||||||
} else {
|
|
||||||
queryTabText = 'Query Builder'
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryTabItem
|
<QueryTabItem
|
||||||
isActive={i === activeQueryIndex}
|
isActive={i === activeQueryIndex}
|
||||||
|
@ -123,7 +115,7 @@ const QueryBuilder = React.createClass({
|
||||||
query={q}
|
query={q}
|
||||||
onSelect={this.handleSetActiveQueryIndex}
|
onSelect={this.handleSetActiveQueryIndex}
|
||||||
onDelete={onDeleteQuery}
|
onDelete={onDeleteQuery}
|
||||||
queryTabText={queryTabText}
|
queryTabText={q.rawText || buildInfluxQLQuery(timeRange, q) || `SELECT "fields" FROM "db"."rp"."measurement"`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -102,7 +102,7 @@ const ChronoTable = React.createClass({
|
||||||
|
|
||||||
// Table data as a list of array.
|
// Table data as a list of array.
|
||||||
render() {
|
render() {
|
||||||
const {containerWidth, height} = this.props
|
const {containerWidth, height, query} = this.props
|
||||||
const {cellData, columnWidths, isLoading} = this.state
|
const {cellData, columnWidths, isLoading} = this.state
|
||||||
const {columns, values} = cellData
|
const {columns, values} = cellData
|
||||||
|
|
||||||
|
@ -117,6 +117,10 @@ const ChronoTable = React.createClass({
|
||||||
const minWidth = 70
|
const minWidth = 70
|
||||||
const styleAdjustedHeight = height - stylePixelOffset
|
const styleAdjustedHeight = height - stylePixelOffset
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
return <div className="generic-empty-state">Please add a query below</div>
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLoading && !values.length) {
|
if (!isLoading && !values.length) {
|
||||||
return <div className="generic-empty-state">Your query returned no data</div>
|
return <div className="generic-empty-state">Your query returned no data</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import classNames from 'classnames'
|
||||||
import AutoRefresh from 'shared/components/AutoRefresh'
|
import AutoRefresh from 'shared/components/AutoRefresh'
|
||||||
import LineGraph from 'shared/components/LineGraph'
|
import LineGraph from 'shared/components/LineGraph'
|
||||||
import SingleStat from 'shared/components/SingleStat'
|
import SingleStat from 'shared/components/SingleStat'
|
||||||
import MultiTable from './MultiTable'
|
import Table from './Table'
|
||||||
import VisHeader from 'src/data_explorer/components/VisHeader'
|
import VisHeader from 'src/data_explorer/components/VisHeader'
|
||||||
|
|
||||||
const RefreshingLineGraph = AutoRefresh(LineGraph)
|
const RefreshingLineGraph = AutoRefresh(LineGraph)
|
||||||
|
@ -36,7 +36,6 @@ const Visualization = React.createClass({
|
||||||
height: string,
|
height: string,
|
||||||
heightPixels: number,
|
heightPixels: number,
|
||||||
onEditRawStatus: func.isRequired,
|
onEditRawStatus: func.isRequired,
|
||||||
onSetActiveQueryIndex: func.isRequired,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
|
@ -77,7 +76,7 @@ const Visualization = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {queryConfigs, timeRange, height, heightPixels, onEditRawStatus, activeQueryIndex, onSetActiveQueryIndex} = this.props
|
const {queryConfigs, timeRange, height, heightPixels, onEditRawStatus, activeQueryIndex} = this.props
|
||||||
const {source} = this.context
|
const {source} = this.context
|
||||||
const proxyLink = source.links.proxy
|
const proxyLink = source.links.proxy
|
||||||
const {view} = this.state
|
const {view} = this.state
|
||||||
|
@ -94,24 +93,21 @@ const Visualization = React.createClass({
|
||||||
<div className={classNames("graph", {active: true})} style={{height}}>
|
<div className={classNames("graph", {active: true})} style={{height}}>
|
||||||
<VisHeader views={VIEWS} view={view} onToggleView={this.handleToggleView} name={name || 'Graph'}/>
|
<VisHeader views={VIEWS} view={view} onToggleView={this.handleToggleView} name={name || 'Graph'}/>
|
||||||
<div className={classNames({"graph-container": view === GRAPH, "table-container": view === TABLE})}>
|
<div className={classNames({"graph-container": view === GRAPH, "table-container": view === TABLE})}>
|
||||||
{this.renderVisualization(view, queries, heightPixels, onEditRawStatus, activeQueryIndex, onSetActiveQueryIndex)}
|
{this.renderVisualization(view, queries, heightPixels, onEditRawStatus, activeQueryIndex)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
renderVisualization(view, queries, heightPixels, onEditRawStatus, activeQueryIndex, onSetActiveQueryIndex) {
|
renderVisualization(view, queries, heightPixels, onEditRawStatus, activeQueryIndex) {
|
||||||
|
const activeQuery = queries[activeQueryIndex]
|
||||||
|
const defaultQuery = queries[0]
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case GRAPH:
|
case GRAPH:
|
||||||
return this.renderGraph(queries)
|
return this.renderGraph(queries)
|
||||||
case TABLE:
|
case TABLE:
|
||||||
return (<MultiTable
|
return (<Table query={activeQuery || defaultQuery} height={heightPixels} onEditRawStatus={onEditRawStatus} />)
|
||||||
queries={queries}
|
|
||||||
height={heightPixels}
|
|
||||||
onEditRawStatus={onEditRawStatus}
|
|
||||||
activeQueryIndex={activeQueryIndex}
|
|
||||||
onSetActiveQueryIndex={onSetActiveQueryIndex}
|
|
||||||
/>)
|
|
||||||
default:
|
default:
|
||||||
this.renderGraph(queries)
|
this.renderGraph(queries)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ const DataExplorer = React.createClass({
|
||||||
queryConfigs={queryConfigs}
|
queryConfigs={queryConfigs}
|
||||||
activeQueryIndex={activeQueryIndex}
|
activeQueryIndex={activeQueryIndex}
|
||||||
onEditRawStatus={queryConfigActions.editRawQueryStatus}
|
onEditRawStatus={queryConfigActions.editRawQueryStatus}
|
||||||
onSetActiveQueryIndex={this.handleSetActiveQueryIndex}
|
|
||||||
/>
|
/>
|
||||||
<ResizeBottom>
|
<ResizeBottom>
|
||||||
<QueryBuilder
|
<QueryBuilder
|
||||||
|
|
Loading…
Reference in New Issue