-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from polarising-oss/AKHQ-18-Topics-Data-Logs
AKHQ-18-Topics-Data-Logs
- Loading branch information
Showing
7 changed files
with
151 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 102 additions & 8 deletions
110
client/src/containers/TopicList/Topic/TopicLogs/TopicLogs.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,107 @@ | ||
import React, {Component} from 'react'; | ||
import React, { Component } from 'react'; | ||
import { uriTopicsLogs } from '../../../../utils/endpoints'; | ||
import Table from '../../../../components/Table'; | ||
import { get } from '../../../../utils/api'; | ||
import converters from '../../../../utils/converters'; | ||
|
||
|
||
class TopicLogs extends Component { | ||
render() { | ||
return ( | ||
<h2> | ||
Logs | ||
</h2> | ||
); | ||
state = { | ||
data: [], | ||
selectedCluster: this.props.clusterId, | ||
selectedTopic: this.props.topic | ||
}; | ||
|
||
componentDidMount() { | ||
this.getTopicLogs(); | ||
} | ||
|
||
async getTopicLogs() { | ||
let logs = []; | ||
const { selectedCluster, selectedTopic } = this.state; | ||
const { history } = this.props; | ||
history.push({ | ||
loading: true | ||
}); | ||
try { | ||
logs = await get(uriTopicsLogs(selectedCluster, selectedTopic)); | ||
this.handleData(logs.data); | ||
} catch (err) { | ||
console.error('Error:', err); | ||
} finally { | ||
history.push({ | ||
loading: false | ||
}); | ||
} | ||
} | ||
|
||
handleData(logs) { | ||
let tableLogs = logs.map(log => { | ||
return { | ||
broker: log.broker, | ||
topic: log.topic, | ||
partition: log.partition, | ||
size: log.size, | ||
offsetLag: log.offsetLag | ||
}; | ||
}); | ||
this.setState({ data: tableLogs }); | ||
} | ||
|
||
handleSize(size) { | ||
|
||
return ( | ||
<label> | ||
{converters.showBytes(size, 0)} | ||
</label> | ||
); | ||
} | ||
render() { | ||
const { data } = this.state; | ||
return ( | ||
<div> | ||
<Table | ||
columns={[ | ||
{ | ||
id: 'broker', | ||
accessor: 'broker', | ||
colName: 'Broker', | ||
type: 'text' | ||
}, | ||
{ | ||
id: 'topic', | ||
accessor: 'topic', | ||
colName: 'Topic', | ||
type: 'text' | ||
}, | ||
{ | ||
id: 'partition', | ||
accessor: 'partition', | ||
colName: 'Partition', | ||
type: 'text' | ||
}, | ||
|
||
{ | ||
id: 'size', | ||
accessor: 'size', | ||
colName: 'Size', | ||
type: 'text', | ||
cell: (obj, col) => { | ||
return this.handleSize(obj[col.accessor]); | ||
} | ||
}, | ||
{ | ||
id: 'offsetLag', | ||
accessor: 'offsetLag', | ||
colName: 'OffsetLag', | ||
type: 'text' | ||
} | ||
]} | ||
data={data} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default TopicLogs; | ||
export default TopicLogs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.kafkahq.service.dto.topic; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class LogDTO { | ||
private int broker; | ||
private String topic; | ||
private int partition; | ||
private long size; | ||
private long offsetLag; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters