Kind of type buildQueriesForLayouts
parent
173346beb1
commit
3e1131c8ff
|
@ -1,3 +1,4 @@
|
||||||
|
import {LayoutCell, LayoutQuery} from './layouts'
|
||||||
import {Service, NewService} from './services'
|
import {Service, NewService} from './services'
|
||||||
import {AuthLinks, Organization, Role, User, Me} from './auth'
|
import {AuthLinks, Organization, Role, User, Me} from './auth'
|
||||||
import {Template, Cell, CellQuery, Legend, Axes} from './dashboard'
|
import {Template, Cell, CellQuery, Legend, Axes} from './dashboard'
|
||||||
|
@ -58,4 +59,6 @@ export {
|
||||||
Axes,
|
Axes,
|
||||||
Service,
|
Service,
|
||||||
NewService,
|
NewService,
|
||||||
|
LayoutCell,
|
||||||
|
LayoutQuery,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
export interface LayoutCell {
|
||||||
|
x: number
|
||||||
|
y: number
|
||||||
|
w: number
|
||||||
|
h: number
|
||||||
|
i: string
|
||||||
|
name: string
|
||||||
|
queries: LayoutQuery[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LayoutQuery {
|
||||||
|
query: string
|
||||||
|
label: string
|
||||||
|
wheres: string[]
|
||||||
|
groupbys: string[]
|
||||||
|
}
|
|
@ -1,18 +1,23 @@
|
||||||
import {buildQuery} from 'utils/influxql'
|
import {buildQuery} from 'src/utils/influxql'
|
||||||
import {TYPE_SHIFTED, TYPE_QUERY_CONFIG} from 'src/dashboards/constants'
|
import {TYPE_SHIFTED, TYPE_QUERY_CONFIG} from 'src/dashboards/constants'
|
||||||
import {
|
import {
|
||||||
TEMP_VAR_DASHBOARD_TIME,
|
TEMP_VAR_DASHBOARD_TIME,
|
||||||
TEMP_VAR_UPPER_DASHBOARD_TIME,
|
TEMP_VAR_UPPER_DASHBOARD_TIME,
|
||||||
} from 'src/shared/constants'
|
} from 'src/shared/constants'
|
||||||
import {timeRanges} from 'shared/data/timeRanges'
|
import {timeRanges} from 'src/shared/data/timeRanges'
|
||||||
|
import {Source, LayoutQuery, TimeRange} from 'src/types'
|
||||||
|
|
||||||
const buildCannedDashboardQuery = (query, {lower, upper}, host) => {
|
const buildCannedDashboardQuery = (
|
||||||
|
query: LayoutQuery,
|
||||||
|
{lower, upper}: TimeRange,
|
||||||
|
host: string
|
||||||
|
): string => {
|
||||||
const {defaultGroupBy} = timeRanges.find(range => range.lower === lower) || {
|
const {defaultGroupBy} = timeRanges.find(range => range.lower === lower) || {
|
||||||
defaultGroupBy: '5m',
|
defaultGroupBy: '5m',
|
||||||
}
|
}
|
||||||
const {wheres, groupbys} = query
|
const {wheres, groupbys} = query
|
||||||
|
|
||||||
let text = query.text
|
let text = query.query
|
||||||
|
|
||||||
if (upper) {
|
if (upper) {
|
||||||
text += ` where time > '${lower}' AND time < '${upper}'`
|
text += ` where time > '${lower}' AND time < '${upper}'`
|
||||||
|
@ -43,7 +48,12 @@ const buildCannedDashboardQuery = (query, {lower, upper}, host) => {
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildQueriesForLayouts = (cell, source, timeRange, host) => {
|
export const buildQueriesForLayouts = (
|
||||||
|
cell,
|
||||||
|
source: Source,
|
||||||
|
timeRange: TimeRange,
|
||||||
|
host: string
|
||||||
|
) => {
|
||||||
return cell.queries.map(query => {
|
return cell.queries.map(query => {
|
||||||
let queryText
|
let queryText
|
||||||
// Canned dashboards use an different a schema different from queryConfig.
|
// Canned dashboards use an different a schema different from queryConfig.
|
Loading…
Reference in New Issue