Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete list of topics #516

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 28 additions & 33 deletions client/src/containers/Tail/Tail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Dropdown from 'react-bootstrap/Dropdown';
import _ from 'lodash';
import Input from '../../components/Form/Input';
import Header from '../Header';
import { uriLiveTail, uriTopics } from '../../utils/endpoints';
import {uriLiveTail, uriTopicsName} from '../../utils/endpoints';
import Table from '../../components/Table';
import AceEditor from 'react-ace';
import 'ace-builds/webpack-resolver';
Expand Down Expand Up @@ -35,33 +35,31 @@ class Tail extends Root {

componentDidMount = async () => {
const { clusterId } = this.props.match.params;
const { state } = this.props.location;
const query = new URLSearchParams(this.props.location.search);

let data = await this.getApi(uriTopics(clusterId, '', 'ALL', ''));
let data = await this.getApi(uriTopicsName(clusterId));
data = data.data;
let topics = [];
if (state && state.topicId && state.topicId.length > 0) {
topics = [{ name: state.topicId }];
if (query && query.get('topicId')) {
topics = [ query.get('topicId') ];
}

if (data) {
if (data.results) {
this.setState({ topics: data.results, selectedTopics: topics }, () => {
if (state && state.topicId && state.topicId.length > 0) {
this.setState({ selectedStatus: STATUS.STARTED });
this.startEventSource();
}
});
} else {
this.setState({ topics: [], selectedTopics: topics }, () => {
if (state && state.topicId && state.topicId.length > 0) {
this.setState({ selectedStatus: STATUS.STARTED });
this.startEventSource();
}
});
}
this.setState({ topics: data, selectedTopics: topics }, () => {
if (query && query.get('topicId')) {
this.setState({ selectedStatus: STATUS.STARTED });
this.startEventSource();
}
});
} else {
this.setState({ topics: [], selectedTopics: topics }, () => {
if (query && query.get('topicId')) {
this.setState({ selectedStatus: STATUS.STARTED });
this.startEventSource();
}
});
}
};
}

componentWillUnmount = () => {
super.componentWillUnmount();
Expand All @@ -71,11 +69,8 @@ class Tail extends Root {
startEventSource = () => {
const { clusterId } = this.props.match.params;
const { search, selectedTopics, maxRecords } = this.state;
let topicsToCall = selectedTopics.map(topic => {
return topic.name;
});
this.eventSource = new EventSource(
uriLiveTail(clusterId, search, topicsToCall, JSON.stringify(maxRecords))
uriLiveTail(clusterId, search, selectedTopics, JSON.stringify(maxRecords))
);
let self = this;
this.eventSource.addEventListener('tailBody', function(e) {
Expand Down Expand Up @@ -112,11 +107,11 @@ class Tail extends Root {
let selectedTopics = this.state.selectedTopics;
if (
selectedTopics.find(el => {
return el.name === topic.name;
return el === topic;
})
) {
let updatedSelected = _.remove(selectedTopics, el => {
return el.name !== topic.name;
return el !== topic;
});
this.setState({
selectedTopics: updatedSelected
Expand All @@ -140,14 +135,14 @@ class Tail extends Root {
{topics
.filter(topic => {
if (dropdownSearch.length > 0) {
return topic.name.includes(dropdownSearch);
return topic.includes(dropdownSearch);
}
return topic;
})
.map((topic, index) => {
let selected = selectedTopics.find(selected => selected.name === topic.name);
let selected = selectedTopics.find(selected => selected === topic);
return (
<li key={`topic_${topic.name}_${index}`}>
<li key={`topic_${topic}_${index}`}>
<div
onClick={() => {
this.onStop();
Expand All @@ -159,7 +154,7 @@ class Tail extends Root {
id={`bs-select-${index}-0`}
aria-selected="false"
>
<span className="text">{topic.name}</span>
<span className="text">{topic}</span>
</div>
</li>
);
Expand Down Expand Up @@ -231,7 +226,7 @@ class Tail extends Root {
{selectedTopics.length === 0
? 'Topics'
: selectedTopics.length === 1
? selectedTopics[0].name
? selectedTopics[0]
: `${selectedTopics.length} Topics Selected`}
</Dropdown.Toggle>
<Dropdown.Menu style={{ maxHeight: '771px', overflow: 'hidden', minHeight: '182px' }}>
Expand Down Expand Up @@ -262,7 +257,7 @@ class Tail extends Root {
data: [],
selectedTopics: JSON.parse(JSON.stringify(topics)).filter(topic => {
if (dropdownSearch.length > 0) {
return topic.name.includes(dropdownSearch);
return topic.includes(dropdownSearch);
}
return topic;
})
Expand Down
11 changes: 3 additions & 8 deletions client/src/containers/Topic/Topic/Topic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,9 @@ class Topic extends Root {
<i className="fa fa-fw fa-level-down" aria-hidden={true} /> Copy Topic
</Link>

<Link to={{
pathname: `/ui/${clusterId}/tail`,
state: {
topicId: topicId
}
}}
className="btn btn-secondary mr-2"
>
<Link to={{ pathname: `/ui/${clusterId}/tail`,
search: `?topicId=${topicId}` }} className="btn btn-secondary mr-2">

<i className="fa fa-fw fa-level-down" aria-hidden={true} /> Live Tail
</Link>

Expand Down