Add button to add torrent in polochon
This commit is contained in:
parent
b9b1fb356f
commit
8c16d8c78b
@ -87,7 +87,7 @@ func main() {
|
||||
env.Handle("/shows/refresh", extmedias.RefreshShows).WithRole(users.UserRole).Methods("POST")
|
||||
env.Handle("/shows/explore", extmedias.ExploreShows).WithRole(users.UserRole).Methods("GET")
|
||||
env.Handle("/shows/search", shows.SearchShow).WithRole(users.UserRole).Methods("POST")
|
||||
env.Handle("/download", torrents.DownloadHandler).WithRole(users.UserRole).Methods("POST")
|
||||
env.Handle("/torrents", torrents.DownloadHandler).WithRole(users.UserRole).Methods("POST")
|
||||
|
||||
n := negroni.Classic()
|
||||
n.Use(authMiddleware)
|
||||
|
@ -142,3 +142,17 @@ export function selectShow(imdbId) {
|
||||
imdbId
|
||||
}
|
||||
}
|
||||
|
||||
// ======================
|
||||
// AddTorrent
|
||||
// ======================
|
||||
|
||||
export function addTorrent(url) {
|
||||
return request(
|
||||
'ADD_TORRENT',
|
||||
configureAxios().post('/torrents', {
|
||||
url: url,
|
||||
}),
|
||||
"Torrent added",
|
||||
)
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ class MovieButtons extends React.Component {
|
||||
}
|
||||
|
||||
{this.props.movie.torrents &&
|
||||
<TorrentsButton torrents={this.props.movie.torrents} />
|
||||
<TorrentsButton
|
||||
torrents={this.props.movie.torrents}
|
||||
addTorrent={this.props.addTorrent}
|
||||
/>
|
||||
}
|
||||
|
||||
<a type="button" className="btn btn-warning btn-sm" href={imdb_link}>
|
||||
@ -104,6 +107,7 @@ export default class MovieList extends React.Component {
|
||||
movie={selectedMovie}
|
||||
fetching={this.props.movieStore.fetchingDetails}
|
||||
getMovieDetails={this.props.getMovieDetails}
|
||||
addTorrent={this.props.addTorrent}
|
||||
/>
|
||||
</ListDetails>
|
||||
}
|
||||
|
@ -2,28 +2,42 @@ import React from 'react'
|
||||
|
||||
import { DropdownButton, MenuItem } from 'react-bootstrap'
|
||||
|
||||
export default function TorrentsButton(props) {
|
||||
const entries = buildMenuItems(props.torrents);
|
||||
return (
|
||||
<DropdownButton className="btn btn-default btn-sm" title="Torrents" dropup id="download-torrents-button">
|
||||
{entries.map(function(e, index) {
|
||||
switch (e.type) {
|
||||
case 'header':
|
||||
return (
|
||||
<MenuItem key={index} className="text-warning" header>{e.value}</MenuItem>
|
||||
);
|
||||
case 'divider':
|
||||
return (
|
||||
<MenuItem key={index} divider></MenuItem>
|
||||
);
|
||||
case 'entry':
|
||||
return (
|
||||
<MenuItem key={index}>{e.quality}</MenuItem>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</DropdownButton>
|
||||
);
|
||||
export default class TorrentsButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
}
|
||||
handleClick(e, url) {
|
||||
e.preventDefault();
|
||||
this.props.addTorrent(url);
|
||||
}
|
||||
render() {
|
||||
const entries = buildMenuItems(this.props.torrents);
|
||||
return (
|
||||
<DropdownButton className="btn btn-default btn-sm" title="Torrents" id="download-torrents-button" dropup>
|
||||
{entries.map(function(e, index) {
|
||||
switch (e.type) {
|
||||
case 'header':
|
||||
return (
|
||||
<MenuItem key={index} className="text-warning" header>
|
||||
{e.value}
|
||||
</MenuItem>
|
||||
);
|
||||
case 'divider':
|
||||
return (
|
||||
<MenuItem key={index} divider></MenuItem>
|
||||
);
|
||||
case 'entry':
|
||||
return (
|
||||
<MenuItem key={index} href={e.url} onClick={(event) => this.handleClick(event, e.url)}>
|
||||
{e.quality}
|
||||
</MenuItem>
|
||||
);
|
||||
}
|
||||
}, this)}
|
||||
</DropdownButton>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function buildMenuItems(torrents) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user