2016-11-21 16:26:58 +00:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
2016-12-22 19:26:18 +00:00
|
|
|
import Icon from 'components/icons/Icon';
|
2016-11-21 16:26:58 +00:00
|
|
|
import hostInterface from 'interfaces/host';
|
|
|
|
|
import { platformIconClass, statusIconClass } from 'utilities/icon_class';
|
|
|
|
|
|
|
|
|
|
const baseClass = 'hosts-table';
|
|
|
|
|
|
|
|
|
|
class HostsTable extends Component {
|
|
|
|
|
static propTypes = {
|
|
|
|
|
hosts: PropTypes.arrayOf(hostInterface),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderHost = (host) => {
|
|
|
|
|
const statusClassName = classnames(`${baseClass}__status`, `${baseClass}__status--${host.status}`);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<tr key={`host-${host.id}-table`}>
|
|
|
|
|
<td className={`${baseClass}__hostname`}>{host.hostname}</td>
|
2016-11-28 19:20:15 +00:00
|
|
|
<td className={statusClassName}><Icon name={statusIconClass(host.status)} /></td>
|
|
|
|
|
<td><Icon name={platformIconClass(host.platform)} /> {host.os_version}</td>
|
2016-11-21 16:26:58 +00:00
|
|
|
<td>{host.osquery_version}</td>
|
|
|
|
|
<td>{host.ip}</td>
|
|
|
|
|
<td>{host.mac}</td>
|
2017-01-05 18:08:50 +00:00
|
|
|
<td><a href="#add-query"><Icon name="add-plus" /></a></td>
|
2016-11-21 16:26:58 +00:00
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
const { hosts } = this.props;
|
|
|
|
|
const { renderHost } = this;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass} ${baseClass}__wrapper`}>
|
|
|
|
|
<table className={`${baseClass}__table`}>
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Hostname</th>
|
|
|
|
|
<th>Status</th>
|
|
|
|
|
<th>OS</th>
|
|
|
|
|
<th>Osquery</th>
|
|
|
|
|
<th>IPv4</th>
|
|
|
|
|
<th>Physical Address</th>
|
2017-01-05 18:08:50 +00:00
|
|
|
<th><Icon name="query" /></th>
|
2016-11-21 16:26:58 +00:00
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{hosts.map((host) => {
|
|
|
|
|
return renderHost(host);
|
|
|
|
|
})}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default HostsTable;
|