import React from "react" import { connect } from "react-redux" import { bindActionCreators } from "redux" import { addTorrent } from "../../actions/torrents" import { refreshSubtitles } from "../../actions/subtitles" import { addShowToWishlist, deleteShowFromWishlist, getEpisodeDetails, updateShowDetails } from "../../actions/shows" import Loader from "../loader/loader" import DownloadButton from "../buttons/download" import SubtitlesButton from "../buttons/subtitles" import ImdbButton from "../buttons/imdb" import RefreshIndicator from "../buttons/refresh" import { OverlayTrigger, Tooltip } from "react-bootstrap" import { Button, Dropdown, MenuItem } from "react-bootstrap" function mapStateToProps(state) { return { loading: state.showStore.loading, show: state.showStore.get("show"), }; } const mapDispatchToProps = (dispatch) => bindActionCreators({addTorrent, addShowToWishlist, deleteShowFromWishlist, updateShowDetails, getEpisodeDetails, refreshSubtitles }, dispatch) class ShowDetails extends React.Component { render() { // Loading if (this.props.loading) { return (); } return (
); } } export default connect(mapStateToProps, mapDispatchToProps)(ShowDetails); function Header(props){ return (
); } function HeaderThumbnail(props){ return (
); } function HeaderDetails(props){ return (
Title
{props.data.get("title")}
Plot
{props.data.get("plot")}
IMDB
Year
{props.data.get("year")}
Rating
{props.data.get("rating")}
); } function SeasonsList(props){ return (
{props.data.get("seasons").entrySeq().map(function([season, data]) { return (
); })}
) } class Season extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); this.state = { colapsed: true }; } handleClick(e) { e.preventDefault(); this.setState({ colapsed: !this.state.colapsed }); } render() { return (
this.handleClick(e)}> Season {this.props.season} — ({this.props.data.toList().size} episodes) {this.state.colapsed || } {this.state.colapsed && }
{this.state.colapsed || {this.props.data.toList().map(function(episode) { let key = `${episode.get("season")}-${episode.get("episode")}`; return ( ) }, this)}
}
) } } function Episode(props) { return ( {props.data.get("episode")} {props.data.get("title")} {props.data.get("polochon_url") !== "" && } {props.data.get("torrents") && props.data.get("torrents").toList().map(function(torrent) { let key = `${props.data.get("season")}-${props.data.get("episode")}-${torrent.get("source")}-${torrent.get("quality")}`; return ( ) })} ) } class Torrent extends React.PureComponent { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick(e, url) { e.preventDefault(); this.props.addTorrent(url); } render() { return ( this.handleClick(e, this.props.data.get("url"))} href={this.props.data.url} > {this.props.data.get("quality")} ) } } class TrackHeader extends React.PureComponent { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick(e) { e.preventDefault(); const trackedSeason = this.props.data.get("tracked_season"); const trackedEpisode = this.props.data.get("tracked_episode"); const imdbId = this.props.data.get("imdb_id"); const wishlisted = (trackedSeason !== null && trackedEpisode !== null); if (wishlisted) { this.props.deleteFromWishlist(imdbId); } else { this.props.addToWishlist(imdbId); } } render() { const trackedSeason = this.props.data.get("tracked_season"); const trackedEpisode = this.props.data.get("tracked_episode"); const wishlisted = (trackedSeason !== null && trackedEpisode !== null); let msg; if (wishlisted) { if (trackedSeason !== 0 && trackedEpisode !== 0) { msg = (
Show tracked from season {trackedSeason} episode {trackedEpisode}
); } else { msg = (
Whole show tracked
); } return (
Tracking active
{msg}
this.handleClick(e)}> Untrack the show
); } else { return (
Tracking inactive
this.handleClick(e)}> Track the whole show
); } } } class TrackButton extends React.PureComponent { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick(e) { e.preventDefault(); const imdbId = this.props.data.get("show_imdb_id"); const season = this.props.data.get("season"); const episode = this.props.data.get("episode"); this.props.addToWishlist(imdbId, season, episode); } render() { const tooltipId = `tooltip-${this.props.data.season}-${this.props.data.episode}`; const tooltip = ( Track show from here ); return ( this.handleClick(e)}> ); } } class GetDetailsButton extends React.PureComponent { constructor(props) { super(props); this.handleFetchClick = this.handleFetchClick.bind(this); this.handleAdvanceTorrentSearchClick = this.handleAdvanceTorrentSearchClick.bind(this); this.state = { imdbId: this.props.data.get("show_imdb_id"), season: this.props.data.get("season"), episode: this.props.data.get("episode"), }; } handleFetchClick() { if (this.props.data.get("fetching")) { return } this.props.getEpisodeDetails(this.state.imdbId, this.state.season, this.state.episode); } handleAdvanceTorrentSearchClick() { const pad = (d) => (d < 10) ? "0" + d.toString() : d.toString(); const search = `${this.props.showName} S${pad(this.state.season)}E${pad(this.state.episode)}`; const url = `/torrents/search/shows/${encodeURI(search)}`; this.props.router.push(url); } render() { const id = `${this.state.imdbId}-${this.state.season}-${this.state.episode}-refresh-dropdown`; return ( Advanced torrent search ); } }