node-resources-metric-box-info.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. export default class NodeResourcesMetricBoxInfo extends React.Component {
  3. humanizedMetricInfo() {
  4. const {
  5. humanizedTotalCapacity, humanizedAbsoluteConsumption,
  6. humanizedRelativeConsumption, showCapacity, format
  7. } = this.props.metricSummary.toJS();
  8. const showExtendedInfo = showCapacity && format !== 'percent';
  9. return (
  10. <span>
  11. <strong>
  12. {showExtendedInfo ? humanizedRelativeConsumption : humanizedAbsoluteConsumption}
  13. </strong>
  14. {' '}
  15. used
  16. {showExtendedInfo
  17. && (
  18. <i>
  19. {' - '}
  20. (
  21. {humanizedAbsoluteConsumption}
  22. {' '}
  23. /
  24. <strong>{humanizedTotalCapacity}</strong>
  25. )
  26. </i>
  27. )
  28. }
  29. </span>
  30. );
  31. }
  32. render() {
  33. const { width, x, y } = this.props;
  34. return (
  35. <foreignObject x={x} y={y} width={width} height="45px">
  36. <div className="node-resources-metric-box-info">
  37. <span className="wrapper label truncate">{this.props.label}</span>
  38. <span className="wrapper consumption truncate">{this.humanizedMetricInfo()}</span>
  39. </div>
  40. </foreignObject>
  41. );
  42. }
  43. }