From cba1e2d093ae30c953385b34674ff55821b94697 Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Thu, 9 Aug 2018 13:28:14 -0700 Subject: [PATCH] =?UTF-8?q?Update=20flux=20queries=20based=20on=20flux=20a?= =?UTF-8?q?pi=20changes=C2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/flux/apis/index.ts | 16 +++++++++++++--- ui/src/shared/apis/flux/metaQueries.ts | 8 +++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ui/src/flux/apis/index.ts b/ui/src/flux/apis/index.ts index e2232d360..c0c823091 100644 --- a/ui/src/flux/apis/index.ts +++ b/ui/src/flux/apis/index.ts @@ -52,12 +52,16 @@ export const getTimeSeries = async ( service: Service, script: string ): Promise => { - 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 diff --git a/ui/src/shared/apis/flux/metaQueries.ts b/ui/src/shared/apis/flux/metaQueries.ts index af326241c..17dc11526 100644 --- a/ui/src/shared/apis/flux/metaQueries.ts +++ b/ui/src/shared/apis/flux/metaQueries.ts @@ -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