Add button to download episode torrent

This commit is contained in:
Grégoire Delattre 2017-01-18 22:41:10 +01:00
parent 70014189d5
commit 9497995cf5

View File

@ -13,7 +13,10 @@ export default class ShowDetails extends React.Component {
return (
<div className="row" id="container">
<Header data={this.props.showStore.show} />
<SeasonsList data={this.props.showStore.show} />
<SeasonsList
data={this.props.showStore.show}
addTorrent={this.props.addTorrent}
/>
</div>
);
}
@ -35,7 +38,8 @@ function Header(props){
function HeaderThumbnail(props){
return (
<div className="col-xs-12 col-sm-2 text-center">
<img src={props.data.poster_url} className="show-thumbnail thumbnail-selected img-thumbnail img-responsive"/>
<img src={props.data.poster_url}
className="show-thumbnail thumbnail-selected img-thumbnail img-responsive"/>
</div>
);
}
@ -70,7 +74,10 @@ function SeasonsList(props){
{props.data.seasons.length > 0 && props.data.seasons.map(function(season, index) {
return (
<div className="col-xs-12 col-sm-10 col-sm-offset-1 col-md-10 col-md-offset-1" key={index}>
<Season data={season} />
<Season
data={season}
addTorrent={props.addTorrent}
/>
</div>
)
})}
@ -109,9 +116,13 @@ class Season extends React.Component {
{this.props.data.episodes.map(function(episode, index) {
let key = `${episode.season}-${episode.episode}`;
return (
<Episode key={key} data={episode} />
<Episode
key={key}
data={episode}
addTorrent={this.props.addTorrent}
/>
)
})}
}, this)}
</tbody>
</table>
}
@ -130,7 +141,11 @@ function Episode(props) {
{props.data.torrents && props.data.torrents.map(function(torrent, index) {
let key = `${props.data.season}-${props.data.episode}-${torrent.source}-${torrent.quality}`;
return (
<Torrent data={torrent} key={key} />
<Torrent
data={torrent}
key={key}
addTorrent={props.addTorrent}
/>
)
})}
</span>
@ -139,12 +154,25 @@ function Episode(props) {
)
}
function Torrent(props) {
return (
<span className="episode-button">
<a type="button" className="btn btn-primary btn-xs" href={props.data.url}>
<i className="fa fa-download"></i> {props.data.quality}
</a>
</span>
)
class Torrent extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e, url) {
e.preventDefault();
this.props.addTorrent(url);
}
render() {
return (
<span className="episode-button">
<a type="button"
className="btn btn-primary btn-xs"
onClick={(e) => this.handleClick(e, this.props.data.url)}
href={this.props.data.url} >
<i className="fa fa-download"></i> {this.props.data.quality}
</a>
</span>
)
}
}