From 8c621447965df6889817ddddd748f6e25fa9b464 Mon Sep 17 00:00:00 2001 From: Will Piers Date: Fri, 4 Nov 2016 11:52:16 -0700 Subject: [PATCH] Use measurement, show app name on hosts page --- ui/src/hosts/apis/index.js | 9 +++++---- ui/src/hosts/containers/HostsPage.js | 4 +--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/src/hosts/apis/index.js b/ui/src/hosts/apis/index.js index 172f64d0a..148df2295 100644 --- a/ui/src/hosts/apis/index.js +++ b/ui/src/hosts/apis/index.js @@ -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; diff --git a/ui/src/hosts/containers/HostsPage.js b/ui/src/hosts/containers/HostsPage.js index 206564277..d93714a88 100644 --- a/ui/src/hosts/containers/HostsPage.js +++ b/ui/src/hosts/containers/HostsPage.js @@ -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(() => {