filter out hosts that don't match the current app
parent
80a29b0054
commit
be6d9a6c30
|
@ -5,6 +5,7 @@ import ReactTooltip from 'react-tooltip';
|
|||
import timeRanges from 'hson!../../shared/data/timeRanges.hson';
|
||||
import {getMappings, getAppsForHosts, getMeasurementsForHost, getAllHosts} from 'src/hosts/apis';
|
||||
import {fetchLayouts} from 'shared/apis';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const HostPage = React.createClass({
|
||||
propTypes: {
|
||||
|
@ -45,15 +46,24 @@ export const HostPage = React.createClass({
|
|||
getAppsForHosts(source.links.proxy, hosts, mappings, source.telegraf).then((newHosts) => {
|
||||
getMeasurementsForHost(source, params.hostID).then((measurements) => {
|
||||
const host = newHosts[this.props.params.hostID];
|
||||
const focusedApp = location.query.app;
|
||||
|
||||
const filteredLayouts = layouts.filter((layout) => {
|
||||
const focusedApp = location.query.app;
|
||||
if (focusedApp) {
|
||||
return layout.app === focusedApp;
|
||||
}
|
||||
|
||||
return host.apps && host.apps.includes(layout.app) && measurements.includes(layout.measurement);
|
||||
});
|
||||
this.setState({layouts: filteredLayouts, hosts});
|
||||
|
||||
// only display hosts in the list if they match the current app
|
||||
let filteredHosts = hosts;
|
||||
if (focusedApp) {
|
||||
filteredHosts = _.pickBy(hosts, (val, __, ___) => {
|
||||
return val.apps.includes(focusedApp);
|
||||
});
|
||||
}
|
||||
this.setState({layouts: filteredLayouts, hosts: filteredHosts});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -123,6 +133,7 @@ export const HostPage = React.createClass({
|
|||
render() {
|
||||
const hostID = this.props.params.hostID;
|
||||
const {layouts, timeRange, hosts} = this.state;
|
||||
const appParam = this.props.location.query.app ? `?app=${this.props.location.query.app}` : '';
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
|
@ -138,7 +149,7 @@ export const HostPage = React.createClass({
|
|||
{Object.keys(hosts).map((host, i) => {
|
||||
return (
|
||||
<li key={i}>
|
||||
<a href={`/sources/${this.props.source.id}/hosts/${host}`} className="role-option">
|
||||
<a href={`/sources/${this.props.source.id}/hosts/${host + appParam}`} className="role-option">
|
||||
{host}
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue