From b11ce92d844775b8bccbb5f9946313587b7412eb Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 4 Oct 2016 13:18:43 -0700 Subject: [PATCH] Make tagKeys / tagValues work in the DE --- ui/src/chronograf/components/TagList.js | 14 +++++++----- ui/src/shared/apis/metaQuery.js | 29 +++++++++++-------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ui/src/chronograf/components/TagList.js b/ui/src/chronograf/components/TagList.js index 18dd00898..002c35021 100644 --- a/ui/src/chronograf/components/TagList.js +++ b/ui/src/chronograf/components/TagList.js @@ -23,8 +23,11 @@ const TagList = React.createClass({ }, contextTypes: { - dataNodes: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired, - clusterID: PropTypes.string, + source: PropTypes.shape({ + links: PropTypes.shape({ + proxy: PropTypes.string.isRequired, + }).isRequired, + }).isRequired, }, getInitialState() { @@ -35,18 +38,19 @@ const TagList = React.createClass({ componentDidMount() { const {database, measurement, retentionPolicy} = this.props.query; - const {dataNodes, clusterID} = this.context; + const {source} = this.context; if (!database || !measurement || !retentionPolicy) { return; } - showTagKeys(dataNodes, {database, retentionPolicy, measurement}, clusterID).then((resp) => { + const sourceProxy = source.links.proxy; + showTagKeys({source: sourceProxy, database, retentionPolicy, measurement}).then((resp) => { const {errors, tagKeys} = showTagKeysParser(resp.data); if (errors.length) { // do something } - return showTagValues(dataNodes, {database, retentionPolicy, measurement, tagKeys, clusterID}); + return showTagValues({source: sourceProxy, database, retentionPolicy, measurement, tagKeys}); }).then((resp) => { const {errors: errs, tags} = showTagValuesParser(resp.data); if (errs.length) { diff --git a/ui/src/shared/apis/metaQuery.js b/ui/src/shared/apis/metaQuery.js index 148889078..bc9a8a111 100644 --- a/ui/src/shared/apis/metaQuery.js +++ b/ui/src/shared/apis/metaQuery.js @@ -27,6 +27,19 @@ export function showMeasurements(source, db) { return proxy({source, db, query}); } +export function showTagKeys({source, database, retentionPolicy, measurement}) { + const query = `SHOW TAG KEYS FROM "${measurement}"`; + + return proxy({source, db: database, rp: retentionPolicy, query}); +} + +export function showTagValues({source, database, retentionPolicy, measurement, tagKeys}) { + const keys = tagKeys.sort().map((k) => `"${k}"`).join(', '); + const query = `SHOW TAG VALUES FROM "${measurement}" WITH KEY IN (${keys})`; + + return proxy({source, db: database, rp: retentionPolicy, query}); +} + export function showRetentionPolicies(source, databases) { let query; if (Array.isArray(databases)) { @@ -63,19 +76,3 @@ export function showFieldKeys(source, db, measurement) { return proxy({source, query, db}); } - -export function showTagKeys(host, {database, retentionPolicy, measurement}, clusterID) { - const statement = `SHOW TAG KEYS FROM "${measurement}"`; - const url = buildInfluxUrl({host, statement, database, retentionPolicy}); - - return proxy(url, clusterID); -} - -export function showTagValues(host, {database, retentionPolicy, measurement, tagKeys, clusterID}) { - const keys = tagKeys.sort().map((k) => `"${k}"`).join(', '); - const statement = `SHOW TAG VALUES FROM "${measurement}" WITH KEY IN (${keys})`; - - const url = buildInfluxUrl({host, statement, database, retentionPolicy}); - - return proxy(url, clusterID); -}