исправление роутинга, отображение общей статистики

This commit is contained in:
Alexey Kasyanchuk
2017-01-02 15:15:47 +03:00
parent e988f11891
commit 0549f099f0
2 changed files with 30 additions and 1 deletions

View File

@ -6,12 +6,17 @@ import RaisedButton from 'material-ui/RaisedButton';
export default class Search extends Component {
search() {
console.log(this.searchValue);
window.torrentSocket.emit('search', this.searchValue, (torrents) => {
this.searchData = torrents;
this.forceUpdate();
});
}
componentDidMount() {
window.torrentSocket.emit('statistic', (statistic) => {
this.stats = statistic;
this.forceUpdate();
});
}
render() {
return (
<div className="column w100p center">
@ -32,6 +37,13 @@ export default class Search extends Component {
this.search()
}} />
</div>
{
this.stats
?
<div className='fs0-75' style={{color: 'rgba(0, 0, 0, 0.541176)'}}>we have {this.stats.torrents} torrents and around {this.stats.files} files here</div>
:
null
}
<SearchResults results={this.searchData} />
</div>
);