Merge pull request #4159 from influxdata/flux/update-queries
Update flux queries based on flux api changespull/4166/head
commit
84dd8eed58
|
@ -52,12 +52,16 @@ export const getTimeSeries = async (
|
|||
service: Service,
|
||||
script: string
|
||||
): Promise<GetTimeSeriesResult> => {
|
||||
const and = encodeURIComponent('&')
|
||||
const mark = encodeURIComponent('?')
|
||||
const garbage = script.replace(/\s/g, '') // server cannot handle whitespace
|
||||
const url = `${window.basepath}${
|
||||
service.links.proxy
|
||||
}?path=/v1/query${mark}orgName=defaulorgname${and}q=${garbage}`
|
||||
}?path=/query${mark}organization=defaultorgname`
|
||||
const dialect = {annotations: ['group', 'datatype', 'default']}
|
||||
const data = JSON.stringify({
|
||||
query: garbage,
|
||||
dialect,
|
||||
})
|
||||
|
||||
let responseBody: string
|
||||
let responseByteLength: number
|
||||
|
@ -69,7 +73,13 @@ export const getTimeSeries = async (
|
|||
// seems to be broken at the moment. We might use this option instead of
|
||||
// the `fetch` API in the future, if it is ever fixed. See
|
||||
// https://github.com/axios/axios/issues/1491.
|
||||
const resp = await fetch(url, {method: 'POST'})
|
||||
const resp = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
const {body, byteLength} = await decodeFluxRespWithLimit(resp)
|
||||
|
||||
responseBody = body
|
||||
|
|
|
@ -114,16 +114,18 @@ const tagsetFilter = (filter: SchemaFilter[]): string => {
|
|||
}
|
||||
|
||||
const proxy = async (service: Service, script: string) => {
|
||||
const and = encodeURIComponent('&')
|
||||
const mark = encodeURIComponent('?')
|
||||
const garbage = script.replace(/\s/g, '') // server cannot handle whitespace
|
||||
|
||||
const dialect = {annotations: ['group', 'datatype', 'default']}
|
||||
const data = {query: garbage, dialect}
|
||||
try {
|
||||
const response = await AJAX({
|
||||
method: 'POST',
|
||||
url: `${
|
||||
service.links.proxy
|
||||
}?path=/v1/query${mark}orgName=defaulorgname${and}q=${garbage}`,
|
||||
}?path=/query${mark}organization=defaultorgname`,
|
||||
data,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
})
|
||||
|
||||
return response.data
|
||||
|
|
Loading…
Reference in New Issue