Access properties more safely
parent
2841cf902a
commit
797b214d95
|
@ -630,7 +630,9 @@ export const hydrateTempVarValuesAsync = (
|
||||||
)
|
)
|
||||||
const templates: Template[] = dashboard.templates
|
const templates: Template[] = dashboard.templates
|
||||||
const queries = templates
|
const queries = templates
|
||||||
.filter(template => !!template.query.influxql)
|
.filter(
|
||||||
|
template => getDeep<string>(template, 'query.influxql', '') !== ''
|
||||||
|
)
|
||||||
.map(async template => {
|
.map(async template => {
|
||||||
const query = makeQueryForTemplate(template.query)
|
const query = makeQueryForTemplate(template.query)
|
||||||
const response = await proxy({source: source.links.proxy, query})
|
const response = await proxy({source: source.links.proxy, query})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {getDeep} from 'src/utils/wrappers'
|
||||||
|
|
||||||
interface ParseShowSeriesResponse {
|
interface ParseShowSeriesResponse {
|
||||||
errors: string[]
|
errors: string[]
|
||||||
series: string[]
|
series: string[]
|
||||||
|
@ -10,17 +12,15 @@ const parseShowSeries = (response): ParseShowSeriesResponse => {
|
||||||
return {errors: [results.error], series: []}
|
return {errors: [results.error], series: []}
|
||||||
}
|
}
|
||||||
|
|
||||||
const series = results.series[0]
|
const seriesValues = getDeep<string[]>(results, 'series.0.values', [])
|
||||||
|
|
||||||
if (!series.values) {
|
if (!seriesValues.length) {
|
||||||
return {errors: [], series: []}
|
return {errors: [], series: []}
|
||||||
}
|
}
|
||||||
|
|
||||||
const seriesValues = series.values.map(s => {
|
const series = seriesValues.map(s => s[0])
|
||||||
return s[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
return {errors: [], series: seriesValues}
|
return {series, errors: []}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default parseShowSeries
|
export default parseShowSeries
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {proxy} from 'src/utils/queryUrlGenerator'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
import TemplateMetaQueryPreview from 'src/tempVars/components/TemplateMetaQueryPreview'
|
import TemplateMetaQueryPreview from 'src/tempVars/components/TemplateMetaQueryPreview'
|
||||||
import {parseMetaQuery, isInvalidMetaQuery} from 'src/tempVars/utils/parsing'
|
import {parseMetaQuery, isInvalidMetaQuery} from 'src/tempVars/utils/parsing'
|
||||||
|
import {getDeep} from 'src/utils/wrappers'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
TemplateBuilderProps,
|
TemplateBuilderProps,
|
||||||
|
@ -39,7 +40,7 @@ class CustomMetaQueryTemplateBuilder extends PureComponent<
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
const metaQuery = _.get(props.template, 'query.influxql', '')
|
const metaQuery = getDeep<string>(props.template, 'query.influxql', '')
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
metaQuery,
|
metaQuery,
|
||||||
|
|
Loading…
Reference in New Issue