import React, { Component } from "react"; import PropTypes from "prop-types"; import { noop } from "lodash"; import AceEditor from "react-ace"; import classnames from "classnames"; import { humanHostMemory } from "utilities/helpers"; import FleetIcon from "components/icons/FleetIcon"; import PlatformIcon from "components/icons/PlatformIcon"; import targetInterface from "interfaces/target"; const baseClass = "target-details"; class TargetDetails extends Component { static propTypes = { target: targetInterface, className: PropTypes.string, handleBackToResults: PropTypes.func, }; static defaultProps = { handleBackToResults: noop, }; onlineHosts = (labelBaseClass, count, online) => { const offline = count - online; const percentCount = ((count - offline) / count) * 100; const percentOnline = parseFloat(percentCount.toFixed(2)); if (online > 0) { return ( {" "} ({percentOnline}% ONLINE) ); } return false; }; renderHost = () => { const { className, handleBackToResults, target } = this.props; const { display_text: displayText, primary_mac: hostMac, primary_ip: hostIpAddress, memory, osquery_version: osqueryVersion, os_version: osVersion, platform, status, } = target; const hostBaseClass = "host-target"; const isOnline = status === "online"; const isOffline = status === "offline"; const statusClassName = classnames( `${hostBaseClass}__status`, { [`${hostBaseClass}__status--is-online`]: isOnline }, { [`${hostBaseClass}__status--is-offline`]: isOffline } ); return (
{isOnline && (
| IP Address | {hostIpAddress} |
|---|---|
| MAC Address | {hostMac} |
| Platform |
|
| Operating system | {osVersion} |
| Osquery version | {osqueryVersion} |
| Memory | {humanHostMemory(memory)} |
{count}HOSTS {onlineHosts(labelBaseClass, count, online)}
{description || "No Description"}
{labelType !== 1 && (