Make tagKeys / tagValues work in the DE

pull/176/head
Andrew Watkins 2016-10-04 13:18:43 -07:00
parent a3fd8aa0cf
commit b11ce92d84
2 changed files with 22 additions and 21 deletions

View File

@ -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) {

View File

@ -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);
}