TopicConsumerGroups.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from 'react';
  2. import {
  3. Topic,
  4. TopicDetails,
  5. ConsumerTopicPartitionDetail,
  6. } from 'generated-sources';
  7. import { ClusterName, TopicName } from 'redux/interfaces';
  8. interface Props extends Topic, TopicDetails {
  9. clusterName: ClusterName;
  10. topicName: TopicName;
  11. consumerGroups: ConsumerTopicPartitionDetail[];
  12. fetchTopicConsumerGroups(
  13. clusterName: ClusterName,
  14. topicName: TopicName
  15. ): void;
  16. }
  17. const TopicConsumerGroups: React.FC<Props> = ({
  18. consumerGroups,
  19. fetchTopicConsumerGroups,
  20. clusterName,
  21. topicName,
  22. }) => {
  23. React.useEffect(() => {
  24. fetchTopicConsumerGroups(clusterName, topicName);
  25. }, []);
  26. return (
  27. <div className="box">
  28. {consumerGroups.length > 0 ? (
  29. <table className="table is-striped is-fullwidth">
  30. <thead>
  31. <tr>
  32. <th>Group ID</th>
  33. <th>Consumer ID</th>
  34. <th>Host</th>
  35. <th>Partition</th>
  36. <th>Messages behind</th>
  37. <th>Current offset</th>
  38. <th>End offset</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. {consumerGroups.map((consumer) => (
  43. <tr key={consumer.consumerId}>
  44. <td>{consumer.groupId}</td>
  45. <td>{consumer.consumerId}</td>
  46. <td>{consumer.host}</td>
  47. <td>{consumer.partition}</td>
  48. <td>{consumer.messagesBehind}</td>
  49. <td>{consumer.currentOffset}</td>
  50. <td>{consumer.endOffset}</td>
  51. </tr>
  52. ))}
  53. </tbody>
  54. </table>
  55. ) : (
  56. 'No active consumer groups'
  57. )}
  58. </div>
  59. );
  60. };
  61. export default TopicConsumerGroups;