diff --git a/ui/package.json b/ui/package.json index cdaf124945..97b25d5d01 100644 --- a/ui/package.json +++ b/ui/package.json @@ -132,7 +132,7 @@ "dependencies": { "@influxdata/clockface": "2.2.0", "@influxdata/flux": "^0.5.1", - "@influxdata/flux-lsp-browser": "^0.5.6", + "@influxdata/flux-lsp-browser": "^0.5.8", "@influxdata/giraffe": "0.18.0", "@influxdata/influx": "0.5.5", "@influxdata/influxdb-templates": "0.9.0", diff --git a/ui/src/external/monaco.flux.server.ts b/ui/src/external/monaco.flux.server.ts index 75d421a640..bb9c08a948 100644 --- a/ui/src/external/monaco.flux.server.ts +++ b/ui/src/external/monaco.flux.server.ts @@ -90,6 +90,22 @@ const queryTagKeys = async (orgID, bucket) => { return raw } +const queryTagValues = async (orgID, bucket, tag) => { + if (!orgID || orgID === '') { + throw new Error('no org is provided') + } + + const query = `import "influxdata/influxdb/v1" + v1.tagValues(bucket:"${bucket}", tag: "${tag}")` + + const raw = await runQuery(orgID, query).promise + if (raw.type !== 'SUCCESS') { + throw new Error('failed to get tagKeys') + } + + return raw +} + export class LSPServer { private server: WASMServer private messageID: number = 0 @@ -103,6 +119,7 @@ export class LSPServer { this.server.register_buckets_callback(this.getBuckets) this.server.register_measurements_callback(this.getMeasurements) this.server.register_tag_keys_callback(this.getTagKeys) + this.server.register_tag_values_callback(this.getTagValues) this.store = reduxStore } @@ -116,6 +133,16 @@ export class LSPServer { } } + getTagValues = async (bucket, tag) => { + try { + const response = await queryTagValues(this.orgID, bucket, tag) + return parseQueryResponse(response) + } catch (e) { + console.error(e) + return [] + } + } + getBuckets = () => { return Promise.resolve(this.buckets) } diff --git a/ui/yarn.lock b/ui/yarn.lock index 82971baa87..79e1c7c824 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1016,10 +1016,10 @@ resolved "https://registry.yarnpkg.com/@influxdata/clockface/-/clockface-2.2.0.tgz#73f09f4832d6b6bad53af029844a11dd6562527e" integrity sha512-pIQPJXjvVgzcryhAjgZPSoC5BRLbQb1sIIY9l6KQCg4DWJkxqFC/sPI7qJItRXd8kiPXbfbHvXGAwqIY+TdWNQ== -"@influxdata/flux-lsp-browser@^0.5.6": - version "0.5.6" - resolved "https://registry.yarnpkg.com/@influxdata/flux-lsp-browser/-/flux-lsp-browser-0.5.6.tgz#ca0d57c713ca4bbca4828b9c26b86c3ec4781249" - integrity sha512-9NP4zl2nLNy4C9lyGfqf09C41w1ENINXg1X5O+LZFgqbc2oRF3HyZFgDbUfPRgsWUAQrjahSNm29bt/KnOgy2w== +"@influxdata/flux-lsp-browser@^0.5.8": + version "0.5.8" + resolved "https://registry.yarnpkg.com/@influxdata/flux-lsp-browser/-/flux-lsp-browser-0.5.8.tgz#95372a08d0d6179efcbed58bc0c4230a17ad9d5b" + integrity sha512-uaza9uZ6IBt9CWNJs4Cfpa3uSt3AsErfy9xKpjUVkuUYOWmJb3qtqAj7mnWzSjvOjRBXbB3ghHkgOnivxTis+g== "@influxdata/flux@^0.4.0": version "0.4.0"