Automatically select table on initial render
parent
264afed4b8
commit
d8ed336248
|
@ -37,7 +37,7 @@ export default class TimeMachineTable extends PureComponent<ScriptResult> {
|
||||||
}: GridCellProps): React.ReactNode => {
|
}: GridCellProps): React.ReactNode => {
|
||||||
const {data} = this.props
|
const {data} = this.props
|
||||||
return (
|
return (
|
||||||
<div key={key} style={style}>
|
<div key={key} style={style} className="table-graph-cell">
|
||||||
{data[rowIndex][columnIndex]}
|
{data[rowIndex][columnIndex]}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, {PureComponent, CSSProperties} from 'react'
|
import React, {PureComponent, CSSProperties} from 'react'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
import {ScriptResult, ScriptStatus} from 'src/types'
|
import {ScriptResult, ScriptStatus} from 'src/types'
|
||||||
|
@ -20,7 +21,13 @@ class TimeMachineVis extends PureComponent<Props, State> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {selectedResultID: null}
|
this.state = {selectedResultID: this.initialResultID}
|
||||||
|
}
|
||||||
|
|
||||||
|
public componentDidUpdate(__, prevState) {
|
||||||
|
if (prevState.selectedResultID === null) {
|
||||||
|
this.setState({selectedResultID: this.initialResultID})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
@ -40,6 +47,10 @@ class TimeMachineVis extends PureComponent<Props, State> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get initialResultID(): string {
|
||||||
|
return _.get(this.props.data, '0.id', null)
|
||||||
|
}
|
||||||
|
|
||||||
private handleSelectResult = (selectedResultID: string): void => {
|
private handleSelectResult = (selectedResultID: string): void => {
|
||||||
this.setState({selectedResultID})
|
this.setState({selectedResultID})
|
||||||
}
|
}
|
||||||
|
@ -51,7 +62,7 @@ class TimeMachineVis extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private get shouldShowTable(): boolean {
|
private get shouldShowTable(): boolean {
|
||||||
return !!this.selectedResult
|
return !!this.props.data && !!this.selectedResult
|
||||||
}
|
}
|
||||||
|
|
||||||
private get selectedResult(): ScriptResult {
|
private get selectedResult(): ScriptResult {
|
||||||
|
|
|
@ -36,6 +36,10 @@ export class CheckServices extends PureComponent<Props & WithRouterProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
if (!this.props.services.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return this.props.children
|
return this.props.children
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getASTResponse(script)
|
this.getASTResponse(script)
|
||||||
|
this.getTimeSeries()
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import uuid from 'uuid'
|
||||||
|
|
||||||
import {ScriptResult} from 'src/types'
|
import {ScriptResult} from 'src/types'
|
||||||
|
|
||||||
export const parseResults = (resp: string): ScriptResult[] => {
|
export const parseResults = (response: string): ScriptResult[] => {
|
||||||
return resp
|
return response
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n\n')
|
.split(/\n\s*\n/)
|
||||||
.map(parseResult)
|
.map(parseResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue