diff --git a/src/main.go b/src/main.go
index cddf6d1..cbea35a 100644
--- a/src/main.go
+++ b/src/main.go
@@ -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)
diff --git a/src/public/js/actions/actionCreators.js b/src/public/js/actions/actionCreators.js
index 9f2e8c5..32354e6 100644
--- a/src/public/js/actions/actionCreators.js
+++ b/src/public/js/actions/actionCreators.js
@@ -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",
+ )
+}
diff --git a/src/public/js/components/movies/list.js b/src/public/js/components/movies/list.js
index d3a8f00..2467689 100644
--- a/src/public/js/components/movies/list.js
+++ b/src/public/js/components/movies/list.js
@@ -40,7 +40,10 @@ class MovieButtons extends React.Component {
}
{this.props.movie.torrents &&
-
+
}
@@ -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}
/>
}
diff --git a/src/public/js/components/movies/torrents.js b/src/public/js/components/movies/torrents.js
index 274f797..79812d4 100644
--- a/src/public/js/components/movies/torrents.js
+++ b/src/public/js/components/movies/torrents.js
@@ -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 (
-
- {entries.map(function(e, index) {
- switch (e.type) {
- case 'header':
- return (
-
- );
- case 'divider':
- return (
-
- );
- case 'entry':
- return (
-
- );
- }
- })}
-
- );
+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 (
+
+ {entries.map(function(e, index) {
+ switch (e.type) {
+ case 'header':
+ return (
+
+ );
+ case 'divider':
+ return (
+
+ );
+ case 'entry':
+ return (
+
+ );
+ }
+ }, this)}
+
+ );
+ }
}
function buildMenuItems(torrents) {