Output proper percentage of online hosts (#1071)

This commit is contained in:
Kyle Knight 2017-01-20 17:08:35 -06:00 committed by Jason Meller
parent bc9273622c
commit eb82856ae4

View File

@ -21,10 +21,13 @@ class TargetDetails extends Component {
handleBackToResults: noop,
};
onlineHosts = (labelBaseClass, online) => {
onlineHosts = (labelBaseClass, count, online) => {
const offline = count - online;
const percentOnline = ((count - offline) / count) * 100;
if (online > 0) {
return (
<span className={`${labelBaseClass}__hosts-online`}> ({online}% ONLINE)</span>
<span className={`${labelBaseClass}__hosts-online`}> ({percentOnline}% ONLINE)</span>
);
}
@ -128,7 +131,7 @@ class TargetDetails extends Component {
<p className={`${labelBaseClass}__hosts`}>
<span className={`${labelBaseClass}__hosts-count`}><strong>{count}</strong>HOSTS</span>
{ onlineHosts(labelBaseClass, online) }
{ onlineHosts(labelBaseClass, count, online) }
</p>
<p className={`${labelBaseClass}__description`}>{description || 'No Description'}</p>