2019-01-07 01:25:33 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-11-07 17:54:56 +00:00
|
|
|
|
|
|
|
import hostInterface from 'interfaces/host';
|
|
|
|
import labelInterface from 'interfaces/label';
|
|
|
|
import HostsTable from 'components/hosts/HostsTable';
|
|
|
|
import Spinner from 'components/loaders/Spinner';
|
2020-12-10 21:09:05 +00:00
|
|
|
import RoboDogImage from '../../../../assets/images/robo-dog-176x144@2x.png';
|
2017-11-07 17:54:56 +00:00
|
|
|
|
|
|
|
const baseClass = 'host-container';
|
|
|
|
|
|
|
|
class HostContainer extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
hosts: PropTypes.arrayOf(hostInterface),
|
|
|
|
selectedLabel: labelInterface,
|
|
|
|
loadingHosts: PropTypes.bool.isRequired,
|
2021-01-28 20:44:48 +00:00
|
|
|
onHostClick: PropTypes.func,
|
2017-11-07 17:54:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
renderNoHosts = () => {
|
|
|
|
const { selectedLabel } = this.props;
|
|
|
|
const { type } = selectedLabel || '';
|
|
|
|
const isCustom = type === 'custom';
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={`${baseClass} ${baseClass}--no-hosts`}>
|
2020-11-30 18:23:58 +00:00
|
|
|
<div className={`${baseClass}--no-hosts__inner`}>
|
2020-12-10 21:09:05 +00:00
|
|
|
<img src={RoboDogImage} alt="robo dog" />
|
2020-11-30 18:23:58 +00:00
|
|
|
<div>
|
|
|
|
<h1>No matching hosts found.</h1>
|
|
|
|
<h2>Where are the missing hosts?</h2>
|
|
|
|
<ul>
|
|
|
|
{isCustom && <li>Check your SQL query above to confirm there are no mistakes.</li>}
|
|
|
|
<li>Check to confirm that your hosts are online.</li>
|
|
|
|
<li>Confirm that your expected hosts have osqueryd installed and configured.</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div className={`${baseClass}__no-hosts-contact`}>
|
|
|
|
<p>Still having trouble?</p>
|
2020-12-10 21:09:05 +00:00
|
|
|
<a href="https://github.com/fleetdm/fleet/issues">File a GitHub issue</a>
|
2020-11-30 18:23:58 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-11-07 17:54:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderHosts = () => {
|
2021-01-28 20:44:48 +00:00
|
|
|
const { hosts, onHostClick } = this.props;
|
2017-11-07 17:54:56 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<HostsTable
|
|
|
|
hosts={hosts}
|
2021-01-28 20:44:48 +00:00
|
|
|
onHostClick={onHostClick}
|
2017-11-07 17:54:56 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { renderHosts, renderNoHosts } = this;
|
2020-12-08 20:07:54 +00:00
|
|
|
const { hosts, loadingHosts, selectedLabel } = this.props;
|
2017-11-07 17:54:56 +00:00
|
|
|
|
|
|
|
if (loadingHosts) {
|
|
|
|
return <Spinner />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hosts.length === 0) {
|
|
|
|
if (selectedLabel && selectedLabel.type === 'all') {
|
2020-12-08 20:07:54 +00:00
|
|
|
return (
|
|
|
|
<div className={`${baseClass} ${baseClass}--no-hosts`}>
|
|
|
|
<div className={`${baseClass}--no-hosts__inner`}>
|
2020-12-10 21:09:05 +00:00
|
|
|
<img src={RoboDogImage} alt="No Hosts" />
|
2020-12-08 20:07:54 +00:00
|
|
|
<div>
|
2020-12-10 21:09:05 +00:00
|
|
|
<h1>It's kinda empty in here...</h1>
|
2020-12-08 20:07:54 +00:00
|
|
|
<h2>Get started adding hosts to Fleet.</h2>
|
2020-12-10 21:09:05 +00:00
|
|
|
<p>Add your laptops and servers to securely monitor them.</p>
|
2020-12-08 20:07:54 +00:00
|
|
|
<div className={`${baseClass}__no-hosts-contact`}>
|
|
|
|
<p>Still having trouble?</p>
|
2020-12-10 21:09:05 +00:00
|
|
|
<a href="https://github.com/fleetdm/fleet/issues">File a GitHub issue</a>
|
2020-12-08 20:07:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2017-11-07 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return renderNoHosts();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2020-11-30 18:23:58 +00:00
|
|
|
<div className={`${baseClass}`}>
|
2017-11-07 17:54:56 +00:00
|
|
|
{renderHosts()}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default HostContainer;
|