瀏覽代碼

Implements #610 (#673)

Roman Zabaluev 4 年之前
父節點
當前提交
9b6952c480

+ 1 - 0
kafka-ui-api/src/main/java/com/provectus/kafka/ui/model/InternalClusterMetrics.java

@@ -27,4 +27,5 @@ public class InternalClusterMetrics {
   private final Map<Integer, InternalBrokerMetrics> internalBrokerMetrics;
   private final Map<Integer, InternalBrokerMetrics> internalBrokerMetrics;
   private final List<Metric> metrics;
   private final List<Metric> metrics;
   private final int zooKeeperStatus;
   private final int zooKeeperStatus;
+  private final String version;
 }
 }

+ 1 - 0
kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/KafkaService.java

@@ -159,6 +159,7 @@ public class KafkaService {
         .onlinePartitionCount(topicsMetrics.getOnlinePartitionCount())
         .onlinePartitionCount(topicsMetrics.getOnlinePartitionCount())
         .offlinePartitionCount(topicsMetrics.getOfflinePartitionCount())
         .offlinePartitionCount(topicsMetrics.getOfflinePartitionCount())
         .zooKeeperStatus(ClusterUtil.convertToIntServerStatus(zookeeperStatus))
         .zooKeeperStatus(ClusterUtil.convertToIntServerStatus(zookeeperStatus))
+        .version(version)
         .build();
         .build();
 
 
     return currentCluster.toBuilder()
     return currentCluster.toBuilder()

+ 2 - 0
kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml

@@ -1417,6 +1417,8 @@ components:
           type: array
           type: array
           items:
           items:
             $ref: '#/components/schemas/BrokerDiskUsage'
             $ref: '#/components/schemas/BrokerDiskUsage'
+        version:
+          type: string
 
 
     BrokerDiskUsage:
     BrokerDiskUsage:
       type: object
       type: object

+ 4 - 0
kafka-ui-react-app/src/components/Brokers/Brokers.tsx

@@ -27,6 +27,7 @@ const Brokers: React.FC<Props> = ({
   diskUsage,
   diskUsage,
   fetchClusterStats,
   fetchClusterStats,
   fetchBrokers,
   fetchBrokers,
+  version,
 }) => {
 }) => {
   const { clusterName } = useParams<{ clusterName: ClusterName }>();
   const { clusterName } = useParams<{ clusterName: ClusterName }>();
 
 
@@ -56,6 +57,9 @@ const Brokers: React.FC<Props> = ({
             {zkOnline ? 'Online' : 'Offline'}
             {zkOnline ? 'Online' : 'Offline'}
           </span>
           </span>
         </Indicator>
         </Indicator>
+        <Indicator className="is-one-third" label="Version">
+          {version}
+        </Indicator>
       </MetricsWrapper>
       </MetricsWrapper>
       <MetricsWrapper title="Partitions">
       <MetricsWrapper title="Partitions">
         <Indicator label="Online">
         <Indicator label="Online">

+ 2 - 0
kafka-ui-react-app/src/components/Brokers/BrokersContainer.ts

@@ -12,6 +12,7 @@ import {
   getOutOfSyncReplicasCount,
   getOutOfSyncReplicasCount,
   getUnderReplicatedPartitionCount,
   getUnderReplicatedPartitionCount,
   getDiskUsage,
   getDiskUsage,
+  getVersion,
 } from 'redux/reducers/brokers/selectors';
 } from 'redux/reducers/brokers/selectors';
 import Brokers from 'components/Brokers/Brokers';
 import Brokers from 'components/Brokers/Brokers';
 
 
@@ -26,6 +27,7 @@ const mapStateToProps = (state: RootState) => ({
   outOfSyncReplicasCount: getOutOfSyncReplicasCount(state),
   outOfSyncReplicasCount: getOutOfSyncReplicasCount(state),
   underReplicatedPartitionCount: getUnderReplicatedPartitionCount(state),
   underReplicatedPartitionCount: getUnderReplicatedPartitionCount(state),
   diskUsage: getDiskUsage(state),
   diskUsage: getDiskUsage(state),
+  version: getVersion(state),
 });
 });
 
 
 const mapDispatchToProps = {
 const mapDispatchToProps = {

+ 2 - 0
kafka-ui-react-app/src/components/Brokers/__test__/Brokers.spec.tsx

@@ -26,6 +26,7 @@ describe('Brokers Component', () => {
           inSyncReplicasCount={0}
           inSyncReplicasCount={0}
           outOfSyncReplicasCount={0}
           outOfSyncReplicasCount={0}
           underReplicatedPartitionCount={0}
           underReplicatedPartitionCount={0}
+          version="1"
           fetchClusterStats={jest.fn()}
           fetchClusterStats={jest.fn()}
           fetchBrokers={jest.fn()}
           fetchBrokers={jest.fn()}
           diskUsage={undefined}
           diskUsage={undefined}
@@ -61,6 +62,7 @@ describe('Brokers Component', () => {
           inSyncReplicasCount={64}
           inSyncReplicasCount={64}
           outOfSyncReplicasCount={0}
           outOfSyncReplicasCount={0}
           underReplicatedPartitionCount={0}
           underReplicatedPartitionCount={0}
+          version="1"
           fetchClusterStats={jest.fn()}
           fetchClusterStats={jest.fn()}
           fetchBrokers={jest.fn()}
           fetchBrokers={jest.fn()}
           diskUsage={[
           diskUsage={[

+ 48 - 0
kafka-ui-react-app/src/components/Brokers/__test__/__snapshots__/Brokers.spec.tsx.snap

@@ -69,6 +69,7 @@ exports[`Brokers Component Brokers Empty matches Brokers Empty snapshot 1`] = `
       onlinePartitionCount={0}
       onlinePartitionCount={0}
       outOfSyncReplicasCount={0}
       outOfSyncReplicasCount={0}
       underReplicatedPartitionCount={0}
       underReplicatedPartitionCount={0}
+      version="1"
       zooKeeperStatus={0}
       zooKeeperStatus={0}
     >
     >
       <div
       <div
@@ -179,6 +180,29 @@ exports[`Brokers Component Brokers Empty matches Brokers Empty snapshot 1`] = `
                   </div>
                   </div>
                 </div>
                 </div>
               </Indicator>
               </Indicator>
+              <Indicator
+                className="is-one-third"
+                label="Version"
+              >
+                <div
+                  className="level-item is-one-third"
+                >
+                  <div
+                    title="Version"
+                  >
+                    <p
+                      className="heading"
+                    >
+                      Version
+                    </p>
+                    <p
+                      className="title has-text-centered"
+                    >
+                      1
+                    </p>
+                  </div>
+                </div>
+              </Indicator>
             </div>
             </div>
           </div>
           </div>
         </MetricsWrapper>
         </MetricsWrapper>
@@ -400,6 +424,7 @@ exports[`Brokers Component Brokers matches snapshot 1`] = `
       onlinePartitionCount={64}
       onlinePartitionCount={64}
       outOfSyncReplicasCount={0}
       outOfSyncReplicasCount={0}
       underReplicatedPartitionCount={0}
       underReplicatedPartitionCount={0}
+      version="1"
       zooKeeperStatus={1}
       zooKeeperStatus={1}
     >
     >
       <div
       <div
@@ -510,6 +535,29 @@ exports[`Brokers Component Brokers matches snapshot 1`] = `
                   </div>
                   </div>
                 </div>
                 </div>
               </Indicator>
               </Indicator>
+              <Indicator
+                className="is-one-third"
+                label="Version"
+              >
+                <div
+                  className="level-item is-one-third"
+                >
+                  <div
+                    title="Version"
+                  >
+                    <p
+                      className="heading"
+                    >
+                      Version
+                    </p>
+                    <p
+                      className="title has-text-centered"
+                    >
+                      1
+                    </p>
+                  </div>
+                </div>
+              </Indicator>
             </div>
             </div>
           </div>
           </div>
         </MetricsWrapper>
         </MetricsWrapper>

+ 5 - 0
kafka-ui-react-app/src/components/Dashboard/ClustersWidget/ClusterWidget.tsx

@@ -18,6 +18,7 @@ const ClusterWidget: React.FC<ClusterWidgetProps> = ({
     bytesOutPerSec,
     bytesOutPerSec,
     onlinePartitionCount,
     onlinePartitionCount,
     readOnly,
     readOnly,
+    version,
   },
   },
 }) => (
 }) => (
   <div className="column is-full-modile is-6">
   <div className="column is-full-modile is-6">
@@ -38,6 +39,10 @@ const ClusterWidget: React.FC<ClusterWidgetProps> = ({
 
 
       <table className="table is-fullwidth">
       <table className="table is-fullwidth">
         <tbody>
         <tbody>
+          <tr>
+            <th>Version</th>
+            <td>{version}</td>
+          </tr>
           <tr>
           <tr>
             <th>Brokers</th>
             <th>Brokers</th>
             <td>
             <td>

+ 12 - 0
kafka-ui-react-app/src/components/Dashboard/ClustersWidget/__test__/__snapshots__/ClusterWidget.spec.tsx.snap

@@ -21,6 +21,12 @@ exports[`ClusterWidget when cluster is offline matches snapshot 1`] = `
       className="table is-fullwidth"
       className="table is-fullwidth"
     >
     >
       <tbody>
       <tbody>
+        <tr>
+          <th>
+            Version
+          </th>
+          <td />
+        </tr>
         <tr>
         <tr>
           <th>
           <th>
             Brokers
             Brokers
@@ -100,6 +106,12 @@ exports[`ClusterWidget when cluster is online matches snapshot 1`] = `
       className="table is-fullwidth"
       className="table is-fullwidth"
     >
     >
       <tbody>
       <tbody>
+        <tr>
+          <th>
+            Version
+          </th>
+          <td />
+        </tr>
         <tr>
         <tr>
           <th>
           <th>
             Brokers
             Brokers

+ 5 - 0
kafka-ui-react-app/src/redux/reducers/brokers/selectors.ts

@@ -48,3 +48,8 @@ export const getDiskUsage = createSelector(
   brokersState,
   brokersState,
   ({ diskUsage }) => diskUsage
   ({ diskUsage }) => diskUsage
 );
 );
+
+export const getVersion = createSelector(
+  brokersState,
+  ({ version }) => version
+);