import _ from 'lodash'; import Metric from './Metric.jsx'; import { metricToFormatter } from './util/Utils.js'; import React from 'react'; import { Col, Progress, Row } from 'antd'; import './../../css/health-pane.css'; const TrafficIndicator = ({healthStat}) => { return ( null} /> ); }; export default class ResourceHealthOverview extends React.Component { getRequestRate(metrics) { return _.sumBy(metrics, 'requestRate'); } getAvgSuccessRate(metrics) { return _.meanBy(metrics, 'successRate'); } getHealthClassName(successRate) { if (_.isNil(successRate) || _.isNaN(successRate)) { return "health-unknown"; } if (successRate < 0.4) { return "health-bad"; } if (successRate > 0.95) { return "health-good"; } return "health-neutral"; } getHealthStats() { let inboundSr = this.getAvgSuccessRate(this.props.upstreamMetrics); let outboundSr = this.getAvgSuccessRate(this.props.downstreamMetrics); let sr = this.props.currentSr; return { inbound: { requests: metricToFormatter["REQUEST_RATE"](this.getRequestRate(this.props.upstreamMetrics)), numDeploys: _.size(this.props.upstreamMetrics), health: this.getHealthClassName(inboundSr) }, outbound: { requests: metricToFormatter["REQUEST_RATE"](this.getRequestRate(this.props.downstreamMetrics)), numDeploys: _.size(this.props.downstreamMetrics), health: this.getHealthClassName(outboundSr) }, current: { health: this.getHealthClassName(sr) } }; } render() { let stats = this.getHealthStats(); return (
{ stats.inbound.numDeploys === 0 ? null : } { stats.outbound.numDeploys === 0 ? null : }
« {stats.inbound.numDeploys} {this.props.resourceType}s
 
{this.props.resourceName}
{stats.outbound.numDeploys} {this.props.resourceType}s »
); } }