Use measurement, show app name on hosts page

pull/363/head
Will Piers 2016-11-04 11:52:16 -07:00
parent b931d8d35e
commit 8c62144796
2 changed files with 6 additions and 7 deletions

View File

@ -36,8 +36,9 @@ export function getMappings() {
});
}
export function getAppsForHosts(proxyLink, hosts, supportedApps) {
const measurements = supportedApps.map((m) => `${m}$`).join('|');
export function getAppsForHosts(proxyLink, hosts, appMappings) {
const measurements = appMappings.map((m) => `${m.measurement}$`).join('|');
const measurementsToApps = _.zipObject(appMappings.map(m => m.measurement), appMappings.map(m => m.name));
return proxy({
source: proxyLink,
query: `show series from /${measurements}/`,
@ -50,7 +51,7 @@ export function getAppsForHosts(proxyLink, hosts, supportedApps) {
if (!matches || matches.length !== 3) { // eslint-disable-line no-magic-numbers
return;
}
const app = matches[1];
const measurement = matches[1];
const host = matches[2];
if (!newHosts[host]) {
@ -59,7 +60,7 @@ export function getAppsForHosts(proxyLink, hosts, supportedApps) {
if (!newHosts[host].apps) {
newHosts[host].apps = [];
}
newHosts[host].apps = _.uniq(newHosts[host].apps.concat(app));
newHosts[host].apps = _.uniq(newHosts[host].apps.concat(measurementsToApps[measurement]));
});
return newHosts;

View File

@ -29,9 +29,7 @@ export const HostsPage = React.createClass({
getMappings(),
]).then(([hosts, {data: {mappings}}]) => {
this.setState({hosts});
const apps = mappings.concat([{name: 'docker'}, {name: 'influxdb'}]).map((m) => m.name);
// concatting docker and influxdb for now
getAppsForHosts(source.links.proxy, hosts, apps).then((newHosts) => {
getAppsForHosts(source.links.proxy, hosts, mappings).then((newHosts) => {
this.setState({hosts: newHosts});
});
}).catch(() => {