Overview.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from 'react';
  2. import { ClusterName, TopicName } from 'redux/interfaces';
  3. import { Topic, TopicDetails } from 'generated-sources';
  4. import MetricsWrapper from 'components/common/Dashboard/MetricsWrapper';
  5. import Indicator from 'components/common/Dashboard/Indicator';
  6. import BytesFormatted from 'components/common/BytesFormatted/BytesFormatted';
  7. interface Props extends Topic, TopicDetails {
  8. isFetched: boolean;
  9. clusterName: ClusterName;
  10. topicName: TopicName;
  11. fetchTopicDetails: (clusterName: ClusterName, topicName: TopicName) => void;
  12. }
  13. const Overview: React.FC<Props> = ({
  14. isFetched,
  15. clusterName,
  16. topicName,
  17. partitions,
  18. underReplicatedPartitions,
  19. inSyncReplicas,
  20. replicas,
  21. partitionCount,
  22. internal,
  23. replicationFactor,
  24. segmentSize,
  25. segmentCount,
  26. fetchTopicDetails,
  27. }) => {
  28. React.useEffect(() => {
  29. fetchTopicDetails(clusterName, topicName);
  30. }, [fetchTopicDetails, clusterName, topicName]);
  31. if (!isFetched) {
  32. return null;
  33. }
  34. return (
  35. <>
  36. <MetricsWrapper>
  37. <Indicator label="Partitions">{partitionCount}</Indicator>
  38. <Indicator label="Replication Factor">{replicationFactor}</Indicator>
  39. <Indicator label="URP" title="Under replicated partitions">
  40. {underReplicatedPartitions}
  41. </Indicator>
  42. <Indicator label="In sync replicas">
  43. {inSyncReplicas}
  44. <span className="subtitle has-text-weight-light">
  45. {' '}
  46. of
  47. {replicas}
  48. </span>
  49. </Indicator>
  50. <Indicator label="Type">
  51. <span className="tag is-primary">
  52. {internal ? 'Internal' : 'External'}
  53. </span>
  54. </Indicator>
  55. <Indicator label="Segment Size" title="">
  56. <BytesFormatted value={segmentSize} />
  57. </Indicator>
  58. <Indicator label="Segment count">{segmentCount}</Indicator>
  59. </MetricsWrapper>
  60. <div className="box">
  61. <table className="table is-striped is-fullwidth">
  62. <thead>
  63. <tr>
  64. <th>Partition ID</th>
  65. <th>Broker leader</th>
  66. <th>Min offset</th>
  67. <th>Max offset</th>
  68. </tr>
  69. </thead>
  70. <tbody>
  71. {partitions &&
  72. partitions.map(({ partition, leader, offsetMin, offsetMax }) => (
  73. <tr key={`partition-list-item-key-${partition}`}>
  74. <td>{partition}</td>
  75. <td>{leader}</td>
  76. <td>{offsetMin}</td>
  77. <td>{offsetMax}</td>
  78. </tr>
  79. ))}
  80. </tbody>
  81. </table>
  82. </div>
  83. </>
  84. );
  85. };
  86. export default Overview;